File indexing completed on 2024-12-22 04:56:54
0001 /* 0002 SPDX-FileCopyrightText: 2013 Christian Mollekopf <mollekopf@kolabsys.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "gidmigrator.h" 0008 0009 #include "gidmigrationjob.h" 0010 #include <KLocalizedString> 0011 0012 GidMigrator::GidMigrator(const QString &mimeType) 0013 : MigratorBase(QLatin1StringView("gidmigrator") + mimeType) 0014 , mMimeType(mimeType) 0015 { 0016 } 0017 0018 GidMigrator::~GidMigrator() = default; 0019 0020 QString GidMigrator::displayName() const 0021 { 0022 return i18nc("Name of the GID Migrator (intended for advanced users).", "GID Migrator: %1", mMimeType); 0023 } 0024 0025 QString GidMigrator::description() const 0026 { 0027 return i18n("Ensures that all items with the mimetype %1 have a GID if a GID extractor is available.", mMimeType); 0028 } 0029 0030 bool GidMigrator::canStart() 0031 { 0032 return MigratorBase::canStart(); 0033 } 0034 0035 bool GidMigrator::shouldAutostart() const 0036 { 0037 return true; 0038 } 0039 0040 void GidMigrator::startWork() 0041 { 0042 auto job = new GidMigrationJob(QStringList() << mMimeType, this); 0043 connect(job, &GidMigrationJob::result, this, &GidMigrator::migrationFinished); 0044 } 0045 0046 void GidMigrator::migrationFinished(KJob *job) 0047 { 0048 if (job->error()) { 0049 Q_EMIT message(Error, i18n("Migration failed: %1", job->errorString())); 0050 setMigrationState(Failed); 0051 } else { 0052 setMigrationState(Complete); 0053 } 0054 } 0055 0056 #include "moc_gidmigrator.cpp"