Merge pull request #1190 from PhenomRetroShare/Add_ShowEmptySubMenuRemoteTree

Add ShowEmpty sub menu in Tree Remote SharedFilesDialog.
This commit is contained in:
csoler 2018-03-17 18:40:32 +01:00 committed by GitHub
commit 24d1f5d9eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 263 additions and 191 deletions

View File

@ -491,53 +491,63 @@ void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
{ {
if (!rsPeers) return; /* not ready yet! */ if (!rsPeers) return; /* not ready yet! */
QMenu *contextMenu = new QMenu(this);
QModelIndex idx = ui.dirTreeView->indexAt(point) ; QModelIndex idx = ui.dirTreeView->indexAt(point) ;
if (!idx.isValid()) return; if (idx.isValid())
{
QModelIndex midx = proxyModel->mapToSource(idx) ; QModelIndex midx = proxyModel->mapToSource(idx) ;
if (!midx.isValid()) return; if (midx.isValid())
{
currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ; currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ;
int type = model->getType(midx) ; int type = model->getType(midx) ;
if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE) return; if ( (type == DIR_TYPE_DIR) || (type == DIR_TYPE_FILE) )
{
QMenu contextMnu( this ) ;
collCreateAct->setEnabled(true); collCreateAct->setEnabled(true);
collOpenAct->setEnabled(true); collOpenAct->setEnabled(true);
QMenu collectionMenu(tr("Collection"), this);
collectionMenu.setIcon(QIcon(IMAGE_LIBRARY));
collectionMenu.addAction(collCreateAct);
collectionMenu.addAction(collOpenAct);
QModelIndexList list = ui.dirTreeView->selectionModel()->selectedRows() ; QModelIndexList list = ui.dirTreeView->selectionModel()->selectedRows() ;
if(type == DIR_TYPE_DIR || list.size() > 1) if(type == DIR_TYPE_DIR || list.size() > 1)
{ {
QAction *downloadActI = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download..." ), &contextMnu ) ; QAction *downloadActI = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download..." ), contextMenu ) ;
connect( downloadActI , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelectedInteractive() ) ) ; connect( downloadActI , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelectedInteractive() ) ) ;
contextMnu.addAction( downloadActI) ; contextMenu->addAction( downloadActI) ;
} }
else else
{ {
QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), &contextMnu ) ; QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), contextMenu ) ;
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ; connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ;
contextMnu.addAction( downloadAct) ; contextMenu->addAction( downloadAct) ;
} }
contextMnu.addSeparator() ;//------------------------------------ contextMenu->addSeparator() ;//------------------------------------
contextMnu.addAction( copylinkAct) ; contextMenu->addAction( copylinkAct) ;
contextMnu.addAction( sendlinkAct) ; contextMenu->addAction( sendlinkAct) ;
contextMnu.addSeparator() ;//------------------------------------ contextMenu->addSeparator() ;//------------------------------------
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ; contextMenu->addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ;
contextMenu->addSeparator() ;//------------------------------------
contextMnu.addSeparator() ;//------------------------------------ QMenu collectionMenu(tr("Collection"), this);
contextMnu.addMenu(&collectionMenu) ; collectionMenu.setIcon(QIcon(IMAGE_LIBRARY));
collectionMenu.addAction(collCreateAct);
collectionMenu.addAction(collOpenAct);
contextMenu->addMenu(&collectionMenu) ;
contextMnu.exec(QCursor::pos()) ; }
}
}
contextMenu = model->getContextMenu(contextMenu);
if (!contextMenu->children().isEmpty())
contextMenu->exec(QCursor::pos()) ;
delete contextMenu;
} }
QModelIndexList SharedFilesDialog::getSelected() QModelIndexList SharedFilesDialog::getSelected()
@ -908,7 +918,7 @@ void SharedFilesDialog::restoreExpandedPathsAndSelection(const std::set<std::str
std::string path = ui.dirTreeView->model()->index(row,0).data(Qt::DisplayRole).toString().toStdString(); std::string path = ui.dirTreeView->model()->index(row,0).data(Qt::DisplayRole).toString().toStdString();
recursRestoreExpandedItems(ui.dirTreeView->model()->index(row,0),path,expanded_indexes,hidden_indexes,selected_indexes); recursRestoreExpandedItems(ui.dirTreeView->model()->index(row,0),path,expanded_indexes,hidden_indexes,selected_indexes);
} }
QItemSelection selection ; //QItemSelection selection ;
ui.dirTreeView->blockSignals(false) ; ui.dirTreeView->blockSignals(false) ;
} }
@ -1603,4 +1613,3 @@ bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString
return (visible || visibleChildCount); return (visible || visibleChildCount);
} }

View File

@ -50,21 +50,40 @@ static const size_t FLAT_VIEW_MAX_REFS_TABLE_SIZE = 10000 ; //
static const uint32_t FLAT_VIEW_MIN_DELAY_BETWEEN_UPDATES = 120 ; // dont rebuild ref list more than every 2 mins. static const uint32_t FLAT_VIEW_MIN_DELAY_BETWEEN_UPDATES = 120 ; // dont rebuild ref list more than every 2 mins.
RetroshareDirModel::RetroshareDirModel(bool mode, QObject *parent) RetroshareDirModel::RetroshareDirModel(bool mode, QObject *parent)
: QAbstractItemModel(parent), : QAbstractItemModel(parent), _visible(false)
ageIndicator(IND_ALWAYS), , ageIndicator(IND_ALWAYS)
RemoteMode(mode), nIndex(1), indexSet(1) /* ass zero index cant be used */ , RemoteMode(mode)//, nIndex(1), indexSet(1) /* ass zero index cant be used */
, mLastRemote(false), mLastReq(0), mUpdating(false)
{ {
_visible = false ;
#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
treeStyle(); treeStyle();
mDirDetails.ref = (void*)intptr_t(0xffffffff) ; mDirDetails.ref = (void*)intptr_t(0xffffffff) ;
mLastRemote = false ;
mUpdating = false;
} }
TreeStyle_RDM::TreeStyle_RDM(bool mode)
: RetroshareDirModel(mode), _showEmpty(false)
{
_showEmptyAct = new QAction(QIcon(), tr("Show Empty"), this);
_showEmptyAct->setCheckable(true);
_showEmptyAct->setChecked(_showEmpty);
connect(_showEmptyAct, SIGNAL(toggled(bool)), this, SLOT(showEmpty(bool)));
}
FlatStyle_RDM::FlatStyle_RDM(bool mode)
: RetroshareDirModel(mode), _ref_mutex("Flat file list")
{
_needs_update = true ;
{
RS_STACK_MUTEX(_ref_mutex) ;
_last_update = 0 ;
}
}
// QAbstractItemModel::setSupportedDragActions() was replaced by virtual QAbstractItemModel::supportedDragActions() // QAbstractItemModel::setSupportedDragActions() was replaced by virtual QAbstractItemModel::supportedDragActions()
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
Qt::DropActions RetroshareDirModel::supportedDragActions() const Qt::DropActions RetroshareDirModel::supportedDragActions() const
@ -78,7 +97,6 @@ static bool isNewerThanEpoque(uint32_t ts)
return ts > 0 ; // this should be conservative enough return ts > 0 ; // this should be conservative enough
} }
void RetroshareDirModel::treeStyle() void RetroshareDirModel::treeStyle()
{ {
categoryIcon.addPixmap(QPixmap(":/images/folder16.png"), categoryIcon.addPixmap(QPixmap(":/images/folder16.png"),
@ -97,6 +115,21 @@ void TreeStyle_RDM::updateRef(const QModelIndex& indx) const
rsFiles->requestDirUpdate(indx.internalPointer()) ; rsFiles->requestDirUpdate(indx.internalPointer()) ;
} }
QMenu* TreeStyle_RDM::getContextMenu(QMenu* contextMenu)
{
if (!contextMenu){
contextMenu = new QMenu();
} else {
if (RemoteMode)
contextMenu->addSeparator();
}
if (RemoteMode)
contextMenu->addAction( _showEmptyAct) ;
return contextMenu;
}
bool TreeStyle_RDM::hasChildren(const QModelIndex &parent) const bool TreeStyle_RDM::hasChildren(const QModelIndex &parent) const
{ {
@ -171,6 +204,10 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const
void *ref = (parent.isValid())? parent.internalPointer() : NULL ; void *ref = (parent.isValid())? parent.internalPointer() : NULL ;
if ((!ref) && RemoteMode)
_parentRow.clear(); //Only clear it when asking root child number and in remote mode.
DirDetails details ; DirDetails details ;
if (! requestDirDetails(ref, RemoteMode,details)) if (! requestDirDetails(ref, RemoteMode,details))
@ -195,9 +232,21 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const
std::cerr << "lookup PER/DIR #" << details->count; std::cerr << "lookup PER/DIR #" << details->count;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
if ((details.type == DIR_TYPE_ROOT) && !_showEmpty && RemoteMode)
{
DirDetails childDetails;
//Scan all children to know if they are empty.
//And save their real row index
//Prefer do like that than modify requestDirDetails with a new flag (rsFiles->RequestDirDetails)
for(uint64_t i = 0; i < details.count; ++i)
{
if (requestDirDetails(details.children[i].ref, RemoteMode,childDetails) && (childDetails.count > 0))
_parentRow.push_back(i);
}
return _parentRow.size();
}
return details.count; return details.count;
} }
int FlatStyle_RDM::rowCount(const QModelIndex &parent) const int FlatStyle_RDM::rowCount(const QModelIndex &parent) const
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
@ -210,6 +259,7 @@ int FlatStyle_RDM::rowCount(const QModelIndex &parent) const
return _ref_entries.size() ; return _ref_entries.size() ;
} }
int TreeStyle_RDM::columnCount(const QModelIndex &/*parent*/) const int TreeStyle_RDM::columnCount(const QModelIndex &/*parent*/) const
{ {
return COLUMN_COUNT; return COLUMN_COUNT;
@ -218,6 +268,7 @@ int FlatStyle_RDM::columnCount(const QModelIndex &/*parent*/) const
{ {
return COLUMN_COUNT; return COLUMN_COUNT;
} }
QString RetroshareDirModel::getFlagsString(FileStorageFlags flags) QString RetroshareDirModel::getFlagsString(FileStorageFlags flags)
{ {
char str[11] = "- - -" ; char str[11] = "- - -" ;
@ -253,7 +304,6 @@ QString RetroshareDirModel::getGroupsString(FileStorageFlags flags,const std::li
return groups_str ; return groups_str ;
} }
QString RetroshareDirModel::getAgeIndicatorString(const DirDetails &details) const QString RetroshareDirModel::getAgeIndicatorString(const DirDetails &details) const
{ {
QString ret(""); QString ret("");
@ -496,17 +546,6 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
return QVariant(); return QVariant();
} /* end of DisplayRole */ } /* end of DisplayRole */
FlatStyle_RDM::FlatStyle_RDM(bool mode)
: RetroshareDirModel(mode), _ref_mutex("Flat file list")
{
_needs_update = true ;
{
RS_STACK_MUTEX(_ref_mutex) ;
_last_update = 0 ;
}
}
void FlatStyle_RDM::update() void FlatStyle_RDM::update()
{ {
if(_needs_update) if(_needs_update)
@ -650,7 +689,6 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
} }
return QVariant(); return QVariant();
} }
QVariant FlatStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails& details,int coln) const QVariant FlatStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails& details,int coln) const
{ {
/* /*
@ -678,9 +716,6 @@ QVariant FlatStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
return QVariant(); return QVariant();
} /* end of SortRole */ } /* end of SortRole */
QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
@ -771,6 +806,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
return QVariant(); return QVariant();
} }
/****
//void RetroshareDirModel::getAgeIndicatorRec(const DirDetails &details, QString &ret) const { //void RetroshareDirModel::getAgeIndicatorRec(const DirDetails &details, QString &ret) const {
// if (details.type == DIR_TYPE_FILE) { // if (details.type == DIR_TYPE_FILE) {
// ret = getAgeIndicatorString(details); // ret = getAgeIndicatorString(details);
@ -786,6 +822,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
// } // }
// } // }
//} //}
****/
QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int role) const QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int role) const
{ {
@ -910,15 +947,19 @@ QModelIndex TreeStyle_RDM::index(int row, int column, const QModelIndex & parent
} }
********/ ********/
//If on root and don't show empty child, get real parent row
if ((!ref) && (!_showEmpty) && RemoteMode && ((size_t)row >= _parentRow.size()))
return QModelIndex();
int parentRow = ((!ref) && (!_showEmpty) && RemoteMode) ? _parentRow[row] : row ;
void *result ; void *result ;
if(rsFiles->findChildPointer(ref, row, result, ((RemoteMode) ? RS_FILE_HINTS_REMOTE : RS_FILE_HINTS_LOCAL))) if(rsFiles->findChildPointer(ref, parentRow, result, ((RemoteMode) ? RS_FILE_HINTS_REMOTE : RS_FILE_HINTS_LOCAL)))
return createIndex(row, column, result) ; return createIndex(row, column, result) ;
else else
return QModelIndex(); return QModelIndex();
} }
QModelIndex FlatStyle_RDM::index(int row, int column, const QModelIndex & parent) const QModelIndex FlatStyle_RDM::index(int row, int column, const QModelIndex & parent) const
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
@ -990,6 +1031,7 @@ QModelIndex TreeStyle_RDM::parent( const QModelIndex & index ) const
std::cerr << "Creating index 3 row=" << details.prow << ", column=" << 0 << ", ref=" << (void*)details.parent << std::endl; std::cerr << "Creating index 3 row=" << details.prow << ", column=" << 0 << ", ref=" << (void*)details.parent << std::endl;
#endif #endif
return createIndex(details.prow, COLUMN_NAME, details.parent); return createIndex(details.prow, COLUMN_NAME, details.parent);
} }
QModelIndex FlatStyle_RDM::parent( const QModelIndex & index ) const QModelIndex FlatStyle_RDM::parent( const QModelIndex & index ) const
@ -1039,7 +1081,7 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const
/* Callback from */ /* Callback from Core*/
void RetroshareDirModel::preMods() void RetroshareDirModel::preMods()
{ {
emit layoutAboutToBeChanged(); emit layoutAboutToBeChanged();
@ -1056,7 +1098,7 @@ void RetroshareDirModel::preMods()
#endif #endif
} }
/* Callback from */ /* Callback from Core*/
void RetroshareDirModel::postMods() void RetroshareDirModel::postMods()
{ {
// emit layoutAboutToBeChanged(); // emit layoutAboutToBeChanged();
@ -1075,6 +1117,30 @@ void RetroshareDirModel::postMods()
emit layoutChanged(); emit layoutChanged();
} }
void FlatStyle_RDM::postMods()
{
time_t now = time(NULL);
if(_last_update + FLAT_VIEW_MIN_DELAY_BETWEEN_UPDATES > now)
return ;
if(visible())
{
emit layoutAboutToBeChanged();
{
RS_STACK_MUTEX(_ref_mutex) ;
_ref_stack.clear() ;
_ref_stack.push_back(NULL) ; // init the stack with the topmost parent directory
_ref_entries.clear();
_last_update = now;
}
QTimer::singleShot(100,this,SLOT(updateRefs())) ;
}
else
_needs_update = true ;
}
bool RetroshareDirModel::requestDirDetails(void *ref, bool remote,DirDetails& d) const bool RetroshareDirModel::requestDirDetails(void *ref, bool remote,DirDetails& d) const
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
@ -1475,35 +1541,11 @@ int RetroshareDirModel::getType ( const QModelIndex & index ) const
return rsFiles->getType(index.internalPointer(),flags); return rsFiles->getType(index.internalPointer(),flags);
} }
FlatStyle_RDM::~FlatStyle_RDM()
{
}
TreeStyle_RDM::~TreeStyle_RDM() TreeStyle_RDM::~TreeStyle_RDM()
{ {
} }
void FlatStyle_RDM::postMods() FlatStyle_RDM::~FlatStyle_RDM()
{ {
time_t now = time(NULL);
if(_last_update + FLAT_VIEW_MIN_DELAY_BETWEEN_UPDATES > now)
return ;
if(visible())
{
emit layoutAboutToBeChanged();
{
RS_STACK_MUTEX(_ref_mutex) ;
_ref_stack.clear() ;
_ref_stack.push_back(NULL) ; // init the stack with the topmost parent directory
_ref_entries.clear();
_last_update = now;
}
QTimer::singleShot(100,this,SLOT(updateRefs())) ;
}
else
_needs_update = true ;
} }
void FlatStyle_RDM::updateRefs() void FlatStyle_RDM::updateRefs()
@ -1563,3 +1605,8 @@ void FlatStyle_RDM::updateRefs()
RetroshareDirModel::postMods() ; RetroshareDirModel::postMods() ;
} }
void TreeStyle_RDM::showEmpty(const bool value)
{
_showEmpty = value;
update();
}

View File

@ -25,7 +25,9 @@
#include <retroshare/rstypes.h> #include <retroshare/rstypes.h>
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QAction>
#include <QIcon> #include <QIcon>
#include <QMenu>
#include <stdint.h> #include <stdint.h>
#include <vector> #include <vector>
@ -63,7 +65,7 @@ class RetroshareDirModel : public QAbstractItemModel
RetroshareDirModel(bool mode, QObject *parent = 0); RetroshareDirModel(bool mode, QObject *parent = 0);
virtual ~RetroshareDirModel() {} virtual ~RetroshareDirModel() {}
Qt::ItemFlags flags ( const QModelIndex & index ) const; virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
/* Callback from Core */ /* Callback from Core */
virtual void preMods(); virtual void preMods();
@ -86,14 +88,17 @@ class RetroshareDirModel : public QAbstractItemModel
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; } void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
bool requestDirDetails(void *ref, bool remote,DirDetails& d) const; bool requestDirDetails(void *ref, bool remote,DirDetails& d) const;
virtual void update() {}
virtual void update() {}
virtual void updateRef(const QModelIndex&) const =0; virtual void updateRef(const QModelIndex&) const =0;
virtual QMenu* getContextMenu(QMenu* contextMenu) {return contextMenu;}
public: public:
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const; //Overloaded from QAbstractItemModel
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual QStringList mimeTypes () const; virtual QStringList mimeTypes () const;
virtual QVariant data(const QModelIndex &index, int role) const; virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
virtual Qt::DropActions supportedDragActions() const; virtual Qt::DropActions supportedDragActions() const;
#endif #endif
@ -119,46 +124,46 @@ class RetroshareDirModel : public QAbstractItemModel
QIcon categoryIcon; QIcon categoryIcon;
QIcon peerIcon; QIcon peerIcon;
class RemoteIndex //class RemoteIndex
{ //{
public: // public:
RemoteIndex() {} // RemoteIndex() {}
RemoteIndex(std::string in_person, // RemoteIndex(std::string in_person,
std::string in_path, // std::string in_path,
int in_idx, // int in_idx,
int in_row, // int in_row,
int in_column, // int in_column,
std::string in_name, // std::string in_name,
int in_size, // int in_size,
int in_type, // int in_type,
int in_ts, int in_rank) // int in_ts, int in_rank)
:id(in_person), path(in_path), parent(in_idx), // :id(in_person), path(in_path), parent(in_idx),
row(in_row), column(in_column), // row(in_row), column(in_column),
name(in_name), size(in_size), // name(in_name), size(in_size),
type(in_type), timestamp(in_ts), rank(in_rank) // type(in_type), timestamp(in_ts), rank(in_rank)
{ // {
return; // return;
} // }
//
std::string id; // std::string id;
std::string path; // std::string path;
int parent; // int parent;
int row; // int row;
int column; // int column;
//
/* display info */ // /* display info */
std::string name; // std::string name;
int size; // int size;
int type; // int type;
int timestamp; // int timestamp;
int rank; // int rank;
//
}; //};
bool RemoteMode; bool RemoteMode;
mutable int nIndex; //mutable int nIndex;
mutable std::vector<RemoteIndex> indexSet; //mutable std::vector<RemoteIndex> indexSet;
// This material attempts to keep last request in cache, with no search cost. // This material attempts to keep last request in cache, with no search cost.
@ -178,28 +183,36 @@ class TreeStyle_RDM: public RetroshareDirModel
Q_OBJECT Q_OBJECT
public: public:
TreeStyle_RDM(bool mode) TreeStyle_RDM(bool mode);
: RetroshareDirModel(mode)
{
}
virtual ~TreeStyle_RDM() ; virtual ~TreeStyle_RDM() ;
protected: protected:
virtual void updateRef(const QModelIndex&) const ;
//Overloaded from RetroshareDirModel
virtual void update() ; virtual void update() ;
virtual void updateRef(const QModelIndex&) const ;
/* These are all overloaded Virtual Functions */ virtual QMenu* getContextMenu(QMenu* contextMenu) ;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
virtual QVariant displayRole(const DirDetails&,int) const ; virtual QVariant displayRole(const DirDetails&,int) const ;
virtual QVariant sortRole(const QModelIndex&,const DirDetails&,int) const ; virtual QVariant sortRole(const QModelIndex&,const DirDetails&,int) const ;
//Overloaded from QAbstractItemModel
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const; virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
virtual QModelIndex parent ( const QModelIndex & index ) const; virtual QModelIndex parent ( const QModelIndex & index ) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const; virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
private slots:
void showEmpty(const bool value);
private:
QAction *_showEmptyAct;
bool _showEmpty;
protected:
mutable std::vector<int> _parentRow ; // used to store the real parent row for non empty child
}; };
// This class shows a flat list of all shared files // This class shows a flat list of all shared files
@ -212,9 +225,9 @@ class FlatStyle_RDM: public RetroshareDirModel
public: public:
FlatStyle_RDM(bool mode); FlatStyle_RDM(bool mode);
virtual ~FlatStyle_RDM() ; virtual ~FlatStyle_RDM() ;
//Overloaded from RetroshareDirModel
virtual void update() ; virtual void update() ;
bool isMaxRefsTableSize(size_t* maxSize = NULL); bool isMaxRefsTableSize(size_t* maxSize = NULL);
@ -223,20 +236,23 @@ class FlatStyle_RDM: public RetroshareDirModel
void updateRefs() ; void updateRefs() ;
protected: protected:
//Overloaded from RetroshareDirModel
virtual void postMods();/* Callback from Core */
virtual void updateRef(const QModelIndex&) const {} virtual void updateRef(const QModelIndex&) const {}
virtual void postMods();
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
virtual QVariant displayRole(const DirDetails&,int) const ; virtual QVariant displayRole(const DirDetails&,int) const ;
virtual QVariant sortRole(const QModelIndex&,const DirDetails&,int) const ; virtual QVariant sortRole(const QModelIndex&,const DirDetails&,int) const ;
//Overloaded from QAbstractItemModel
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const; virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
virtual QModelIndex parent ( const QModelIndex & index ) const; virtual QModelIndex parent ( const QModelIndex & index ) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const; virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
QString computeDirectoryPath(const DirDetails& details) const ; QString computeDirectoryPath(const DirDetails& details) const ;
mutable RsMutex _ref_mutex ; mutable RsMutex _ref_mutex ;