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
|
2009-07-07 14:56:31 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2007-11-14 22:18:48 -05:00
|
|
|
* Boston, MA 02110-1301, USA.
|
2008-11-18 12:14:49 -05:00
|
|
|
****************************************************************/
|
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include <QString>
|
|
|
|
#include <QTreeView>
|
|
|
|
#include <QClipboard>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QMovie>
|
|
|
|
#include <QProcess>
|
2010-09-19 20:10:51 -04:00
|
|
|
#include <QSortFilterProxyModel>
|
2010-07-23 14:52:58 -04:00
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
#include "SharedFilesDialog.h"
|
2009-12-14 12:13:10 -05:00
|
|
|
#include "settings/AddFileAssociationDialog.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
#include "util/RsAction.h"
|
2010-05-23 15:13:41 -04:00
|
|
|
#include "msgs/MessageComposer.h"
|
2009-12-14 12:13:10 -05:00
|
|
|
#include "settings/rsharesettings.h"
|
2009-08-17 16:19:53 -04:00
|
|
|
#include "AddLinksDialog.h"
|
2010-03-10 16:38:26 -05:00
|
|
|
#include "RetroShareLink.h"
|
2010-07-23 14:52:58 -04:00
|
|
|
#include "gui/RemoteDirModel.h"
|
2009-05-18 10:23:55 -04:00
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
#include <retroshare/rsfiles.h>
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
|
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"
|
2009-07-10 20:45:17 -04:00
|
|
|
#define IMAGE_HASH_DONE ":/images/accepted16.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-05-18 10:23:55 -04:00
|
|
|
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
2009-08-17 17:40:34 -04:00
|
|
|
#define IMAGE_OPENFOLDER ":/images/folderopen.png"
|
2009-07-07 14:56:31 -04:00
|
|
|
#define IMAGE_OPENFILE ":/images/fileopen.png"
|
2009-05-18 10:23:55 -04:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
const QString Image_AddNewAssotiationForFile = ":/images/kcmsystem24.png";
|
2008-04-05 10:37:22 -04:00
|
|
|
|
2010-09-19 20:10:51 -04:00
|
|
|
class SFDSortFilterProxyModel : public QSortFilterProxyModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SFDSortFilterProxyModel(RemoteDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent)
|
|
|
|
{
|
|
|
|
m_dirModel = dirModel;
|
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
|
|
|
|
{
|
|
|
|
bool dirLeft = m_dirModel->isDir(left);
|
|
|
|
bool dirRight = m_dirModel->isDir(right);
|
|
|
|
|
|
|
|
if (dirLeft ^ dirRight) {
|
|
|
|
return dirLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QSortFilterProxyModel::lessThan(left, right);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
RemoteDirModel *m_dirModel;
|
|
|
|
};
|
2008-11-18 12:14:49 -05:00
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
2010-01-31 09:21:24 -05:00
|
|
|
: RsAutoUpdatePage(1000,parent)
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
2008-04-05 16:03:25 -04:00
|
|
|
ui.setupUi(this);
|
2009-07-07 14:56:31 -04:00
|
|
|
|
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-07-20 13:03:27 -04:00
|
|
|
connect(ui.localButton, SIGNAL(toggled(bool)), this, SLOT(showFrame(bool)));
|
|
|
|
connect(ui.remoteButton, SIGNAL(toggled(bool)), this, SLOT(showFrameRemote(bool)));
|
|
|
|
connect(ui.splittedButton, SIGNAL(toggled(bool)), this, SLOT(showFrameSplitted(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
|
|
|
|
2010-05-16 05:54:21 -04:00
|
|
|
// connect( ui.remoteDirTreeView, SIGNAL( doubleClicked(const QModelIndex&)), this, SLOT( downloadRemoteSelected()));
|
2009-01-01 19:09:59 -05:00
|
|
|
connect( ui.downloadButton, SIGNAL( clicked()), this, SLOT( downloadRemoteSelected()));
|
|
|
|
|
2009-10-13 16:36:29 -04:00
|
|
|
connect(ui.indicatorCBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indicatorChanged(int)));
|
2009-01-01 19:09:59 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/*
|
2009-07-07 14:56:31 -04:00
|
|
|
connect( ui.remoteDirTreeView, SIGNAL( itemExpanded( QTreeWidgetItem * ) ),
|
2007-11-14 22:18:48 -05:00
|
|
|
this, SLOT( checkForLocalDirRequest( QTreeWidgetItem * ) ) );
|
|
|
|
|
2009-07-07 14:56:31 -04:00
|
|
|
connect( ui.localDirTreeWidget, SIGNAL( itemExpanded( QTreeWidgetItem * ) ),
|
2007-11-14 22:18:48 -05:00
|
|
|
this, SLOT( checkForRemoteDirRequest( QTreeWidgetItem * ) ) );
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
model = new RemoteDirModel(true);
|
2010-09-19 20:10:51 -04:00
|
|
|
|
|
|
|
proxyModel = new SFDSortFilterProxyModel(model, this);
|
|
|
|
proxyModel->setDynamicSortFilter(true);
|
|
|
|
proxyModel->setSourceModel(model);
|
|
|
|
proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
proxyModel->setSortRole(RemoteDirModel::SortRole);
|
|
|
|
proxyModel->sort(0);
|
|
|
|
|
|
|
|
ui.remoteDirTreeView->setModel(proxyModel);
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
localModel = new RemoteDirModel(false);
|
2010-09-19 20:10:51 -04:00
|
|
|
|
|
|
|
localProxyModel = new SFDSortFilterProxyModel(localModel, this);
|
|
|
|
localProxyModel->setDynamicSortFilter(true);
|
|
|
|
localProxyModel->setSourceModel(localModel);
|
|
|
|
localProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
localProxyModel->setSortRole(RemoteDirModel::SortRole);
|
|
|
|
localProxyModel->sort(0);
|
|
|
|
|
|
|
|
ui.localDirTreeView->setModel(localProxyModel);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-02-04 11:54:59 -05:00
|
|
|
ui.remoteDirTreeView->setColumnHidden(3,true) ;
|
2010-01-20 07:40:17 -05:00
|
|
|
ui.remoteDirTreeView->setColumnHidden(4,true) ;
|
|
|
|
ui.localDirTreeView->setColumnHidden(4,true) ;
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
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 & ) ) );
|
|
|
|
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* Set header resize modes and initial section sizes */
|
2009-07-07 14:56:31 -04:00
|
|
|
QHeaderView * l_header = ui.localDirTreeView->header () ;
|
2010-01-20 07:40:17 -05:00
|
|
|
// l_header->setResizeMode (0, QHeaderView::Interactive);
|
|
|
|
// l_header->setResizeMode (1, QHeaderView::Fixed);
|
|
|
|
// l_header->setResizeMode (2, QHeaderView::Interactive);
|
|
|
|
// l_header->setResizeMode (3, QHeaderView::Interactive);
|
|
|
|
// l_header->setResizeMode (4, QHeaderView::Interactive);
|
2009-07-07 14:56:31 -04:00
|
|
|
|
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 );
|
2010-02-04 11:54:59 -05:00
|
|
|
l_header->resizeSection ( 2, 100 );
|
2007-11-14 22:18:48 -05:00
|
|
|
l_header->resizeSection ( 3, 100 );
|
2010-01-20 07:40:17 -05:00
|
|
|
// l_header->resizeSection ( 4, 100 );
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* Set header resize modes and initial section sizes */
|
2009-07-07 14:56:31 -04: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
|
|
|
|
2010-01-20 07:40:17 -05:00
|
|
|
// r_header->setResizeMode (1, QHeaderView::Fixed);
|
|
|
|
// // r_header->setResizeMode (2, QHeaderView::Interactive);
|
|
|
|
// r_header->setResizeMode (3, QHeaderView::Fixed);
|
|
|
|
// // r_header->setResizeMode (4, QHeaderView::Interactive);
|
2009-07-07 14:56:31 -04: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 );
|
2010-01-20 07:40:17 -05:00
|
|
|
// r_header->resizeSection ( 2, 0 );
|
2007-11-14 22:18:48 -05:00
|
|
|
r_header->resizeSection ( 3, 100 );
|
2010-01-20 07:40:17 -05:00
|
|
|
// r_header->resizeSection ( 4, 0 );
|
2009-07-07 14:56:31 -04:00
|
|
|
|
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);
|
|
|
|
|
2010-09-19 20:10:51 -04:00
|
|
|
// load settings
|
|
|
|
processSettings(true);
|
2010-01-21 07:35:11 -05:00
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
/* Hide platform specific features */
|
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
|
|
|
|
#endif
|
2010-03-28 16:46:45 -04:00
|
|
|
copylinklocalAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard" ), this );
|
|
|
|
connect( copylinklocalAct , SIGNAL( triggered() ), this, SLOT( copyLinkLocal() ) );
|
|
|
|
copylinklocalhtmlAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard (HTML)" ), this );
|
|
|
|
connect( copylinklocalhtmlAct , SIGNAL( triggered() ), this, SLOT( copyLinkhtml() ) );
|
|
|
|
sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links" ), this );
|
|
|
|
connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( ) ) );
|
|
|
|
sendhtmllinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links (HTML)" ), this );
|
|
|
|
connect( sendhtmllinkAct , SIGNAL( triggered() ), this, SLOT( sendHtmlLinkTo( ) ) );
|
|
|
|
sendlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links to Cloud" ), this );
|
|
|
|
connect( sendlinkCloudAct , SIGNAL( triggered() ), this, SLOT( sendLinkToCloud( ) ) );
|
|
|
|
addlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Add Links to Cloud" ), this );
|
|
|
|
connect( addlinkCloudAct , SIGNAL( triggered() ), this, SLOT( addLinkToCloud( ) ) );
|
|
|
|
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()));
|
2010-09-19 20:10:51 -04:00
|
|
|
}
|
2010-03-28 16:46:45 -04:00
|
|
|
|
2010-09-19 20:10:51 -04:00
|
|
|
SharedFilesDialog::~SharedFilesDialog()
|
|
|
|
{
|
|
|
|
// save settings
|
|
|
|
processSettings(false);
|
|
|
|
}
|
2010-03-28 16:46:45 -04:00
|
|
|
|
2010-09-19 20:10:51 -04:00
|
|
|
void SharedFilesDialog::processSettings(bool bLoad)
|
|
|
|
{
|
|
|
|
Settings->beginGroup("SharedFilesDialog");
|
|
|
|
|
|
|
|
if (bLoad) {
|
|
|
|
// load settings
|
|
|
|
|
|
|
|
// state of the trees
|
|
|
|
ui.localDirTreeView->header()->restoreState(Settings->value("LocalDirTreeView").toByteArray());
|
|
|
|
ui.remoteDirTreeView->header()->restoreState(Settings->value("RemoteDirTreeView").toByteArray());
|
|
|
|
|
|
|
|
// state of splitter
|
|
|
|
ui.splitter->restoreState(Settings->value("Splitter").toByteArray());
|
|
|
|
} else {
|
|
|
|
// save settings
|
|
|
|
|
|
|
|
// state of trees
|
|
|
|
Settings->setValue("LocalDirTreeView", ui.localDirTreeView->header()->saveState());
|
|
|
|
Settings->setValue("RemoteDirTreeView", ui.remoteDirTreeView->header()->saveState());
|
|
|
|
|
|
|
|
// state of splitter
|
|
|
|
Settings->setValue("Splitter", ui.splitter->saveState());
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings->endGroup();
|
2008-11-18 12:14:49 -05:00
|
|
|
}
|
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-07-10 20:45:17 -04:00
|
|
|
ui.checkButton->setText(tr("Checking..."));
|
2009-04-09 14:22:55 -04:00
|
|
|
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-07-10 20:45:17 -04:00
|
|
|
ui.checkButton->setText(tr("Check files"));
|
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 )
|
|
|
|
{
|
2010-07-15 07:25:34 -04:00
|
|
|
QMenu contextMnu( this );
|
|
|
|
|
|
|
|
QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), &contextMnu );
|
2007-11-14 22:18:48 -05:00
|
|
|
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) );
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *copyremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), &contextMnu );
|
2009-05-18 10:23:55 -04:00
|
|
|
connect( copyremotelinkAct , SIGNAL( triggered() ), this, SLOT( copyLinkRemote() ) );
|
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *sendremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), &contextMnu );
|
2009-05-18 10:23:55 -04:00
|
|
|
connect( sendremotelinkAct , SIGNAL( triggered() ), this, SLOT( sendremoteLinkTo( ) ) );
|
2009-07-07 14:56:31 -04:00
|
|
|
|
|
|
|
|
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() ) );
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
contextMnu.addAction( downloadAct);
|
2009-05-18 10:23:55 -04:00
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction( copyremotelinkAct);
|
|
|
|
contextMnu.addAction( sendremotelinkAct);
|
2007-11-14 22:18:48 -05:00
|
|
|
// contextMnu.addAction( addMsgAct);
|
2010-05-14 16:55:44 -04:00
|
|
|
|
|
|
|
contextMnu.exec(QCursor::pos());
|
2008-11-18 12:14:49 -05:00
|
|
|
}
|
|
|
|
|
2010-09-19 20:10:51 -04:00
|
|
|
QModelIndexList SharedFilesDialog::getLocalSelected()
|
|
|
|
{
|
|
|
|
QModelIndexList list = ui.localDirTreeView->selectionModel()->selectedIndexes();
|
|
|
|
QModelIndexList proxyList;
|
|
|
|
for (QModelIndexList::iterator index = list.begin(); index != list.end(); index++) {
|
|
|
|
proxyList.append(localProxyModel->mapToSource(*index));
|
|
|
|
}
|
|
|
|
|
|
|
|
return proxyList;
|
|
|
|
}
|
|
|
|
|
|
|
|
QModelIndexList SharedFilesDialog::getRemoteSelected()
|
|
|
|
{
|
|
|
|
QModelIndexList list = ui.remoteDirTreeView->selectionModel()->selectedIndexes();
|
|
|
|
QModelIndexList proxyList;
|
|
|
|
for (QModelIndexList::iterator index = list.begin(); index != list.end(); index++) {
|
|
|
|
proxyList.append(proxyModel->mapToSource(*index));
|
|
|
|
}
|
|
|
|
|
|
|
|
return proxyList;
|
|
|
|
}
|
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;
|
|
|
|
|
2010-09-19 20:10:51 -04:00
|
|
|
QModelIndexList lst = getRemoteSelected();
|
|
|
|
model -> downloadSelected(lst);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2009-05-18 10:23:55 -04:00
|
|
|
void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
|
|
|
{
|
|
|
|
std::vector<DirDetails> dirVec;
|
|
|
|
|
|
|
|
if (remote)
|
|
|
|
model->getDirDetailsFromSelect(lst, dirVec);
|
|
|
|
else
|
|
|
|
localModel->getDirDetailsFromSelect(lst, dirVec);
|
|
|
|
|
2010-03-15 08:57:08 -04:00
|
|
|
std::vector<RetroShareLink> urls ;
|
2010-03-10 18:09:35 -05:00
|
|
|
|
2009-05-18 10:23:55 -04:00
|
|
|
for (int i = 0, n = dirVec.size(); i < n; ++i)
|
|
|
|
{
|
|
|
|
const DirDetails& details = dirVec[i];
|
|
|
|
|
|
|
|
if (details.type == DIR_TYPE_DIR)
|
|
|
|
{
|
2010-03-10 18:09:35 -05:00
|
|
|
for (std::list<DirStub>::const_iterator cit = details.children.begin();cit != details.children.end(); ++cit)
|
2009-05-18 10:23:55 -04:00
|
|
|
{
|
|
|
|
const DirStub& dirStub = *cit;
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
|
|
|
if (remote)
|
|
|
|
flags |= DIR_FLAGS_REMOTE;
|
|
|
|
else
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
|
|
|
|
// do not recursive copy sub dirs.
|
|
|
|
if (!rsFiles->RequestDirDetails(dirStub.ref, details, flags) || details.type != DIR_TYPE_FILE)
|
|
|
|
continue;
|
|
|
|
|
2010-09-17 17:54:25 -04:00
|
|
|
RetroShareLink link(QString::fromUtf8(details.name.c_str()), details.count, details.hash.c_str());
|
2010-03-15 08:57:08 -04:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
if(link.valid() && link.type() == RetroShareLink::TYPE_FILE)
|
2010-03-15 08:57:08 -04:00
|
|
|
urls.push_back(link) ;
|
2009-05-18 10:23:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-03-10 18:09:35 -05:00
|
|
|
{
|
2010-09-17 17:54:25 -04:00
|
|
|
RetroShareLink link(QString::fromUtf8(details.name.c_str()), details.count, details.hash.c_str());
|
2010-03-10 18:09:35 -05:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
if(link.valid() && link.type() == RetroShareLink::TYPE_FILE)
|
2010-03-15 08:57:08 -04:00
|
|
|
urls.push_back(link) ;
|
2010-03-10 18:09:35 -05:00
|
|
|
}
|
2009-05-18 10:23:55 -04:00
|
|
|
}
|
2010-03-15 08:57:08 -04:00
|
|
|
RSLinkClipboard::copyLinks(urls) ;
|
2009-05-18 10:23:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SharedFilesDialog::copyLinkRemote()
|
|
|
|
{
|
2010-09-19 20:10:51 -04:00
|
|
|
QModelIndexList lst = getRemoteSelected();
|
2009-05-18 10:23:55 -04:00
|
|
|
copyLink (lst, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SharedFilesDialog::copyLinkLocal()
|
|
|
|
{
|
2010-09-19 20:10:51 -04:00
|
|
|
QModelIndexList lst = getLocalSelected();
|
2009-05-18 10:23:55 -04:00
|
|
|
copyLink (lst, false);
|
|
|
|
}
|
|
|
|
|
2010-03-04 10:42:50 -05:00
|
|
|
void SharedFilesDialog::copyLinkhtml( )
|
|
|
|
{
|
|
|
|
copyLinkLocal ();
|
|
|
|
|
|
|
|
QString link = QApplication::clipboard()->text();
|
|
|
|
|
|
|
|
QClipboard *clipboard = QApplication::clipboard();
|
|
|
|
clipboard->setText("<a href='" + link + "'> " + link + "</a>");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-05-18 10:23:55 -04:00
|
|
|
void SharedFilesDialog::sendremoteLinkTo()
|
|
|
|
{
|
|
|
|
copyLinkRemote ();
|
|
|
|
|
|
|
|
/* create a message */
|
2010-05-25 05:32:14 -04:00
|
|
|
MessageComposer *nMsgDialog = new MessageComposer();
|
2009-05-18 10:23:55 -04:00
|
|
|
|
|
|
|
/* fill it in
|
|
|
|
* files are receommended already
|
|
|
|
* just need to set peers
|
|
|
|
*/
|
|
|
|
std::cerr << "SharedFilesDialog::sendremoteLinkTo()" << std::endl;
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
nMsgDialog->insertTitleText("RetroShare Link");
|
2010-03-15 08:57:08 -04:00
|
|
|
nMsgDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString());
|
2009-05-18 10:23:55 -04:00
|
|
|
|
|
|
|
nMsgDialog->show();
|
2010-05-02 20:09:55 -04:00
|
|
|
|
|
|
|
/* window will destroy itself! */
|
2009-05-18 10:23:55 -04:00
|
|
|
}
|
|
|
|
|
2010-03-04 10:42:50 -05:00
|
|
|
void SharedFilesDialog::sendLinkTo()
|
2009-05-18 10:23:55 -04:00
|
|
|
{
|
|
|
|
copyLinkLocal ();
|
|
|
|
|
|
|
|
/* create a message */
|
2010-05-25 05:32:14 -04:00
|
|
|
MessageComposer *nMsgDialog = new MessageComposer();
|
2009-05-18 10:23:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* fill it in
|
|
|
|
* files are receommended already
|
|
|
|
* just need to set peers
|
|
|
|
*/
|
|
|
|
std::cerr << "SharedFilesDialog::sendLinkTo()" << std::endl;
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
nMsgDialog->insertTitleText("RetroShare Link");
|
2010-03-15 08:57:08 -04:00
|
|
|
|
|
|
|
nMsgDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString());
|
2009-05-18 10:23:55 -04:00
|
|
|
|
|
|
|
nMsgDialog->show();
|
2010-05-02 20:09:55 -04:00
|
|
|
|
|
|
|
/* window will destroy itself! */
|
2009-05-18 10:23:55 -04:00
|
|
|
}
|
|
|
|
|
2010-01-16 13:03:35 -05:00
|
|
|
void SharedFilesDialog::sendHtmlLinkTo( )
|
|
|
|
{
|
|
|
|
copyLinkLocal ();
|
|
|
|
|
|
|
|
/* create a message */
|
2010-05-25 05:32:14 -04:00
|
|
|
MessageComposer *nMsgDialog = new MessageComposer();
|
2010-01-16 13:03:35 -05:00
|
|
|
|
|
|
|
/* fill it in
|
|
|
|
* files are receommended already
|
|
|
|
* just need to set peers
|
|
|
|
*/
|
|
|
|
std::cerr << "SharedFilesDialog::sendLinkTo()" << std::endl;
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
nMsgDialog->insertTitleText("RetroShare Link");
|
2010-03-15 08:57:08 -04:00
|
|
|
// nMsgDialog->insertHtmlText(QApplication::clipboard()->text().toStdString());// not compatible with multiple links
|
|
|
|
nMsgDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString());
|
2010-01-16 13:03:35 -05:00
|
|
|
|
|
|
|
nMsgDialog->show();
|
2010-05-02 20:09:55 -04:00
|
|
|
|
|
|
|
/* window will destroy itself! */
|
2010-01-16 13:03:35 -05:00
|
|
|
}
|
|
|
|
|
2010-03-15 08:57:08 -04:00
|
|
|
//void SharedFilesDialog::sendLinktoChat()
|
|
|
|
//{
|
|
|
|
// copyLinkLocal ();
|
|
|
|
//
|
|
|
|
// static SendLinkDialog *slinkDialog = new SendLinkDialog(this);
|
|
|
|
//
|
|
|
|
// slinkDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString());
|
|
|
|
// slinkDialog->show();
|
|
|
|
//
|
|
|
|
//}
|
2010-02-01 09:47:54 -05:00
|
|
|
|
2009-08-17 16:19:53 -04:00
|
|
|
void SharedFilesDialog::sendLinkToCloud()
|
|
|
|
{
|
|
|
|
copyLinkLocal ();
|
|
|
|
|
2009-08-17 18:06:48 -04:00
|
|
|
AddLinksDialog *nAddLinksDialog = new AddLinksDialog(QApplication::clipboard()->text());
|
2009-08-17 16:19:53 -04:00
|
|
|
|
|
|
|
nAddLinksDialog->addLinkComment();
|
|
|
|
nAddLinksDialog->close();
|
2010-05-04 20:05:36 -04:00
|
|
|
|
|
|
|
/* window will destroy itself! */
|
2009-08-17 16:19:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SharedFilesDialog::addLinkToCloud()
|
|
|
|
{
|
|
|
|
copyLinkLocal ();
|
|
|
|
|
2009-08-17 18:06:48 -04:00
|
|
|
AddLinksDialog *nAddLinksDialog = new AddLinksDialog(QApplication::clipboard()->text());
|
2009-08-17 16:19:53 -04:00
|
|
|
|
|
|
|
nAddLinksDialog->show();
|
2010-05-04 20:05:36 -04:00
|
|
|
|
|
|
|
/* window will destroy itself! */
|
2009-08-17 16:19:53 -04: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;
|
|
|
|
|
|
|
|
std::list<std::string> paths;
|
2010-09-19 20:10:51 -04:00
|
|
|
localModel -> getFilePaths(getLocalSelected(), paths);
|
2008-03-31 14:37:50 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
//#if 0
|
|
|
|
|
|
|
|
//void SharedFilesDialog::addMsgRemoteSelected()
|
|
|
|
//{
|
|
|
|
// /* call back to the model (which does all the interfacing? */
|
|
|
|
//
|
|
|
|
// std::cerr << "Recommending Files";
|
|
|
|
// std::cerr << std::endl;
|
|
|
|
//
|
2010-09-19 20:10:51 -04:00
|
|
|
// model -> recommendSelected(getRemoteSelected());
|
2009-05-17 15:38:42 -04:00
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//void SharedFilesDialog::recommendfile()
|
|
|
|
//{
|
|
|
|
// /* call back to the model (which does all the interfacing? */
|
|
|
|
//
|
|
|
|
// std::cerr << "Recommending Files";
|
|
|
|
// std::cerr << std::endl;
|
|
|
|
//
|
2010-09-19 20:10:51 -04:00
|
|
|
// localModel -> recommendSelected(getLocalSelected());
|
2009-05-17 15:38:42 -04:00
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//void SharedFilesDialog::recommendFileSetOnly()
|
|
|
|
//{
|
|
|
|
// /* 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 */
|
|
|
|
//
|
2010-09-19 20:10:51 -04:00
|
|
|
// localModel -> recommendSelectedOnly(getLocalSelected());
|
2009-05-17 15:38:42 -04:00
|
|
|
//}
|
2008-07-02 12:59:56 -04:00
|
|
|
|
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
void SharedFilesDialog::recommendFilesTo( std::string rsid )
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
2009-05-17 15:38:42 -04:00
|
|
|
// recommendFileSetOnly();
|
|
|
|
// rsicontrol -> ClearInMsg();
|
|
|
|
// rsicontrol -> SetInMsg(rsid, true);
|
2008-07-02 12:59:56 -04:00
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
std::list<DirDetails> files_info ;
|
2008-07-02 12:59:56 -04:00
|
|
|
|
2010-09-19 20:10:51 -04:00
|
|
|
localModel->getFileInfoFromIndexList(getLocalSelected(),files_info);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
if(files_info.empty())
|
|
|
|
return ;
|
2008-11-18 12:14:49 -05:00
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
/* create a message */
|
2010-05-25 05:32:14 -04:00
|
|
|
MessageComposer *nMsgDialog = new MessageComposer();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-07-07 14:56:31 -04:00
|
|
|
/* fill it in
|
2009-05-17 15:38:42 -04:00
|
|
|
* files are receommended already
|
|
|
|
* just need to set peers
|
|
|
|
*/
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
nMsgDialog->insertFileList(files_info) ;
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
nMsgDialog->insertTitleText("Recommendation(s)");
|
|
|
|
nMsgDialog->insertMsgText(rsPeers->getPeerName(rsPeers->getOwnId())+" recommends " + ( (files_info.size()>1)?"a list of files":"a file")+" to you");
|
|
|
|
nMsgDialog->addRecipient(rsid) ;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
nMsgDialog->sendMessage();
|
|
|
|
nMsgDialog->close();
|
2010-05-02 20:09:55 -04:00
|
|
|
|
|
|
|
/* window will destroy itself! */
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
void SharedFilesDialog::recommendFilesToMsg( std::string rsid )
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
2009-05-17 15:38:42 -04:00
|
|
|
std::list<DirDetails> files_info ;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-09-19 20:10:51 -04:00
|
|
|
localModel->getFileInfoFromIndexList(getLocalSelected(),files_info);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
if(files_info.empty())
|
|
|
|
return ;
|
2008-07-02 12:59:56 -04:00
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
/* create a message */
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-05-25 05:32:14 -04:00
|
|
|
MessageComposer *nMsgDialog = new MessageComposer();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
nMsgDialog->insertFileList(files_info) ;
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
nMsgDialog->insertTitleText("Recommendation(s)");
|
|
|
|
nMsgDialog->insertMsgText("Recommendation(s)");
|
|
|
|
nMsgDialog->show();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
std::cout << "recommending to " << rsid << std::endl ;
|
|
|
|
nMsgDialog->addRecipient(rsid) ;
|
2010-05-02 20:09:55 -04:00
|
|
|
|
|
|
|
/* window will destroy itself! */
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
//#endif
|
2008-07-02 12:59:56 -04:00
|
|
|
|
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? */
|
|
|
|
|
2009-07-07 14:56:31 -04:00
|
|
|
std::cerr << "SharedFilesDialog::openfile" << std::endl;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-09-19 20:10:51 -04:00
|
|
|
QModelIndexList qmil = getLocalSelected();
|
2009-07-07 14:56:31 -04:00
|
|
|
localModel->openSelected(qmil, false);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
void SharedFilesDialog::openfolder()
|
|
|
|
{
|
2009-07-07 14:56:31 -04:00
|
|
|
std::cerr << "SharedFilesDialog::openfolder" << std::endl;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-09-19 20:10:51 -04:00
|
|
|
QModelIndexList qmil = getLocalSelected();
|
2009-07-07 14:56:31 -04:00
|
|
|
localModel->openSelected(qmil, true);
|
2008-11-18 12:14:49 -05:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
void SharedFilesDialog::preModDirectories(bool update_local)
|
|
|
|
{
|
2010-02-07 16:28:40 -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
|
|
|
{
|
2010-02-07 16:28:40 -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)
|
2009-08-11 14:14:55 -04:00
|
|
|
{
|
2007-11-14 22:18:48 -05:00
|
|
|
localModel->postMods();
|
2009-08-11 14:14:55 -04:00
|
|
|
ui.localDirTreeView->update() ;
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
else
|
2009-08-11 14:14:55 -04:00
|
|
|
{
|
2007-11-14 22:18:48 -05:00
|
|
|
model->postMods();
|
2009-08-11 14:14:55 -04:00
|
|
|
ui.remoteDirTreeView->update() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
QCoreApplication::flush();
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
2009-05-17 15:38:42 -04:00
|
|
|
//=== at this moment we'll show menu only for files, not for folders
|
|
|
|
QModelIndex midx = ui.localDirTreeView->indexAt(point);
|
2009-05-18 10:23:55 -04:00
|
|
|
//if (localModel->isDir( midx ) )
|
|
|
|
// return;
|
2009-05-17 15:38:42 -04:00
|
|
|
|
2010-01-31 09:21:24 -05:00
|
|
|
currentFile = localModel->data(midx, RemoteDirModel::FileNameRole).toString();
|
2009-05-17 15:38:42 -04:00
|
|
|
|
|
|
|
QMenu contextMnu2( this );
|
2009-07-07 14:56:31 -04:00
|
|
|
//
|
2009-05-17 15:38:42 -04:00
|
|
|
|
2010-03-28 16:46:45 -04:00
|
|
|
// QAction* menuAction = fileAssotiationAction(currentFile) ;
|
2009-05-17 15:38:42 -04:00
|
|
|
//new QAction(QIcon(IMAGE_PLAY), currentFile, this);
|
|
|
|
//tr( "111Play File(s)" ), this );
|
|
|
|
// connect( openfolderAct , SIGNAL( triggered() ), this,
|
|
|
|
// SLOT( playselectedfiles() ) );
|
|
|
|
|
|
|
|
// openfileAct = new QAction(QIcon(IMAGE_ATTACHMENT), tr( "Add to Recommend List" ), this );
|
|
|
|
// connect( openfileAct , SIGNAL( triggered() ), this, SLOT( recommendfile() ) );
|
|
|
|
|
|
|
|
// #if 0
|
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>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-03-28 16:46:45 -04:00
|
|
|
QMenu recMenu( tr("Recommend (Automated message) To "), this );
|
|
|
|
recMenu.setIcon(QIcon(IMAGE_ATTACHMENT));
|
|
|
|
QMenu msgMenu( tr("Recommend in a message to "), &contextMnu2 );
|
|
|
|
msgMenu.setIcon(QIcon(IMAGE_MSG));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
std::list<std::string> peers;
|
2008-01-25 03:49:40 -05:00
|
|
|
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;
|
|
|
|
}
|
2009-05-17 15:38:42 -04:00
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
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
|
|
|
{
|
2010-01-31 09:21:24 -05:00
|
|
|
RsPeerDetails details ;
|
|
|
|
if(!rsPeers->getPeerDetails(*it,details))
|
|
|
|
continue ;
|
|
|
|
|
|
|
|
std::string name = details.name ;
|
|
|
|
std::string location = details.location ;
|
|
|
|
|
|
|
|
std::string nn = name + " (" + location +")" ;
|
2007-11-14 22:18:48 -05:00
|
|
|
/* parents are
|
|
|
|
* recMenu
|
|
|
|
* msgMenu
|
|
|
|
*/
|
2008-01-25 03:49:40 -05:00
|
|
|
|
2010-03-28 16:46:45 -04:00
|
|
|
RsAction *qaf1 = new RsAction( QIcon(IMAGE_FRIEND), QString::fromStdString( nn ), &recMenu, *it );
|
2009-05-17 15:38:42 -04:00
|
|
|
connect( qaf1 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesTo( std::string ) ) );
|
2010-03-28 16:46:45 -04:00
|
|
|
RsAction *qaf2 = new RsAction( QIcon(IMAGE_FRIEND), QString::fromStdString( nn ), &msgMenu, *it );
|
2009-05-17 15:38:42 -04:00
|
|
|
connect( qaf2 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesToMsg( std::string ) ) );
|
2010-03-28 16:46:45 -04:00
|
|
|
|
|
|
|
recMenu.addAction(qaf1);
|
|
|
|
msgMenu.addAction(qaf2);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* create list of ids */
|
|
|
|
|
|
|
|
}
|
2009-05-17 15:38:42 -04:00
|
|
|
//#endif
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2010-01-31 09:21:24 -05:00
|
|
|
if(localModel->isDir( midx ) )
|
|
|
|
contextMnu2.addAction( openfolderAct);
|
|
|
|
else
|
|
|
|
{
|
2010-03-28 16:46:45 -04:00
|
|
|
// contextMnu2.addAction( menuAction );
|
2010-01-31 09:21:24 -05:00
|
|
|
contextMnu2.addAction( openfileAct);
|
|
|
|
}
|
|
|
|
|
2009-07-07 14:56:31 -04:00
|
|
|
contextMnu2.addSeparator();
|
2009-04-07 04:08:03 -04:00
|
|
|
|
2010-01-31 09:21:24 -05:00
|
|
|
if(!localModel->isDir( midx ) )
|
|
|
|
{
|
|
|
|
contextMnu2.addAction( copylinklocalAct);
|
2010-03-15 08:57:08 -04:00
|
|
|
// contextMnu2.addAction( copylinklocalhtmlAct);
|
2010-01-31 09:21:24 -05:00
|
|
|
contextMnu2.addAction( sendlinkAct);
|
2010-03-15 08:57:08 -04:00
|
|
|
// contextMnu2.addAction( sendhtmllinkAct);
|
|
|
|
// contextMnu2.addAction( sendchatlinkAct);
|
2010-01-31 09:21:24 -05:00
|
|
|
contextMnu2.addSeparator();
|
2010-02-07 15:10:31 -05:00
|
|
|
#ifndef RS_RELEASE_VERSION
|
2010-01-31 09:21:24 -05:00
|
|
|
contextMnu2.addAction( sendlinkCloudAct);
|
|
|
|
contextMnu2.addAction( addlinkCloudAct);
|
|
|
|
contextMnu2.addSeparator();
|
2010-02-07 15:10:31 -05:00
|
|
|
#endif
|
2010-03-28 16:46:45 -04:00
|
|
|
contextMnu2.addMenu( &recMenu);
|
|
|
|
contextMnu2.addMenu( &msgMenu);
|
2010-01-31 09:21:24 -05:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-05-14 16:55:44 -04:00
|
|
|
contextMnu2.exec(QCursor::pos());
|
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;
|
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->beginGroup("FileAssotiations");
|
2009-04-07 04:08:03 -04:00
|
|
|
|
2009-12-14 12:13:10 -05:00
|
|
|
QString key = AddFileAssociationDialog::cleanFileType(currentFile) ;
|
2010-05-20 17:53:27 -04:00
|
|
|
if ( Settings->contains(key) )
|
2009-04-07 04:08:03 -04:00
|
|
|
{
|
|
|
|
result = new QAction(QIcon(IMAGE_PLAY), tr( "Open File" ), this );
|
|
|
|
connect( result , SIGNAL( triggered() ),
|
|
|
|
this, SLOT( runCommandForFile() ) );
|
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
currentCommand = (Settings->value( key )).toString();
|
2009-04-07 04:08:03 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = new QAction(QIcon(Image_AddNewAssotiationForFile),
|
|
|
|
tr( "Set command for opening this file"), this );
|
|
|
|
connect( result , SIGNAL( triggered() ),
|
|
|
|
this, SLOT( tryToAddNewAssotiation() ) );
|
|
|
|
}
|
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->endGroup();
|
2009-04-07 04:08:03 -04:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void
|
|
|
|
SharedFilesDialog::runCommandForFile()
|
|
|
|
{
|
|
|
|
QStringList tsl;
|
|
|
|
tsl.append( currentFile );
|
|
|
|
QProcess::execute( currentCommand, tsl);
|
|
|
|
//QString("%1 %2").arg(currentCommand).arg(currentFile) );
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
// 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()
|
|
|
|
{
|
2009-12-14 12:13:10 -05:00
|
|
|
AddFileAssociationDialog afad(true, this);//'add file assotiations' dialog
|
2009-04-07 04:08:03 -04:00
|
|
|
|
2009-12-14 12:13:10 -05:00
|
|
|
afad.setFileType(AddFileAssociationDialog::cleanFileType(currentFile));
|
2009-04-07 04:08:03 -04:00
|
|
|
|
|
|
|
int ti = afad.exec();
|
|
|
|
|
|
|
|
if (ti==QDialog::Accepted)
|
|
|
|
{
|
|
|
|
QString currType = afad.resultFileType() ;
|
|
|
|
QString currCmd = afad.resultCommand() ;
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValueToGroup("FileAssotiations", currType, currCmd);
|
2009-04-07 04:08:03 -04:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
//============================================================================
|
2008-08-07 14:49:57 -04:00
|
|
|
/**
|
2009-07-20 13:03:27 -04:00
|
|
|
Toggles the Splitted, Remote and Local View on and off*/
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2008-08-07 14:49:57 -04:00
|
|
|
void SharedFilesDialog::showFrame(bool show)
|
|
|
|
{
|
|
|
|
if (show) {
|
2009-07-20 13:03:27 -04:00
|
|
|
ui.localframe->setVisible(true);
|
|
|
|
ui.remoteframe->setVisible(false);
|
2009-08-17 16:19:53 -04:00
|
|
|
|
2009-07-20 13:03:27 -04:00
|
|
|
ui.localButton->setChecked(true);
|
2009-08-17 16:19:53 -04:00
|
|
|
|
2009-07-20 13:03:27 -04:00
|
|
|
ui.remoteButton->setChecked(false);
|
|
|
|
ui.splittedButton->setChecked(false);
|
2009-10-13 16:36:29 -04:00
|
|
|
|
2010-04-03 14:42:03 -04:00
|
|
|
ui.labeltext->setText( tr("<strong>My Shared Files</strong>"));
|
2009-08-17 16:19:53 -04:00
|
|
|
}
|
2009-07-20 13:03:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SharedFilesDialog::showFrameRemote(bool show)
|
|
|
|
{
|
|
|
|
if (show) {
|
|
|
|
ui.remoteframe->setVisible(true);
|
|
|
|
ui.localframe->setVisible(false);
|
2009-08-17 16:19:53 -04:00
|
|
|
|
2009-07-20 13:03:27 -04:00
|
|
|
ui.remoteButton->setChecked(true);
|
|
|
|
ui.localButton->setChecked(false);
|
|
|
|
ui.splittedButton->setChecked(false);
|
2009-01-01 19:09:59 -05:00
|
|
|
|
2010-02-13 20:34:14 -05:00
|
|
|
ui.labeltext->setText( tr("<strong>Friends Files</strong>"));
|
2009-08-17 16:19:53 -04:00
|
|
|
}
|
2009-07-20 13:03:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SharedFilesDialog::showFrameSplitted(bool show)
|
|
|
|
{
|
|
|
|
if (show) {
|
|
|
|
ui.remoteframe->setVisible(true);
|
|
|
|
ui.localframe->setVisible(true);
|
2009-08-17 16:19:53 -04:00
|
|
|
|
2009-07-20 13:03:27 -04:00
|
|
|
ui.splittedButton->setChecked(true);
|
2009-08-17 16:19:53 -04:00
|
|
|
|
|
|
|
ui.localButton->setChecked(false);
|
2009-07-20 13:03:27 -04:00
|
|
|
ui.remoteButton->setChecked(false);
|
2009-10-13 16:36:29 -04:00
|
|
|
|
2010-02-13 20:34:14 -05:00
|
|
|
ui.labeltext->setText( tr("<strong>Files</strong>"));
|
2009-08-17 16:19:53 -04:00
|
|
|
}
|
2009-07-20 13:03:27 -04:00
|
|
|
}
|
2009-10-13 16:36:29 -04:00
|
|
|
|
|
|
|
void SharedFilesDialog::indicatorChanged(int index)
|
|
|
|
{
|
2010-02-08 17:32:00 -05:00
|
|
|
static uint32_t correct_indicator[4] = { IND_ALWAYS,IND_LAST_DAY,IND_LAST_WEEK,IND_LAST_MONTH } ;
|
|
|
|
|
|
|
|
model->changeAgeIndicator(correct_indicator[index]);
|
|
|
|
localModel->changeAgeIndicator(correct_indicator[index]);
|
|
|
|
|
|
|
|
ui.remoteDirTreeView->update(ui.remoteDirTreeView->rootIndex());
|
|
|
|
ui.localDirTreeView->update(ui.localDirTreeView->rootIndex()) ;
|
2010-02-08 18:09:46 -05:00
|
|
|
|
|
|
|
updateDisplay() ;
|
2009-10-13 16:36:29 -04:00
|
|
|
}
|
|
|
|
|