- separated SharedFilesDialog into two classes: remote and local, both deriving from a common

SharedFilesDialog class.
 As a side effect the tree view/flat view are both available in local and remote mode, as well
 as the file filter tool.
 The gui is common. Each sub-class hides whatever it does not want to show/use.
- moved local and friends files into tabs of Transfers.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-ImprovedGUI@6108 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-02-08 20:35:40 +00:00
parent 8fe75acfaf
commit 174226eb21
9 changed files with 520 additions and 731 deletions

View file

@ -43,7 +43,7 @@
#include "SearchDialog.h" #include "SearchDialog.h"
#include "TransfersDialog.h" #include "TransfersDialog.h"
#include "MessagesDialog.h" #include "MessagesDialog.h"
#include "SharedFilesDialog.h" //#include "SharedFilesDialog.h"
#include "PluginsPage.h" #include "PluginsPage.h"
#include "NewsFeed.h" #include "NewsFeed.h"
#include "ShareManager.h" #include "ShareManager.h"
@ -255,8 +255,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
action = createPageAction(QIcon(IMAGE_TRANSFERS), tr("Transfers"), grp)); action = createPageAction(QIcon(IMAGE_TRANSFERS), tr("Transfers"), grp));
notify.push_back(QPair<MainPage*, QAction*>(transfersDialog, action)); notify.push_back(QPair<MainPage*, QAction*>(transfersDialog, action));
ui->stackPages->add(sharedfilesDialog = new SharedFilesDialog(ui->stackPages), // ui->stackPages->add(sharedfilesDialog = new SharedFilesDialog(ui->stackPages),
createPageAction(QIcon(IMAGE_FILES), tr("Files"), grp)); // createPageAction(QIcon(IMAGE_FILES), tr("Files"), grp));
ui->stackPages->add(messagesDialog = new MessagesDialog(ui->stackPages), ui->stackPages->add(messagesDialog = new MessagesDialog(ui->stackPages),
action = createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp)); action = createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));
@ -800,8 +800,8 @@ void SetForegroundWindowInternal(HWND hWnd)
case Transfers: case Transfers:
Page = _instance->transfersDialog; Page = _instance->transfersDialog;
break; break;
case SharedDirectories: // case SharedDirectories:
Page = _instance->sharedfilesDialog; // Page = _instance->sharedfilesDialog;
break; break;
case Messages: case Messages:
Page = _instance->messagesDialog; Page = _instance->messagesDialog;
@ -849,9 +849,9 @@ void SetForegroundWindowInternal(HWND hWnd)
if (page == _instance->transfersDialog) { if (page == _instance->transfersDialog) {
return Transfers; return Transfers;
} }
if (page == _instance->sharedfilesDialog) { // if (page == _instance->sharedfilesDialog) {
return SharedDirectories; // return SharedDirectories;
} // }
if (page == _instance->messagesDialog) { if (page == _instance->messagesDialog) {
return Messages; return Messages;
} }
@ -891,8 +891,8 @@ void SetForegroundWindowInternal(HWND hWnd)
// return _instance->searchDialog; // return _instance->searchDialog;
case Transfers: case Transfers:
return _instance->transfersDialog; return _instance->transfersDialog;
case SharedDirectories: // case SharedDirectories:
return _instance->sharedfilesDialog; // return _instance->sharedfilesDialog;
case Messages: case Messages:
return _instance->messagesDialog; return _instance->messagesDialog;
#ifdef RS_USE_LINKS #ifdef RS_USE_LINKS

View file

@ -37,137 +37,140 @@
<item> <item>
<widget class="QCheckBox" name="showUnvalidKeys"> <widget class="QCheckBox" name="showUnvalidKeys">
<property name="text"> <property name="text">
<string>Show keys that are not validated by the PGP web of trust</string> <string>Show all accessible keys</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QTreeWidget" name="connecttreeWidget"> <widget class="QSplitter" name="splitter">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <enum>Qt::Vertical</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="contextMenuPolicy"> <widget class="QTreeWidget" name="connecttreeWidget">
<enum>Qt::CustomContextMenu</enum> <property name="sizePolicy">
</property> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<property name="acceptDrops"> <horstretch>0</horstretch>
<bool>false</bool> <verstretch>0</verstretch>
</property> </sizepolicy>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="lineWidth">
<number>20</number>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="animated">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<attribute name="headerCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string/>
</property> </property>
</column> <property name="contextMenuPolicy">
<column> <enum>Qt::CustomContextMenu</enum>
<property name="text">
<string>Name</string>
</property> </property>
</column> <property name="acceptDrops">
<column> <bool>false</bool>
<property name="text">
<string>Did I authenticated peer</string>
</property> </property>
<property name="toolTip"> <property name="autoFillBackground">
<string>Did I sign his PGP key</string> <bool>false</bool>
</property> </property>
</column> <property name="lineWidth">
<column> <number>20</number>
<property name="text">
<string>Did peer authenticated me</string>
</property> </property>
</column> <property name="iconSize">
<column> <size>
<property name="text"> <width>16</width>
<string>Cert Id</string> <height>16</height>
</size>
</property> </property>
</column> <property name="uniformRowHeights">
</widget> <bool>true</bool>
</item>
<item>
<widget class="QTreeWidget" name="unvalidGPGkeyWidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<attribute name="headerCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string/>
</property> </property>
</column> <property name="sortingEnabled">
<column> <bool>true</bool>
<property name="text">
<string>Name</string>
</property> </property>
</column> <property name="animated">
<column> <bool>true</bool>
<property name="text">
<string>Did I authenticated peer</string>
</property> </property>
</column> <property name="allColumnsShowFocus">
<column> <bool>true</bool>
<property name="text">
<string>Did peer authenticated me</string>
</property> </property>
</column> <property name="wordWrap">
<column> <bool>true</bool>
<property name="text">
<string>Cert Id</string>
</property> </property>
</column> <attribute name="headerCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string/>
</property>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Did I authenticated peer</string>
</property>
<property name="toolTip">
<string>Did I sign his PGP key</string>
</property>
</column>
<column>
<property name="text">
<string>Did peer authenticated me</string>
</property>
</column>
<column>
<property name="text">
<string>Cert Id</string>
</property>
</column>
</widget>
<widget class="QTreeWidget" name="unvalidGPGkeyWidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<attribute name="headerCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string/>
</property>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Did I authenticated peer</string>
</property>
</column>
<column>
<property name="text">
<string>Did peer authenticated me</string>
</property>
</column>
<column>
<property name="text">
<string>Cert Id</string>
</property>
</column>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>

View file

@ -1307,8 +1307,9 @@ void FlatStyle_RDM::updateRefs()
#endif #endif
_ref_stack.pop_back() ; _ref_stack.pop_back() ;
DirDetails details ; DirDetails details ;
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if (requestDirDetails(ref, details, RS_FILE_HINTS_REMOTE)) if (requestDirDetails(ref, details, flags))
{ {
if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons. if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons.
_ref_entries.push_back(std::pair<void*,QString>(ref,computeDirectoryPath(details))); _ref_entries.push_back(std::pair<void*,QString>(ref,computeDirectoryPath(details)));

View file

@ -90,36 +90,24 @@ private:
}; };
/** Constructor */ /** Constructor */
SharedFilesDialog::SharedFilesDialog(QWidget *parent) SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareDirModel *_flat_model,QWidget *parent)
: RsAutoUpdatePage(1000,parent),model(NULL) : RsAutoUpdatePage(1000,parent),model(NULL)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck())); connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck()));
connect(ui.localButton, SIGNAL(toggled(bool)), this, SLOT(showFrame(bool))); //== connect(ui.localButton, SIGNAL(toggled(bool)), this, SLOT(showFrame(bool)));
connect(ui.remoteButton, SIGNAL(toggled(bool)), this, SLOT(showFrameRemote(bool))); //== connect(ui.remoteButton, SIGNAL(toggled(bool)), this, SLOT(showFrameRemote(bool)));
connect(ui.splittedButton, SIGNAL(toggled(bool)), this, SLOT(showFrameSplitted(bool))); //== connect(ui.splittedButton, SIGNAL(toggled(bool)), this, SLOT(showFrameSplitted(bool)));
connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int))); connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int)));
connect( ui.localDirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( sharedDirTreeWidgetContextMenu( QPoint ) ) ); connect( ui.dirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( spawnCustomPopupMenu( QPoint ) ) );
connect( ui.remoteDirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( shareddirtreeviewCostumPopupMenu( QPoint ) ) );
// connect( ui.remoteDirTreeView, SIGNAL( doubleClicked(const QModelIndex&)), this, SLOT( downloadRemoteSelected()));
connect( ui.downloadButton, SIGNAL( clicked()), this, SLOT( downloadRemoteSelected()));
connect(ui.indicatorCBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indicatorChanged(int))); connect(ui.indicatorCBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indicatorChanged(int)));
/* tree_model = _tree_model ;
connect( ui.remoteDirTreeView, SIGNAL( itemExpanded( QTreeWidgetItem * ) ), flat_model = _flat_model ;
this, SLOT( checkForLocalDirRequest( QTreeWidgetItem * ) ) );
connect( ui.localDirTreeWidget, SIGNAL( itemExpanded( QTreeWidgetItem * ) ),
this, SLOT( checkForRemoteDirRequest( QTreeWidgetItem * ) ) );
*/
tree_model = new TreeStyle_RDM(true);
flat_model = new FlatStyle_RDM(true);
tree_proxyModel = new SFDSortFilterProxyModel(tree_model, this); tree_proxyModel = new SFDSortFilterProxyModel(tree_model, this);
tree_proxyModel->setDynamicSortFilter(true); tree_proxyModel->setDynamicSortFilter(true);
@ -135,22 +123,22 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
flat_proxyModel->setSortRole(RetroshareDirModel::SortRole); flat_proxyModel->setSortRole(RetroshareDirModel::SortRole);
flat_proxyModel->sort(0); flat_proxyModel->sort(0);
localModel = new TreeStyle_RDM(false); //== localModel = new TreeStyle_RDM(false);
//==
//== localProxyModel = new SFDSortFilterProxyModel(localModel, this);
//== localProxyModel->setDynamicSortFilter(true);
//== localProxyModel->setSourceModel(localModel);
//== localProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
//== localProxyModel->setSortRole(RetroshareDirModel::SortRole);
//== localProxyModel->sort(0);
localProxyModel = new SFDSortFilterProxyModel(localModel, this); //== ui.dirTreeView->setModel(localProxyModel);
localProxyModel->setDynamicSortFilter(true);
localProxyModel->setSourceModel(localModel);
localProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
localProxyModel->setSortRole(RetroshareDirModel::SortRole);
localProxyModel->sort(0);
ui.localDirTreeView->setModel(localProxyModel); //== connect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), localModel, SLOT( collapsed(const QModelIndex & ) ) );
//== connect( ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), localModel, SLOT( expanded(const QModelIndex & ) ) );
connect( ui.localDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), localModel, SLOT( collapsed(const QModelIndex & ) ) ); //== connect( localModel, SIGNAL( layoutAboutToBeChanged() ), ui.localDirTreeView, SLOT( reset() ) );
connect( ui.localDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), localModel, SLOT( expanded(const QModelIndex & ) ) ); //== connect( localModel, SIGNAL( layoutChanged() ), ui.localDirTreeView, SLOT( update() ) );
connect( localModel, SIGNAL( layoutAboutToBeChanged() ), ui.localDirTreeView, SLOT( reset() ) );
connect( localModel, SIGNAL( layoutChanged() ), ui.localDirTreeView, SLOT( update() ) );
connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter())); connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter()));
@ -158,61 +146,25 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged())); connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
/* Set header resize modes and initial section sizes */ /* Set header resize modes and initial section sizes */
QHeaderView * l_header = ui.localDirTreeView->header () ; QHeaderView * header = ui.dirTreeView->header () ;
header->setResizeMode (0, QHeaderView::Interactive);
l_header->resizeSection ( 0, 490 ); header->resizeSection ( 0, 490 );
l_header->resizeSection ( 1, 70 ); header->resizeSection ( 1, 70 );
l_header->resizeSection ( 2, 100 ); header->resizeSection ( 2, 100 );
l_header->resizeSection ( 3, 100 ); header->resizeSection ( 3, 100 );
l_header->resizeSection ( 4, 100 ); header->resizeSection ( 4, 100 );
l_header->setStretchLastSection(false); header->setStretchLastSection(false);
// l_header->setHighlightSections(false);
// Setup the current view model. // Setup the current view model.
// //
changeCurrentViewModel(ui.viewType_CB->currentIndex()) ; changeCurrentViewModel(ui.viewType_CB->currentIndex()) ;
/* Set header resize modes and initial section sizes */
QHeaderView * r_header = ui.remoteDirTreeView->header () ;
r_header->setResizeMode (0, QHeaderView::Interactive);
r_header->setStretchLastSection(false);
// r_header->setResizeMode (1, QHeaderView::Fixed);
// // r_header->setResizeMode (2, QHeaderView::Interactive);
// r_header->setResizeMode (3, QHeaderView::Fixed);
// // r_header->setResizeMode (4, QHeaderView::Interactive);
r_header->resizeSection ( 0, 490 );
r_header->resizeSection ( 1, 70 );
r_header->resizeSection ( 2, 80 );
r_header->resizeSection ( 3, 100 );
r_header->resizeSection ( 4, 80 );
// r_header->setHighlightSections(false);
/* Set Multi Selection */ /* Set Multi Selection */
ui.remoteDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection); ui.dirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
ui.localDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
//#ifdef RS_RELEASE_VERSION
// ui.filterLabel->hide();
// ui.filterPatternLineEdit->hide();
//#endif
// load settings
processSettings(true);
// Hide columns after loading the settings
ui.remoteDirTreeView->setColumnHidden(3,false) ;
ui.remoteDirTreeView->setColumnHidden(4,true) ;
ui.localDirTreeView->setColumnHidden(4,false) ;
/* Hide platform specific features */ /* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
copylinklocalAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard" ), this ); copylinklocalAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard" ), this );
connect( copylinklocalAct , SIGNAL( triggered() ), this, SLOT( copyLinkLocal() ) ); connect( copylinklocalAct , SIGNAL( triggered() ), this, SLOT( copyLinkLocal() ) );
copylinklocalhtmlAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard (HTML)" ), this ); copylinklocalhtmlAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard (HTML)" ), this );
@ -235,11 +187,34 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
connect(editshareAct, SIGNAL(triggered()), this, SLOT(editSharePermissions())); connect(editshareAct, SIGNAL(triggered()), this, SLOT(editSharePermissions()));
} }
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);
}
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);
}
void SharedFilesDialog::hideEvent(QHideEvent *) void SharedFilesDialog::hideEvent(QHideEvent *)
{ {
if(model!=NULL) if(model!=NULL)
model->setVisible(false) ; model->setVisible(false) ;
//std::cerr << "Hidden!"<< std::endl;
} }
void SharedFilesDialog::showEvent(QShowEvent *) void SharedFilesDialog::showEvent(QShowEvent *)
{ {
@ -248,15 +223,50 @@ void SharedFilesDialog::showEvent(QShowEvent *)
model->setVisible(true) ; model->setVisible(true) ;
model->update() ; model->update() ;
} }
//std::cerr << "Shown!"<< std::endl;
} }
SharedFilesDialog::~SharedFilesDialog() RemoteSharedFilesDialog::~RemoteSharedFilesDialog()
{ {
// save settings // save settings
processSettings(false); processSettings(false);
} }
void SharedFilesDialog::processSettings(bool bLoad) LocalSharedFilesDialog::~LocalSharedFilesDialog()
{
// save settings
processSettings(false);
}
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)
{ {
Settings->beginGroup("SharedFilesDialog"); Settings->beginGroup("SharedFilesDialog");
@ -264,26 +274,24 @@ void SharedFilesDialog::processSettings(bool bLoad)
// load settings // load settings
// state of the trees // state of the trees
ui.localDirTreeView->header()->restoreState(Settings->value("LocalDirTreeView").toByteArray()); ui.dirTreeView->header()->restoreState(Settings->value("RemoteDirTreeView").toByteArray());
ui.remoteDirTreeView->header()->restoreState(Settings->value("RemoteDirTreeView").toByteArray());
// state of splitter // state of splitter
ui.splitter->restoreState(Settings->value("Splitter").toByteArray()); ui.splitter->restoreState(Settings->value("RemoteSplitter").toByteArray());
// view type // view type
ui.viewType_CB->setCurrentIndex(Settings->value("ViewType").toInt()); ui.viewType_CB->setCurrentIndex(Settings->value("RemoteViewType").toInt());
} else { } else {
// save settings // save settings
// state of trees // state of trees
Settings->setValue("LocalDirTreeView", ui.localDirTreeView->header()->saveState()); Settings->setValue("RemoteDirTreeView", ui.dirTreeView->header()->saveState());
Settings->setValue("RemoteDirTreeView", ui.remoteDirTreeView->header()->saveState());
// state of splitter // state of splitter
Settings->setValue("Splitter", ui.splitter->saveState()); Settings->setValue("RemoteSplitter", ui.splitter->saveState());
// view type // view type
Settings->setValue("ViewType", ui.viewType_CB->currentIndex()); Settings->setValue("RemoteViewType", ui.viewType_CB->currentIndex());
} }
Settings->endGroup(); Settings->endGroup();
@ -291,8 +299,8 @@ void SharedFilesDialog::processSettings(bool bLoad)
void SharedFilesDialog::changeCurrentViewModel(int c) void SharedFilesDialog::changeCurrentViewModel(int c)
{ {
disconnect( ui.remoteDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), 0, 0 ); disconnect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), 0, 0 );
disconnect( ui.remoteDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), 0, 0 ); disconnect( ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), 0, 0 );
if(model!=NULL) if(model!=NULL)
model->setVisible(false) ; model->setVisible(false) ;
@ -301,8 +309,8 @@ void SharedFilesDialog::changeCurrentViewModel(int c)
{ {
model = tree_model ; model = tree_model ;
proxyModel = tree_proxyModel ; proxyModel = tree_proxyModel ;
ui.remoteDirTreeView->setColumnHidden(3,true) ; ui.dirTreeView->setColumnHidden(3,true) ;
ui.remoteDirTreeView->setColumnHidden(4,true) ; ui.dirTreeView->setColumnHidden(4,true) ;
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW #ifdef DONT_USE_SEARCH_IN_TREE_VIEW
ui.filterLabel->hide(); ui.filterLabel->hide();
ui.filterPatternLineEdit->hide(); ui.filterPatternLineEdit->hide();
@ -314,8 +322,8 @@ void SharedFilesDialog::changeCurrentViewModel(int c)
{ {
model = flat_model ; model = flat_model ;
proxyModel = flat_proxyModel ; proxyModel = flat_proxyModel ;
ui.remoteDirTreeView->setColumnHidden(3,false) ; ui.dirTreeView->setColumnHidden(3,false) ;
ui.remoteDirTreeView->setColumnHidden(4,false) ; ui.dirTreeView->setColumnHidden(4,false) ;
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW #ifdef DONT_USE_SEARCH_IN_TREE_VIEW
ui.filterLabel->show(); ui.filterLabel->show();
ui.filterPatternLineEdit->show(); ui.filterPatternLineEdit->show();
@ -328,13 +336,13 @@ void SharedFilesDialog::changeCurrentViewModel(int c)
model->update() ; model->update() ;
} }
connect( ui.remoteDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), model, SLOT( collapsed(const QModelIndex & ) ) ); connect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), model, SLOT( collapsed(const QModelIndex & ) ) );
connect( ui.remoteDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), model, SLOT( expanded(const QModelIndex & ) ) ); connect( ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), model, SLOT( expanded(const QModelIndex & ) ) );
ui.remoteDirTreeView->setModel(proxyModel); ui.dirTreeView->setModel(proxyModel);
ui.remoteDirTreeView->update(); ui.dirTreeView->update();
ui.remoteDirTreeView->header()->headerDataChanged(Qt::Horizontal,0,4) ; ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal,0,4) ;
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW #ifdef DONT_USE_SEARCH_IN_TREE_VIEW
if(c == 1) if(c == 1)
@ -342,16 +350,16 @@ void SharedFilesDialog::changeCurrentViewModel(int c)
FilterItems(); FilterItems();
} }
void SharedFilesDialog::checkUpdate() void LocalSharedFilesDialog::checkUpdate()
{ {
/* update */ /* update */
if (rsFiles->InDirectoryCheck()) if (rsFiles->InDirectoryCheck())
{ {
ui.checkButton->setText(tr("Checking...")); ui.checkButton->setText(tr("Checking..."));
} }
else else
{ {
ui.checkButton->setText(tr("Check files")); ui.checkButton->setText(tr("Check files"));
ui.hashLabel->setPixmap(QPixmap(IMAGE_HASH_DONE)); ui.hashLabel->setPixmap(QPixmap(IMAGE_HASH_DONE));
ui.hashLabel->setToolTip("") ; ui.hashLabel->setToolTip("") ;
} }
@ -359,17 +367,15 @@ void SharedFilesDialog::checkUpdate()
return; return;
} }
void LocalSharedFilesDialog::forceCheck()
void SharedFilesDialog::forceCheck()
{ {
rsFiles->ForceDirectoryCheck(); rsFiles->ForceDirectoryCheck();
return; return;
} }
void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
void SharedFilesDialog::shareddirtreeviewCostumPopupMenu( QPoint point )
{ {
QModelIndex idx = ui.remoteDirTreeView->indexAt(point); QModelIndex idx = ui.dirTreeView->indexAt(point);
if (!idx.isValid()) if (!idx.isValid())
return; return;
QModelIndex midx = proxyModel->mapToSource(idx); QModelIndex midx = proxyModel->mapToSource(idx);
@ -404,20 +410,9 @@ void SharedFilesDialog::shareddirtreeviewCostumPopupMenu( QPoint point )
contextMnu.exec(QCursor::pos()); contextMnu.exec(QCursor::pos());
} }
QModelIndexList SharedFilesDialog::getLocalSelected() QModelIndexList SharedFilesDialog::getSelected()
{ {
QModelIndexList list = ui.localDirTreeView->selectionModel()->selectedIndexes(); QModelIndexList list = ui.dirTreeView->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; QModelIndexList proxyList;
for (QModelIndexList::iterator index = list.begin(); index != list.end(); index++) { for (QModelIndexList::iterator index = list.begin(); index != list.end(); index++) {
proxyList.append(proxyModel->mapToSource(*index)); proxyList.append(proxyModel->mapToSource(*index));
@ -426,27 +421,27 @@ QModelIndexList SharedFilesDialog::getRemoteSelected()
return proxyList; return proxyList;
} }
void SharedFilesDialog::createCollectionFile() void LocalSharedFilesDialog::createCollectionFile()
{ {
/* call back to the model (which does all the interfacing? */ /* call back to the model (which does all the interfacing? */
std::cerr << "Creating a collection file!" << std::endl; std::cerr << "Creating a collection file!" << std::endl;
QModelIndexList lst = getLocalSelected(); QModelIndexList lst = getSelected();
localModel->createCollectionFile(this, lst); model->createCollectionFile(this, lst);
} }
void SharedFilesDialog::downloadRemoteSelected() void RemoteSharedFilesDialog::downloadRemoteSelected()
{ {
/* call back to the model (which does all the interfacing? */ /* call back to the model (which does all the interfacing? */
std::cerr << "Downloading Files"; std::cerr << "Downloading Files";
std::cerr << std::endl; std::cerr << std::endl;
QModelIndexList lst = getRemoteSelected(); QModelIndexList lst = getSelected();
model -> downloadSelected(lst); model -> downloadSelected(lst);
} }
void SharedFilesDialog::editSharePermissions() void LocalSharedFilesDialog::editSharePermissions()
{ {
std::list<SharedDirInfo> dirs; std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs); rsFiles->getSharedDirectories(dirs);
@ -468,10 +463,7 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
{ {
std::vector<DirDetails> dirVec; std::vector<DirDetails> dirVec;
if (remote) model->getDirDetailsFromSelect(lst, dirVec);
model->getDirDetailsFromSelect(lst, dirVec);
else
localModel->getDirDetailsFromSelect(lst, dirVec);
QList<RetroShareLink> urls ; QList<RetroShareLink> urls ;
@ -509,55 +501,24 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
RSLinkClipboard::copyLinks(urls) ; RSLinkClipboard::copyLinks(urls) ;
} }
void SharedFilesDialog::copyLinkRemote() void SharedFilesDialog::copyLink()
{ {
QModelIndexList lst = getRemoteSelected(); copyLink ( getSelected() , true);
copyLink (lst, true);
}
void SharedFilesDialog::copyLinkLocal()
{
QModelIndexList lst = getLocalSelected();
copyLink (lst, false);
} }
void SharedFilesDialog::copyLinkhtml( ) void SharedFilesDialog::copyLinkhtml( )
{ {
copyLinkLocal (); copyLink();
QString link = QApplication::clipboard()->text(); QString link = QApplication::clipboard()->text();
QClipboard *clipboard = QApplication::clipboard(); QClipboard *clipboard = QApplication::clipboard();
clipboard->setText("<a href='" + link + "'> " + link + "</a>"); clipboard->setText("<a href='" + link + "'> " + link + "</a>");
}
void SharedFilesDialog::sendremoteLinkTo()
{
copyLinkRemote ();
/* create a message */
MessageComposer *nMsgDialog = MessageComposer::newMsg();
if (nMsgDialog == NULL) {
return;
}
/* fill it in
* files are receommended already
* just need to set peers
*/
std::cerr << "SharedFilesDialog::sendremoteLinkTo()" << std::endl;
nMsgDialog->setTitleText(tr("RetroShare Link"));
nMsgDialog->setMsgText(RSLinkClipboard::toHtml(), true);
nMsgDialog->show();
/* window will destroy itself! */
} }
void SharedFilesDialog::sendLinkTo() void SharedFilesDialog::sendLinkTo()
{ {
copyLinkLocal (); copyLink();
/* create a message */ /* create a message */
MessageComposer *nMsgDialog = MessageComposer::newMsg(); MessageComposer *nMsgDialog = MessageComposer::newMsg();
@ -603,7 +564,7 @@ void SharedFilesDialog::addLinkToCloud()
} }
#endif #endif
void SharedFilesDialog::playselectedfiles() void LocalSharedFilesDialog::playselectedfiles()
{ {
/* call back to the model (which does all the interfacing? */ /* call back to the model (which does all the interfacing? */
@ -611,19 +572,18 @@ void SharedFilesDialog::playselectedfiles()
std::cerr << std::endl; std::cerr << std::endl;
std::list<std::string> paths; std::list<std::string> paths;
localModel -> getFilePaths(getLocalSelected(), paths); model -> getFilePaths(getSelected(), paths);
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
QStringList fullpaths; QStringList fullpaths;
for(it = paths.begin(); it != paths.end(); it++) for(it = paths.begin(); it != paths.end(); it++)
{ {
std::string fullpath; std::string fullpath;
rsFiles->ConvertSharedFilePath(*it, fullpath); rsFiles->ConvertSharedFilePath(*it, fullpath);
fullpaths.push_back(QString::fromStdString(fullpath)); fullpaths.push_back(QString::fromStdString(fullpath));
std::cerr << "Playing: " << fullpath;
std::cerr << std::endl;
std::cerr << "Playing: " << fullpath;
std::cerr << std::endl;
} }
playFiles(fullpaths); playFiles(fullpaths);
@ -632,35 +592,11 @@ void SharedFilesDialog::playselectedfiles()
std::cerr << std::endl; std::cerr << std::endl;
} }
void SharedFilesDialog::addMsgRemoteSelected()
{
std::list<DirDetails> files_info ;
model->getFileInfoFromIndexList(getRemoteSelected(),files_info);
if(files_info.empty())
return ;
/* create a message */
MessageComposer *nMsgDialog = MessageComposer::newMsg();
if (nMsgDialog == NULL) {
return;
}
nMsgDialog->setFileList(files_info) ;
nMsgDialog->setTitleText(tr("Recommendation(s)"));
nMsgDialog->setMsgText(tr("Recommendation(s)"));
nMsgDialog->show();
/* window will destroy itself! */
}
void SharedFilesDialog::recommendFilesToMsg() void SharedFilesDialog::recommendFilesToMsg()
{ {
std::list<DirDetails> files_info ; std::list<DirDetails> files_info ;
localModel->getFileInfoFromIndexList(getLocalSelected(),files_info); model->getFileInfoFromIndexList(getSelected(),files_info);
if(files_info.empty()) if(files_info.empty())
return ; return ;
@ -680,112 +616,89 @@ void SharedFilesDialog::recommendFilesToMsg()
/* window will destroy itself! */ /* window will destroy itself! */
} }
void SharedFilesDialog::openfile() void LocalSharedFilesDialog::openfile()
{ {
/* call back to the model (which does all the interfacing? */ /* call back to the model (which does all the interfacing? */
std::cerr << "SharedFilesDialog::openfile" << std::endl; std::cerr << "SharedFilesDialog::openfile" << std::endl;
QModelIndexList qmil = getLocalSelected(); QModelIndexList qmil = getSelected();
localModel->openSelected(qmil); model->openSelected(qmil);
} }
void SharedFilesDialog::openfolder() void LocalSharedFilesDialog::openfolder()
{ {
std::cerr << "SharedFilesDialog::openfolder" << std::endl; std::cerr << "SharedFilesDialog::openfolder" << std::endl;
QModelIndexList qmil = getLocalSelected(); QModelIndexList qmil = getSelected();
localModel->openSelected(qmil); model->openSelected(qmil);
} }
void SharedFilesDialog::preModDirectories(bool update_local) void SharedFilesDialog::preModDirectories()
{ {
//std::cerr << "SharedFilesDialog::preModDirectories called with update_local = " << update_local << std::endl ; model->preMods();
if (update_local)
localModel->preMods();
else
model->preMods();
} }
void SharedFilesDialog::postModDirectories()
void SharedFilesDialog::postModDirectories(bool update_local)
{ {
//std::cerr << "SharedFilesDialog::postModDirectories called with update_local = " << update_local << std::endl ; model->postMods();
if (update_local) ui.dirTreeView->update() ;
{
localModel->postMods();
ui.localDirTreeView->update() ;
}
else
{
model->postMods();
ui.remoteDirTreeView->update() ;
if (ui.filterPatternLineEdit->text().isEmpty() == false) { if (ui.filterPatternLineEdit->text().isEmpty() == false)
FilterItems(); FilterItems();
}
}
QCoreApplication::flush(); QCoreApplication::flush();
} }
void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point ) void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
{ {
if (!rsPeers) { if (!rsPeers)
{
/* not ready yet! */ /* not ready yet! */
return; return;
} }
QModelIndex idx = ui.localDirTreeView->indexAt(point); QModelIndex idx = ui.dirTreeView->indexAt(point);
if (!idx.isValid()) if (!idx.isValid())
return; return;
QModelIndex midx = localProxyModel->mapToSource(idx); QModelIndex midx = proxyModel->mapToSource(idx);
if (!midx.isValid()) if (!midx.isValid())
return; return;
currentFile = localModel->data(midx, RetroshareDirModel::FileNameRole).toString(); currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString();
int type = localModel->getType(midx); int type = model->getType(midx);
QMenu contextMnu(this); QMenu contextMnu(this);
// QAction* menuAction = fileAssotiationAction(currentFile) ; switch (type)
//new QAction(QIcon(IMAGE_PLAY), currentFile, this); {
//tr( "111Play File(s)" ), this ); case DIR_TYPE_DIR:
// connect( openfolderAct , SIGNAL( triggered() ), this, contextMnu.addAction(openfolderAct);
// SLOT( playselectedfiles() ) ); contextMnu.addSeparator() ;
contextMnu.addAction(createcollectionfileAct) ;
switch (type) { break;
case DIR_TYPE_DIR: case DIR_TYPE_FILE:
contextMnu.addAction(openfolderAct); contextMnu.addAction(openfileAct);
//contextMnu.addSeparator(); contextMnu.addSeparator();
//contextMnu.addAction(editshareAct) ; contextMnu.addAction(copylinklocalAct);
contextMnu.addSeparator(); contextMnu.addAction(sendlinkAct);
contextMnu.addAction(createcollectionfileAct) ; contextMnu.addSeparator();
break; contextMnu.addAction(createcollectionfileAct) ;
case DIR_TYPE_FILE: contextMnu.addSeparator();
contextMnu.addAction(openfileAct);
contextMnu.addSeparator();
contextMnu.addAction(copylinklocalAct);
// contextMnu.addAction(copylinklocalhtmlAct);
contextMnu.addAction(sendlinkAct);
// contextMnu.addAction(sendhtmllinkAct);
contextMnu.addSeparator();
contextMnu.addAction(createcollectionfileAct) ;
contextMnu.addSeparator();
#ifdef RS_USE_LINKS #ifdef RS_USE_LINKS
contextMnu.addAction(sendlinkCloudAct); contextMnu.addAction(sendlinkCloudAct);
contextMnu.addAction(addlinkCloudAct); contextMnu.addAction(addlinkCloudAct);
contextMnu.addSeparator(); contextMnu.addSeparator();
#endif #endif
contextMnu.addSeparator(); contextMnu.addSeparator();
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to"), this, SLOT(recommendFilesToMsg())); contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to"), this, SLOT(recommendFilesToMsg()));
break; break;
default: default:
return; return;
} }
contextMnu.exec(QCursor::pos()); contextMnu.exec(QCursor::pos());
} }
@ -793,7 +706,7 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
//============================================================================ //============================================================================
QAction* QAction*
SharedFilesDialog::fileAssotiationAction(const QString /*fileName*/) LocalSharedFilesDialog::fileAssotiationAction(const QString /*fileName*/)
{ {
QAction* result = 0; QAction* result = 0;
@ -824,22 +737,17 @@ SharedFilesDialog::fileAssotiationAction(const QString /*fileName*/)
//============================================================================ //============================================================================
void void
SharedFilesDialog::runCommandForFile() LocalSharedFilesDialog::runCommandForFile()
{ {
QStringList tsl; QStringList tsl;
tsl.append( currentFile ); tsl.append( currentFile );
QProcess::execute( currentCommand, tsl); QProcess::execute( currentCommand, tsl);
//QString("%1 %2").arg(currentCommand).arg(currentFile) );
// QString tmess = "Some command(%1) should be executed here for file %2";
// tmess = tmess.arg(currentCommand).arg(currentFile);
// QMessageBox::warning(this, tr("RetroShare"), tmess, QMessageBox::Ok);
} }
//============================================================================ //============================================================================
void void
SharedFilesDialog::tryToAddNewAssotiation() LocalSharedFilesDialog::tryToAddNewAssotiation()
{ {
AddFileAssociationDialog afad(true, this);//'add file assotiations' dialog AddFileAssociationDialog afad(true, this);//'add file assotiations' dialog
@ -860,68 +768,62 @@ SharedFilesDialog::tryToAddNewAssotiation()
/** /**
Toggles the Splitted, Remote and Local View on and off*/ Toggles the Splitted, Remote and Local View on and off*/
void SharedFilesDialog::showFrame(bool show) //== void SharedFilesDialog::showFrame(bool show)
{ //== {
if (show) { //== if (show) {
ui.localframe->setVisible(true); //== ui.localframe->setVisible(true);
ui.remoteframe->setVisible(false); //== ui.remoteframe->setVisible(false);
//==
ui.localButton->setChecked(true); //== ui.localButton->setChecked(true);
//==
ui.remoteButton->setChecked(false); //== ui.remoteButton->setChecked(false);
ui.splittedButton->setChecked(false); //== ui.splittedButton->setChecked(false);
//==
ui.titleBarLabel->setText( tr("<strong>My Shared Files</strong>")); //== ui.titleBarLabel->setText( tr("<strong>My Shared Files</strong>"));
} //== }
} //== }
//==
void SharedFilesDialog::showFrameRemote(bool show) //== void SharedFilesDialog::showFrameRemote(bool show)
{ //== {
if (show) { //== if (show) {
ui.remoteframe->setVisible(true); //== ui.remoteframe->setVisible(true);
ui.localframe->setVisible(false); //== ui.localframe->setVisible(false);
//==
ui.remoteButton->setChecked(true); //== ui.remoteButton->setChecked(true);
ui.localButton->setChecked(false); //== ui.localButton->setChecked(false);
ui.splittedButton->setChecked(false); //== ui.splittedButton->setChecked(false);
//==
ui.titleBarLabel->setText( tr("<strong>Friends Files</strong>")); //== ui.titleBarLabel->setText( tr("<strong>Friends Files</strong>"));
} //== }
} //== }
//==
void SharedFilesDialog::showFrameSplitted(bool show) //== void SharedFilesDialog::showFrameSplitted(bool show)
{ //== {
if (show) { //== if (show) {
ui.remoteframe->setVisible(true); //== ui.remoteframe->setVisible(true);
ui.localframe->setVisible(true); //== ui.localframe->setVisible(true);
//==
ui.splittedButton->setChecked(true); //== ui.splittedButton->setChecked(true);
//==
ui.localButton->setChecked(false); //== ui.localButton->setChecked(false);
ui.remoteButton->setChecked(false); //== ui.remoteButton->setChecked(false);
//==
ui.titleBarLabel->setText( tr("<strong>Files</strong>")); //== ui.titleBarLabel->setText( tr("<strong>Files</strong>"));
} //== }
} //== }
void SharedFilesDialog::indicatorChanged(int index) void SharedFilesDialog::indicatorChanged(int index)
{ {
static uint32_t correct_indicator[4] = { IND_ALWAYS,IND_LAST_DAY,IND_LAST_WEEK,IND_LAST_MONTH } ; static uint32_t correct_indicator[4] = { IND_ALWAYS,IND_LAST_DAY,IND_LAST_WEEK,IND_LAST_MONTH } ;
model->changeAgeIndicator(correct_indicator[index]); model->changeAgeIndicator(correct_indicator[index]);
localModel->changeAgeIndicator(correct_indicator[index]);
ui.remoteDirTreeView->update(ui.remoteDirTreeView->rootIndex()); ui.dirTreeView->update(ui.dirTreeView->rootIndex());
ui.localDirTreeView->update(ui.localDirTreeView->rootIndex()) ;
if (correct_indicator[index] != IND_ALWAYS) if (correct_indicator[index] != IND_ALWAYS)
{ ui.dirTreeView->sortByColumn(2, Qt::AscendingOrder);
ui.remoteDirTreeView->sortByColumn(2, Qt::AscendingOrder);
}
else else
{ ui.dirTreeView->sortByColumn(0, Qt::AscendingOrder);
ui.remoteDirTreeView->sortByColumn(0, Qt::AscendingOrder);
}
updateDisplay() ; updateDisplay() ;
} }
@ -968,12 +870,12 @@ void SharedFilesDialog::FilterItems()
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);
QCoreApplication::processEvents() ; QCoreApplication::processEvents() ;
int rowCount = ui.remoteDirTreeView->model()->rowCount(); int rowCount = ui.dirTreeView->model()->rowCount();
for (int row = 0; row < rowCount; row++) for (int row = 0; row < rowCount; row++)
if(proxyModel == tree_proxyModel) if(proxyModel == tree_proxyModel)
tree_FilterItem(ui.remoteDirTreeView->model()->index(row, 0), text, 0); tree_FilterItem(ui.dirTreeView->model()->index(row, 0), text, 0);
else else
flat_FilterItem(ui.remoteDirTreeView->model()->index(row, 0), text, 0); flat_FilterItem(ui.dirTreeView->model()->index(row, 0), text, 0);
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
} }
@ -982,12 +884,12 @@ bool SharedFilesDialog::flat_FilterItem(const QModelIndex &index, const QString
{ {
if(index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive)) if(index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive))
{ {
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), false); ui.dirTreeView->setRowHidden(index.row(), index.parent(), false);
return false ; return false ;
} }
else else
{ {
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), true); ui.dirTreeView->setRowHidden(index.row(), index.parent(), true);
return true ; return true ;
} }
} }
@ -1008,17 +910,17 @@ bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString
} }
int visibleChildCount = 0; int visibleChildCount = 0;
int rowCount = ui.remoteDirTreeView->model()->rowCount(index); int rowCount = ui.dirTreeView->model()->rowCount(index);
for (int row = 0; row < rowCount; row++) { for (int row = 0; row < rowCount; row++) {
if (tree_FilterItem(ui.remoteDirTreeView->model()->index(row, index.column(), index), text, level + 1)) { if (tree_FilterItem(ui.dirTreeView->model()->index(row, index.column(), index), text, level + 1)) {
visibleChildCount++; visibleChildCount++;
} }
} }
if (visible || visibleChildCount) { if (visible || visibleChildCount) {
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), false); ui.dirTreeView->setRowHidden(index.row(), index.parent(), false);
} else { } else {
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), true); ui.dirTreeView->setRowHidden(index.row(), index.parent(), true);
} }
return (visible || visibleChildCount); return (visible || visibleChildCount);

View file

@ -34,55 +34,40 @@ class SharedFilesDialog : public RsAutoUpdatePage
public: public:
/** Default Constructor */ /** Default Constructor */
SharedFilesDialog(QWidget *parent = 0); SharedFilesDialog(RetroshareDirModel *tree_model,RetroshareDirModel *flat_model,QWidget *parent = 0);
/** Default Destructor */
~SharedFilesDialog(); /** Default Destructor */
~SharedFilesDialog() {}
virtual void updatePage() { checkUpdate() ; }
virtual void hideEvent(QHideEvent *) ; virtual void hideEvent(QHideEvent *) ;
virtual void showEvent(QShowEvent *) ; virtual void showEvent(QShowEvent *) ;
protected:
QTreeView *directoryView() ;
private slots: private slots:
virtual void spawnCustomPopupMenu(QPoint point) = 0;
/* For handling the model updates */ /* For handling the model updates */
void preModDirectories(bool update_local); void preModDirectories() ;
void postModDirectories(bool update_local); void postModDirectories() ;
void checkUpdate();
void forceCheck();
/** Create the context popup menu and it's submenus */ /** Create the context popup menu and it's submenus */
void shareddirtreeviewCostumPopupMenu( QPoint point ); // void customPopupMenu(QPoint point) ;
void sharedDirTreeWidgetContextMenu( QPoint point ); void copyLink();
void downloadRemoteSelected();
void createCollectionFile();
void addMsgRemoteSelected();
void copyLinkRemote();
void copyLinkLocal();
void copyLinkhtml(); void copyLinkhtml();
void sendLinkTo(); void sendLinkTo();
void sendremoteLinkTo();
#ifdef RS_USE_LINKS #ifdef RS_USE_LINKS
void sendLinkToCloud(); void sendLinkToCloud();
void addLinkToCloud(); void addLinkToCloud();
#endif #endif
void showFrame(bool show); //== void showFrame(bool show);
void showFrameRemote(bool show); //== void showFrameRemote(bool show);
void showFrameSplitted(bool show); //== void showFrameSplitted(bool show);
void playselectedfiles();
void openfile();
void openfolder();
void editSharePermissions();
void recommendFilesToMsg(); void recommendFilesToMsg();
void runCommandForFile();
void tryToAddNewAssotiation();
void indicatorChanged(int index); void indicatorChanged(int index);
@ -95,7 +80,12 @@ private slots:
signals: signals:
void playFiles(QStringList files); void playFiles(QStringList files);
private: protected:
/** Qt Designer generated object */
Ui::SharedFilesDialog ui;
virtual void processSettings(bool bLoad) = 0;
protected:
//now context menu are created again every time theu are called ( in some //now context menu are created again every time theu are called ( in some
//slots.. Maybe it's not good... //slots.. Maybe it's not good...
//** Define the popup menus for the Context menu */ //** Define the popup menus for the Context menu */
@ -103,16 +93,13 @@ private:
//QMenu* contextMnu2; //QMenu* contextMnu2;
void processSettings(bool bLoad);
void copyLink (const QModelIndexList& lst, bool remote); void copyLink (const QModelIndexList& lst, bool remote);
void FilterItems(); void FilterItems();
bool tree_FilterItem(const QModelIndex &index, const QString &text, int level); bool tree_FilterItem(const QModelIndex &index, const QString &text, int level);
bool flat_FilterItem(const QModelIndex &index, const QString &text, int level); bool flat_FilterItem(const QModelIndex &index, const QString &text, int level);
QModelIndexList getRemoteSelected(); QModelIndexList getSelected();
QModelIndexList getLocalSelected();
/** Defines the actions for the context menu for QTreeWidget */ /** Defines the actions for the context menu for QTreeWidget */
QAction* openfileAct; QAction* openfileAct;
@ -129,9 +116,6 @@ private:
QAction* sendchatlinkAct; QAction* sendchatlinkAct;
QAction* copylinklocalhtmlAct; QAction* copylinklocalhtmlAct;
/** Qt Designer generated object */
Ui::SharedFilesDialog ui;
/* RetroshareDirModel */ /* RetroshareDirModel */
RetroshareDirModel *tree_model; RetroshareDirModel *tree_model;
RetroshareDirModel *flat_model; RetroshareDirModel *flat_model;
@ -140,15 +124,54 @@ private:
QSortFilterProxyModel *flat_proxyModel; QSortFilterProxyModel *flat_proxyModel;
QSortFilterProxyModel *proxyModel; QSortFilterProxyModel *proxyModel;
RetroshareDirModel *localModel;
QSortFilterProxyModel *localProxyModel;
QString currentCommand; QString currentCommand;
QString currentFile; QString currentFile;
QString lastFilterString; QString lastFilterString;
};
QAction* fileAssotiationAction(const QString fileName); class LocalSharedFilesDialog : public SharedFilesDialog
{
Q_OBJECT
public:
LocalSharedFilesDialog(QWidget *parent=NULL) ;
virtual ~LocalSharedFilesDialog();
virtual void spawnCustomPopupMenu(QPoint point);
virtual void updatePage() { checkUpdate() ; }
protected:
virtual void processSettings(bool bLoad) ;
private slots:
void createCollectionFile();
void checkUpdate() ;
void editSharePermissions();
void playselectedfiles();
void openfile();
void openfolder();
void runCommandForFile();
void tryToAddNewAssotiation();
void forceCheck();
QAction* fileAssotiationAction(const QString fileName);
};
class RemoteSharedFilesDialog : public SharedFilesDialog
{
Q_OBJECT
public:
RemoteSharedFilesDialog(QWidget *parent=NULL) ;
virtual ~RemoteSharedFilesDialog() ;
virtual void spawnCustomPopupMenu(QPoint point);
protected:
virtual void processSettings(bool bLoad) ;
private slots:
void downloadRemoteSelected();
}; };
#endif #endif

View file

@ -14,167 +14,6 @@
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>0</number> <number>0</number>
</property> </property>
<item row="1" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QFrame" name="remoteframe">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTreeView" name="remoteDirTreeView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
</property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
<property name="autoExpandDelay">
<number>0</number>
</property>
<property name="itemsExpandable">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="headerStretchLastSection">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<widget class="QFrame" name="localframe">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTreeView" name="localDirTreeView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
</property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ContiguousSelection</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="headerStretchLastSection">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<property name="topMargin">
<number>2</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="downloadButton">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Download selected</string>
</property>
<property name="text">
<string>Download</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/download16.png</normaloff>:/images/download16.png</iconset>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>391</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="checkButton">
<property name="text">
<string>check files</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="hashLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QFrame" name="titleBarFrame"> <widget class="QFrame" name="titleBarFrame">
<property name="sizePolicy"> <property name="sizePolicy">
@ -297,8 +136,7 @@
</size> </size>
</property> </property>
<property name="font"> <property name="font">
<font> <font/>
</font>
</property> </property>
<property name="focusPolicy"> <property name="focusPolicy">
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
@ -330,8 +168,7 @@
</size> </size>
</property> </property>
<property name="font"> <property name="font">
<font> <font/>
</font>
</property> </property>
<property name="focusPolicy"> <property name="focusPolicy">
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
@ -416,89 +253,102 @@ border-image: url(:/images/closepressed.png)
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="splittedButton"> <widget class="QLabel" name="hashLabel">
<property name="maximumSize"> <property name="text">
<size> <string/>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Split View</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/view_split_top_bottom.png</normaloff>:/images/view_split_top_bottom.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="remoteButton"> <widget class="QPushButton" name="checkButton">
<property name="maximumSize"> <property name="text">
<size> <string>check files</string>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Friends Folders</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/friendsfolder24.png</normaloff>:/images/friendsfolder24.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="localButton"> <widget class="QPushButton" name="downloadButton">
<property name="maximumSize"> <property name="minimumSize">
<size> <size>
<width>24</width> <width>140</width>
<height>24</height> <height>0</height>
</size> </size>
</property> </property>
<property name="focusPolicy"> <property name="maximumSize">
<enum>Qt::NoFocus</enum> <size>
<width>16777215</width>
<height>28</height>
</size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>My Folders</string> <string>Download selected</string>
</property>
<property name="text">
<string>Download</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset resource="images.qrc">
<normaloff>:/images/folder16.png</normaloff>:/images/folder16.png</iconset> <normaloff>:/images/download16.png</normaloff>:/images/download16.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QFrame" name="remoteframe">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTreeView" name="dirTreeView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
</property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
<property name="autoExpandDelay">
<number>0</number>
</property>
<property name="itemsExpandable">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="headerStretchLastSection">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources> <resources>

View file

@ -43,6 +43,7 @@
#include "ULListDelegate.h" #include "ULListDelegate.h"
#include "FileTransferInfoWidget.h" #include "FileTransferInfoWidget.h"
#include "SearchDialog.h" #include "SearchDialog.h"
#include "SharedFilesDialog.h"
#include "xprogressbar.h" #include "xprogressbar.h"
#include "settings/rsharesettings.h" #include "settings/rsharesettings.h"
#include "util/misc.h" #include "util/misc.h"
@ -304,6 +305,9 @@ TransfersDialog::TransfersDialog(QWidget *parent)
QObject::connect(ui.downloadList->selectionModel(),SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),this,SLOT(showFileDetails())) ; QObject::connect(ui.downloadList->selectionModel(),SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),this,SLOT(showFileDetails())) ;
ui.tabWidget->insertTab(0,searchDialog = new SearchDialog(), QIcon(IMAGE_SEARCH), tr("Search")) ; ui.tabWidget->insertTab(0,searchDialog = new SearchDialog(), QIcon(IMAGE_SEARCH), tr("Search")) ;
ui.tabWidget->insertTab(1,remoteSharedFiles = new RemoteSharedFilesDialog(), QIcon(IMAGE_SEARCH), tr("Friends files")) ;
ui.tabWidget->addTab(localSharedFiles = new LocalSharedFilesDialog(), QIcon(IMAGE_SEARCH), tr("Your files")) ;
//ui.tabWidget->addTab( new TurtleRouterStatistics(), tr("Router Statistics")) ; //ui.tabWidget->addTab( new TurtleRouterStatistics(), tr("Router Statistics")) ;
//ui.tabWidget->addTab( new TurtleRouterDialog(), tr("Router Requests")) ; //ui.tabWidget->addTab( new TurtleRouterDialog(), tr("Router Requests")) ;

View file

@ -37,6 +37,8 @@ class QStandardItem;
class DetailsDialog; class DetailsDialog;
class FileProgressInfo; class FileProgressInfo;
class SearchDialog; class SearchDialog;
class LocalSharedFilesDialog;
class RemoteSharedFilesDialog;
class TransfersDialog : public RsAutoUpdatePage class TransfersDialog : public RsAutoUpdatePage
{ {
@ -56,6 +58,8 @@ public:
static DetailsDialog *detailsdlg; static DetailsDialog *detailsdlg;
SearchDialog *searchDialog ; SearchDialog *searchDialog ;
LocalSharedFilesDialog *localSharedFiles ;
RemoteSharedFilesDialog *remoteSharedFiles ;
public slots: public slots:
void insertTransfers(); void insertTransfers();

View file

@ -325,9 +325,11 @@ int main(int argc, char *argv[])
std::cerr << "connecting signals and slots" << std::endl ; std::cerr << "connecting signals and slots" << std::endl ;
QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->transfersDialog->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ; QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->transfersDialog->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ;
QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ;
QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->sharedfilesDialog ,SLOT(preModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->transfersDialog->localSharedFiles ,SLOT(preModDirectories(bool) )) ;
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->sharedfilesDialog ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->transfersDialog->remoteSharedFiles ,SLOT(preModDirectories(bool) )) ;
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->transfersDialog->localSharedFiles ,SLOT(postModDirectories(bool) )) ;
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->transfersDialog->remoteSharedFiles ,SLOT(postModDirectories(bool) )) ;
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ;
QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ;
QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) ));
QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(insertConnect() )) ; QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(insertConnect() )) ;