added open file/folder actions in local sharedfiles dialog

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1330 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
alexandrut 2009-07-07 18:56:31 +00:00
parent 902c475b9d
commit cfc2aa89c7
3 changed files with 140 additions and 79 deletions

View File

@ -65,6 +65,8 @@
#define IMAGE_FRIEND ":/images/peers_16x16.png"
#define IMAGE_PROGRESS ":/images/browse-looking.gif"
#define IMAGE_COPYLINK ":/images/copyrslink.png"
#define IMAGE_OPENFOLDER ":/images/folderopen.png"
#define IMAGE_OPENFILE ":/images/fileopen.png"
const QString Image_AddNewAssotiationForFile = ":/images/kcmsystem24.png";
@ -206,6 +208,7 @@ void SharedFilesDialog::shareddirtreeviewCostumPopupMenu( QPoint point )
sendremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), this );
connect( sendremotelinkAct , SIGNAL( triggered() ), this, SLOT( sendremoteLinkTo( ) ) );
// addMsgAct = new QAction( tr( "Add to Message" ), this );
// connect( addMsgAct , SIGNAL( triggered() ), this, SLOT( addMsgRemoteSelected() ) );
@ -470,21 +473,21 @@ void SharedFilesDialog::openfile()
{
/* call back to the model (which does all the interfacing? */
std::cerr << "Opening File";
std::cerr << std::endl;
QItemSelectionModel *qism = ui.localDirTreeView->selectionModel();
model -> openSelected(qism->selectedIndexes());
std::cerr << "SharedFilesDialog::openfile" << std::endl;
QModelIndexList qmil = ui.localDirTreeView->selectionModel()->selectedIndexes();
localModel->openSelected(qmil, false);
}
void SharedFilesDialog::openfolder()
{
std::cerr << "SharedFilesDialog::openfolder" << std::endl;
QModelIndexList qmil = ui.localDirTreeView->selectionModel()->selectedIndexes();
localModel->openSelected(qmil, true);
}
void SharedFilesDialog::preModDirectories(bool update_local)
{
std::cerr << "SharedFilesDialog::preModDirectories called with update_local = " << update_local << std::endl ;
@ -584,12 +587,20 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), this );
connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( /*std::string rsid*/ ) ) );
openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this);
connect(openfileAct, SIGNAL(triggered()), this, SLOT(openfile()));
openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openfolder()));
contextMnu2.addAction( menuAction );
//contextMnu2.addAction( openfileAct);
contextMnu2.addAction( copylinklocalAct);
contextMnu2.addAction( sendlinkAct);
contextMnu2.addSeparator();
contextMnu2.addAction( openfileAct);
contextMnu2.addAction( openfolderAct);
contextMnu2.addSeparator();
contextMnu2.addMenu( recMenu);
contextMnu2.addMenu( msgMenu);

View File

@ -923,11 +923,61 @@ void RemoteDirModel::recommendSelectedOnly(QModelIndexList list)
* OLD RECOMMEND SYSTEM - DISABLED
******/
void RemoteDirModel::openSelected(QModelIndexList)
void RemoteDirModel::openSelected(QModelIndexList qmil, bool openFolder)
{
//recommendSelected(list);
}
#ifdef RDM_DEBUG
std::cerr << "RemoteDirModel::openSelected()" << std::endl;
#endif
if (RemoteMode) {
#ifdef RDM_DEBUG
std::cerr << "Cannot open remote. Download first." << std::endl;
#endif
return;
}
std::list<std::string> dirs_to_open;
std::list<DirDetails> files_info;
std::list<DirDetails>::iterator it;
getFileInfoFromIndexList(qmil, files_info);
for (it = files_info.begin(); it != files_info.end(); it++) {
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 += '/';
if ((*it).type & DIR_TYPE_FILE) {
name = fullpath + (*it).name;
} else if ((*it).type & DIR_TYPE_DIR) {
name = fullpath;
}
if (!openFolder) {
if ((*it).type & DIR_TYPE_FILE) {
QDesktopServices::openUrl(QUrl::fromLocalFile(name.c_str()));
}
} else {
if (dirs_to_open.end() == std::find(dirs_to_open.begin(), dirs_to_open.end(), fullpath)) {
dirs_to_open.push_back(fullpath);
}
}
}
if (openFolder) {
std::list<std::string>::iterator dit;
for (dit = dirs_to_open.begin(); dit != dirs_to_open.end(); dit++) {
QDesktopServices::openUrl(QUrl::fromLocalFile((*dit).c_str()));
}
}
#ifdef RDM_DEBUG
std::cerr << "::::::::::::Done RemoteDirModel::openSelected()" << std::endl;
#endif
}
void RemoteDirModel::getFilePaths(QModelIndexList list, std::list<std::string> &fullpaths)
{

View File

@ -51,7 +51,7 @@ public:
//#endif
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
void openSelected(QModelIndexList list);
void openSelected(QModelIndexList list, bool openFolder);
void getFilePaths(QModelIndexList list, std::list<std::string> &fullpaths);