]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/versioncontrol/versioncontrolobserver.cpp
Respect Shift- and Control-key for the rubberband selection
[dolphin.git] / src / views / versioncontrol / versioncontrolobserver.cpp
index 76f1754512f0e03f5a203c6df33e43ade70eebff..583e183fce16d61e267b0acaaeb701e7f04206e2 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2009 by Peter Penz <peter.penz19@gmail.com>             *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
 #include <QMutexLocker>
 #include <QTimer>
 
-#include <views/dolphinmodel.h>
-
-VersionControlObserver::VersionControlObserver(QAbstractItemView* view) :
+VersionControlObserver::VersionControlObserver(QWidget* view) :
     QObject(view),
     m_pendingItemStatesUpdate(false),
     m_versionedDirectory(false),
     m_silentUpdate(false),
     m_view(view),
-    m_dirLister(0),
-    m_dolphinModel(0),
+    //m_dirLister(0),
+    //m_dolphinModel(0),
     m_dirVerificationTimer(0),
     m_plugin(0),
     m_updateItemStatesThread(0)
 {
-    Q_ASSERT(view != 0);
+    Q_ASSERT(view);
+
+    /*QAbstractProxyModel* proxyModel = qobject_cast<QAbstractProxyModel*>(view->model());
+    m_dolphinModel = proxyModel ?
+                     qobject_cast<DolphinModel*>(proxyModel->sourceModel()) :
+                     qobject_cast<DolphinModel*>(view->model());
 
-    QAbstractProxyModel* proxyModel = qobject_cast<QAbstractProxyModel*>(view->model());
-    m_dolphinModel = (proxyModel == 0) ?
-                     qobject_cast<DolphinModel*>(view->model()) :
-                     qobject_cast<DolphinModel*>(proxyModel->sourceModel());
-    if (m_dolphinModel != 0) {
+    if (m_dolphinModel) {
         m_dirLister = m_dolphinModel->dirLister();
         connect(m_dirLister, SIGNAL(completed()),
                 this, SLOT(delayedDirectoryVerification()));
@@ -70,12 +69,12 @@ VersionControlObserver::VersionControlObserver(QAbstractItemView* view) :
         m_dirVerificationTimer->setInterval(500);
         connect(m_dirVerificationTimer, SIGNAL(timeout()),
                 this, SLOT(verifyDirectory()));
-    }
+    }*/
 }
 
 VersionControlObserver::~VersionControlObserver()
 {
-    if (m_updateItemStatesThread != 0) {
+    if (m_updateItemStatesThread) {
         if (m_updateItemStatesThread->isFinished()) {
             delete m_updateItemStatesThread;
             m_updateItemStatesThread = 0;
@@ -91,7 +90,7 @@ VersionControlObserver::~VersionControlObserver()
         }
     }
 
-    if (m_plugin != 0) {
+    if (m_plugin) {
         m_plugin->disconnect();
         m_plugin = 0;
     }
@@ -132,17 +131,17 @@ void VersionControlObserver::silentDirectoryVerification()
 
 void VersionControlObserver::verifyDirectory()
 {
-    const KUrl versionControlUrl = m_dirLister->url();
+    const KUrl versionControlUrl; // = m_dirLister->url();
     if (!versionControlUrl.isLocalFile()) {
         return;
     }
 
-    if (m_plugin != 0) {
+    if (m_plugin) {
         m_plugin->disconnect();
     }
 
     m_plugin = searchPlugin(versionControlUrl);
-    if (m_plugin != 0) {
+    /*if (m_plugin) {
         connect(m_plugin, SIGNAL(versionStatesChanged()),
                 this, SLOT(silentDirectoryVerification()));
         connect(m_plugin, SIGNAL(infoMessage(QString)),
@@ -158,9 +157,9 @@ void VersionControlObserver::verifyDirectory()
             // The directory is versioned. Assume that the user will further browse through
             // versioned directories and decrease the verification timer.
             m_dirVerificationTimer->setInterval(100);
-            connect(m_dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
+            connect(m_dirLister, SIGNAL(refreshItems(QList<QPair<KFileItem,KFileItem> >)),
                     this, SLOT(delayedDirectoryVerification()));
-            connect(m_dirLister, SIGNAL(newItems(const KFileItemList&)),
+            connect(m_dirLister, SIGNAL(newItems(KFileItemList)),
                     this, SLOT(delayedDirectoryVerification()));
         }
         updateItemStates();
@@ -171,16 +170,16 @@ void VersionControlObserver::verifyDirectory()
         // value, so that browsing through non-versioned directories is not slown down
         // by an immediate verification.
         m_dirVerificationTimer->setInterval(500);
-        disconnect(m_dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
+        disconnect(m_dirLister, SIGNAL(refreshItems(QList<QPair<KFileItem,KFileItem> >)),
                    this, SLOT(delayedDirectoryVerification()));
-        disconnect(m_dirLister, SIGNAL(newItems(const KFileItemList&)),
+        disconnect(m_dirLister, SIGNAL(newItems(KFileItemList)),
                    this, SLOT(delayedDirectoryVerification()));
-    }
+    }*/
 }
 
 void VersionControlObserver::slotThreadFinished()
 {
-    if (m_plugin == 0) {
+    if (!m_plugin) {
         return;
     }
 
@@ -194,7 +193,7 @@ void VersionControlObserver::slotThreadFinished()
     // (a detailed description of the root cause is given in the class KFilePreviewGenerator
     // from kdelibs). To bypass this bottleneck, the signals of the model are temporary blocked.
     // This works as the update of the data does not require a relayout of the views used in Dolphin.
-    const bool signalsBlocked = m_dolphinModel->signalsBlocked();
+    /*const bool signalsBlocked = m_dolphinModel->signalsBlocked();
     m_dolphinModel->blockSignals(true);
 
     const QList<ItemState> itemStates = m_updateItemStatesThread->itemStates();
@@ -217,13 +216,13 @@ void VersionControlObserver::slotThreadFinished()
     if (m_pendingItemStatesUpdate) {
         m_pendingItemStatesUpdate = false;
         updateItemStates();
-    }
+    }*/
 }
 
 void VersionControlObserver::updateItemStates()
 {
-    Q_ASSERT(m_plugin != 0);
-    if (m_updateItemStatesThread == 0) {
+    Q_ASSERT(m_plugin);
+    if (!m_updateItemStatesThread) {
         m_updateItemStatesThread = new UpdateItemStatesThread();
         connect(m_updateItemStatesThread, SIGNAL(finished()),
                 this, SLOT(slotThreadFinished()));
@@ -248,7 +247,9 @@ void VersionControlObserver::updateItemStates()
 
 void VersionControlObserver::addDirectory(const QModelIndex& parentIndex, QList<ItemState>& itemStates)
 {
-    const int rowCount = m_dolphinModel->rowCount(parentIndex);
+    Q_UNUSED(parentIndex);
+    Q_UNUSED(itemStates);
+    /*const int rowCount = m_dolphinModel->rowCount(parentIndex);
     for (int row = 0; row < rowCount; ++row) {
         const QModelIndex index = m_dolphinModel->index(row, DolphinModel::Version, parentIndex);
         addDirectory(index, itemStates);
@@ -259,7 +260,7 @@ void VersionControlObserver::addDirectory(const QModelIndex& parentIndex, QList<
         itemState.version = KVersionControlPlugin::UnversionedVersion;
 
         itemStates.append(itemState);
-    }
+    }*/
 }
 
 KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& directory) const
@@ -282,7 +283,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
         for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) {
             if (enabledPlugins.contains((*it)->name())) {
                 KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>();
-                if (plugin != 0) {
+                if (plugin) {
                     plugins.append(plugin);
                 }
             }
@@ -295,7 +296,8 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
 
     // Verify whether the current directory contains revision information
     // like .svn, .git, ...
-    foreach (KVersionControlPlugin* plugin, plugins) {
+    Q_UNUSED(directory);
+    /*foreach (KVersionControlPlugin* plugin, plugins) {
         // Use the KDirLister cache to check for .svn, .git, ... files
         KUrl dirUrl(directory);
         KUrl fileUrl = dirUrl;
@@ -323,14 +325,14 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
                 upUrl = dirUrl.upUrl();
             }
         }
-    }
+    }*/
 
     return 0;
 }
 
 bool VersionControlObserver::isVersioned() const
 {
-    return m_dolphinModel->hasVersionData() && (m_plugin != 0);
+    return false; //m_dolphinModel->hasVersionData() && m_plugin;
 }
 
 #include "versioncontrolobserver.moc"