]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge branch 'Applications/18.12'
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Sat, 2 Feb 2019 20:37:06 +0000 (21:37 +0100)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sat, 2 Feb 2019 20:37:06 +0000 (21:37 +0100)
1  2 
src/views/dolphinview.cpp
src/views/versioncontrol/versioncontrolobserver.cpp

index e3a986e118e5b9a7787020642e575505cc78849d,d64ae86224f83cc25b646966a912b6c25e21ac4c..7eb4d24546ecf69140a12fa7b6a74958fb8262f6
@@@ -182,6 -182,7 +182,7 @@@ DolphinView::DolphinView(const QUrl& ur
  #endif
  
      m_versionControlObserver = new VersionControlObserver(this);
+     m_versionControlObserver->setView(this);
      m_versionControlObserver->setModel(m_model);
      connect(m_versionControlObserver, &VersionControlObserver::infoMessage, this, &DolphinView::infoMessage);
      connect(m_versionControlObserver, &VersionControlObserver::errorMessage, this, &DolphinView::errorMessage);
@@@ -638,7 -639,9 +639,7 @@@ void DolphinView::renameSelectedItems(
          RenameDialog* dialog = new RenameDialog(this, items);
          connect(dialog, &RenameDialog::renamingFinished, this, &DolphinView::slotRenameDialogRenamingFinished);
  
 -        dialog->show();
 -        dialog->raise();
 -        dialog->activateWindow();
 +        dialog->open();
      }
  
      // Assure that the current index remains visible when KFileItemModel
index 62f4cfd167b4268b1367fd93e80c767b81917398,cfbebc7601385f0d2525e648a48214d9f96d106c..fc74390a9999978f2f9dc18f68fe4abbf78afa64
@@@ -21,6 -21,7 +21,7 @@@
  
  #include "dolphin_versioncontrolsettings.h"
  #include "dolphindebug.h"
+ #include "views/dolphinview.h"
  #include "kitemviews/kfileitemmodel.h"
  #include "updateitemstatesthread.h"
  
@@@ -35,8 -36,10 +36,10 @@@ VersionControlObserver::VersionControlO
      m_pendingItemStatesUpdate(false),
      m_versionedDirectory(false),
      m_silentUpdate(false),
+     m_view(nullptr),
      m_model(nullptr),
      m_dirVerificationTimer(nullptr),
+     m_pluginsInitialized(false),
      m_plugin(nullptr),
      m_updateItemStatesThread(nullptr)
  {
@@@ -84,6 -87,26 +87,26 @@@ KFileItemModel* VersionControlObserver:
      return m_model;
  }
  
+ void VersionControlObserver::setView(DolphinView* view)
+ {
+     if (m_view) {
+         disconnect(m_view, &DolphinView::activated,
+                    this, &VersionControlObserver::delayedDirectoryVerification);
+     }
+     m_view = view;
+     if (m_view) {
+         connect(m_view, &DolphinView::activated,
+                 this, &VersionControlObserver::delayedDirectoryVerification);
+     }
+ }
+ DolphinView* VersionControlObserver::view() const
+ {
+     return m_view;
+ }
  QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) const
  {
      bool hasNullItems = false;
@@@ -248,7 -271,7 +271,7 @@@ int VersionControlObserver::createItemS
          }
      }
  
 -    if (items.count() > 0) {
 +    if (!items.isEmpty()) {
          const QUrl& url = items.first().first.url();
          itemStates.insert(url.adjusted(QUrl::RemoveFilename).path(), items);
      }
      return index - firstIndex; // number of processed items
  }
  
- KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& directory) const
+ KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& directory)
  {
-     static bool pluginsAvailable = true;
-     static QList<KVersionControlPlugin*> plugins;
-     if (!pluginsAvailable) {
-         // A searching for plugins has already been done, but no
-         // plugins are installed
-         return nullptr;
-     }
-     if (plugins.isEmpty()) {
+     if (!m_pluginsInitialized) {
          // No searching for plugins has been done yet. Query the KServiceTypeTrader for
          // all fileview version control plugins and remember them in 'plugins'.
          const QStringList enabledPlugins = VersionControlSettings::enabledPlugins();
          const KService::List pluginServices = KServiceTypeTrader::self()->query(QStringLiteral("FileViewVersionControlPlugin"));
          for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) {
              if (enabledPlugins.contains((*it)->name())) {
-                 KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>();
+                 KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>(this);
                  if (plugin) {
-                     plugins.append(plugin);
+                     m_plugins.append(plugin);
                  }
              }
          }
-         if (plugins.isEmpty()) {
-             pluginsAvailable = false;
-             return nullptr;
-         }
+         m_pluginsInitialized = true;
+     }
+     if (m_plugins.empty()) {
+         // A searching for plugins has already been done, but no
+         // plugins are installed
+         return nullptr;
      }
  
      // We use the number of upUrl() calls to find the best matching plugin
  
      // Verify whether the current directory contains revision information
      // like .svn, .git, ...
-     foreach (KVersionControlPlugin* plugin, plugins) {
+     foreach (KVersionControlPlugin* plugin, m_plugins) {
          const QString fileName = directory.path() + '/' + plugin->fileName();
          if (QFile::exists(fileName)) {
              // The score of this plugin is 0 (best), so we can just return this plugin,