diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 8978ccf71..a7cc487fc 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -22,7 +22,6 @@ #include "rshare.h" #include "gui/MainWindow.h" -#include "gui/notifyqt.h" #include "gui/RemoteDirModel.h" #include "gui/RetroShareLink.h" #include "gui/ShareManager.h" @@ -35,6 +34,7 @@ #include "gui/settings/rsharesettings.h" #include "util/QtVersion.h" #include "util/RsAction.h" +#include "util/qtthreadsutils.h" #include "util/misc.h" #include "util/rstime.h" #include "util/rsdir.h" @@ -166,6 +166,7 @@ public: SharedFilesDialog::~SharedFilesDialog() { + rsEvents->unregisterEventsHandler(mEventHandlerId); delete tree_model; delete flat_model; delete tree_proxyModel; @@ -177,9 +178,36 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent) /* 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(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool))); + //connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool))); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler([this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + + auto e = dynamic_cast(event.get()); + + switch(e->mEventCode) + { + case RsSharedDirectoriesEventCode::OWN_DIR_LIST_PROCESSING: + preModDirectories(true); + break; + + case RsSharedDirectoriesEventCode::OWN_DIR_LIST_UPDATED: + postModDirectories(true); + break; + + case RsSharedDirectoriesEventCode::FRIEND_DIR_LIST_UPDATED: + preModDirectories(false); + postModDirectories(false); + break; + + default: + break; + };}, this); + }, mEventHandlerId,RsEventType::SHARED_DIRECTORIES); connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int))); connect(ui.dirTreeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT( spawnCustomPopupMenu( QPoint ) ) ); diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h index 7524d5035..375b6c075 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h @@ -21,6 +21,7 @@ #ifndef _SHAREDFILESDIALOG_H #define _SHAREDFILESDIALOG_H +#include #include "ui_SharedFilesDialog.h" #include @@ -145,6 +146,8 @@ protected: QString lastFilterString; QString mLastFilterText ; RsProtectedTimer* mFilterTimer; + + RsEventsHandlerId_t mEventHandlerId ; }; class LocalSharedFilesDialog : public SharedFilesDialog diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index d3fe147a8..860ce043f 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -549,26 +549,26 @@ void NotifyQt::notifyListChange(int list, int type) #endif emit friendsChanged() ; break; -#endif case NOTIFY_LIST_DIRLIST_LOCAL: #ifdef NOTIFY_DEBUG std::cerr << "received files changed" << std::endl ; #endif emit filesPostModChanged(true) ; /* Local */ break; - case NOTIFY_LIST_CHAT_LOBBY_INVITATION: -#ifdef NOTIFY_DEBUG - std::cerr << "received files changed" << std::endl ; -#endif - emit chatLobbyInviteReceived() ; /* Local */ - break; case NOTIFY_LIST_DIRLIST_FRIENDS: #ifdef NOTIFY_DEBUG std::cerr << "received files changed" << std::endl ; #endif emit filesPostModChanged(false) ; /* Local */ break; - case NOTIFY_LIST_CONFIG: +#endif + case NOTIFY_LIST_CHAT_LOBBY_INVITATION: +#ifdef NOTIFY_DEBUG + std::cerr << "received files changed" << std::endl ; +#endif + emit chatLobbyInviteReceived() ; /* Local */ + break; + case NOTIFY_LIST_CONFIG: #ifdef NOTIFY_DEBUG std::cerr << "received config changed" << std::endl ; #endif @@ -653,14 +653,14 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/) case NOTIFY_LIST_FRIENDS: emit friendsChanged() ; break; -#endif case NOTIFY_LIST_DIRLIST_FRIENDS: emit filesPreModChanged(false) ; /* remote */ break ; case NOTIFY_LIST_DIRLIST_LOCAL: emit filesPreModChanged(true) ; /* local */ break; - case NOTIFY_LIST_SEARCHLIST: +#endif + case NOTIFY_LIST_SEARCHLIST: break; case NOTIFY_LIST_CHANNELLIST: break; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index eb52fad1a..7be023772 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -105,7 +105,7 @@ class NotifyQt: public QObject, public NotifyClient // as they get queued by Qt. // void hashingInfoChanged(const QString&) const ; - void filesPreModChanged(bool) const ; +// void filesPreModChanged(bool) const ; void filesPostModChanged(bool) const ; // void transfersChanged() const ; // void friendsChanged() const ; diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index c349df404..ad37fb54c 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -728,7 +728,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); // 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(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ; +// QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ; // QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ;