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 <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"
|
2010-11-20 15:58:35 -05:00
|
|
|
#ifdef RS_USE_LINKS
|
2009-08-17 16:19:53 -04:00
|
|
|
#include "AddLinksDialog.h"
|
2010-11-20 15:58:35 -05:00
|
|
|
#endif
|
2010-03-10 16:38:26 -05:00
|
|
|
#include "RetroShareLink.h"
|
2010-09-28 16:33:34 -04:00
|
|
|
#include "RemoteDirModel.h"
|
|
|
|
#include "common/PeerDefs.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"
|
2011-11-13 08:58:39 -05:00
|
|
|
#define IMAGE_COLLECTION ":/images/mimetypes/rscollection-16.png"
|
2009-05-18 10:23:55 -04:00
|
|
|
|
2011-04-03 15:59:12 -04:00
|
|
|
// Define to avoid using the search in treeview, because it is really slow for now.
|
|
|
|
//
|
|
|
|
#define DONT_USE_SEARCH_IN_TREE_VIEW 1
|
|
|
|
|
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:
|
2011-04-01 17:46:06 -04:00
|
|
|
SFDSortFilterProxyModel(RetroshareDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent)
|
2010-09-19 20:10:51 -04:00
|
|
|
{
|
|
|
|
m_dirModel = dirModel;
|
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
|
|
|
|
{
|
2010-11-07 16:33:48 -05:00
|
|
|
bool dirLeft = (m_dirModel->getType(left) == DIR_TYPE_DIR);
|
|
|
|
bool dirRight = (m_dirModel->getType(right) == DIR_TYPE_DIR);
|
2010-09-19 20:10:51 -04:00
|
|
|
|
|
|
|
if (dirLeft ^ dirRight) {
|
|
|
|
return dirLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QSortFilterProxyModel::lessThan(left, right);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2011-04-01 17:46:06 -04:00
|
|
|
RetroshareDirModel *m_dirModel;
|
2010-09-19 20:10:51 -04:00
|
|
|
};
|
2008-11-18 12:14:49 -05:00
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
2011-04-14 17:58:15 -04:00
|
|
|
: RsAutoUpdatePage(1000,parent),model(NULL)
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
2011-04-05 20:19:56 -04:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck()));
|
|
|
|
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)));
|
|
|
|
connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int)));
|
2009-07-20 13:03:27 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
connect( ui.localDirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( sharedDirTreeWidgetContextMenu( QPoint ) ) );
|
|
|
|
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()));
|
2011-04-05 20:19:56 -04:00
|
|
|
connect( ui.downloadButton, SIGNAL( clicked()), this, SLOT( downloadRemoteSelected()));
|
2009-01-01 19:09:59 -05:00
|
|
|
|
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 * ) ) );
|
|
|
|
*/
|
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
tree_model = new TreeStyle_RDM(true);
|
|
|
|
flat_model = new FlatStyle_RDM(true);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
tree_proxyModel = new SFDSortFilterProxyModel(tree_model, this);
|
|
|
|
tree_proxyModel->setDynamicSortFilter(true);
|
|
|
|
tree_proxyModel->setSourceModel(tree_model);
|
|
|
|
tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
tree_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
|
|
|
tree_proxyModel->sort(0);
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
flat_proxyModel = new SFDSortFilterProxyModel(flat_model, this);
|
|
|
|
flat_proxyModel->setDynamicSortFilter(true);
|
|
|
|
flat_proxyModel->setSourceModel(flat_model);
|
|
|
|
flat_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
flat_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
|
|
|
flat_proxyModel->sort(0);
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
localModel = new TreeStyle_RDM(false);
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
localProxyModel = new SFDSortFilterProxyModel(localModel, this);
|
|
|
|
localProxyModel->setDynamicSortFilter(true);
|
|
|
|
localProxyModel->setSourceModel(localModel);
|
|
|
|
localProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
localProxyModel->setSortRole(RetroshareDirModel::SortRole);
|
|
|
|
localProxyModel->sort(0);
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
ui.localDirTreeView->setModel(localProxyModel);
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
connect( ui.localDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), localModel, SLOT( collapsed(const QModelIndex & ) ) );
|
|
|
|
connect( ui.localDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), localModel, SLOT( expanded(const QModelIndex & ) ) );
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
connect( localModel, SIGNAL( layoutAboutToBeChanged() ), ui.localDirTreeView, SLOT( reset() ) );
|
|
|
|
connect( localModel, SIGNAL( layoutChanged() ), ui.localDirTreeView, SLOT( update() ) );
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
|
|
|
connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter()));
|
|
|
|
connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter()));
|
|
|
|
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2011-04-05 20:19:56 -04: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
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
l_header->setStretchLastSection(false);
|
|
|
|
// l_header->setHighlightSections(false);
|
|
|
|
|
|
|
|
// Setup the current view model.
|
|
|
|
//
|
|
|
|
changeCurrentViewModel(ui.viewType_CB->currentIndex()) ;
|
|
|
|
|
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 );
|
2011-04-01 17:46:06 -04:00
|
|
|
r_header->resizeSection ( 2, 80 );
|
2007-11-14 22:18:48 -05:00
|
|
|
r_header->resizeSection ( 3, 100 );
|
2011-04-01 17:46:06 -04:00
|
|
|
r_header->resizeSection ( 4, 80 );
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2011-04-01 17:46:06 -04:00
|
|
|
// r_header->setHighlightSections(false);
|
2008-08-07 14:49:57 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
/* Set Multi Selection */
|
|
|
|
ui.remoteDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
ui.localDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2011-04-01 17:46:06 -04:00
|
|
|
//#ifdef RS_RELEASE_VERSION
|
|
|
|
// ui.filterLabel->hide();
|
|
|
|
// ui.filterPatternLineEdit->hide();
|
|
|
|
//#endif
|
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
// load settings
|
|
|
|
processSettings(true);
|
|
|
|
|
|
|
|
// Hide columns after loading the settings
|
|
|
|
ui.remoteDirTreeView->setColumnHidden(3,false) ;
|
|
|
|
ui.remoteDirTreeView->setColumnHidden(4,true) ;
|
|
|
|
ui.localDirTreeView->setColumnHidden(4,true) ;
|
2011-04-01 17:46:06 -04: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( ) ) );
|
2010-11-20 15:58:35 -05:00
|
|
|
#ifdef RS_USE_LINKS
|
2010-03-28 16:46:45 -04:00
|
|
|
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( ) ) );
|
2010-11-20 15:58:35 -05:00
|
|
|
#endif
|
2011-11-13 08:58:39 -05:00
|
|
|
createcollectionfileAct = new QAction(QIcon(IMAGE_COLLECTION), tr("Create collection file"), this);
|
2011-11-07 18:07:25 -05:00
|
|
|
connect(createcollectionfileAct, SIGNAL(triggered()), this, SLOT(createCollectionFile()));
|
2010-03-28 16:46:45 -04:00
|
|
|
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
|
|
|
|
2011-04-14 17:58:15 -04:00
|
|
|
void SharedFilesDialog::hideEvent(QHideEvent *)
|
|
|
|
{
|
|
|
|
if(model!=NULL)
|
|
|
|
model->setVisible(false) ;
|
|
|
|
//std::cerr << "Hidden!"<< std::endl;
|
|
|
|
}
|
|
|
|
void SharedFilesDialog::showEvent(QShowEvent *)
|
|
|
|
{
|
|
|
|
if(model!=NULL)
|
|
|
|
{
|
|
|
|
model->setVisible(true) ;
|
|
|
|
model->update() ;
|
|
|
|
}
|
|
|
|
//std::cerr << "Shown!"<< std::endl;
|
|
|
|
}
|
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)
|
|
|
|
{
|
2011-04-05 20:19:56 -04:00
|
|
|
Settings->beginGroup("SharedFilesDialog");
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
if (bLoad) {
|
|
|
|
// load settings
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
// state of the trees
|
|
|
|
ui.localDirTreeView->header()->restoreState(Settings->value("LocalDirTreeView").toByteArray());
|
|
|
|
ui.remoteDirTreeView->header()->restoreState(Settings->value("RemoteDirTreeView").toByteArray());
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
// state of splitter
|
|
|
|
ui.splitter->restoreState(Settings->value("Splitter").toByteArray());
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
// view type
|
|
|
|
ui.viewType_CB->setCurrentIndex(Settings->value("ViewType").toInt());
|
|
|
|
} else {
|
|
|
|
// save settings
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
// 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());
|
|
|
|
|
|
|
|
// view type
|
|
|
|
Settings->setValue("ViewType", ui.viewType_CB->currentIndex());
|
|
|
|
}
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
Settings->endGroup();
|
2008-11-18 12:14:49 -05:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2011-04-01 17:46:06 -04:00
|
|
|
void SharedFilesDialog::changeCurrentViewModel(int c)
|
|
|
|
{
|
|
|
|
disconnect( ui.remoteDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), 0, 0 );
|
|
|
|
disconnect( ui.remoteDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), 0, 0 );
|
|
|
|
|
2011-04-14 17:58:15 -04:00
|
|
|
if(model!=NULL)
|
|
|
|
model->setVisible(false) ;
|
|
|
|
|
2011-04-01 17:46:06 -04:00
|
|
|
if(c == 0)
|
|
|
|
{
|
|
|
|
model = tree_model ;
|
|
|
|
proxyModel = tree_proxyModel ;
|
|
|
|
ui.remoteDirTreeView->setColumnHidden(3,true) ;
|
2011-04-07 16:09:32 -04:00
|
|
|
ui.remoteDirTreeView->setColumnHidden(4,true) ;
|
2011-04-03 15:59:12 -04:00
|
|
|
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
2011-04-01 17:46:06 -04:00
|
|
|
ui.filterLabel->hide();
|
|
|
|
ui.filterPatternLineEdit->hide();
|
2011-04-03 15:59:12 -04:00
|
|
|
ui.filterStartButton->hide();
|
|
|
|
ui.filterClearButton->hide();
|
|
|
|
#endif
|
2011-04-01 17:46:06 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
model = flat_model ;
|
|
|
|
proxyModel = flat_proxyModel ;
|
|
|
|
ui.remoteDirTreeView->setColumnHidden(3,false) ;
|
2011-04-07 16:09:32 -04:00
|
|
|
ui.remoteDirTreeView->setColumnHidden(4,false) ;
|
2011-04-03 15:59:12 -04:00
|
|
|
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
2011-04-01 17:46:06 -04:00
|
|
|
ui.filterLabel->show();
|
|
|
|
ui.filterPatternLineEdit->show();
|
2011-04-03 15:59:12 -04:00
|
|
|
#endif
|
2011-04-01 17:46:06 -04:00
|
|
|
}
|
|
|
|
|
2011-04-14 17:58:15 -04:00
|
|
|
if(isVisible())
|
|
|
|
{
|
|
|
|
model->setVisible(true) ;
|
|
|
|
model->update() ;
|
|
|
|
}
|
2011-04-01 17:46:06 -04: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 & ) ) );
|
|
|
|
|
|
|
|
ui.remoteDirTreeView->setModel(proxyModel);
|
|
|
|
ui.remoteDirTreeView->update();
|
|
|
|
|
|
|
|
ui.remoteDirTreeView->header()->headerDataChanged(Qt::Horizontal,0,4) ;
|
|
|
|
|
2011-04-03 15:59:12 -04:00
|
|
|
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
2011-04-01 17:46:06 -04:00
|
|
|
if(c == 1)
|
2011-04-03 15:59:12 -04:00
|
|
|
#endif
|
2011-04-01 17:46:06 -04:00
|
|
|
FilterItems();
|
|
|
|
}
|
|
|
|
|
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..."));
|
2008-03-31 14:37:50 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-29 08:50:33 -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-11-07 16:33:48 -05:00
|
|
|
QModelIndex idx = ui.remoteDirTreeView->indexAt(point);
|
|
|
|
if (!idx.isValid())
|
|
|
|
return;
|
|
|
|
QModelIndex midx = proxyModel->mapToSource(idx);
|
|
|
|
if (!midx.isValid())
|
|
|
|
return;
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
int type = model->getType(midx);
|
|
|
|
if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE) {
|
|
|
|
return;
|
|
|
|
}
|
2009-05-18 10:23:55 -04:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
QMenu contextMnu( this );
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), &contextMnu );
|
|
|
|
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) );
|
|
|
|
contextMnu.addAction( downloadAct);
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
if (type == DIR_TYPE_FILE) {
|
|
|
|
QAction *copyremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), &contextMnu );
|
|
|
|
connect( copyremotelinkAct , SIGNAL( triggered() ), this, SLOT( copyLinkRemote() ) );
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
QAction *sendremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), &contextMnu );
|
|
|
|
connect( sendremotelinkAct , SIGNAL( triggered() ), this, SLOT( sendremoteLinkTo( ) ) );
|
2008-11-18 12:14:49 -05:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction( copyremotelinkAct);
|
|
|
|
contextMnu.addAction( sendremotelinkAct);
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to"), this, SLOT(addMsgRemoteSelected()));
|
|
|
|
}
|
2010-05-14 16:55:44 -04:00
|
|
|
|
2010-11-07 16:33:48 -05: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
|
|
|
|
2011-11-07 18:07:25 -05:00
|
|
|
void SharedFilesDialog::createCollectionFile()
|
|
|
|
{
|
|
|
|
/* call back to the model (which does all the interfacing? */
|
|
|
|
|
|
|
|
std::cerr << "Creating a collection file!" << std::endl;
|
|
|
|
QModelIndexList lst = getLocalSelected();
|
2012-08-31 10:07:15 -04:00
|
|
|
localModel->createCollectionFile(this, lst);
|
2011-11-07 18:07:25 -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);
|
|
|
|
|
2011-09-11 18:07:24 -04:00
|
|
|
QList<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;
|
|
|
|
|
2011-05-04 06:22:49 -04:00
|
|
|
RetroShareLink link;
|
|
|
|
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.c_str())) {
|
|
|
|
urls.push_back(link) ;
|
|
|
|
}
|
2009-05-18 10:23:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-05-04 06:22:49 -04:00
|
|
|
{
|
|
|
|
RetroShareLink link;
|
|
|
|
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.c_str())) {
|
|
|
|
urls.push_back(link) ;
|
|
|
|
}
|
|
|
|
}
|
2009-05-18 10:23:55 -04:00
|
|
|
}
|
2011-05-04 06:22:49 -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-11-02 17:11:11 -04:00
|
|
|
MessageComposer *nMsgDialog = MessageComposer::newMsg();
|
|
|
|
if (nMsgDialog == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
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;
|
2012-05-04 19:39:36 -04:00
|
|
|
nMsgDialog->setTitleText(tr("RetroShare Link"));
|
|
|
|
nMsgDialog->setMsgText(RSLinkClipboard::toHtml(), true);
|
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-11-02 17:11:11 -04:00
|
|
|
MessageComposer *nMsgDialog = MessageComposer::newMsg();
|
|
|
|
if (nMsgDialog == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
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;
|
2012-05-04 19:39:36 -04:00
|
|
|
nMsgDialog->setTitleText(tr("RetroShare Link"));
|
|
|
|
nMsgDialog->setMsgText(RSLinkClipboard::toHtml(), true);
|
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-11-20 15:58:35 -05:00
|
|
|
#ifdef RS_USE_LINKS
|
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
|
|
|
}
|
2010-11-20 15:58:35 -05:00
|
|
|
#endif
|
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
|
|
|
}
|
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
void SharedFilesDialog::addMsgRemoteSelected()
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
2010-11-07 16:33:48 -05:00
|
|
|
std::list<DirDetails> files_info ;
|
2008-07-02 12:59:56 -04:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
model->getFileInfoFromIndexList(getRemoteSelected(),files_info);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
if(files_info.empty())
|
|
|
|
return ;
|
2008-11-18 12:14:49 -05:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
/* create a message */
|
2010-11-02 17:11:11 -04:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
MessageComposer *nMsgDialog = MessageComposer::newMsg();
|
|
|
|
if (nMsgDialog == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2012-05-04 19:39:36 -04:00
|
|
|
nMsgDialog->setFileList(files_info) ;
|
|
|
|
nMsgDialog->setTitleText(tr("Recommendation(s)"));
|
|
|
|
nMsgDialog->setMsgText(tr("Recommendation(s)"));
|
2010-11-07 16:33:48 -05:00
|
|
|
nMsgDialog->show();
|
2010-05-02 20:09:55 -04:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
/* window will destroy itself! */
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
void SharedFilesDialog::recommendFilesToMsg()
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
2010-11-07 16:33:48 -05:00
|
|
|
std::list<DirDetails> files_info ;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
localModel->getFileInfoFromIndexList(getLocalSelected(),files_info);
|
2008-07-02 12:59:56 -04:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
if(files_info.empty())
|
|
|
|
return ;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
/* create a message */
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
MessageComposer *nMsgDialog = MessageComposer::newMsg();
|
|
|
|
if (nMsgDialog == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2012-05-04 19:39:36 -04:00
|
|
|
nMsgDialog->setFileList(files_info) ;
|
|
|
|
nMsgDialog->setTitleText(tr("Recommendation(s)"));
|
|
|
|
nMsgDialog->setMsgText(tr("Recommendation(s)"));
|
2010-11-07 16:33:48 -05:00
|
|
|
nMsgDialog->show();
|
2010-05-02 20:09:55 -04:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
/* window will destroy itself! */
|
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();
|
2010-11-20 09:50:14 -05:00
|
|
|
localModel->openSelected(qmil);
|
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();
|
2010-11-20 09:50:14 -05:00
|
|
|
localModel->openSelected(qmil);
|
2008-11-18 12:14:49 -05:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
void SharedFilesDialog::preModDirectories(bool update_local)
|
|
|
|
{
|
2011-04-14 17:58:15 -04: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() ;
|
2010-11-30 07:29:04 -05:00
|
|
|
|
|
|
|
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
|
|
|
FilterItems();
|
|
|
|
}
|
2009-08-11 14:14:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2010-11-07 16:33:48 -05:00
|
|
|
if (!rsPeers) {
|
|
|
|
/* not ready yet! */
|
|
|
|
return;
|
|
|
|
}
|
2010-01-31 09:21:24 -05:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
QModelIndex idx = ui.localDirTreeView->indexAt(point);
|
|
|
|
if (!idx.isValid())
|
|
|
|
return;
|
|
|
|
QModelIndex midx = localProxyModel->mapToSource(idx);
|
|
|
|
if (!midx.isValid())
|
|
|
|
return;
|
2008-01-25 03:49:40 -05:00
|
|
|
|
2011-04-01 17:46:06 -04:00
|
|
|
currentFile = localModel->data(midx, RetroshareDirModel::FileNameRole).toString();
|
2010-03-28 16:46:45 -04:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
int type = localModel->getType(midx);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
QMenu contextMnu(this);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
// QAction* menuAction = fileAssotiationAction(currentFile) ;
|
|
|
|
//new QAction(QIcon(IMAGE_PLAY), currentFile, this);
|
|
|
|
//tr( "111Play File(s)" ), this );
|
|
|
|
// connect( openfolderAct , SIGNAL( triggered() ), this,
|
|
|
|
// SLOT( playselectedfiles() ) );
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case DIR_TYPE_DIR:
|
|
|
|
contextMnu.addAction(openfolderAct);
|
2011-11-07 18:07:25 -05:00
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction(createcollectionfileAct) ;
|
2010-11-07 16:33:48 -05:00
|
|
|
break;
|
|
|
|
case DIR_TYPE_FILE:
|
|
|
|
contextMnu.addAction(openfileAct);
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction(copylinklocalAct);
|
|
|
|
// contextMnu.addAction(copylinklocalhtmlAct);
|
|
|
|
contextMnu.addAction(sendlinkAct);
|
|
|
|
// contextMnu.addAction(sendhtmllinkAct);
|
2011-11-07 18:07:25 -05:00
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction(createcollectionfileAct) ;
|
2010-11-07 16:33:48 -05:00
|
|
|
contextMnu.addSeparator();
|
2010-11-20 15:58:35 -05:00
|
|
|
#ifdef RS_USE_LINKS
|
2010-11-07 16:33:48 -05:00
|
|
|
contextMnu.addAction(sendlinkCloudAct);
|
|
|
|
contextMnu.addAction(addlinkCloudAct);
|
|
|
|
contextMnu.addSeparator();
|
2010-02-07 15:10:31 -05:00
|
|
|
#endif
|
2010-11-07 16:33:48 -05:00
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to"), this, SLOT(recommendFilesToMsg()));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-11-07 16:33:48 -05:00
|
|
|
contextMnu.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*
|
2011-08-12 10:06:29 -04:00
|
|
|
SharedFilesDialog::fileAssotiationAction(const QString /*fileName*/)
|
2009-04-07 04:08:03 -04:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2012-08-26 16:31:10 -04:00
|
|
|
ui.titleBarLabel->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
|
|
|
|
2012-08-26 16:31:10 -04:00
|
|
|
ui.titleBarLabel->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
|
|
|
|
2012-08-26 16:31:10 -04:00
|
|
|
ui.titleBarLabel->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]);
|
|
|
|
|
2011-05-21 14:34:34 -04:00
|
|
|
ui.remoteDirTreeView->update(ui.remoteDirTreeView->rootIndex());
|
|
|
|
ui.localDirTreeView->update(ui.localDirTreeView->rootIndex()) ;
|
|
|
|
|
|
|
|
if (correct_indicator[index] != IND_ALWAYS)
|
|
|
|
{
|
|
|
|
ui.remoteDirTreeView->sortByColumn(2, Qt::AscendingOrder);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.remoteDirTreeView->sortByColumn(0, Qt::AscendingOrder);
|
|
|
|
}
|
2010-02-08 18:09:46 -05:00
|
|
|
|
2011-05-21 14:34:34 -04:00
|
|
|
updateDisplay() ;
|
2009-10-13 16:36:29 -04:00
|
|
|
}
|
|
|
|
|
2010-11-30 07:29:04 -05:00
|
|
|
void SharedFilesDialog::filterRegExpChanged()
|
|
|
|
{
|
|
|
|
QString text = ui.filterPatternLineEdit->text();
|
|
|
|
|
|
|
|
if (text.isEmpty()) {
|
|
|
|
ui.filterClearButton->hide();
|
|
|
|
} else {
|
|
|
|
ui.filterClearButton->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (text == lastFilterString) {
|
|
|
|
ui.filterStartButton->hide();
|
|
|
|
} else {
|
|
|
|
ui.filterStartButton->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear Filter */
|
|
|
|
void SharedFilesDialog::clearFilter()
|
|
|
|
{
|
|
|
|
ui.filterPatternLineEdit->clear();
|
|
|
|
ui.filterPatternLineEdit->setFocus();
|
|
|
|
|
|
|
|
startFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear Filter */
|
|
|
|
void SharedFilesDialog::startFilter()
|
|
|
|
{
|
|
|
|
ui.filterStartButton->hide();
|
|
|
|
lastFilterString = ui.filterPatternLineEdit->text();
|
|
|
|
|
|
|
|
FilterItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SharedFilesDialog::FilterItems()
|
|
|
|
{
|
|
|
|
QString text = ui.filterPatternLineEdit->text();
|
|
|
|
|
|
|
|
setCursor(Qt::WaitCursor);
|
2011-04-01 17:46:06 -04:00
|
|
|
QCoreApplication::processEvents() ;
|
2010-11-30 07:29:04 -05:00
|
|
|
|
|
|
|
int rowCount = ui.remoteDirTreeView->model()->rowCount();
|
2011-04-01 17:46:06 -04:00
|
|
|
for (int row = 0; row < rowCount; row++)
|
|
|
|
if(proxyModel == tree_proxyModel)
|
|
|
|
tree_FilterItem(ui.remoteDirTreeView->model()->index(row, 0), text, 0);
|
|
|
|
else
|
|
|
|
flat_FilterItem(ui.remoteDirTreeView->model()->index(row, 0), text, 0);
|
2010-11-30 07:29:04 -05:00
|
|
|
|
|
|
|
setCursor(Qt::ArrowCursor);
|
|
|
|
}
|
|
|
|
|
2011-08-12 10:06:29 -04:00
|
|
|
bool SharedFilesDialog::flat_FilterItem(const QModelIndex &index, const QString &text, int /*level*/)
|
2011-04-01 17:46:06 -04:00
|
|
|
{
|
|
|
|
if(index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive))
|
|
|
|
{
|
|
|
|
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), false);
|
|
|
|
return false ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), true);
|
|
|
|
return true ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString &text, int level)
|
2010-11-30 07:29:04 -05:00
|
|
|
{
|
|
|
|
bool visible = true;
|
|
|
|
|
|
|
|
if (text.isEmpty() == false) {
|
2011-04-01 17:46:06 -04:00
|
|
|
// better use RetroshareDirModel::getType, but its slow enough
|
2010-11-30 07:29:04 -05:00
|
|
|
if (/*index.parent().isValid()*/ level >= 1) {
|
2011-04-01 17:46:06 -04:00
|
|
|
if (index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive) == false) {
|
2010-11-30 07:29:04 -05:00
|
|
|
visible = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int visibleChildCount = 0;
|
|
|
|
int rowCount = ui.remoteDirTreeView->model()->rowCount(index);
|
|
|
|
for (int row = 0; row < rowCount; row++) {
|
2011-04-01 17:46:06 -04:00
|
|
|
if (tree_FilterItem(ui.remoteDirTreeView->model()->index(row, index.column(), index), text, level + 1)) {
|
2010-11-30 07:29:04 -05:00
|
|
|
visibleChildCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visible || visibleChildCount) {
|
|
|
|
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), false);
|
|
|
|
} else {
|
|
|
|
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (visible || visibleChildCount);
|
|
|
|
}
|
2011-04-01 17:46:06 -04:00
|
|
|
|