2007-11-14 22:18:48 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006, crypton
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2008-11-18 12:14:49 -05:00
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "rshare.h"
|
|
|
|
#include "SharedFilesDialog.h"
|
2009-04-07 04:08:03 -04:00
|
|
|
#include "Preferences/AddFileAssotiationDialog.h"
|
2008-01-25 03:49:40 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
#include "rsiface/rsiface.h"
|
2008-01-25 03:49:40 -05:00
|
|
|
#include "rsiface/rspeers.h"
|
2008-07-02 12:59:56 -04:00
|
|
|
#include "rsiface/rsfiles.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
#include "rsiface/RemoteDirModel.h"
|
|
|
|
#include "util/RsAction.h"
|
|
|
|
#include "msgs/ChanMsgDialog.h"
|
2009-04-07 04:08:03 -04:00
|
|
|
#include "Preferences/rsharesettings.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
2008-12-03 09:30:21 -05:00
|
|
|
#include <QDesktopServices>
|
2007-11-14 22:18:48 -05:00
|
|
|
#include <QContextMenuEvent>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QCursor>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QHeaderView>
|
2008-03-31 14:37:50 -04:00
|
|
|
#include <QTimer>
|
2008-04-05 16:03:25 -04:00
|
|
|
#include <QMovie>
|
|
|
|
#include <QLabel>
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QProcess>
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* Images for context menu icons */
|
2008-08-07 06:48:18 -04:00
|
|
|
#define IMAGE_DOWNLOAD ":/images/download16.png"
|
2008-11-18 12:14:49 -05:00
|
|
|
#define IMAGE_PLAY ":/images/start.png"
|
2008-03-31 14:37:50 -04:00
|
|
|
#define IMAGE_HASH_BUSY ":/images/settings.png"
|
2008-08-03 17:26:25 -04:00
|
|
|
#define IMAGE_HASH_DONE ":/images/friendsfolder24.png"
|
2008-04-05 10:37:22 -04:00
|
|
|
#define IMAGE_MSG ":/images/message-mail.png"
|
|
|
|
#define IMAGE_ATTACHMENT ":/images/attachment.png"
|
|
|
|
#define IMAGE_FRIEND ":/images/peers_16x16.png"
|
2008-04-05 16:03:25 -04:00
|
|
|
#define IMAGE_PROGRESS ":/images/browse-looking.gif"
|
2009-04-07 04:08:03 -04:00
|
|
|
const QString Image_AddNewAssotiationForFile = ":/images/kcmsystem24.png";
|
2008-04-05 10:37:22 -04:00
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
|
|
|
: MainPage(parent)
|
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
2008-04-05 16:03:25 -04:00
|
|
|
ui.setupUi(this);
|
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
|
2008-03-31 14:37:50 -04:00
|
|
|
|
2008-08-07 14:49:57 -04:00
|
|
|
connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck()));
|
2008-03-31 14:37:50 -04:00
|
|
|
|
2009-01-27 20:24:41 -05:00
|
|
|
//connect(ui.frameButton, SIGNAL(toggled(bool)), this, SLOT(showFrame(bool)));
|
2008-11-18 12:14:49 -05:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
connect( ui.localDirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ),
|
|
|
|
this, SLOT( sharedDirTreeWidgetContextMenu( QPoint ) ) );
|
2008-11-18 12:14:49 -05:00
|
|
|
|
|
|
|
connect( ui.remoteDirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( shareddirtreeviewCostumPopupMenu( QPoint ) ) );
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-01-01 19:09:59 -05:00
|
|
|
connect( ui.remoteDirTreeView, SIGNAL( doubleClicked(const QModelIndex&)), this, SLOT( downloadRemoteSelected()));
|
|
|
|
connect( ui.downloadButton, SIGNAL( clicked()), this, SLOT( downloadRemoteSelected()));
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/*
|
|
|
|
connect( ui.remoteDirTreeView, SIGNAL( itemExpanded( QTreeWidgetItem * ) ),
|
|
|
|
this, SLOT( checkForLocalDirRequest( QTreeWidgetItem * ) ) );
|
|
|
|
|
|
|
|
connect( ui.localDirTreeWidget, SIGNAL( itemExpanded( QTreeWidgetItem * ) ),
|
|
|
|
this, SLOT( checkForRemoteDirRequest( QTreeWidgetItem * ) ) );
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
model = new RemoteDirModel(true);
|
|
|
|
localModel = new RemoteDirModel(false);
|
|
|
|
ui.remoteDirTreeView->setModel(model);
|
|
|
|
ui.localDirTreeView->setModel(localModel);
|
|
|
|
|
|
|
|
connect( ui.remoteDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ),
|
|
|
|
model, SLOT( collapsed(const QModelIndex & ) ) );
|
|
|
|
connect( ui.remoteDirTreeView, SIGNAL( expanded(const QModelIndex & ) ),
|
|
|
|
model, SLOT( expanded(const QModelIndex & ) ) );
|
|
|
|
|
|
|
|
connect( ui.localDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ),
|
|
|
|
localModel, SLOT( collapsed(const QModelIndex & ) ) );
|
|
|
|
connect( ui.localDirTreeView, SIGNAL( expanded(const QModelIndex & ) ),
|
|
|
|
localModel, SLOT( expanded(const QModelIndex & ) ) );
|
|
|
|
|
|
|
|
|
|
|
|
/* Set header resize modes and initial section sizes */
|
2008-11-18 12:14:49 -05:00
|
|
|
QHeaderView * l_header = ui.localDirTreeView->header () ;
|
|
|
|
l_header->setResizeMode (0, QHeaderView::Interactive);
|
|
|
|
l_header->setResizeMode (1, QHeaderView::Interactive);
|
2007-11-14 22:18:48 -05:00
|
|
|
l_header->setResizeMode (2, QHeaderView::Interactive);
|
2008-11-18 12:14:49 -05:00
|
|
|
l_header->setResizeMode (3, QHeaderView::Interactive);
|
|
|
|
|
2009-01-30 20:46:49 -05:00
|
|
|
l_header->resizeSection ( 0, 490 );
|
2008-11-18 12:14:49 -05:00
|
|
|
l_header->resizeSection ( 1, 70 );
|
2009-01-30 20:46:49 -05:00
|
|
|
l_header->resizeSection ( 2, 60 );
|
2007-11-14 22:18:48 -05:00
|
|
|
l_header->resizeSection ( 3, 100 );
|
|
|
|
|
|
|
|
/* Set header resize modes and initial section sizes */
|
2008-11-18 12:14:49 -05:00
|
|
|
QHeaderView * r_header = ui.remoteDirTreeView->header () ;
|
2009-01-30 20:46:49 -05:00
|
|
|
|
2008-12-10 20:19:34 -05:00
|
|
|
r_header->setResizeMode (0, QHeaderView::Interactive);
|
|
|
|
r_header->setStretchLastSection(false);
|
2009-01-30 20:46:49 -05:00
|
|
|
|
2008-12-03 09:30:21 -05:00
|
|
|
r_header->setResizeMode (1, QHeaderView::Fixed);
|
|
|
|
r_header->setResizeMode (2, QHeaderView::Fixed);
|
|
|
|
r_header->setResizeMode (3, QHeaderView::Fixed);
|
2008-08-07 14:49:57 -04:00
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
|
2009-01-30 20:46:49 -05:00
|
|
|
r_header->resizeSection ( 0, 490 );
|
2008-11-18 12:14:49 -05:00
|
|
|
r_header->resizeSection ( 1, 70 );
|
2009-01-30 20:46:49 -05:00
|
|
|
r_header->resizeSection ( 2, 60 );
|
2007-11-14 22:18:48 -05:00
|
|
|
r_header->resizeSection ( 3, 100 );
|
2008-08-07 14:49:57 -04:00
|
|
|
|
|
|
|
l_header->setHighlightSections(false);
|
|
|
|
r_header->setHighlightSections(false);
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* Set Multi Selection */
|
|
|
|
ui.remoteDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
ui.localDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
|
2008-03-31 14:37:50 -04:00
|
|
|
QTimer *timer = new QTimer(this);
|
|
|
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
|
|
|
timer->start(1000);
|
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
/* Hide platform specific features */
|
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-03-31 14:37:50 -04:00
|
|
|
void SharedFilesDialog::checkUpdate()
|
|
|
|
{
|
|
|
|
/* update */
|
2008-07-02 12:59:56 -04:00
|
|
|
if (rsFiles->InDirectoryCheck())
|
2008-03-31 14:37:50 -04:00
|
|
|
{
|
2009-04-09 14:22:55 -04:00
|
|
|
//ui.hashLabel->setPixmap(QPixmap(IMAGE_HASH_BUSY));
|
|
|
|
QMovie *movie = new QMovie(":/images/loader/16-loader.gif");
|
|
|
|
ui.hashLabel->setMovie(movie);
|
|
|
|
movie->start();
|
|
|
|
movie->setSpeed(100); // 2x speed
|
2008-03-31 14:37:50 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-09 14:22:55 -04:00
|
|
|
//movie->stop();
|
2008-03-31 14:37:50 -04:00
|
|
|
ui.hashLabel->setPixmap(QPixmap(IMAGE_HASH_DONE));
|
2009-01-25 14:05:53 -05:00
|
|
|
ui.hashLabel->setToolTip("") ;
|
2008-03-31 14:37:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SharedFilesDialog::forceCheck()
|
|
|
|
{
|
2008-07-02 12:59:56 -04:00
|
|
|
rsFiles->ForceDirectoryCheck();
|
2008-03-31 14:37:50 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
void SharedFilesDialog::shareddirtreeviewCostumPopupMenu( QPoint point )
|
|
|
|
{
|
|
|
|
QMenu contextMnu( this );
|
|
|
|
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
2009-04-07 04:08:03 -04:00
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), this );
|
2007-11-14 22:18:48 -05:00
|
|
|
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) );
|
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
// addMsgAct = new QAction( tr( "Add to Message" ), this );
|
2007-11-14 22:18:48 -05:00
|
|
|
// connect( addMsgAct , SIGNAL( triggered() ), this, SLOT( addMsgRemoteSelected() ) );
|
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
|
|
|
|
contextMnu.clear();
|
2007-11-14 22:18:48 -05:00
|
|
|
contextMnu.addAction( downloadAct);
|
|
|
|
// contextMnu.addAction( addMsgAct);
|
2008-11-18 12:14:49 -05:00
|
|
|
contextMnu.exec( mevent->globalPos() );
|
|
|
|
}
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
void SharedFilesDialog::downloadRemoteSelected()
|
|
|
|
{
|
2007-11-14 22:18:48 -05:00
|
|
|
/* call back to the model (which does all the interfacing? */
|
|
|
|
|
|
|
|
std::cerr << "Downloading Files";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
QItemSelectionModel *qism = ui.remoteDirTreeView->selectionModel();
|
|
|
|
model -> downloadSelected(qism->selectedIndexes());
|
|
|
|
|
2009-01-01 19:09:59 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
|
|
|
|
void SharedFilesDialog::playselectedfiles()
|
|
|
|
{
|
2008-03-31 14:37:50 -04:00
|
|
|
/* call back to the model (which does all the interfacing? */
|
|
|
|
|
|
|
|
std::cerr << "SharedFilesDialog::playselectedfiles()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
QItemSelectionModel *qism = ui.localDirTreeView->selectionModel();
|
|
|
|
|
|
|
|
std::list<std::string> paths;
|
|
|
|
localModel -> getFilePaths(qism->selectedIndexes(), paths);
|
|
|
|
|
|
|
|
std::list<std::string>::iterator it;
|
|
|
|
QStringList fullpaths;
|
|
|
|
for(it = paths.begin(); it != paths.end(); it++)
|
|
|
|
{
|
|
|
|
std::string fullpath;
|
2008-07-02 12:59:56 -04:00
|
|
|
rsFiles->ConvertSharedFilePath(*it, fullpath);
|
2008-03-31 14:37:50 -04:00
|
|
|
fullpaths.push_back(QString::fromStdString(fullpath));
|
|
|
|
|
|
|
|
std::cerr << "Playing: " << fullpath;
|
|
|
|
std::cerr << std::endl;
|
2008-12-03 09:30:21 -05:00
|
|
|
|
2008-03-31 14:37:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
playFiles(fullpaths);
|
2008-07-10 14:52:56 -04:00
|
|
|
|
|
|
|
std::cerr << "SharedFilesDialog::playselectedfiles() Completed";
|
|
|
|
std::cerr << std::endl;
|
2008-03-31 14:37:50 -04:00
|
|
|
}
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
#if 0
|
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
void SharedFilesDialog::addMsgRemoteSelected()
|
|
|
|
{
|
2008-07-02 12:59:56 -04:00
|
|
|
/* call back to the model (which does all the interfacing? */
|
|
|
|
|
|
|
|
std::cerr << "Recommending Files";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
QItemSelectionModel *qism = ui.remoteDirTreeView->selectionModel();
|
|
|
|
model -> recommendSelected(qism->selectedIndexes());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
void SharedFilesDialog::recommendfile()
|
|
|
|
{
|
2008-07-02 12:59:56 -04:00
|
|
|
/* call back to the model (which does all the interfacing? */
|
|
|
|
|
|
|
|
std::cerr << "Recommending Files";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
QItemSelectionModel *qism = ui.localDirTreeView->selectionModel();
|
|
|
|
localModel -> recommendSelected(qism->selectedIndexes());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
|
|
|
|
void SharedFilesDialog::recommendFileSetOnly()
|
|
|
|
{
|
2007-11-14 22:18:48 -05:00
|
|
|
/* call back to the model (which does all the interfacing? */
|
|
|
|
|
|
|
|
std::cerr << "Recommending File Set (clearing old selection)";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
/* clear current recommend Selection done by model */
|
|
|
|
|
|
|
|
QItemSelectionModel *qism = ui.localDirTreeView->selectionModel();
|
|
|
|
localModel -> recommendSelectedOnly(qism->selectedIndexes());
|
|
|
|
}
|
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
|
|
|
|
void SharedFilesDialog::recommendFilesTo( std::string rsid )
|
|
|
|
{
|
2007-11-14 22:18:48 -05:00
|
|
|
recommendFileSetOnly();
|
|
|
|
rsicontrol -> ClearInMsg();
|
|
|
|
rsicontrol -> SetInMsg(rsid, true);
|
|
|
|
|
|
|
|
/* create a message */
|
|
|
|
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
|
|
|
|
|
|
|
/* fill it in
|
|
|
|
* files are receommended already
|
|
|
|
* just need to set peers
|
|
|
|
*/
|
|
|
|
std::cerr << "SharedFilesDialog::recommendFilesTo()" << std::endl;
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
nMsgDialog->insertTitleText("Recommendation(s)");
|
|
|
|
nMsgDialog->insertMsgText("Recommendation(s)");
|
|
|
|
|
|
|
|
nMsgDialog->sendMessage();
|
|
|
|
nMsgDialog->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
|
|
|
|
void SharedFilesDialog::recommendFilesToMsg( std::string rsid )
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
recommendFileSetOnly();
|
|
|
|
|
|
|
|
rsicontrol -> ClearInMsg();
|
|
|
|
rsicontrol -> SetInMsg(rsid, true);
|
|
|
|
|
|
|
|
/* create a message */
|
|
|
|
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
|
|
|
|
|
|
|
/* fill it in
|
|
|
|
* files are receommended already
|
|
|
|
* just need to set peers
|
|
|
|
*/
|
|
|
|
std::cerr << "SharedFilesDialog::recommendFilesToMsg()" << std::endl;
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
nMsgDialog->insertTitleText("Recommendation(s)");
|
|
|
|
nMsgDialog->insertMsgText("Recommendation(s)");
|
|
|
|
|
|
|
|
nMsgDialog->show();
|
|
|
|
}
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
#endif
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
void SharedFilesDialog::openfile()
|
|
|
|
{
|
2007-11-14 22:18:48 -05:00
|
|
|
/* 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());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
void SharedFilesDialog::openfolder()
|
|
|
|
{
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
void SharedFilesDialog::preModDirectories(bool update_local)
|
|
|
|
{
|
2009-02-12 06:48:43 -05:00
|
|
|
std::cerr << "SharedFilesDialog::preModDirectories called with update_local = " << update_local << std::endl ;
|
2007-11-14 22:18:48 -05:00
|
|
|
if (update_local)
|
|
|
|
localModel->preMods();
|
|
|
|
else
|
|
|
|
model->preMods();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-12 06:48:43 -05:00
|
|
|
void SharedFilesDialog::postModDirectories(bool update_local)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2009-02-12 06:48:43 -05:00
|
|
|
std::cerr << "SharedFilesDialog::postModDirectories called with update_local = " << update_local << std::endl ;
|
2007-11-14 22:18:48 -05:00
|
|
|
if (update_local)
|
|
|
|
localModel->postMods();
|
|
|
|
else
|
|
|
|
model->postMods();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
2009-04-07 04:08:03 -04:00
|
|
|
//=== at this moment we'll show menu only for files, not for folders
|
|
|
|
QModelIndex midx = ui.localDirTreeView->indexAt(point);
|
|
|
|
if (localModel->isDir( midx ) )
|
|
|
|
return;
|
2008-11-18 12:14:49 -05:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
currentFile = localModel->data(midx,
|
|
|
|
RemoteDirModel::FileNameRole).toString();
|
2008-11-18 12:14:49 -05:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
QMenu contextMnu2( this );
|
|
|
|
//
|
|
|
|
|
|
|
|
QAction* menuAction = fileAssotiationAction(currentFile) ;
|
|
|
|
//new QAction(QIcon(IMAGE_PLAY), currentFile, this);
|
|
|
|
//tr( "111Play File(s)" ), this );
|
|
|
|
// connect( openfolderAct , SIGNAL( triggered() ), this,
|
|
|
|
// SLOT( playselectedfiles() ) );
|
2008-03-31 14:37:50 -04:00
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
#if 0
|
2008-11-18 12:14:49 -05:00
|
|
|
openfileAct = new QAction(QIcon(IMAGE_ATTACHMENT), tr( "Add to Recommend List" ), this );
|
2007-11-14 22:18:48 -05:00
|
|
|
connect( openfileAct , SIGNAL( triggered() ), this, SLOT( recommendfile() ) );
|
2008-03-31 14:37:50 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* now we're going to ask who to recommend it to...
|
|
|
|
* First Level.
|
|
|
|
*
|
|
|
|
* Add to Recommend List.
|
|
|
|
* Recommend to >
|
|
|
|
* all.
|
|
|
|
* list of <people>
|
|
|
|
* Recommend with msg >
|
|
|
|
* all.
|
|
|
|
* list of <people>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
QMenu *recMenu = new QMenu( tr("Recommend To "), this );
|
2008-04-05 10:37:22 -04:00
|
|
|
recMenu->setIcon(QIcon(IMAGE_ATTACHMENT));
|
2007-11-14 22:18:48 -05:00
|
|
|
QMenu *msgMenu = new QMenu( tr("Message Friend "), &contextMnu2 );
|
2008-04-05 10:37:22 -04:00
|
|
|
msgMenu->setIcon(QIcon(IMAGE_MSG));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
std::list<std::string> peers;
|
|
|
|
std::list<std::string>::iterator it;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
if (!rsPeers)
|
|
|
|
{
|
|
|
|
/* not ready yet! */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rsPeers->getFriendList(peers);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
for(it = peers.begin(); it != peers.end(); it++)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2008-01-25 03:49:40 -05:00
|
|
|
std::string name = rsPeers->getPeerName(*it);
|
2007-11-14 22:18:48 -05:00
|
|
|
/* parents are
|
|
|
|
* recMenu
|
|
|
|
* msgMenu
|
|
|
|
*/
|
2008-01-25 03:49:40 -05:00
|
|
|
|
2008-04-05 10:37:22 -04:00
|
|
|
RsAction *qaf1 = new RsAction( QIcon(IMAGE_FRIEND), QString::fromStdString( name ), recMenu, *it );
|
2007-11-14 22:18:48 -05:00
|
|
|
connect( qaf1 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesTo( std::string ) ) );
|
|
|
|
recMenu->addAction(qaf1);
|
|
|
|
|
2008-04-05 10:37:22 -04:00
|
|
|
RsAction *qaf2 = new RsAction( QIcon(IMAGE_FRIEND), QString::fromStdString( name ), msgMenu, *it );
|
2007-11-14 22:18:48 -05:00
|
|
|
connect( qaf2 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesToMsg( std::string ) ) );
|
|
|
|
msgMenu->addAction(qaf2);
|
|
|
|
|
|
|
|
/* create list of ids */
|
|
|
|
|
|
|
|
}
|
2008-07-02 12:59:56 -04:00
|
|
|
#endif
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
contextMnu2.addAction( menuAction );
|
2008-07-02 12:59:56 -04:00
|
|
|
//contextMnu2.addAction( openfileAct);
|
|
|
|
//contextMnu2.addSeparator();
|
|
|
|
//contextMnu2.addMenu( recMenu);
|
|
|
|
//contextMnu2.addMenu( msgMenu);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
QMouseEvent *mevent2 = new QMouseEvent( QEvent::MouseButtonPress, point,
|
|
|
|
Qt::RightButton, Qt::RightButton,
|
|
|
|
Qt::NoModifier );
|
|
|
|
contextMnu2.exec( mevent2->globalPos() );
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
QAction*
|
|
|
|
SharedFilesDialog::fileAssotiationAction(const QString fileName)
|
|
|
|
{
|
|
|
|
QAction* result = 0;
|
|
|
|
|
|
|
|
RshareSettings* settings = new RshareSettings();
|
|
|
|
//QSettings* settings= new QSettings(qApp->applicationDirPath()+"/sett.ini",
|
|
|
|
// QSettings::IniFormat);
|
|
|
|
settings->beginGroup("FileAssotiations");
|
|
|
|
|
|
|
|
QString key = AddFileAssotiationDialog::cleanFileType(currentFile) ;
|
|
|
|
if ( settings->contains(key) )
|
|
|
|
{
|
|
|
|
result = new QAction(QIcon(IMAGE_PLAY), tr( "Open File" ), this );
|
|
|
|
connect( result , SIGNAL( triggered() ),
|
|
|
|
this, SLOT( runCommandForFile() ) );
|
|
|
|
|
|
|
|
currentCommand = (settings->value( key )).toString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = new QAction(QIcon(Image_AddNewAssotiationForFile),
|
|
|
|
tr( "Set command for opening this file"), this );
|
|
|
|
connect( result , SIGNAL( triggered() ),
|
|
|
|
this, SLOT( tryToAddNewAssotiation() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
delete settings;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void
|
|
|
|
SharedFilesDialog::runCommandForFile()
|
|
|
|
{
|
|
|
|
QStringList tsl;
|
|
|
|
tsl.append( currentFile );
|
|
|
|
QProcess::execute( currentCommand, tsl);
|
|
|
|
//QString("%1 %2").arg(currentCommand).arg(currentFile) );
|
|
|
|
|
|
|
|
// QString tmess = "Some command(%1) should be executed here for file %2";
|
|
|
|
// tmess = tmess.arg(currentCommand).arg(currentFile);
|
|
|
|
// QMessageBox::warning(this, tr("RetroShare"), tmess, QMessageBox::Ok);
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void
|
|
|
|
SharedFilesDialog::tryToAddNewAssotiation()
|
|
|
|
{
|
|
|
|
AddFileAssotiationDialog afad(true, this);//'add file assotiations' dialog
|
|
|
|
|
|
|
|
afad.setFileType(AddFileAssotiationDialog::cleanFileType(currentFile));
|
|
|
|
|
|
|
|
int ti = afad.exec();
|
|
|
|
|
|
|
|
if (ti==QDialog::Accepted)
|
|
|
|
{
|
|
|
|
RshareSettings* settings = new RshareSettings();
|
|
|
|
//QSettings settings( qApp->applicationDirPath()+"/sett.ini",
|
|
|
|
// QSettings::IniFormat);
|
|
|
|
settings->beginGroup("FileAssotiations");
|
|
|
|
|
|
|
|
QString currType = afad.resultFileType() ;
|
|
|
|
QString currCmd = afad.resultCommand() ;
|
|
|
|
|
|
|
|
settings->setValue(currType, currCmd);
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
//============================================================================
|
2008-08-07 14:49:57 -04:00
|
|
|
/**
|
|
|
|
Toggles the Lokal TreeView on and off, changes toggle button text
|
2009-01-27 20:24:41 -05:00
|
|
|
|
2008-08-07 14:49:57 -04:00
|
|
|
void SharedFilesDialog::showFrame(bool show)
|
|
|
|
{
|
|
|
|
if (show) {
|
|
|
|
ui.frame->setVisible(true);
|
|
|
|
ui.frameButton->setChecked(true);
|
|
|
|
ui.frameButton->setToolTip(tr("Hide Lokal Direrectories"));
|
|
|
|
ui.frameButton->setIcon(QIcon(tr(":images/hide_toolbox_frame.png")));
|
|
|
|
} else {
|
|
|
|
ui.frame->setVisible(false);
|
|
|
|
ui.frameButton->setChecked(false);
|
|
|
|
ui.frameButton->setToolTip(tr("Show Lokal Directories"));
|
|
|
|
ui.frameButton->setIcon(QIcon(tr(":images/show_toolbox_frame.png")));
|
|
|
|
}
|
2009-01-27 20:24:41 -05:00
|
|
|
}*/
|
2009-01-01 19:09:59 -05:00
|
|
|
|