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"
|
2013-02-22 16:42:27 -05:00
|
|
|
#include "ShareManager.h"
|
2013-02-26 19:23:56 -05:00
|
|
|
#include "RemoteDirModel.h"
|
2012-12-05 08:26:26 -05:00
|
|
|
#include "ShareDialog.h"
|
2010-09-28 16:33:34 -04:00
|
|
|
#include "common/PeerDefs.h"
|
2013-10-19 09:25:06 -04:00
|
|
|
#include "util/QtVersion.h"
|
2014-01-05 17:51:54 -05:00
|
|
|
#include "notifyqt.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"
|
2012-12-05 08:26:26 -05:00
|
|
|
#define IMAGE_OPENFOLDER ":/images/folderopen.png"
|
2009-07-07 14:56:31 -04:00
|
|
|
#define IMAGE_OPENFILE ":/images/fileopen.png"
|
2013-02-26 19:23:56 -05:00
|
|
|
#define IMAGE_COLLECTION ":/images/mimetypes/rscollection-16.png"
|
|
|
|
#define IMAGE_EDITSHARE ":/images/edit_16.png"
|
2013-09-05 11:48:44 -04:00
|
|
|
#define IMAGE_MYFILES ":images/my_documents_22.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;
|
2014-01-05 17:51:54 -05:00
|
|
|
}
|
2010-09-19 20:10:51 -04:00
|
|
|
|
|
|
|
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 */
|
2013-02-22 16:42:27 -05:00
|
|
|
SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareDirModel *_flat_model,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
|
|
|
|
2014-01-05 17:51:54 -05:00
|
|
|
NotifyQt *notify = NotifyQt::getInstance();
|
|
|
|
connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool)));
|
|
|
|
connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool)));
|
|
|
|
|
2013-02-22 16:42:27 -05: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)));
|
2011-04-05 20:19:56 -04:00
|
|
|
connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int)));
|
2009-07-20 13:03:27 -04:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
connect( ui.dirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( spawnCustomPopupMenu( QPoint ) ) );
|
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
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
tree_model = _tree_model ;
|
|
|
|
flat_model = _flat_model ;
|
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
|
|
|
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 */
|
2013-02-22 16:42:27 -05:00
|
|
|
QHeaderView * header = ui.dirTreeView->header () ;
|
2009-01-30 20:46:49 -05:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
header->resizeSection ( 0, 490 );
|
|
|
|
header->resizeSection ( 1, 70 );
|
|
|
|
header->resizeSection ( 2, 100 );
|
|
|
|
header->resizeSection ( 3, 100 );
|
|
|
|
header->resizeSection ( 4, 100 );
|
2009-01-30 20:46:49 -05:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
header->setStretchLastSection(false);
|
2008-08-07 14:49:57 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
/* Set Multi Selection */
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
2011-04-01 17:46:06 -04:00
|
|
|
|
2008-11-18 12:14:49 -05:00
|
|
|
/* Hide platform specific features */
|
2013-02-22 16:42:27 -05:00
|
|
|
copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard" ), this );
|
|
|
|
connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
|
|
|
|
copylinkhtmlAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard (HTML)" ), this );
|
|
|
|
connect( copylinkhtmlAct , SIGNAL( triggered() ), this, SLOT( copyLinkhtml() ) );
|
2010-03-28 16:46:45 -04:00
|
|
|
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
|
2013-02-22 16:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent)
|
|
|
|
: SharedFilesDialog(new TreeStyle_RDM(false),new FlatStyle_RDM(false),parent)
|
|
|
|
{
|
|
|
|
// Hide columns after loading the settings
|
|
|
|
ui.dirTreeView->setColumnHidden(4,false) ;
|
|
|
|
ui.downloadButton->hide() ;
|
|
|
|
|
|
|
|
// load settings
|
|
|
|
processSettings(true);
|
|
|
|
// Setup the current view model.
|
|
|
|
//
|
|
|
|
changeCurrentViewModel(ui.viewType_CB->currentIndex()) ;
|
|
|
|
|
|
|
|
connect(ui.addShares_PB, SIGNAL(clicked()), this, SLOT(addShares()));
|
|
|
|
connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck()));
|
|
|
|
|
2011-11-13 08:58:39 -05:00
|
|
|
createcollectionfileAct = new QAction(QIcon(IMAGE_COLLECTION), tr("Create collection file"), this);
|
2010-03-28 16:46:45 -04:00
|
|
|
openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this);
|
|
|
|
openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
|
2013-02-22 16:42:27 -05:00
|
|
|
editshareAct = new QAction(QIcon(IMAGE_EDITSHARE), tr("Edit Share Permissions"), this);
|
|
|
|
|
|
|
|
connect(createcollectionfileAct, SIGNAL(triggered()), this, SLOT(createCollectionFile()));
|
|
|
|
connect(openfileAct, SIGNAL(triggered()), this, SLOT(openfile()));
|
|
|
|
connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openfolder()));
|
2012-12-05 08:26:26 -05:00
|
|
|
connect(editshareAct, SIGNAL(triggered()), this, SLOT(editSharePermissions()));
|
2013-08-25 16:19:01 -04:00
|
|
|
|
|
|
|
ui.titleBarPixmap->setPixmap(QPixmap(IMAGE_MYFILES));
|
2010-09-19 20:10:51 -04:00
|
|
|
}
|
2010-03-28 16:46:45 -04:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
RemoteSharedFilesDialog::RemoteSharedFilesDialog(QWidget *parent)
|
|
|
|
: SharedFilesDialog(new TreeStyle_RDM(true),new FlatStyle_RDM(true),parent)
|
|
|
|
{
|
|
|
|
ui.dirTreeView->setColumnHidden(3,false) ;
|
|
|
|
ui.dirTreeView->setColumnHidden(4,true) ;
|
|
|
|
ui.checkButton->hide() ;
|
|
|
|
|
|
|
|
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadRemoteSelected()));
|
|
|
|
|
|
|
|
// load settings
|
|
|
|
processSettings(true);
|
|
|
|
// Setup the current view model.
|
|
|
|
//
|
|
|
|
changeCurrentViewModel(ui.viewType_CB->currentIndex()) ;
|
|
|
|
|
|
|
|
ui.addShares_PB->hide() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LocalSharedFilesDialog::addShares()
|
|
|
|
{
|
|
|
|
ShareManager::showYourself();
|
|
|
|
}
|
|
|
|
|
2011-04-14 17:58:15 -04:00
|
|
|
void SharedFilesDialog::hideEvent(QHideEvent *)
|
|
|
|
{
|
|
|
|
if(model!=NULL)
|
|
|
|
model->setVisible(false) ;
|
|
|
|
}
|
|
|
|
void SharedFilesDialog::showEvent(QShowEvent *)
|
|
|
|
{
|
|
|
|
if(model!=NULL)
|
|
|
|
{
|
|
|
|
model->setVisible(true) ;
|
|
|
|
model->update() ;
|
|
|
|
}
|
|
|
|
}
|
2013-02-22 16:42:27 -05:00
|
|
|
RemoteSharedFilesDialog::~RemoteSharedFilesDialog()
|
|
|
|
{
|
|
|
|
// save settings
|
|
|
|
processSettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
LocalSharedFilesDialog::~LocalSharedFilesDialog()
|
2010-09-19 20:10:51 -04:00
|
|
|
{
|
|
|
|
// save settings
|
|
|
|
processSettings(false);
|
|
|
|
}
|
2010-03-28 16:46:45 -04:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
void LocalSharedFilesDialog::processSettings(bool bLoad)
|
|
|
|
{
|
|
|
|
Settings->beginGroup("LocalSharedFilesDialog");
|
|
|
|
|
|
|
|
if (bLoad) {
|
|
|
|
// load settings
|
|
|
|
|
|
|
|
// state of the trees
|
|
|
|
ui.dirTreeView->header()->restoreState(Settings->value("LocalDirTreeView").toByteArray());
|
|
|
|
|
|
|
|
// state of splitter
|
|
|
|
ui.splitter->restoreState(Settings->value("LocalSplitter").toByteArray());
|
|
|
|
|
|
|
|
// view type
|
|
|
|
ui.viewType_CB->setCurrentIndex(Settings->value("LocalViewType").toInt());
|
|
|
|
} else {
|
|
|
|
// save settings
|
|
|
|
|
|
|
|
// state of trees
|
|
|
|
Settings->setValue("LocalDirTreeView", ui.dirTreeView->header()->saveState());
|
|
|
|
|
|
|
|
// state of splitter
|
|
|
|
Settings->setValue("LocalSplitter", ui.splitter->saveState());
|
|
|
|
|
|
|
|
// view type
|
|
|
|
Settings->setValue("LocalViewType", ui.viewType_CB->currentIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings->endGroup();
|
|
|
|
}
|
|
|
|
void RemoteSharedFilesDialog::processSettings(bool bLoad)
|
2010-09-19 20:10:51 -04:00
|
|
|
{
|
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
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->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
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.splitter->restoreState(Settings->value("RemoteSplitter").toByteArray());
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
// view type
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.viewType_CB->setCurrentIndex(Settings->value("RemoteViewType").toInt());
|
2011-04-05 20:19:56 -04:00
|
|
|
} else {
|
|
|
|
// save settings
|
2010-09-19 20:10:51 -04:00
|
|
|
|
2011-04-05 20:19:56 -04:00
|
|
|
// state of trees
|
2013-02-22 16:42:27 -05:00
|
|
|
Settings->setValue("RemoteDirTreeView", ui.dirTreeView->header()->saveState());
|
2011-04-05 20:19:56 -04:00
|
|
|
|
|
|
|
// state of splitter
|
2013-02-22 16:42:27 -05:00
|
|
|
Settings->setValue("RemoteSplitter", ui.splitter->saveState());
|
2011-04-05 20:19:56 -04:00
|
|
|
|
|
|
|
// view type
|
2013-02-22 16:42:27 -05:00
|
|
|
Settings->setValue("RemoteViewType", ui.viewType_CB->currentIndex());
|
2011-04-05 20:19:56 -04:00
|
|
|
}
|
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)
|
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
disconnect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), 0, 0 );
|
|
|
|
disconnect( ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), 0, 0 );
|
2011-04-01 17:46:06 -04:00
|
|
|
|
2011-04-14 17:58:15 -04:00
|
|
|
if(model!=NULL)
|
|
|
|
model->setVisible(false) ;
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
if(c==0)
|
2011-04-01 17:46:06 -04:00
|
|
|
{
|
|
|
|
model = tree_model ;
|
|
|
|
proxyModel = tree_proxyModel ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
model = flat_model ;
|
|
|
|
proxyModel = flat_proxyModel ;
|
|
|
|
}
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
showProperColumns() ;
|
|
|
|
|
2011-04-14 17:58:15 -04:00
|
|
|
if(isVisible())
|
|
|
|
{
|
|
|
|
model->setVisible(true) ;
|
|
|
|
model->update() ;
|
|
|
|
}
|
2011-04-01 17:46:06 -04:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
connect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), model, SLOT( collapsed(const QModelIndex & ) ) );
|
|
|
|
connect( ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), model, SLOT( expanded(const QModelIndex & ) ) );
|
2011-04-01 17:46:06 -04:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->setModel(proxyModel);
|
|
|
|
ui.dirTreeView->update();
|
2011-04-01 17:46:06 -04:00
|
|
|
|
2013-02-26 19:23:56 -05:00
|
|
|
QHeaderView * header = ui.dirTreeView->header () ;
|
2013-10-19 09:25:06 -04:00
|
|
|
QHeaderView_setSectionResizeMode(header, 0, QHeaderView::Interactive);
|
2013-02-26 19:23:56 -05:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal,0,4) ;
|
2011-04-01 17:46:06 -04:00
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
void LocalSharedFilesDialog::showProperColumns()
|
|
|
|
{
|
|
|
|
if(model == tree_model)
|
|
|
|
{
|
|
|
|
ui.dirTreeView->setColumnHidden(3,false) ;
|
|
|
|
ui.dirTreeView->setColumnHidden(4,false) ;
|
|
|
|
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
|
|
|
ui.filterLabel->hide();
|
|
|
|
ui.filterPatternLineEdit->hide();
|
|
|
|
ui.filterStartButton->hide();
|
|
|
|
ui.filterClearButton->hide();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.dirTreeView->setColumnHidden(3,true) ;
|
|
|
|
ui.dirTreeView->setColumnHidden(4,false) ;
|
|
|
|
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
|
|
|
ui.filterLabel->show();
|
|
|
|
ui.filterPatternLineEdit->show();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void RemoteSharedFilesDialog::showProperColumns()
|
|
|
|
{
|
|
|
|
if(model == tree_model)
|
|
|
|
{
|
|
|
|
ui.dirTreeView->setColumnHidden(3,true) ;
|
|
|
|
ui.dirTreeView->setColumnHidden(4,true) ;
|
|
|
|
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
|
|
|
ui.filterLabel->hide();
|
|
|
|
ui.filterPatternLineEdit->hide();
|
|
|
|
ui.filterStartButton->hide();
|
|
|
|
ui.filterClearButton->hide();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.dirTreeView->setColumnHidden(3,false) ;
|
|
|
|
ui.dirTreeView->setColumnHidden(4,false) ;
|
|
|
|
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
|
|
|
ui.filterLabel->show();
|
|
|
|
ui.filterPatternLineEdit->show();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LocalSharedFilesDialog::checkUpdate()
|
2008-03-31 14:37:50 -04:00
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
/* 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
|
|
|
|
{
|
2013-02-22 16:42:27 -05: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;
|
|
|
|
}
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
void LocalSharedFilesDialog::forceCheck()
|
2008-03-31 14:37:50 -04:00
|
|
|
{
|
2008-07-02 12:59:56 -04:00
|
|
|
rsFiles->ForceDirectoryCheck();
|
2008-03-31 14:37:50 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
QModelIndex idx = ui.dirTreeView->indexAt(point);
|
2010-11-07 16:33:48 -05:00
|
|
|
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) {
|
2013-02-22 16:42:27 -05:00
|
|
|
//QAction *copyremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), &contextMnu );
|
|
|
|
//connect( copyremotelinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2013-02-22 16:42:27 -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();
|
2013-02-22 16:42:27 -05:00
|
|
|
contextMnu.addAction( copylinkAct);
|
|
|
|
contextMnu.addAction( sendlinkAct);
|
2010-11-07 16:33:48 -05:00
|
|
|
contextMnu.addSeparator();
|
2013-02-22 16:42:27 -05:00
|
|
|
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to"), this, SLOT(recommendFilesToMsg()));
|
2010-11-07 16:33:48 -05:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
QModelIndexList SharedFilesDialog::getSelected()
|
2010-09-19 20:10:51 -04:00
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
QModelIndexList list = ui.dirTreeView->selectionModel()->selectedIndexes();
|
2010-09-19 20:10:51 -04:00
|
|
|
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
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
void LocalSharedFilesDialog::createCollectionFile()
|
2011-11-07 18:07:25 -05:00
|
|
|
{
|
|
|
|
/* call back to the model (which does all the interfacing? */
|
|
|
|
|
|
|
|
std::cerr << "Creating a collection file!" << std::endl;
|
2013-02-22 16:42:27 -05:00
|
|
|
QModelIndexList lst = getSelected();
|
|
|
|
model->createCollectionFile(this, lst);
|
2013-02-26 19:23:56 -05:00
|
|
|
}
|
2012-12-05 08:26:26 -05:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
void RemoteSharedFilesDialog::downloadRemoteSelected()
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
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;
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
QModelIndexList lst = getSelected();
|
2010-09-19 20:10:51 -04:00
|
|
|
model -> downloadSelected(lst);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
2013-02-26 19:23:56 -05:00
|
|
|
|
|
|
|
void LocalSharedFilesDialog::editSharePermissions()
|
|
|
|
{
|
|
|
|
std::list<SharedDirInfo> dirs;
|
|
|
|
rsFiles->getSharedDirectories(dirs);
|
|
|
|
|
|
|
|
std::list<SharedDirInfo>::const_iterator it;
|
|
|
|
for (it = dirs.begin(); it != dirs.end(); it++) {
|
|
|
|
if (currentFile == currentFile) {
|
|
|
|
/* file name found, show dialog */
|
|
|
|
ShareDialog sharedlg (it->filename, this);
|
|
|
|
sharedlg.setWindowTitle(tr("Edit Shared Folder"));
|
|
|
|
sharedlg.exec();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
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;
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
model->getDirDetailsFromSelect(lst, dirVec);
|
2009-05-18 10:23:55 -04:00
|
|
|
|
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;
|
2012-11-02 09:52:29 -04:00
|
|
|
FileSearchFlags flags = remote?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;
|
2009-05-18 10:23:55 -04:00
|
|
|
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
void SharedFilesDialog::copyLink()
|
2009-05-18 10:23:55 -04:00
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
copyLink ( getSelected() , isRemote());
|
2009-05-18 10:23:55 -04:00
|
|
|
}
|
|
|
|
|
2010-03-04 10:42:50 -05:00
|
|
|
void SharedFilesDialog::copyLinkhtml( )
|
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
copyLink();
|
2010-03-04 10:42:50 -05:00
|
|
|
|
|
|
|
QString link = QApplication::clipboard()->text();
|
|
|
|
|
|
|
|
QClipboard *clipboard = QApplication::clipboard();
|
|
|
|
clipboard->setText("<a href='" + link + "'> " + link + "</a>");
|
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
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
copyLink();
|
2009-05-18 10:23:55 -04:00
|
|
|
|
|
|
|
/* 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()
|
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
copyLink();
|
2009-08-17 16:19:53 -04:00
|
|
|
|
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()
|
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
copyLink();
|
2009-08-17 16:19:53 -04:00
|
|
|
|
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
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
void LocalSharedFilesDialog::playselectedfiles()
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
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;
|
2013-02-22 16:42:27 -05:00
|
|
|
model -> getFilePaths(getSelected(), 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++)
|
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
std::string fullpath;
|
|
|
|
rsFiles->ConvertSharedFilePath(*it, fullpath);
|
|
|
|
fullpaths.push_back(QString::fromStdString(fullpath));
|
2008-12-03 09:30:21 -05:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
std::cerr << "Playing: " << fullpath;
|
|
|
|
std::cerr << std::endl;
|
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::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
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
model->getFileInfoFromIndexList(getSelected(),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
|
|
|
}
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
void LocalSharedFilesDialog::openfile()
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
/* call back to the model (which does all the interfacing? */
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
std::cerr << "SharedFilesDialog::openfile" << std::endl;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
QModelIndexList qmil = getSelected();
|
|
|
|
model->openSelected(qmil);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
void LocalSharedFilesDialog::openfolder()
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
2009-07-07 14:56:31 -04:00
|
|
|
std::cerr << "SharedFilesDialog::openfolder" << std::endl;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
QModelIndexList qmil = getSelected();
|
|
|
|
model->openSelected(qmil);
|
2008-11-18 12:14:49 -05:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2014-01-05 17:51:54 -05:00
|
|
|
void SharedFilesDialog::preModDirectories(bool local)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2014-01-05 17:51:54 -05:00
|
|
|
if (isRemote() == local) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Notify both models, only one is visible */
|
|
|
|
tree_model->preMods();
|
|
|
|
flat_model->preMods();
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2014-01-05 17:51:54 -05:00
|
|
|
void SharedFilesDialog::postModDirectories(bool local)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2014-01-05 17:51:54 -05:00
|
|
|
if (isRemote() == local) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Notify both models, only one is visible */
|
|
|
|
tree_model->postMods();
|
|
|
|
flat_model->postMods();
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->update() ;
|
2010-11-30 07:29:04 -05:00
|
|
|
|
2013-02-22 16:42:27 -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
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
2008-11-18 12:14:49 -05:00
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
if (!rsPeers)
|
|
|
|
{
|
2010-11-07 16:33:48 -05:00
|
|
|
/* not ready yet! */
|
|
|
|
return;
|
|
|
|
}
|
2010-01-31 09:21:24 -05:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
QModelIndex idx = ui.dirTreeView->indexAt(point);
|
2010-11-07 16:33:48 -05:00
|
|
|
if (!idx.isValid())
|
|
|
|
return;
|
2013-02-22 16:42:27 -05:00
|
|
|
QModelIndex midx = proxyModel->mapToSource(idx);
|
2010-11-07 16:33:48 -05:00
|
|
|
if (!midx.isValid())
|
|
|
|
return;
|
2008-01-25 03:49:40 -05:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString();
|
2010-03-28 16:46:45 -04:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
int type = model->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
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case DIR_TYPE_DIR:
|
|
|
|
contextMnu.addAction(openfolderAct);
|
|
|
|
contextMnu.addSeparator() ;
|
|
|
|
contextMnu.addAction(createcollectionfileAct) ;
|
|
|
|
break;
|
|
|
|
case DIR_TYPE_FILE:
|
|
|
|
contextMnu.addAction(openfileAct);
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction(copylinkAct);
|
|
|
|
contextMnu.addAction(sendlinkAct);
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction(createcollectionfileAct) ;
|
|
|
|
contextMnu.addSeparator();
|
2010-11-20 15:58:35 -05:00
|
|
|
#ifdef RS_USE_LINKS
|
2013-02-22 16:42:27 -05:00
|
|
|
contextMnu.addAction(sendlinkCloudAct);
|
|
|
|
contextMnu.addAction(addlinkCloudAct);
|
|
|
|
contextMnu.addSeparator();
|
2010-02-07 15:10:31 -05:00
|
|
|
#endif
|
2013-02-22 16:42:27 -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*
|
2013-02-22 16:42:27 -05:00
|
|
|
LocalSharedFilesDialog::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
|
2013-02-22 16:42:27 -05:00
|
|
|
LocalSharedFilesDialog::runCommandForFile()
|
2009-04-07 04:08:03 -04:00
|
|
|
{
|
|
|
|
QStringList tsl;
|
|
|
|
tsl.append( currentFile );
|
|
|
|
QProcess::execute( currentCommand, tsl);
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void
|
2013-02-22 16:42:27 -05:00
|
|
|
LocalSharedFilesDialog::tryToAddNewAssotiation()
|
2009-04-07 04:08:03 -04:00
|
|
|
{
|
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-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]);
|
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->update(ui.dirTreeView->rootIndex());
|
2011-05-21 14:34:34 -04:00
|
|
|
|
|
|
|
if (correct_indicator[index] != IND_ALWAYS)
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->sortByColumn(2, Qt::AscendingOrder);
|
2011-05-21 14:34:34 -04:00
|
|
|
else
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->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
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
int rowCount = ui.dirTreeView->model()->rowCount();
|
2011-04-01 17:46:06 -04:00
|
|
|
for (int row = 0; row < rowCount; row++)
|
|
|
|
if(proxyModel == tree_proxyModel)
|
2013-02-22 16:42:27 -05:00
|
|
|
tree_FilterItem(ui.dirTreeView->model()->index(row, 0), text, 0);
|
2011-04-01 17:46:06 -04:00
|
|
|
else
|
2013-02-22 16:42:27 -05:00
|
|
|
flat_FilterItem(ui.dirTreeView->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))
|
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->setRowHidden(index.row(), index.parent(), false);
|
2011-04-01 17:46:06 -04:00
|
|
|
return false ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->setRowHidden(index.row(), index.parent(), true);
|
2011-04-01 17:46:06 -04:00
|
|
|
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;
|
2013-02-22 16:42:27 -05:00
|
|
|
int rowCount = ui.dirTreeView->model()->rowCount(index);
|
2010-11-30 07:29:04 -05:00
|
|
|
for (int row = 0; row < rowCount; row++) {
|
2013-02-22 16:42:27 -05:00
|
|
|
if (tree_FilterItem(ui.dirTreeView->model()->index(row, index.column(), index), text, level + 1)) {
|
2010-11-30 07:29:04 -05:00
|
|
|
visibleChildCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visible || visibleChildCount) {
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->setRowHidden(index.row(), index.parent(), false);
|
2010-11-30 07:29:04 -05:00
|
|
|
} else {
|
2013-02-22 16:42:27 -05:00
|
|
|
ui.dirTreeView->setRowHidden(index.row(), index.parent(), true);
|
2010-11-30 07:29:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return (visible || visibleChildCount);
|
|
|
|
}
|
2011-04-01 17:46:06 -04:00
|
|
|
|