From 38c34eeca315c7be58e65d4d3fb72aaf7b866719 Mon Sep 17 00:00:00 2001 From: Serg Podtynnyi Date: Sat, 4 Feb 2023 00:14:53 +0700 Subject: Add clang-format and format code as in Frameworks --- src/views/versioncontrol/kversioncontrolplugin.cpp | 6 +- src/views/versioncontrol/kversioncontrolplugin.h | 22 ++--- .../versioncontrol/updateitemstatesthread.cpp | 21 ++--- src/views/versioncontrol/updateitemstatesthread.h | 11 +-- .../versioncontrol/versioncontrolobserver.cpp | 101 +++++++++------------ src/views/versioncontrol/versioncontrolobserver.h | 36 ++++---- 6 files changed, 87 insertions(+), 110 deletions(-) (limited to 'src/views/versioncontrol') diff --git a/src/views/versioncontrol/kversioncontrolplugin.cpp b/src/views/versioncontrol/kversioncontrolplugin.cpp index 9cbf0eb5b..0190bb365 100644 --- a/src/views/versioncontrol/kversioncontrolplugin.cpp +++ b/src/views/versioncontrol/kversioncontrolplugin.cpp @@ -7,8 +7,8 @@ #include "kversioncontrolplugin.h" -KVersionControlPlugin::KVersionControlPlugin(QObject* parent) : - QObject(parent) +KVersionControlPlugin::KVersionControlPlugin(QObject *parent) + : QObject(parent) { } @@ -16,7 +16,7 @@ KVersionControlPlugin::~KVersionControlPlugin() { } -QString KVersionControlPlugin::localRepositoryRoot(const QString &/*directory*/) const +QString KVersionControlPlugin::localRepositoryRoot(const QString & /*directory*/) const { return QString(); } diff --git a/src/views/versioncontrol/kversioncontrolplugin.h b/src/views/versioncontrol/kversioncontrolplugin.h index d3a39fbd6..1a4111452 100644 --- a/src/views/versioncontrol/kversioncontrolplugin.h +++ b/src/views/versioncontrol/kversioncontrolplugin.h @@ -73,8 +73,7 @@ class DOLPHINVCS_EXPORT KVersionControlPlugin : public QObject Q_OBJECT public: - enum ItemVersion - { + enum ItemVersion { /** The file is not under version control. */ UnversionedVersion, /** @@ -131,7 +130,7 @@ public: MissingVersion }; - KVersionControlPlugin(QObject* parent = nullptr); + KVersionControlPlugin(QObject *parent = nullptr); ~KVersionControlPlugin() override; /** @@ -145,7 +144,7 @@ public: * Returns the path of the local repository root for the versioned directory * Returns an empty QString when directory is not part of a working copy */ - virtual QString localRepositoryRoot(const QString& directory) const; + virtual QString localRepositoryRoot(const QString &directory) const; /** * Is invoked whenever the version control @@ -153,7 +152,7 @@ public: * \p directory. It is assured that the directory * contains a trailing slash. */ - virtual bool beginRetrieval(const QString& directory) = 0; + virtual bool beginRetrieval(const QString &directory) = 0; /** * Is invoked after the version control information has been @@ -169,13 +168,13 @@ public: * invoked before and that the file is part of the directory specified * in beginRetrieval(). */ - virtual ItemVersion itemVersion(const KFileItem& item) const = 0; + virtual ItemVersion itemVersion(const KFileItem &item) const = 0; /** * @return List of actions that are available for the \p items in a version controlled * path. */ - virtual QList versionControlActions(const KFileItemList& items) const = 0; + virtual QList versionControlActions(const KFileItemList &items) const = 0; /** * @return List of actions that are available for the out of version control @@ -183,7 +182,7 @@ public: * is for clone/checkout actions. * @since 21.04 */ - virtual QList outOfVersionControlActions(const KFileItemList& items) const = 0; + virtual QList outOfVersionControlActions(const KFileItemList &items) const = 0; Q_SIGNALS: /** @@ -201,20 +200,19 @@ Q_SIGNALS: * Is emitted if an information message with the content \a msg * should be shown. */ - void infoMessage(const QString& msg); + void infoMessage(const QString &msg); /** * Is emitted if an error message with the content \a msg * should be shown. */ - void errorMessage(const QString& msg); + void errorMessage(const QString &msg); /** * Is emitted if an "operation completed" message with the content \a msg * should be shown. */ - void operationCompletedMessage(const QString& msg); + void operationCompletedMessage(const QString &msg); }; #endif // KVERSIONCONTROLPLUGIN_H - diff --git a/src/views/versioncontrol/updateitemstatesthread.cpp b/src/views/versioncontrol/updateitemstatesthread.cpp index cf45bbff1..37c36f40c 100644 --- a/src/views/versioncontrol/updateitemstatesthread.cpp +++ b/src/views/versioncontrol/updateitemstatesthread.cpp @@ -6,13 +6,11 @@ #include "updateitemstatesthread.h" - -UpdateItemStatesThread::UpdateItemStatesThread(KVersionControlPlugin* plugin, - const QMap >& itemStates) : - QThread(), - m_globalPluginMutex(nullptr), - m_plugin(plugin), - m_itemStates(itemStates) +UpdateItemStatesThread::UpdateItemStatesThread(KVersionControlPlugin *plugin, const QMap> &itemStates) + : QThread() + , m_globalPluginMutex(nullptr) + , m_plugin(plugin) + , m_itemStates(itemStates) { // Several threads may share one instance of a plugin. A global // mutex is required to serialize the retrieval of version control @@ -31,13 +29,13 @@ void UpdateItemStatesThread::run() Q_ASSERT(m_plugin); QMutexLocker pluginLocker(m_globalPluginMutex); - QMap >::iterator it = m_itemStates.begin(); + QMap>::iterator it = m_itemStates.begin(); for (; it != m_itemStates.end(); ++it) { if (m_plugin->beginRetrieval(it.key())) { - QVector& items = it.value(); + QVector &items = it.value(); const int count = items.count(); for (int i = 0; i < count; ++i) { - const KFileItem& item = items.at(i).first; + const KFileItem &item = items.at(i).first; const KVersionControlPlugin::ItemVersion version = m_plugin->itemVersion(item); items[i].second = version; } @@ -47,8 +45,7 @@ void UpdateItemStatesThread::run() } } -QMap > UpdateItemStatesThread::itemStates() const +QMap> UpdateItemStatesThread::itemStates() const { return m_itemStates; } - diff --git a/src/views/versioncontrol/updateitemstatesthread.h b/src/views/versioncontrol/updateitemstatesthread.h index eac28bb78..24f060d26 100644 --- a/src/views/versioncontrol/updateitemstatesthread.h +++ b/src/views/versioncontrol/updateitemstatesthread.h @@ -31,20 +31,19 @@ public: * UpdateItemStatesThread::unlockPlugin() must be used. * @param itemStates List of items, where the states get updated. */ - UpdateItemStatesThread(KVersionControlPlugin* plugin, - const QMap >& itemStates); + UpdateItemStatesThread(KVersionControlPlugin *plugin, const QMap> &itemStates); ~UpdateItemStatesThread() override; - QMap > itemStates() const; + QMap> itemStates() const; protected: void run() override; private: - QMutex* m_globalPluginMutex; // Protects the m_plugin globally - KVersionControlPlugin* m_plugin; + QMutex *m_globalPluginMutex; // Protects the m_plugin globally + KVersionControlPlugin *m_plugin; - QMap > m_itemStates; + QMap> m_itemStates; }; #endif // UPDATEITEMSTATESTHREAD_H diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp index e0505675a..28fbbef1a 100644 --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@ -8,9 +8,9 @@ #include "dolphin_versioncontrolsettings.h" #include "dolphindebug.h" -#include "views/dolphinview.h" #include "kitemviews/kfileitemmodel.h" #include "updateitemstatesthread.h" +#include "views/dolphinview.h" #include #include @@ -18,16 +18,16 @@ #include -VersionControlObserver::VersionControlObserver(QObject* parent) : - QObject(parent), - m_pendingItemStatesUpdate(false), - m_silentUpdate(false), - m_view(nullptr), - m_model(nullptr), - m_dirVerificationTimer(nullptr), - m_pluginsInitialized(false), - m_plugin(nullptr), - m_updateItemStatesThread(nullptr) +VersionControlObserver::VersionControlObserver(QObject *parent) + : QObject(parent) + , m_pendingItemStatesUpdate(false) + , m_silentUpdate(false) + , m_view(nullptr) + , m_model(nullptr) + , m_dirVerificationTimer(nullptr) + , m_pluginsInitialized(false) + , m_plugin(nullptr) + , m_updateItemStatesThread(nullptr) { // The verification timer specifies the timeout until the shown directory // is checked whether it is versioned. Per default it is assumed that users @@ -37,8 +37,7 @@ VersionControlObserver::VersionControlObserver(QObject* parent) : m_dirVerificationTimer = new QTimer(this); m_dirVerificationTimer->setSingleShot(true); m_dirVerificationTimer->setInterval(500); - connect(m_dirVerificationTimer, &QTimer::timeout, - this, &VersionControlObserver::verifyDirectory); + connect(m_dirVerificationTimer, &QTimer::timeout, this, &VersionControlObserver::verifyDirectory); } VersionControlObserver::~VersionControlObserver() @@ -49,54 +48,48 @@ VersionControlObserver::~VersionControlObserver() } } -void VersionControlObserver::setModel(KFileItemModel* model) +void VersionControlObserver::setModel(KFileItemModel *model) { if (m_model) { - disconnect(m_model, &KFileItemModel::itemsInserted, - this, &VersionControlObserver::delayedDirectoryVerification); - disconnect(m_model, &KFileItemModel::itemsChanged, - this, &VersionControlObserver::slotItemsChanged); + disconnect(m_model, &KFileItemModel::itemsInserted, this, &VersionControlObserver::delayedDirectoryVerification); + disconnect(m_model, &KFileItemModel::itemsChanged, this, &VersionControlObserver::slotItemsChanged); } m_model = model; if (model) { - connect(m_model, &KFileItemModel::itemsInserted, - this, &VersionControlObserver::delayedDirectoryVerification); - connect(m_model, &KFileItemModel::itemsChanged, - this, &VersionControlObserver::slotItemsChanged); + connect(m_model, &KFileItemModel::itemsInserted, this, &VersionControlObserver::delayedDirectoryVerification); + connect(m_model, &KFileItemModel::itemsChanged, this, &VersionControlObserver::slotItemsChanged); } } -KFileItemModel* VersionControlObserver::model() const +KFileItemModel *VersionControlObserver::model() const { return m_model; } -void VersionControlObserver::setView(DolphinView* view) +void VersionControlObserver::setView(DolphinView *view) { if (m_view) { - disconnect(m_view, &DolphinView::activated, - this, &VersionControlObserver::delayedDirectoryVerification); + disconnect(m_view, &DolphinView::activated, this, &VersionControlObserver::delayedDirectoryVerification); } m_view = view; if (m_view) { - connect(m_view, &DolphinView::activated, - this, &VersionControlObserver::delayedDirectoryVerification); + connect(m_view, &DolphinView::activated, this, &VersionControlObserver::delayedDirectoryVerification); } } -DolphinView* VersionControlObserver::view() const +DolphinView *VersionControlObserver::view() const { return m_view; } -QList VersionControlObserver::actions(const KFileItemList& items) const +QList VersionControlObserver::actions(const KFileItemList &items) const { bool hasNullItems = false; - for (const KFileItem& item : items) { + for (const KFileItem &item : items) { if (item.isNull()) { qCWarning(DolphinDebug) << "Requesting version-control-actions for empty items"; hasNullItems = true; @@ -111,7 +104,7 @@ QList VersionControlObserver::actions(const KFileItemList& items) cons if (isVersionControlled()) { return m_plugin->versionControlActions(items); } else { - QList actions; + QList actions; for (const QPointer &plugin : qAsConst(m_plugins)) { actions << plugin->outOfVersionControlActions(items); } @@ -131,14 +124,14 @@ void VersionControlObserver::silentDirectoryVerification() m_dirVerificationTimer->start(); } -void VersionControlObserver::slotItemsChanged(const KItemRangeList& itemRanges, const QSet& roles) +void VersionControlObserver::slotItemsChanged(const KItemRangeList &itemRanges, const QSet &roles) { Q_UNUSED(itemRanges) // Because "version" role is emitted by VCS plugin (ourselves) we don't need to // analyze it and update directory item states information. So lets check if // there is only "version". - if ( !(roles.count() == 1 && roles.contains("version")) ) { + if (!(roles.count() == 1 && roles.contains("version"))) { delayedDirectoryVerification(); } } @@ -176,20 +169,20 @@ void VersionControlObserver::verifyDirectory() void VersionControlObserver::slotThreadFinished() { - UpdateItemStatesThread* thread = m_updateItemStatesThread; + UpdateItemStatesThread *thread = m_updateItemStatesThread; m_updateItemStatesThread = nullptr; // The thread deletes itself automatically (see updateItemStates()) if (!m_plugin || !thread) { return; } - const QMap >& itemStates = thread->itemStates(); - QMap >::const_iterator it = itemStates.constBegin(); + const QMap> &itemStates = thread->itemStates(); + QMap>::const_iterator it = itemStates.constBegin(); for (; it != itemStates.constEnd(); ++it) { - const QVector& items = it.value(); + const QVector &items = it.value(); - for (const ItemState& item : items) { - const KFileItem& fileItem = item.first; + for (const ItemState &item : items) { + const KFileItem &fileItem = item.first; const KVersionControlPlugin::ItemVersion version = item.second; QHash values; values.insert("version", QVariant(version)); @@ -220,7 +213,7 @@ void VersionControlObserver::updateItemStates() return; } - QMap > itemStates; + QMap> itemStates; createItemStatesList(itemStates); if (!itemStates.isEmpty()) { @@ -228,17 +221,14 @@ void VersionControlObserver::updateItemStates() Q_EMIT infoMessage(i18nc("@info:status", "Updating version information...")); } m_updateItemStatesThread = new UpdateItemStatesThread(m_plugin, itemStates); - connect(m_updateItemStatesThread, &UpdateItemStatesThread::finished, - this, &VersionControlObserver::slotThreadFinished); - connect(m_updateItemStatesThread, &UpdateItemStatesThread::finished, - m_updateItemStatesThread, &UpdateItemStatesThread::deleteLater); + connect(m_updateItemStatesThread, &UpdateItemStatesThread::finished, this, &VersionControlObserver::slotThreadFinished); + connect(m_updateItemStatesThread, &UpdateItemStatesThread::finished, m_updateItemStatesThread, &UpdateItemStatesThread::deleteLater); m_updateItemStatesThread->start(); // slotThreadFinished() is called when finished } } -int VersionControlObserver::createItemStatesList(QMap >& itemStates, - const int firstIndex) +int VersionControlObserver::createItemStatesList(QMap> &itemStates, const int firstIndex) { const int itemCount = m_model->count(); const int currentExpansionLevel = m_model->expandedParentsCount(firstIndex); @@ -265,7 +255,7 @@ int VersionControlObserver::createItemStatesList(QMap actions(const KFileItemList& items) const; + QList actions(const KFileItemList &items) const; Q_SIGNALS: /** * Is emitted if an information message with the content \a msg * should be shown. */ - void infoMessage(const QString& msg); + void infoMessage(const QString &msg); /** * Is emitted if an error message with the content \a msg * should be shown. */ - void errorMessage(const QString& msg); + void errorMessage(const QString &msg); /** * Is emitted if an "operation completed" message with the content \a msg * should be shown. */ - void operationCompletedMessage(const QString& msg); + void operationCompletedMessage(const QString &msg); private Q_SLOTS: /** @@ -89,7 +89,7 @@ private Q_SLOTS: * Invokes delayedDirectoryVerification() only if the itemsChanged() signal has not * been triggered by the VCS plugin itself. */ - void slotItemsChanged(const KItemRangeList& itemRanges, const QSet& roles); + void slotItemsChanged(const KItemRangeList &itemRanges, const QSet &roles); void verifyDirectory(); @@ -117,14 +117,13 @@ private: * * @return The number of (recursive) processed items. */ - int createItemStatesList(QMap >& itemStates, - const int firstIndex = 0); + int createItemStatesList(QMap> &itemStates, const int firstIndex = 0); /** * Returns a matching plugin for the given directory. * 0 is returned, if no matching plugin has been found. */ - KVersionControlPlugin* searchPlugin(const QUrl& directory); + KVersionControlPlugin *searchPlugin(const QUrl &directory); /** * Returns true, if the directory contains a version control information. @@ -139,18 +138,17 @@ private: // of version states QString m_localRepoRoot; - DolphinView* m_view; - KFileItemModel* m_model; + DolphinView *m_view; + KFileItemModel *m_model; - QTimer* m_dirVerificationTimer; + QTimer *m_dirVerificationTimer; bool m_pluginsInitialized; - KVersionControlPlugin* m_plugin; + KVersionControlPlugin *m_plugin; QList> m_plugins; - UpdateItemStatesThread* m_updateItemStatesThread; + UpdateItemStatesThread *m_updateItemStatesThread; friend class UpdateItemStatesThread; }; #endif // REVISIONCONTROLOBSERVER_H - -- cgit v1.3