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));
}
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();
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 );
}
* 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& );