diff --git a/CMakeLists.txt b/CMakeLists.txt index e53f50538..25cb8adc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,166 +1,167 @@ cmake_minimum_required(VERSION 3.5) set(PIM_VERSION "5.14.40") set(KDEPIM_RUNTIME_VERSION_NUMBER ${PIM_VERSION}) project(kdepim-runtime VERSION ${KDEPIM_RUNTIME_VERSION_NUMBER}) if (POLICY CMP0053) cmake_policy(SET CMP0053 NEW) endif() ############### KDEPIM-Runtime version ################ # KDEPIM_RUNTIME_VERSION # Version scheme: "x.y.z build". # # x is the version number. # y is the major release number. # z is the minor release number. # # "x.y.z" follow the kdelibs version kdepim is released with. # # If "z" is 0, it the version is "x.y" # # KDEPIM_DEV_VERSION # is empty for final versions. For development versions "build" is # something like "pre", "", "alpha", "beta1", "beta2", "rc1", "rc2". # # Examples in chronological order: # # 3.0 # 3.0.1 # 3.1 # 3.1 beta1 # 3.1 beta2 # 3.1 rc1 # 3.1 # 3.1.1 # 3.2 pre # 3.2 set(KDEPIM_DEV_VERSION alpha) set(RELEASE_SERVICE_VERSION "20.07.40") # add an extra space if(DEFINED KDEPIM_DEV_VERSION) set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}") endif() set(KDEPIM_RUNTIME_VERSION "${KDEPIM_RUNTIME_VERSION_NUMBER}${KDEPIM_DEV_VERSION} (${RELEASE_SERVICE_VERSION})") configure_file(kdepim-runtime-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kdepim-runtime-version.h @ONLY) set(KF5_MIN_VERSION "5.69.0") find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${kdepim-runtime_SOURCE_DIR}/cmake/ ${ECM_MODULE_PATH}) include(ECMSetupVersion) include(FeatureSummary) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(ECMInstallIcons) include(ECMQtDeclareLoggingCategory) include(GenerateExportHeader) set(QT_REQUIRED_VERSION "5.12.0") set(KDEPIMRUNTIME_LIB_VERSION "${KDEPIM_RUNTIME_VERSION_NUMBER}") set(KDEPIMRUNTIME_LIB_SOVERSION "5") set(AKONADI_VERSION "5.14.40") set(IDENTITYMANAGEMENT_LIB_VERSION "5.14.40") set(KMAILTRANSPORT_LIB_VERSION "5.14.40") set(CALENDARUTILS_LIB_VERSION "5.14.40") set(KDAV_LIB_VERSION "5.14.41") set(KIMAP_LIB_VERSION "5.14.40") set(KMBOX_LIB_VERSION "5.14.40") set(AKONADICALENDAR_LIB_VERSION "5.14.40") set(KONTACTINTERFACE_LIB_VERSION "5.14.40") set(AKONADIKALARM_LIB_VERSION "5.14.40") set(KMIME_LIB_VERSION "5.14.40") set(XMLRPCCLIENT_LIB_VERSION "5.14.40") set(AKONADIMIME_LIB_VERSION "5.14.43") set(AKONADICONTACT_LIB_VERSION "5.14.40") set(AKONADINOTE_LIB_VERSION "5.14.40") set(PIMCOMMON_LIB_VERSION "5.14.40") set(KGAPI_LIB_VERSION "5.14.40") set( SharedMimeInfo_MINIMUM_VERSION "1.3" ) find_package(SharedMimeInfo ${SharedMimeInfo_MINIMUM_VERSION} REQUIRED) find_package(Sasl2) set_package_properties(Sasl2 PROPERTIES TYPE REQUIRED) find_package(Qca-qt5 2.3.0 CONFIG REQUIRED) option(KDEPIM_RUN_AKONADI_TEST "Enable autotest based on Akonadi." TRUE) # QT5 package find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED TextToSpeech Network Widgets Test XmlPatterns DBus WebEngineWidgets NetworkAuth) # KF5 package find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5NotifyConfig ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ItemModels ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Codecs ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5WindowSystem ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5TextWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) # for KPluralHandlingSpinBox find_package(KF5Notifications ${KF5_MIN_VERSION} CONFIG REQUIRED) # pop3, ews find_package(KF5DocTools ${KF5_MIN_VERSION} CONFIG REQUIRED) # pop3 find_package(KF5Holidays ${KF5_MIN_VERSION} CONFIG REQUIRED) # KdepimLibs package find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED) find_package(KF5DAV ${KDAV_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Mime ${KMIME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiMime ${AKONADIMIME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MailTransportAkonadi ${KMAILTRANSPORT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IdentityManagement ${IDENTITYMANAGEMENT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADICONTACT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Contacts ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5AlarmCalendar ${AKONADIKALARM_LIB_VERSION} CONFIG) find_package(KF5CalendarCore ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5CalendarUtils ${CALENDARUTILS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Mbox ${KMBOX_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IMAP ${KIMAP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiNotes ${AKONADINOTE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiCalendar ${AKONADICALENDAR_LIB_VERSION} CONFIG REQUIRED) find_package(KF5PimCommon ${PIMCOMMON_LIB_VERSION} CONFIG REQUIRED) find_package(KPimGAPI ${KGAPI_LIB_VERSION} CONFIG REQUIRED) option(KDEPIM_RUN_ISOLATED_TESTS "Run the isolated tests." FALSE) option(NO_REGENERATE_MIME "Don't regenerate mime file (developer-only option)" FALSE ) if (EXISTS "${CMAKE_SOURCE_DIR}/.git") #add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00) add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x600000) endif() find_package(Xsltproc) set_package_properties(Xsltproc PROPERTIES DESCRIPTION "XSLT processor from libxslt" TYPE REQUIRED PURPOSE "Required to generate D-Bus interfaces for all Akonadi resources.") - +add_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS) +add_definitions(-DQT_NO_EMIT) add_subdirectory(resources) add_subdirectory(agents) add_subdirectory(defaultsetup) add_subdirectory(kioslave) add_subdirectory(migration) add_subdirectory(doc) ## install the MIME type spec file for KDEPIM specific MIME types install(FILES kdepim-mime.xml DESTINATION ${KDE_INSTALL_MIMEDIR}) if (NOT NO_REGENERATE_MIME) update_xdg_mimetypes(${KDE_INSTALL_MIMEDIR}) endif() ecm_qt_install_logging_categories( EXPORT KDEPIMRUNTIME FILE kdepim-runtime.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR} ) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES ) diff --git a/agents/newmailnotifier/newmailnotifierselectcollectionwidget.cpp b/agents/newmailnotifier/newmailnotifierselectcollectionwidget.cpp index b09a1fe9e..ac3a40aa2 100644 --- a/agents/newmailnotifier/newmailnotifierselectcollectionwidget.cpp +++ b/agents/newmailnotifier/newmailnotifierselectcollectionwidget.cpp @@ -1,240 +1,240 @@ /* Copyright (c) 2013-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "newmailnotifierselectcollectionwidget.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "newmailnotifier_debug.h" #include #include #include #include #include NewMailNotifierCollectionProxyModel::NewMailNotifierCollectionProxyModel(QObject *parent) : QIdentityProxyModel(parent) { } QVariant NewMailNotifierCollectionProxyModel::data(const QModelIndex &index, int role) const { if (role == Qt::CheckStateRole) { if (index.isValid()) { const Akonadi::Collection collection = data(index, Akonadi::EntityTreeModel::CollectionRole).value(); if (mNotificationCollection.contains(collection)) { return mNotificationCollection.value(collection) ? Qt::Checked : Qt::Unchecked; } else { const Akonadi::NewMailNotifierAttribute *attr = collection.attribute(); if (!attr || !attr->ignoreNewMail()) { return Qt::Checked; } return Qt::Unchecked; } } } return QIdentityProxyModel::data(index, role); } bool NewMailNotifierCollectionProxyModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (role == Qt::CheckStateRole) { if (index.isValid()) { const Akonadi::Collection collection = data(index, Akonadi::EntityTreeModel::CollectionRole).value(); mNotificationCollection[collection] = (value == Qt::Checked); - emit dataChanged(index, index); + Q_EMIT dataChanged(index, index); return true; } } return QIdentityProxyModel::setData(index, value, role); } Qt::ItemFlags NewMailNotifierCollectionProxyModel::flags(const QModelIndex &index) const { if (index.isValid()) { return QIdentityProxyModel::flags(index) | Qt::ItemIsUserCheckable; } else { return QIdentityProxyModel::flags(index); } } QHash NewMailNotifierCollectionProxyModel::notificationCollection() const { return mNotificationCollection; } NewMailNotifierSelectCollectionWidget::NewMailNotifierSelectCollectionWidget(QWidget *parent) : QWidget(parent) { Akonadi::AttributeFactory::registerAttribute(); QVBoxLayout *vbox = new QVBoxLayout(this); QLabel *label = new QLabel(i18n("Select which folders to monitor for new message notifications:")); vbox->addWidget(label); // Create a new change recorder. mChangeRecorder = new Akonadi::ChangeRecorder(this); mChangeRecorder->setMimeTypeMonitored(KMime::Message::mimeType()); mChangeRecorder->fetchCollection(true); mChangeRecorder->setAllMonitored(true); mModel = new Akonadi::EntityTreeModel(mChangeRecorder, this); // Set the model to show only collections, not items. mModel->setItemPopulationStrategy(Akonadi::EntityTreeModel::NoItemPopulation); connect(mModel, &Akonadi::EntityTreeModel::collectionTreeFetched, this, &NewMailNotifierSelectCollectionWidget::slotCollectionTreeFetched); Akonadi::CollectionFilterProxyModel *mimeTypeProxy = new Akonadi::CollectionFilterProxyModel(this); mimeTypeProxy->setExcludeVirtualCollections(true); mimeTypeProxy->setDynamicSortFilter(true); mimeTypeProxy->addMimeTypeFilters(QStringList() << KMime::Message::mimeType()); mimeTypeProxy->setSourceModel(mModel); mNewMailNotifierProxyModel = new NewMailNotifierCollectionProxyModel(this); mNewMailNotifierProxyModel->setSourceModel(mimeTypeProxy); mCollectionFilter = new QSortFilterProxyModel(this); mCollectionFilter->setRecursiveFilteringEnabled(true); mCollectionFilter->setSourceModel(mNewMailNotifierProxyModel); mCollectionFilter->setDynamicSortFilter(true); mCollectionFilter->setFilterCaseSensitivity(Qt::CaseInsensitive); mCollectionFilter->setSortRole(Qt::DisplayRole); mCollectionFilter->setSortCaseSensitivity(Qt::CaseSensitive); mCollectionFilter->setSortLocaleAware(true); KLineEdit *searchLine = new KLineEdit(this); searchLine->setPlaceholderText(i18n("Search...")); searchLine->setClearButtonEnabled(true); connect(searchLine, &QLineEdit::textChanged, this, &NewMailNotifierSelectCollectionWidget::slotSetCollectionFilter); vbox->addWidget(searchLine); mFolderView = new QTreeView(this); mFolderView->setEditTriggers(QAbstractItemView::NoEditTriggers); mFolderView->setAlternatingRowColors(true); vbox->addWidget(mFolderView); mFolderView->setModel(mCollectionFilter); QHBoxLayout *hbox = new QHBoxLayout; vbox->addLayout(hbox); QPushButton *button = new QPushButton(i18n("&Select All"), this); connect(button, &QPushButton::clicked, this, &NewMailNotifierSelectCollectionWidget::slotSelectAllCollections); hbox->addWidget(button); button = new QPushButton(i18n("&Unselect All"), this); connect(button, &QPushButton::clicked, this, &NewMailNotifierSelectCollectionWidget::slotUnselectAllCollections); hbox->addWidget(button); hbox->addStretch(1); } NewMailNotifierSelectCollectionWidget::~NewMailNotifierSelectCollectionWidget() { } void NewMailNotifierSelectCollectionWidget::slotCollectionTreeFetched() { mCollectionFilter->sort(0, Qt::AscendingOrder); mFolderView->expandAll(); } void NewMailNotifierSelectCollectionWidget::slotSetCollectionFilter(const QString &filter) { mCollectionFilter->setFilterWildcard(filter); mFolderView->expandAll(); } void NewMailNotifierSelectCollectionWidget::slotSelectAllCollections() { forceStatus(QModelIndex(), true); } void NewMailNotifierSelectCollectionWidget::slotUnselectAllCollections() { forceStatus(QModelIndex(), false); } void NewMailNotifierSelectCollectionWidget::forceStatus(const QModelIndex &parent, bool status) { const int nbCol = mNewMailNotifierProxyModel->rowCount(parent); for (int i = 0; i < nbCol; ++i) { const QModelIndex child = mNewMailNotifierProxyModel->index(i, 0, parent); mNewMailNotifierProxyModel->setData(child, status ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); forceStatus(child, status); } } void NewMailNotifierSelectCollectionWidget::updateCollectionsRecursive() { QHashIterator i(mNewMailNotifierProxyModel->notificationCollection()); while (i.hasNext()) { i.next(); Akonadi::Collection collection = i.key(); Akonadi::NewMailNotifierAttribute *attr = collection.attribute(); Akonadi::CollectionModifyJob *modifyJob = nullptr; const bool selected = i.value(); if (selected && attr && attr->ignoreNewMail()) { collection.removeAttribute(); modifyJob = new Akonadi::CollectionModifyJob(collection); modifyJob->setProperty("AttributeAdded", true); } else if (!selected && (!attr || !attr->ignoreNewMail())) { attr = collection.attribute(Akonadi::Collection::AddIfMissing); attr->setIgnoreNewMail(true); modifyJob = new Akonadi::CollectionModifyJob(collection); modifyJob->setProperty("AttributeAdded", false); } if (modifyJob) { connect(modifyJob, &Akonadi::CollectionModifyJob::finished, this, &NewMailNotifierSelectCollectionWidget::slotModifyJobDone); } } } void NewMailNotifierSelectCollectionWidget::slotModifyJobDone(KJob *job) { Akonadi::CollectionModifyJob *modifyJob = qobject_cast(job); if (modifyJob && job->error()) { if (job->property("AttributeAdded").toBool()) { qCWarning(NEWMAILNOTIFIER_LOG) << "Failed to append NewMailNotifierAttribute to collection" << modifyJob->collection().id() << ":" << job->errorString(); } else { qCWarning(NEWMAILNOTIFIER_LOG) << "Failed to remove NewMailNotifierAttribute from collection" << modifyJob->collection().id() << ":" << job->errorString(); } } } diff --git a/resources/shared/singlefileresource/singlefileresource.h b/resources/shared/singlefileresource/singlefileresource.h index f660cb111..b5020f491 100644 --- a/resources/shared/singlefileresource/singlefileresource.h +++ b/resources/shared/singlefileresource/singlefileresource.h @@ -1,333 +1,333 @@ /* Copyright (c) 2008 Bertjan Broeksema Copyright (c) 2008 Volker Krause Copyright (c) 2010 David Jarvie This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef AKONADI_SINGLEFILERESOURCE_H #define AKONADI_SINGLEFILERESOURCE_H #include "akonadi-singlefileresource_export.h" #include "singlefileresourcebase.h" #include #include #include #include #include #include #include #include Q_DECLARE_METATYPE(QEventLoopLocker *) namespace Akonadi { /** * Base class for single file based resources. */ template class AKONADI_SINGLEFILERESOURCE_EXPORT SingleFileResource : public SingleFileResourceBase { public: SingleFileResource(const QString &id) : SingleFileResourceBase(id) , mSettings(new Settings(config())) { // The resource needs network when the path refers to a non local file. setNeedsNetwork(!QUrl::fromUserInput(mSettings->path()).isLocalFile()); } ~SingleFileResource() { delete mSettings; } /** * Read changes from the backend file. */ void readFile(bool taskContext = false) override { if (KDirWatch::self()->contains(mCurrentUrl.toLocalFile())) { KDirWatch::self()->removeFile(mCurrentUrl.toLocalFile()); } if (mSettings->path().isEmpty()) { const QString message = i18n("No file selected."); qWarning() << message; - emit status(NotConfigured, i18n("The resource not configured yet")); + Q_EMIT status(NotConfigured, i18n("The resource not configured yet")); if (taskContext) { cancelTask(); } return; } mCurrentUrl = QUrl::fromUserInput(mSettings->path()); // the string contains the scheme if remote, doesn't if local path if (mCurrentHash.isEmpty()) { // First call to readFile() lets see if there is a hash stored in a // cache file. If both are the same than there is no need to load the // file and synchronize the resource. mCurrentHash = loadHash(); } if (mCurrentUrl.isLocalFile()) { if (mSettings->displayName().isEmpty() && (name().isEmpty() || name() == identifier()) && !mCurrentUrl.isEmpty()) { setName(mCurrentUrl.fileName()); } // check if the file does not exist yet, if so, create it if (!QFile::exists(mCurrentUrl.toLocalFile())) { QFile f(mCurrentUrl.toLocalFile()); // first create try to create the directory the file should be located in QDir dir = QFileInfo(f).dir(); if (!dir.exists()) { dir.mkpath(dir.path()); } if (f.open(QIODevice::WriteOnly) && f.resize(0)) { - emit status(Idle, i18nc("@info:status", "Ready")); + Q_EMIT status(Idle, i18nc("@info:status", "Ready")); } else { const QString message = i18n("Could not create file '%1'.", mCurrentUrl.toDisplayString()); qWarning() << message; - emit status(Broken, message); + Q_EMIT status(Broken, message); mCurrentUrl.clear(); if (taskContext) { cancelTask(); } return; } } // Cache, because readLocalFile will clear mCurrentUrl on failure. const QString localFileName = mCurrentUrl.toLocalFile(); if (!readLocalFile(localFileName)) { const QString message = i18n("Could not read file '%1'", localFileName); qWarning() << message; - emit status(Broken, message); + Q_EMIT status(Broken, message); if (taskContext) { cancelTask(); } return; } if (mSettings->monitorFile()) { KDirWatch::self()->addFile(localFileName); } - emit status(Idle, i18nc("@info:status", "Ready")); + Q_EMIT status(Idle, i18nc("@info:status", "Ready")); } else { // !mCurrentUrl.isLocalFile() if (mDownloadJob) { const QString message = i18n("Another download is still in progress."); qWarning() << message; - emit error(message); + Q_EMIT error(message); if (taskContext) { cancelTask(); } return; } if (mUploadJob) { const QString message = i18n("Another file upload is still in progress."); qWarning() << message; - emit error(message); + Q_EMIT error(message); if (taskContext) { cancelTask(); } return; } auto ref = new QEventLoopLocker(); // NOTE: Test what happens with remotefile -> save, close before save is finished. mDownloadJob = KIO::file_copy(mCurrentUrl, QUrl::fromLocalFile(cacheFile()), -1, KIO::Overwrite |KIO::DefaultFlags | KIO::HideProgressInfo); mDownloadJob->setProperty("QEventLoopLocker", QVariant::fromValue(ref)); connect(mDownloadJob, &KJob::result, this, &SingleFileResource::slotDownloadJobResult); connect(mDownloadJob, SIGNAL(percent(KJob*,ulong)), SLOT(handleProgress(KJob*,ulong))); - emit status(Running, i18n("Downloading remote file.")); + Q_EMIT status(Running, i18n("Downloading remote file.")); } const QString display = mSettings->displayName(); if (!display.isEmpty()) { setName(display); } } void writeFile(const QVariant &task_context) override { writeFile(task_context.canConvert() && task_context.toBool()); } /** * Write changes to the backend file. */ void writeFile(bool taskContext = false) override { if (mSettings->readOnly()) { const QString message = i18n("Trying to write to a read-only file: '%1'.", mSettings->path()); qWarning() << message; - emit error(message); + Q_EMIT error(message); if (taskContext) { cancelTask(); } return; } // We don't use the Settings::self()->path() here as that might have changed // and in that case it would probably cause data lose. if (mCurrentUrl.isEmpty()) { const QString message = i18n("No file specified."); qWarning() << message; - emit status(Broken, message); + Q_EMIT status(Broken, message); if (taskContext) { cancelTask(); } return; } if (mCurrentUrl.isLocalFile()) { KDirWatch::self()->stopScan(); const bool writeResult = writeToFile(mCurrentUrl.toLocalFile()); // Update the hash so we can detect at fileChanged() if the file actually // did change. mCurrentHash = calculateHash(mCurrentUrl.toLocalFile()); saveHash(mCurrentHash); KDirWatch::self()->startScan(); if (!writeResult) { qWarning() << "Error writing to file..."; if (taskContext) { cancelTask(); } return; } - emit status(Idle, i18nc("@info:status", "Ready")); + Q_EMIT status(Idle, i18nc("@info:status", "Ready")); } else { // Check if there is a download or an upload in progress. if (mDownloadJob) { const QString message = i18n("A download is still in progress."); qWarning() << message; - emit error(message); + Q_EMIT error(message); if (taskContext) { cancelTask(); } return; } if (mUploadJob) { const QString message = i18n("Another file upload is still in progress."); qWarning() << message; - emit error(message); + Q_EMIT error(message); if (taskContext) { cancelTask(); } return; } // Write te items to the locally cached file. if (!writeToFile(cacheFile())) { qWarning() << "Error writing to file"; if (taskContext) { cancelTask(); } return; } // Update the hash so we can detect at fileChanged() if the file actually // did change. mCurrentHash = calculateHash(cacheFile()); saveHash(mCurrentHash); auto ref = new QEventLoopLocker(); // Start a job to upload the locally cached file to the remote location. mUploadJob = KIO::file_copy(QUrl::fromLocalFile(cacheFile()), mCurrentUrl, -1, KIO::Overwrite | KIO::DefaultFlags | KIO::HideProgressInfo); mUploadJob->setProperty("QEventLoopLocker", QVariant::fromValue(ref)); connect(mUploadJob, &KJob::result, this, &SingleFileResource::slotUploadJobResult); connect(mUploadJob, SIGNAL(percent(KJob*,ulong)), SLOT(handleProgress(KJob*,ulong))); - emit status(Running, i18n("Uploading cached file to remote location.")); + Q_EMIT status(Running, i18n("Uploading cached file to remote location.")); } if (taskContext) { taskDone(); } } void collectionChanged(const Collection &collection) override { QString newName; if (collection.hasAttribute()) { const EntityDisplayAttribute *attr = collection.attribute(); newName = attr->displayName(); } const QString oldName = mSettings->displayName(); if (newName != oldName) { mSettings->setDisplayName(newName); mSettings->save(); } SingleFileResourceBase::collectionChanged(collection); } Collection rootCollection() const override { Collection c; c.setParentCollection(Collection::root()); c.setRemoteId(mSettings->path()); const QString display = mSettings->displayName(); c.setName(display.isEmpty() ? identifier() : display); c.setContentMimeTypes(mSupportedMimetypes); if (readOnly()) { c.setRights(Collection::CanChangeCollection); } else { Collection::Rights rights; rights |= Collection::CanChangeItem; rights |= Collection::CanCreateItem; rights |= Collection::CanDeleteItem; rights |= Collection::CanChangeCollection; c.setRights(rights); } EntityDisplayAttribute *attr = c.attribute(Collection::AddIfMissing); attr->setDisplayName(name()); attr->setIconName(mCollectionIcon); return c; } protected: void retrieveCollections() override { Collection::List list; list << rootCollection(); collectionsRetrieved(list); } bool readOnly() const override { return mSettings->readOnly(); } protected: Settings *mSettings = nullptr; }; } #endif