Activity List: Improve double click handling on filenames #4168
authorMarkus Goetz <markus@woboq.com>
Tue, 24 Nov 2015 13:24:18 +0000 (14:24 +0100)
committerMarkus Goetz <markus@woboq.com>
Tue, 24 Nov 2015 13:25:16 +0000 (14:25 +0100)
src/gui/activitywidget.cpp
src/gui/folderman.cpp
src/gui/folderman.h

index 67f8db90daa0f02ae76cffcb5e05a9fde272c19e..cd40c9ae88f94aea33c6af9e554513fe004b3fae 100644 (file)
@@ -73,7 +73,12 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
 
     switch (role) {
     case ActivityItemDelegate::PathRole:
-        list = FolderMan::instance()->findFileInLocalFolders(a._file);
+        list = FolderMan::instance()->findFileInLocalFolders(a._file, ast->account());
+        if( list.count() > 0 ) {
+            return QVariant(list.at(0));
+        }
+        // File does not exist anymore? Let's try to open its path
+        list = FolderMan::instance()->findFileInLocalFolders(QFileInfo(a._file).path(), ast->account());
         if( list.count() > 0 ) {
             return QVariant(list.at(0));
         }
@@ -366,6 +371,7 @@ void ActivityWidget::storeActivityList( QTextStream& ts )
 
 void ActivityWidget::slotOpenFile(QModelIndex indx)
 {
+    qDebug() << indx.isValid() << indx.data(ActivityItemDelegate::PathRole).toString() << QFile::exists(indx.data(ActivityItemDelegate::PathRole).toString());
     if( indx.isValid() ) {
         QString fullPath = indx.data(ActivityItemDelegate::PathRole).toString();
 
index 8400c4dad0b8290fba4e363a0ddf8cdf9e258b70..18759a6f31d690133746544579554093178b067a 100644 (file)
@@ -815,17 +815,20 @@ Folder *FolderMan::folderForPath(const QString &path)
     return 0;
 }
 
-QStringList FolderMan::findFileInLocalFolders( const QString& relPath )
+QStringList FolderMan::findFileInLocalFolders( const QString& relPath, const AccountPtr acc )
 {
     QStringList re;
 
     foreach(Folder* folder, this->map().values()) {
+        if (acc != 0 && folder->accountState()->account() != acc) {
+            continue;
+        }
         QString path = folder->cleanPath();
         QString remRelPath;
         // cut off the remote path from the server path.
         remRelPath = relPath.mid(folder->remotePath().length());
+        path += "/";
         path += remRelPath;
-
         if( QFile::exists(path) ) {
             re.append( path );
         }
index eb9a3e3d438a99c8bb5be47f47f4144b121a5f28..b63e750d886d2fdd94ee6052b019d7eb4e84e6e9 100644 (file)
@@ -62,7 +62,7 @@ public:
       * incoming relative server path. The method checks with all existing sync
       * folders.
       */
-    QStringList findFileInLocalFolders( const QString& relPath );
+    QStringList findFileInLocalFolders( const QString& relPath, const AccountPtr acc );
 
     /** Returns the folder by alias or NULL if no folder with the alias exists. */
     Folder *folder( const QString& );