From 3e13311be0ca0b09ef86162ee702306201c49bd7 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sun, 5 Jan 2014 22:51:54 +0000 Subject: [PATCH] Fixed slot for signal "filesPreModChanged" and "filesPostModChanged" on SharedFilesDialog. The list of files is now updated also when the tab is visible. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6990 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/RemoteDirModel.cpp | 35 ++++++++++++-------- retroshare-gui/src/gui/RemoteDirModel.h | 7 ++-- retroshare-gui/src/gui/SharedFilesDialog.cpp | 27 ++++++++++++--- retroshare-gui/src/gui/SharedFilesDialog.h | 6 ++-- retroshare-gui/src/main.cpp | 4 --- 5 files changed, 51 insertions(+), 28 deletions(-) diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index af7be29ed..630dedf06 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -49,7 +49,6 @@ RetroshareDirModel::RetroshareDirModel(bool mode, QObject *parent) RemoteMode(mode), nIndex(1), indexSet(1) /* ass zero index cant be used */ { _visible = false ; - _needs_update = true ; #if QT_VERSION < QT_VERSION_CHECK (5, 0, 0) setSupportedDragActions(Qt::CopyAction); #endif @@ -64,7 +63,7 @@ Qt::DropActions RetroshareDirModel::supportedDragActions() const } #endif -void RetroshareDirModel::update() +void FlatStyle_RDM::update() { if(_needs_update) { @@ -845,34 +844,42 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const /* Callback from */ - void RetroshareDirModel::preMods() - { +void RetroshareDirModel::preMods() +{ + reset(); + #ifdef RDM_DEBUG std::cerr << "RetroshareDirModel::preMods()" << std::endl; #endif - //modelAboutToBeReset(); -// reset(); +} + +/* Callback from */ +void RetroshareDirModel::postMods() +{ + emit layoutAboutToBeChanged(); #if QT_VERSION >= 0x040600 beginResetModel(); #endif - layoutAboutToBeChanged(); + +// QModelIndexList piList = persistentIndexList(); +// QModelIndexList empty; +// for (int i = 0; i < piList.size(); i++) { +// empty.append(QModelIndex()); +// } +// changePersistentIndexList(piList, empty); /* Clear caches */ mCache.clear(); - } -/* Callback from */ - void RetroshareDirModel::postMods() - { #ifdef RDM_DEBUG std::cerr << "RetroshareDirModel::postMods()" << std::endl; #endif - //modelReset(); - layoutChanged(); + #if QT_VERSION >= 0x040600 endResetModel(); #endif - } + emit layoutChanged(); +} const DirDetailsVector *RetroshareDirModel::requestDirDetails(void *ref, bool remote) const { diff --git a/retroshare-gui/src/gui/RemoteDirModel.h b/retroshare-gui/src/gui/RemoteDirModel.h index f1fb73a87..61188386d 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.h +++ b/retroshare-gui/src/gui/RemoteDirModel.h @@ -75,7 +75,7 @@ class RetroshareDirModel : public QAbstractItemModel void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; } const DirDetailsVector *requestDirDetails(void *ref, bool remote) const; - void update() ; + virtual void update() {} ; public: virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const; @@ -87,7 +87,6 @@ class RetroshareDirModel : public QAbstractItemModel protected: bool _visible ; - bool _needs_update ; void treeStyle(); void downloadDirectory(const DirDetails & details, int prefixLen); @@ -192,10 +191,13 @@ class FlatStyle_RDM: public RetroshareDirModel FlatStyle_RDM(bool mode) : RetroshareDirModel(mode) { + _needs_update = true ; } virtual ~FlatStyle_RDM() ; + virtual void update() ; + protected slots: void updateRefs() ; @@ -217,6 +219,7 @@ class FlatStyle_RDM: public RetroshareDirModel std::vector > _ref_entries ;// used to store the refs to display std::vector _ref_stack ; // used to store the refs to update + bool _needs_update ; }; diff --git a/retroshare-gui/src/gui/SharedFilesDialog.cpp b/retroshare-gui/src/gui/SharedFilesDialog.cpp index e8ab8bc0c..4011783b8 100644 --- a/retroshare-gui/src/gui/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/SharedFilesDialog.cpp @@ -40,6 +40,7 @@ #include "ShareDialog.h" #include "common/PeerDefs.h" #include "util/QtVersion.h" +#include "notifyqt.h" #include #include @@ -73,7 +74,7 @@ public: SFDSortFilterProxyModel(RetroshareDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent) { m_dirModel = dirModel; - }; + } protected: virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const @@ -99,6 +100,10 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); + NotifyQt *notify = NotifyQt::getInstance(); + connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool))); + connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool))); + //== 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))); @@ -673,14 +678,26 @@ void LocalSharedFilesDialog::openfolder() model->openSelected(qmil); } -void SharedFilesDialog::preModDirectories() +void SharedFilesDialog::preModDirectories(bool local) { - model->preMods(); + if (isRemote() == local) { + return; + } + + /* Notify both models, only one is visible */ + tree_model->preMods(); + flat_model->preMods(); } -void SharedFilesDialog::postModDirectories() +void SharedFilesDialog::postModDirectories(bool local) { - model->postMods(); + if (isRemote() == local) { + return; + } + + /* Notify both models, only one is visible */ + tree_model->postMods(); + flat_model->postMods(); ui.dirTreeView->update() ; if (ui.filterPatternLineEdit->text().isEmpty() == false) diff --git a/retroshare-gui/src/gui/SharedFilesDialog.h b/retroshare-gui/src/gui/SharedFilesDialog.h index 5c3d8ae4f..bfb43db00 100644 --- a/retroshare-gui/src/gui/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/SharedFilesDialog.h @@ -53,8 +53,8 @@ protected slots: private slots: /* For handling the model updates */ - void preModDirectories() ; - void postModDirectories() ; + void preModDirectories(bool local) ; + void postModDirectories(bool local) ; /** Create the context popup menu and it's submenus */ // void customPopupMenu(QPoint point) ; @@ -107,7 +107,7 @@ protected: /** Defines the actions for the context menu for QTreeWidget */ QAction* copylinkAct; - QAction* sendlinkAct; + QAction* sendlinkAct; #ifdef RS_USE_LINKS QAction* sendlinkCloudAct; QAction* addlinkCloudAct; diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 7b8f15f7f..b157dc5c4 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -372,10 +372,6 @@ int main(int argc, char *argv[]) QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; - QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->transfersDialog->localSharedFiles ,SLOT(preModDirectories(bool) )) ; - QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->transfersDialog->remoteSharedFiles ,SLOT(preModDirectories(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(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) ));