mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-11 15:50:38 -04:00
Add ShowEmpty sub menu in Tree Remote SharedFilesDialog.
This commit is contained in:
parent
593e57b14c
commit
a89ab8ffa3
4 changed files with 263 additions and 191 deletions
|
@ -25,7 +25,9 @@
|
|||
#include <retroshare/rstypes.h>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAction>
|
||||
#include <QIcon>
|
||||
#include <QMenu>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
@ -63,7 +65,7 @@ class RetroshareDirModel : public QAbstractItemModel
|
|||
RetroshareDirModel(bool mode, QObject *parent = 0);
|
||||
virtual ~RetroshareDirModel() {}
|
||||
|
||||
Qt::ItemFlags flags ( const QModelIndex & index ) const;
|
||||
virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
|
||||
|
||||
/* Callback from Core */
|
||||
virtual void preMods();
|
||||
|
@ -82,18 +84,21 @@ class RetroshareDirModel : public QAbstractItemModel
|
|||
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
|
||||
void openSelected(const QModelIndexList &list);
|
||||
void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
|
||||
void getFilePath(const QModelIndex& index, std::string& fullpath);
|
||||
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
|
||||
void getFilePath(const QModelIndex& index, std::string& fullpath);
|
||||
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 updateRef(const QModelIndex&) const =0;
|
||||
|
||||
virtual void updateRef(const QModelIndex&) const =0;
|
||||
virtual QMenu* getContextMenu(QMenu* contextMenu) {return contextMenu;}
|
||||
|
||||
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 QVariant data(const QModelIndex &index, int role) const;
|
||||
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
|
||||
virtual Qt::DropActions supportedDragActions() const;
|
||||
#endif
|
||||
|
@ -104,10 +109,10 @@ class RetroshareDirModel : public QAbstractItemModel
|
|||
void treeStyle();
|
||||
void downloadDirectory(const DirDetails & details, int prefixLen);
|
||||
static QString getFlagsString(FileStorageFlags f) ;
|
||||
static QString getGroupsString(FileStorageFlags flags, const std::list<RsNodeGroupId> &) ;
|
||||
static QString getGroupsString(FileStorageFlags flags, const std::list<RsNodeGroupId> &) ;
|
||||
QString getAgeIndicatorString(const DirDetails &) const;
|
||||
// void getAgeIndicatorRec(const DirDetails &details, QString &ret) const;
|
||||
static const QIcon& getFlagsIcon(FileStorageFlags flags) ;
|
||||
static const QIcon& getFlagsIcon(FileStorageFlags flags) ;
|
||||
|
||||
virtual QVariant displayRole(const DirDetails&,int) const = 0 ;
|
||||
virtual QVariant sortRole(const QModelIndex&,const DirDetails&,int) const =0;
|
||||
|
@ -119,46 +124,46 @@ class RetroshareDirModel : public QAbstractItemModel
|
|||
QIcon categoryIcon;
|
||||
QIcon peerIcon;
|
||||
|
||||
class RemoteIndex
|
||||
{
|
||||
public:
|
||||
RemoteIndex() {}
|
||||
RemoteIndex(std::string in_person,
|
||||
std::string in_path,
|
||||
int in_idx,
|
||||
int in_row,
|
||||
int in_column,
|
||||
std::string in_name,
|
||||
int in_size,
|
||||
int in_type,
|
||||
int in_ts, int in_rank)
|
||||
:id(in_person), path(in_path), parent(in_idx),
|
||||
row(in_row), column(in_column),
|
||||
name(in_name), size(in_size),
|
||||
type(in_type), timestamp(in_ts), rank(in_rank)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::string id;
|
||||
std::string path;
|
||||
int parent;
|
||||
int row;
|
||||
int column;
|
||||
|
||||
/* display info */
|
||||
std::string name;
|
||||
int size;
|
||||
int type;
|
||||
int timestamp;
|
||||
int rank;
|
||||
|
||||
};
|
||||
//class RemoteIndex
|
||||
//{
|
||||
// public:
|
||||
// RemoteIndex() {}
|
||||
// RemoteIndex(std::string in_person,
|
||||
// std::string in_path,
|
||||
// int in_idx,
|
||||
// int in_row,
|
||||
// int in_column,
|
||||
// std::string in_name,
|
||||
// int in_size,
|
||||
// int in_type,
|
||||
// int in_ts, int in_rank)
|
||||
// :id(in_person), path(in_path), parent(in_idx),
|
||||
// row(in_row), column(in_column),
|
||||
// name(in_name), size(in_size),
|
||||
// type(in_type), timestamp(in_ts), rank(in_rank)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// std::string id;
|
||||
// std::string path;
|
||||
// int parent;
|
||||
// int row;
|
||||
// int column;
|
||||
//
|
||||
// /* display info */
|
||||
// std::string name;
|
||||
// int size;
|
||||
// int type;
|
||||
// int timestamp;
|
||||
// int rank;
|
||||
//
|
||||
//};
|
||||
|
||||
bool RemoteMode;
|
||||
|
||||
mutable int nIndex;
|
||||
mutable std::vector<RemoteIndex> indexSet;
|
||||
//mutable int nIndex;
|
||||
//mutable std::vector<RemoteIndex> indexSet;
|
||||
|
||||
// This material attempts to keep last request in cache, with no search cost.
|
||||
|
||||
|
@ -178,28 +183,36 @@ class TreeStyle_RDM: public RetroshareDirModel
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TreeStyle_RDM(bool mode)
|
||||
: RetroshareDirModel(mode)
|
||||
{
|
||||
}
|
||||
|
||||
TreeStyle_RDM(bool mode);
|
||||
virtual ~TreeStyle_RDM() ;
|
||||
|
||||
protected:
|
||||
virtual void updateRef(const QModelIndex&) const ;
|
||||
|
||||
//Overloaded from RetroshareDirModel
|
||||
virtual void update() ;
|
||||
|
||||
/* These are all overloaded Virtual Functions */
|
||||
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 void updateRef(const QModelIndex&) const ;
|
||||
virtual QMenu* getContextMenu(QMenu* contextMenu) ;
|
||||
virtual QVariant displayRole(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 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 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
|
||||
|
@ -212,9 +225,9 @@ class FlatStyle_RDM: public RetroshareDirModel
|
|||
|
||||
public:
|
||||
FlatStyle_RDM(bool mode);
|
||||
|
||||
virtual ~FlatStyle_RDM() ;
|
||||
|
||||
//Overloaded from RetroshareDirModel
|
||||
virtual void update() ;
|
||||
|
||||
bool isMaxRefsTableSize(size_t* maxSize = NULL);
|
||||
|
@ -223,27 +236,30 @@ class FlatStyle_RDM: public RetroshareDirModel
|
|||
void updateRefs() ;
|
||||
|
||||
protected:
|
||||
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;
|
||||
//Overloaded from RetroshareDirModel
|
||||
virtual void postMods();/* Callback from Core */
|
||||
virtual void updateRef(const QModelIndex&) const {}
|
||||
virtual QVariant displayRole(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 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 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
|
||||
|
||||
QString computeDirectoryPath(const DirDetails& details) const ;
|
||||
|
||||
mutable RsMutex _ref_mutex ;
|
||||
std::vector<void *> _ref_entries ;// used to store the refs to display
|
||||
std::vector<void *> _ref_stack ; // used to store the refs to update
|
||||
mutable RsMutex _ref_mutex ;
|
||||
std::vector<void *> _ref_entries ; // used to store the refs to display
|
||||
std::vector<void *> _ref_stack ; // used to store the refs to update
|
||||
bool _needs_update ;
|
||||
time_t _last_update ;
|
||||
time_t _last_update ;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue