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 */
{
_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
{

View File

@ -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<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
bool _needs_update ;
};

View File

@ -40,6 +40,7 @@
#include "ShareDialog.h"
#include "common/PeerDefs.h"
#include "util/QtVersion.h"
#include "notifyqt.h"
#include <retroshare/rspeers.h>
#include <retroshare/rsfiles.h>
@ -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)

View File

@ -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;

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(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) ));