From f0f3dc413a1ab1d1c34ac52fcb2adb2f0c34e68e Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sat, 20 Nov 2010 14:50:14 +0000 Subject: [PATCH] Fixed open folder in shared files in portable version. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3834 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/RemoteDirModel.cpp | 37 ++++++++------------ retroshare-gui/src/gui/RemoteDirModel.h | 8 ++--- retroshare-gui/src/gui/SharedFilesDialog.cpp | 4 +-- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index bcd3a4729..0eab1e76a 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -766,7 +766,7 @@ Qt::ItemFlags RemoteDirModel::flags( const QModelIndex & index ) const // //rsFiles -> RequestDirectories(id, path, 1); //} -void RemoteDirModel::downloadSelected(QModelIndexList list) +void RemoteDirModel::downloadSelected(const QModelIndexList &list) { if (!RemoteMode) { @@ -846,12 +846,12 @@ void RemoteDirModel::downloadDirectory(const DirDetails & dirDetails, int prefix } } -void RemoteDirModel::getDirDetailsFromSelect (QModelIndexList list, std::vector & dirVec) +void RemoteDirModel::getDirDetailsFromSelect (const QModelIndexList &list, std::vector & dirVec) { dirVec.clear(); /* Fire off requests */ - QModelIndexList::iterator it; + QModelIndexList::const_iterator it; for(it = list.begin(); it != list.end(); it++) { if(it->column()==1) @@ -945,7 +945,7 @@ void RemoteDirModel::getFileInfoFromIndexList(const QModelIndexList& list, std:: * OLD RECOMMEND SYSTEM - DISABLED ******/ -void RemoteDirModel::openSelected(QModelIndexList qmil, bool openFolder) +void RemoteDirModel::openSelected(const QModelIndexList &qmil) { #ifdef RDM_DEBUG std::cerr << "RemoteDirModel::openSelected()" << std::endl; @@ -968,37 +968,28 @@ void RemoteDirModel::openSelected(QModelIndexList qmil, bool openFolder) { if ((*it).type & DIR_TYPE_PERSON) continue; - std::string fullpath, name; - rsFiles->ConvertSharedFilePath((*it).path, fullpath); - int len = fullpath.length(); - if (len && (fullpath[len - 1] != '/')) fullpath += '/'; + std::string path, name; + rsFiles->ConvertSharedFilePath((*it).path, path); + QDir dir(QString::fromUtf8(path.c_str())); + QString dest; if ((*it).type & DIR_TYPE_FILE) { - name = fullpath + (*it).name; + dest = dir.absoluteFilePath(QString::fromUtf8(it->name.c_str())); } else if ((*it).type & DIR_TYPE_DIR) { - name = fullpath; + dest = dir.absolutePath(); } - std::cerr << "Opennign this file: " << name << std::endl ; + std::cerr << "Opening this file: " << dest.toStdString() << std::endl ; - QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromUtf8(name.c_str(),name.length()))); + QDesktopServices::openUrl(QUrl::fromLocalFile(dest)); } -// if (openFolder) { -// std::list::iterator dit; -// for (dit = dirs_to_open.begin(); dit != dirs_to_open.end(); dit++) -// { -// std::cerr << "Opennign this folder: " << (*dit).c_str() << std::endl ; -// QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromUtf8((*dit).c_str()))); -// } -// } - #ifdef RDM_DEBUG std::cerr << "::::::::::::Done RemoteDirModel::openSelected()" << std::endl; #endif } -void RemoteDirModel::getFilePaths(QModelIndexList list, std::list &fullpaths) +void RemoteDirModel::getFilePaths(const QModelIndexList &list, std::list &fullpaths) { #ifdef RDM_DEBUG std::cerr << "RemoteDirModel::getFilePaths()" << std::endl; @@ -1011,7 +1002,7 @@ void RemoteDirModel::getFilePaths(QModelIndexList list, std::list & return; } /* translate */ - QModelIndexList::iterator it; + QModelIndexList::const_iterator it; for(it = list.begin(); it != list.end(); it++) { void *ref = it -> internalPointer(); diff --git a/retroshare-gui/src/gui/RemoteDirModel.h b/retroshare-gui/src/gui/RemoteDirModel.h index 57a834ad6..baf5f1320 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.h +++ b/retroshare-gui/src/gui/RemoteDirModel.h @@ -63,18 +63,18 @@ class RemoteDirModel : public QAbstractItemModel void postMods(); /* Callback from GUI */ - void downloadSelected(QModelIndexList list); + void downloadSelected(const QModelIndexList &list); - void getDirDetailsFromSelect (QModelIndexList list, std::vector & dirVec); + void getDirDetailsFromSelect (const QModelIndexList &list, std::vector & dirVec); int getType ( const QModelIndex & index ) const ; //void openFile(QModelIndex fileIndex, const QString command); void getFileInfoFromIndexList(const QModelIndexList& list, std::list& files_info) ; - void openSelected(QModelIndexList list, bool openFolder); + void openSelected(const QModelIndexList &list); - void getFilePaths(QModelIndexList list, std::list &fullpaths); + void getFilePaths(const QModelIndexList &list, std::list &fullpaths); void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; } diff --git a/retroshare-gui/src/gui/SharedFilesDialog.cpp b/retroshare-gui/src/gui/SharedFilesDialog.cpp index 01ccf3c21..baea40ec4 100644 --- a/retroshare-gui/src/gui/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/SharedFilesDialog.cpp @@ -601,7 +601,7 @@ void SharedFilesDialog::openfile() std::cerr << "SharedFilesDialog::openfile" << std::endl; QModelIndexList qmil = getLocalSelected(); - localModel->openSelected(qmil, false); + localModel->openSelected(qmil); } @@ -610,7 +610,7 @@ void SharedFilesDialog::openfolder() std::cerr << "SharedFilesDialog::openfolder" << std::endl; QModelIndexList qmil = getLocalSelected(); - localModel->openSelected(qmil, true); + localModel->openSelected(qmil); } void SharedFilesDialog::preModDirectories(bool update_local)