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
This commit is contained in:
thunder2 2014-01-05 22:51:54 +00:00
parent aff10a352c
commit 3e13311be0
5 changed files with 51 additions and 28 deletions

View File

@ -49,7 +49,6 @@ RetroshareDirModel::RetroshareDirModel(bool mode, QObject *parent)
RemoteMode(mode), nIndex(1), indexSet(1) /* ass zero index cant be used */ RemoteMode(mode), nIndex(1), indexSet(1) /* ass zero index cant be used */
{ {
_visible = false ; _visible = false ;
_needs_update = true ;
#if QT_VERSION < QT_VERSION_CHECK (5, 0, 0) #if QT_VERSION < QT_VERSION_CHECK (5, 0, 0)
setSupportedDragActions(Qt::CopyAction); setSupportedDragActions(Qt::CopyAction);
#endif #endif
@ -64,7 +63,7 @@ Qt::DropActions RetroshareDirModel::supportedDragActions() const
} }
#endif #endif
void RetroshareDirModel::update() void FlatStyle_RDM::update()
{ {
if(_needs_update) if(_needs_update)
{ {
@ -845,34 +844,42 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const
/* Callback from */ /* Callback from */
void RetroshareDirModel::preMods() void RetroshareDirModel::preMods()
{ {
reset();
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "RetroshareDirModel::preMods()" << std::endl; std::cerr << "RetroshareDirModel::preMods()" << std::endl;
#endif #endif
//modelAboutToBeReset(); }
// reset();
/* Callback from */
void RetroshareDirModel::postMods()
{
emit layoutAboutToBeChanged();
#if QT_VERSION >= 0x040600 #if QT_VERSION >= 0x040600
beginResetModel(); beginResetModel();
#endif #endif
layoutAboutToBeChanged();
// QModelIndexList piList = persistentIndexList();
// QModelIndexList empty;
// for (int i = 0; i < piList.size(); i++) {
// empty.append(QModelIndex());
// }
// changePersistentIndexList(piList, empty);
/* Clear caches */ /* Clear caches */
mCache.clear(); mCache.clear();
}
/* Callback from */
void RetroshareDirModel::postMods()
{
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "RetroshareDirModel::postMods()" << std::endl; std::cerr << "RetroshareDirModel::postMods()" << std::endl;
#endif #endif
//modelReset();
layoutChanged();
#if QT_VERSION >= 0x040600 #if QT_VERSION >= 0x040600
endResetModel(); endResetModel();
#endif #endif
} emit layoutChanged();
}
const DirDetailsVector *RetroshareDirModel::requestDirDetails(void *ref, bool remote) const const DirDetailsVector *RetroshareDirModel::requestDirDetails(void *ref, bool remote) const
{ {

View File

@ -75,7 +75,7 @@ class RetroshareDirModel : public QAbstractItemModel
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; } void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
const DirDetailsVector *requestDirDetails(void *ref, bool remote) const; const DirDetailsVector *requestDirDetails(void *ref, bool remote) const;
void update() ; virtual void update() {} ;
public: public:
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const; virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
@ -87,7 +87,6 @@ class RetroshareDirModel : public QAbstractItemModel
protected: protected:
bool _visible ; bool _visible ;
bool _needs_update ;
void treeStyle(); void treeStyle();
void downloadDirectory(const DirDetails & details, int prefixLen); void downloadDirectory(const DirDetails & details, int prefixLen);
@ -192,10 +191,13 @@ class FlatStyle_RDM: public RetroshareDirModel
FlatStyle_RDM(bool mode) FlatStyle_RDM(bool mode)
: RetroshareDirModel(mode) : RetroshareDirModel(mode)
{ {
_needs_update = true ;
} }
virtual ~FlatStyle_RDM() ; virtual ~FlatStyle_RDM() ;
virtual void update() ;
protected slots: protected slots:
void updateRefs() ; void updateRefs() ;
@ -217,6 +219,7 @@ class FlatStyle_RDM: public RetroshareDirModel
std::vector<std::pair<void *,QString> > _ref_entries ;// used to store the refs to display std::vector<std::pair<void *,QString> > _ref_entries ;// used to store the refs to display
std::vector<void *> _ref_stack ; // used to store the refs to update std::vector<void *> _ref_stack ; // used to store the refs to update
bool _needs_update ;
}; };

View File

@ -40,6 +40,7 @@
#include "ShareDialog.h" #include "ShareDialog.h"
#include "common/PeerDefs.h" #include "common/PeerDefs.h"
#include "util/QtVersion.h" #include "util/QtVersion.h"
#include "notifyqt.h"
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <retroshare/rsfiles.h> #include <retroshare/rsfiles.h>
@ -73,7 +74,7 @@ public:
SFDSortFilterProxyModel(RetroshareDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent) SFDSortFilterProxyModel(RetroshareDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent)
{ {
m_dirModel = dirModel; m_dirModel = dirModel;
}; }
protected: protected:
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const 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 */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); 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.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)));
@ -673,14 +678,26 @@ void LocalSharedFilesDialog::openfolder()
model->openSelected(qmil); 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() ; ui.dirTreeView->update() ;
if (ui.filterPatternLineEdit->text().isEmpty() == false) if (ui.filterPatternLineEdit->text().isEmpty() == false)

View File

@ -53,8 +53,8 @@ protected slots:
private slots: private slots:
/* For handling the model updates */ /* For handling the model updates */
void preModDirectories() ; void preModDirectories(bool local) ;
void postModDirectories() ; void postModDirectories(bool local) ;
/** Create the context popup menu and it's submenus */ /** Create the context popup menu and it's submenus */
// void customPopupMenu(QPoint point) ; // void customPopupMenu(QPoint point) ;
@ -107,7 +107,7 @@ protected:
/** Defines the actions for the context menu for QTreeWidget */ /** Defines the actions for the context menu for QTreeWidget */
QAction* copylinkAct; QAction* copylinkAct;
QAction* sendlinkAct; QAction* sendlinkAct;
#ifdef RS_USE_LINKS #ifdef RS_USE_LINKS
QAction* sendlinkCloudAct; QAction* sendlinkCloudAct;
QAction* addlinkCloudAct; QAction* addlinkCloudAct;

View File

@ -372,10 +372,6 @@ int main(int argc, char *argv[])
QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; 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(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ;
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->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(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) ));