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
This commit is contained in:
thunder2 2010-11-20 14:50:14 +00:00
parent 7bcebc8e2b
commit f0f3dc413a
3 changed files with 20 additions and 29 deletions

View File

@ -766,7 +766,7 @@ Qt::ItemFlags RemoteDirModel::flags( const QModelIndex & index ) const
// //rsFiles -> RequestDirectories(id, path, 1); // //rsFiles -> RequestDirectories(id, path, 1);
//} //}
void RemoteDirModel::downloadSelected(QModelIndexList list) void RemoteDirModel::downloadSelected(const QModelIndexList &list)
{ {
if (!RemoteMode) if (!RemoteMode)
{ {
@ -846,12 +846,12 @@ void RemoteDirModel::downloadDirectory(const DirDetails & dirDetails, int prefix
} }
} }
void RemoteDirModel::getDirDetailsFromSelect (QModelIndexList list, std::vector <DirDetails>& dirVec) void RemoteDirModel::getDirDetailsFromSelect (const QModelIndexList &list, std::vector <DirDetails>& dirVec)
{ {
dirVec.clear(); dirVec.clear();
/* Fire off requests */ /* Fire off requests */
QModelIndexList::iterator it; QModelIndexList::const_iterator it;
for(it = list.begin(); it != list.end(); it++) for(it = list.begin(); it != list.end(); it++)
{ {
if(it->column()==1) if(it->column()==1)
@ -945,7 +945,7 @@ void RemoteDirModel::getFileInfoFromIndexList(const QModelIndexList& list, std::
* OLD RECOMMEND SYSTEM - DISABLED * OLD RECOMMEND SYSTEM - DISABLED
******/ ******/
void RemoteDirModel::openSelected(QModelIndexList qmil, bool openFolder) void RemoteDirModel::openSelected(const QModelIndexList &qmil)
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "RemoteDirModel::openSelected()" << std::endl; std::cerr << "RemoteDirModel::openSelected()" << std::endl;
@ -968,37 +968,28 @@ void RemoteDirModel::openSelected(QModelIndexList qmil, bool openFolder)
{ {
if ((*it).type & DIR_TYPE_PERSON) continue; if ((*it).type & DIR_TYPE_PERSON) continue;
std::string fullpath, name; std::string path, name;
rsFiles->ConvertSharedFilePath((*it).path, fullpath); rsFiles->ConvertSharedFilePath((*it).path, path);
int len = fullpath.length();
if (len && (fullpath[len - 1] != '/')) fullpath += '/';
QDir dir(QString::fromUtf8(path.c_str()));
QString dest;
if ((*it).type & DIR_TYPE_FILE) { 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) { } 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<std::string>::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 #ifdef RDM_DEBUG
std::cerr << "::::::::::::Done RemoteDirModel::openSelected()" << std::endl; std::cerr << "::::::::::::Done RemoteDirModel::openSelected()" << std::endl;
#endif #endif
} }
void RemoteDirModel::getFilePaths(QModelIndexList list, std::list<std::string> &fullpaths) void RemoteDirModel::getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths)
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "RemoteDirModel::getFilePaths()" << std::endl; std::cerr << "RemoteDirModel::getFilePaths()" << std::endl;
@ -1011,7 +1002,7 @@ void RemoteDirModel::getFilePaths(QModelIndexList list, std::list<std::string> &
return; return;
} }
/* translate */ /* translate */
QModelIndexList::iterator it; QModelIndexList::const_iterator it;
for(it = list.begin(); it != list.end(); it++) for(it = list.begin(); it != list.end(); it++)
{ {
void *ref = it -> internalPointer(); void *ref = it -> internalPointer();

View File

@ -63,18 +63,18 @@ class RemoteDirModel : public QAbstractItemModel
void postMods(); void postMods();
/* Callback from GUI */ /* Callback from GUI */
void downloadSelected(QModelIndexList list); void downloadSelected(const QModelIndexList &list);
void getDirDetailsFromSelect (QModelIndexList list, std::vector <DirDetails>& dirVec); void getDirDetailsFromSelect (const QModelIndexList &list, std::vector <DirDetails>& dirVec);
int getType ( const QModelIndex & index ) const ; int getType ( const QModelIndex & index ) const ;
//void openFile(QModelIndex fileIndex, const QString command); //void openFile(QModelIndex fileIndex, const QString command);
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ; void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
void openSelected(QModelIndexList list, bool openFolder); void openSelected(const QModelIndexList &list);
void getFilePaths(QModelIndexList list, std::list<std::string> &fullpaths); void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; } void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }

View File

@ -601,7 +601,7 @@ void SharedFilesDialog::openfile()
std::cerr << "SharedFilesDialog::openfile" << std::endl; std::cerr << "SharedFilesDialog::openfile" << std::endl;
QModelIndexList qmil = getLocalSelected(); QModelIndexList qmil = getLocalSelected();
localModel->openSelected(qmil, false); localModel->openSelected(qmil);
} }
@ -610,7 +610,7 @@ void SharedFilesDialog::openfolder()
std::cerr << "SharedFilesDialog::openfolder" << std::endl; std::cerr << "SharedFilesDialog::openfolder" << std::endl;
QModelIndexList qmil = getLocalSelected(); QModelIndexList qmil = getLocalSelected();
localModel->openSelected(qmil, true); localModel->openSelected(qmil);
} }
void SharedFilesDialog::preModDirectories(bool update_local) void SharedFilesDialog::preModDirectories(bool update_local)