mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
- implemented an optional flat view for shared files that allows sorting by date/peer/name
- restored the search for flat view only (very slow for tree view) - cleaned the code a bit: made two subclasses of RetroshareDirModel: TreeStyle_RDM and FlatStyle_RDM git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4117 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c22a0c79e7
commit
f634331442
File diff suppressed because it is too large
Load Diff
@ -34,33 +34,21 @@ static const uint32_t IND_LAST_WEEK = 3600*24*7 ;
|
|||||||
static const uint32_t IND_LAST_MONTH = 3600*24*31 ; // I know, this is approximate
|
static const uint32_t IND_LAST_MONTH = 3600*24*31 ; // I know, this is approximate
|
||||||
static const uint32_t IND_ALWAYS = ~(uint32_t)0 ;
|
static const uint32_t IND_ALWAYS = ~(uint32_t)0 ;
|
||||||
|
|
||||||
class RemoteDirModel : public QAbstractItemModel
|
class RetroshareDirModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Roles{ FileNameRole = Qt::UserRole+1, SortRole = Qt::UserRole+2 };
|
enum Roles{ FileNameRole = Qt::UserRole+1, SortRole = Qt::UserRole+2 };
|
||||||
|
|
||||||
RemoteDirModel(bool mode, QObject *parent = 0);
|
RetroshareDirModel(bool mode, QObject *parent = 0);
|
||||||
|
virtual ~RetroshareDirModel() {}
|
||||||
/* These are all overloaded Virtual Functions */
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
|
||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
|
||||||
int role = Qt::DisplayRole) const;
|
|
||||||
|
|
||||||
QModelIndex index(int row, int column,
|
|
||||||
const QModelIndex & parent = QModelIndex() ) const;
|
|
||||||
QModelIndex parent ( const QModelIndex & index ) const;
|
|
||||||
|
|
||||||
Qt::ItemFlags flags ( const QModelIndex & index ) const;
|
Qt::ItemFlags flags ( const QModelIndex & index ) const;
|
||||||
bool hasChildren(const QModelIndex & parent = QModelIndex()) const;
|
|
||||||
|
|
||||||
/* Callback from Core */
|
/* Callback from Core */
|
||||||
void preMods();
|
virtual void preMods();
|
||||||
void postMods();
|
virtual void postMods();
|
||||||
|
|
||||||
/* Callback from GUI */
|
/* Callback from GUI */
|
||||||
void downloadSelected(const QModelIndexList &list);
|
void downloadSelected(const QModelIndexList &list);
|
||||||
@ -68,36 +56,29 @@ class RemoteDirModel : public QAbstractItemModel
|
|||||||
void getDirDetailsFromSelect (const QModelIndexList &list, std::vector <DirDetails>& dirVec);
|
void getDirDetailsFromSelect (const QModelIndexList &list, std::vector <DirDetails>& dirVec);
|
||||||
|
|
||||||
int getType ( const QModelIndex & index ) const ;
|
int getType ( const QModelIndex & index ) const ;
|
||||||
//void openFile(QModelIndex fileIndex, const QString command);
|
|
||||||
|
|
||||||
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
|
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
|
||||||
|
|
||||||
void openSelected(const QModelIndexList &list);
|
void openSelected(const QModelIndexList &list);
|
||||||
|
|
||||||
void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
|
void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
|
||||||
|
|
||||||
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
|
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
// void collapsed ( const QModelIndex & index ) { update(index); }
|
|
||||||
// void expanded ( const QModelIndex & index ) { update(index); }
|
|
||||||
|
|
||||||
/* Drag and Drop Functionality */
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
|
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
|
||||||
virtual QStringList mimeTypes () const;
|
virtual QStringList mimeTypes () const;
|
||||||
|
virtual QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
// void update (const QModelIndex &index );
|
|
||||||
void treeStyle();
|
void treeStyle();
|
||||||
void downloadDirectory(const DirDetails & details, int prefixLen);
|
void downloadDirectory(const DirDetails & details, int prefixLen);
|
||||||
static QString getFlagsString(uint32_t) ;
|
static QString getFlagsString(uint32_t) ;
|
||||||
QString getAgeIndicatorString(const DirDetails &) const;
|
QString getAgeIndicatorString(const DirDetails &) const;
|
||||||
void getAgeIndicatorRec(DirDetails &details, QString &ret) const;
|
void getAgeIndicatorRec(DirDetails &details, QString &ret) const;
|
||||||
|
|
||||||
|
virtual QVariant displayRole(const DirDetails&,int) const = 0 ;
|
||||||
|
|
||||||
|
QVariant decorationRole(const DirDetails&,int) const ;
|
||||||
|
QVariant sortRole(const DirDetails&,int) const ;
|
||||||
|
|
||||||
uint32_t ageIndicator;
|
uint32_t ageIndicator;
|
||||||
|
|
||||||
QIcon categoryIcon;
|
QIcon categoryIcon;
|
||||||
@ -146,4 +127,62 @@ class RemoteDirModel : public QAbstractItemModel
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This class shows the classical hierarchical directory view of shared files
|
||||||
|
// Columns are:
|
||||||
|
// file name | Size | Age
|
||||||
|
//
|
||||||
|
class TreeStyle_RDM: public RetroshareDirModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TreeStyle_RDM(bool mode)
|
||||||
|
: RetroshareDirModel(mode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~TreeStyle_RDM() ;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/* 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 QVariant displayRole(const DirDetails&,int) const ;
|
||||||
|
|
||||||
|
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
|
||||||
|
virtual QModelIndex parent ( const QModelIndex & index ) const;
|
||||||
|
virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
// This class shows a flat list of all shared files
|
||||||
|
// Columns are:
|
||||||
|
// file name | Owner | Size | Age
|
||||||
|
//
|
||||||
|
class FlatStyle_RDM: public RetroshareDirModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FlatStyle_RDM(bool mode)
|
||||||
|
: RetroshareDirModel(mode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~FlatStyle_RDM() ;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
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 QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
|
||||||
|
virtual QModelIndex parent ( const QModelIndex & index ) const;
|
||||||
|
virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const;
|
||||||
|
|
||||||
|
std::vector<void *> _ref_entries ;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,7 +60,7 @@ const QString Image_AddNewAssotiationForFile = ":/images/kcmsystem24.png";
|
|||||||
class SFDSortFilterProxyModel : public QSortFilterProxyModel
|
class SFDSortFilterProxyModel : public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SFDSortFilterProxyModel(RemoteDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent)
|
SFDSortFilterProxyModel(RetroshareDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
m_dirModel = dirModel;
|
m_dirModel = dirModel;
|
||||||
};
|
};
|
||||||
@ -79,7 +79,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RemoteDirModel *m_dirModel;
|
RetroshareDirModel *m_dirModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
@ -89,13 +89,11 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
|||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck()));
|
connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck()));
|
||||||
|
|
||||||
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)));
|
||||||
|
connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int)));
|
||||||
|
|
||||||
connect( ui.localDirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( sharedDirTreeWidgetContextMenu( QPoint ) ) );
|
connect( ui.localDirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( sharedDirTreeWidgetContextMenu( QPoint ) ) );
|
||||||
connect( ui.remoteDirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( shareddirtreeviewCostumPopupMenu( QPoint ) ) );
|
connect( ui.remoteDirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( shareddirtreeviewCostumPopupMenu( QPoint ) ) );
|
||||||
@ -114,35 +112,34 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
model = new RemoteDirModel(true);
|
tree_model = new TreeStyle_RDM(true);
|
||||||
|
flat_model = new FlatStyle_RDM(true);
|
||||||
|
|
||||||
proxyModel = new SFDSortFilterProxyModel(model, this);
|
tree_proxyModel = new SFDSortFilterProxyModel(tree_model, this);
|
||||||
proxyModel->setDynamicSortFilter(true);
|
tree_proxyModel->setDynamicSortFilter(true);
|
||||||
proxyModel->setSourceModel(model);
|
tree_proxyModel->setSourceModel(tree_model);
|
||||||
proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
proxyModel->setSortRole(RemoteDirModel::SortRole);
|
tree_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||||
proxyModel->sort(0);
|
tree_proxyModel->sort(0);
|
||||||
|
|
||||||
ui.remoteDirTreeView->setModel(proxyModel);
|
flat_proxyModel = new SFDSortFilterProxyModel(flat_model, this);
|
||||||
|
flat_proxyModel->setDynamicSortFilter(true);
|
||||||
|
flat_proxyModel->setSourceModel(flat_model);
|
||||||
|
flat_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
flat_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||||
|
flat_proxyModel->sort(0);
|
||||||
|
|
||||||
localModel = new RemoteDirModel(false);
|
localModel = new TreeStyle_RDM(false);
|
||||||
|
|
||||||
localProxyModel = new SFDSortFilterProxyModel(localModel, this);
|
localProxyModel = new SFDSortFilterProxyModel(localModel, this);
|
||||||
localProxyModel->setDynamicSortFilter(true);
|
localProxyModel->setDynamicSortFilter(true);
|
||||||
localProxyModel->setSourceModel(localModel);
|
localProxyModel->setSourceModel(localModel);
|
||||||
localProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
localProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
localProxyModel->setSortRole(RemoteDirModel::SortRole);
|
localProxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||||
localProxyModel->sort(0);
|
localProxyModel->sort(0);
|
||||||
|
|
||||||
ui.localDirTreeView->setModel(localProxyModel);
|
ui.localDirTreeView->setModel(localProxyModel);
|
||||||
|
|
||||||
ui.remoteDirTreeView->setColumnHidden(3,true) ;
|
|
||||||
ui.remoteDirTreeView->setColumnHidden(4,true) ;
|
|
||||||
ui.localDirTreeView->setColumnHidden(4,true) ;
|
|
||||||
|
|
||||||
connect( ui.remoteDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), model, SLOT( collapsed(const QModelIndex & ) ) );
|
|
||||||
connect( ui.remoteDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), model, SLOT( expanded(const QModelIndex & ) ) );
|
|
||||||
|
|
||||||
connect( ui.localDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), localModel, SLOT( collapsed(const QModelIndex & ) ) );
|
connect( ui.localDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), localModel, SLOT( collapsed(const QModelIndex & ) ) );
|
||||||
connect( ui.localDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), localModel, SLOT( expanded(const QModelIndex & ) ) );
|
connect( ui.localDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), localModel, SLOT( expanded(const QModelIndex & ) ) );
|
||||||
|
|
||||||
@ -154,6 +151,13 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
|||||||
connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter()));
|
connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter()));
|
||||||
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||||
|
|
||||||
|
// load settings
|
||||||
|
processSettings(true);
|
||||||
|
|
||||||
|
ui.remoteDirTreeView->setColumnHidden(3,false) ;
|
||||||
|
ui.remoteDirTreeView->setColumnHidden(4,true) ;
|
||||||
|
ui.localDirTreeView->setColumnHidden(4,true) ;
|
||||||
|
|
||||||
/* Set header resize modes and initial section sizes */
|
/* Set header resize modes and initial section sizes */
|
||||||
QHeaderView * l_header = ui.localDirTreeView->header () ;
|
QHeaderView * l_header = ui.localDirTreeView->header () ;
|
||||||
// l_header->setResizeMode (0, QHeaderView::Interactive);
|
// l_header->setResizeMode (0, QHeaderView::Interactive);
|
||||||
@ -173,6 +177,7 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
|||||||
|
|
||||||
r_header->setResizeMode (0, QHeaderView::Interactive);
|
r_header->setResizeMode (0, QHeaderView::Interactive);
|
||||||
r_header->setStretchLastSection(false);
|
r_header->setStretchLastSection(false);
|
||||||
|
l_header->setStretchLastSection(false);
|
||||||
|
|
||||||
// r_header->setResizeMode (1, QHeaderView::Fixed);
|
// r_header->setResizeMode (1, QHeaderView::Fixed);
|
||||||
// // r_header->setResizeMode (2, QHeaderView::Interactive);
|
// // r_header->setResizeMode (2, QHeaderView::Interactive);
|
||||||
@ -182,28 +187,30 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
|||||||
|
|
||||||
r_header->resizeSection ( 0, 490 );
|
r_header->resizeSection ( 0, 490 );
|
||||||
r_header->resizeSection ( 1, 70 );
|
r_header->resizeSection ( 1, 70 );
|
||||||
// r_header->resizeSection ( 2, 0 );
|
r_header->resizeSection ( 2, 80 );
|
||||||
r_header->resizeSection ( 3, 100 );
|
r_header->resizeSection ( 3, 100 );
|
||||||
// r_header->resizeSection ( 4, 0 );
|
r_header->resizeSection ( 4, 80 );
|
||||||
|
|
||||||
l_header->setHighlightSections(false);
|
// l_header->setHighlightSections(false);
|
||||||
r_header->setHighlightSections(false);
|
// r_header->setHighlightSections(false);
|
||||||
|
|
||||||
|
|
||||||
/* Set Multi Selection */
|
/* Set Multi Selection */
|
||||||
ui.remoteDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
ui.remoteDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
ui.localDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
ui.localDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
|
||||||
#ifdef RS_RELEASE_VERSION
|
//#ifdef RS_RELEASE_VERSION
|
||||||
ui.filterLabel->hide();
|
// ui.filterLabel->hide();
|
||||||
ui.filterPatternLineEdit->hide();
|
// ui.filterPatternLineEdit->hide();
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
|
// Setup the current view model.
|
||||||
|
//
|
||||||
|
changeCurrentViewModel(ui.viewType_CB->currentIndex()) ;
|
||||||
|
|
||||||
ui.filterStartButton->hide();
|
ui.filterStartButton->hide();
|
||||||
ui.filterClearButton->hide();
|
ui.filterClearButton->hide();
|
||||||
|
|
||||||
// load settings
|
|
||||||
processSettings(true);
|
|
||||||
|
|
||||||
/* Hide platform specific features */
|
/* Hide platform specific features */
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
|
|
||||||
@ -261,6 +268,43 @@ void SharedFilesDialog::processSettings(bool bLoad)
|
|||||||
Settings->endGroup();
|
Settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SharedFilesDialog::changeCurrentViewModel(int c)
|
||||||
|
{
|
||||||
|
disconnect( ui.remoteDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), 0, 0 );
|
||||||
|
disconnect( ui.remoteDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), 0, 0 );
|
||||||
|
|
||||||
|
if(c == 0)
|
||||||
|
{
|
||||||
|
model = tree_model ;
|
||||||
|
proxyModel = tree_proxyModel ;
|
||||||
|
ui.remoteDirTreeView->setColumnHidden(3,true) ;
|
||||||
|
ui.filterLabel->hide();
|
||||||
|
ui.filterPatternLineEdit->hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model = flat_model ;
|
||||||
|
proxyModel = flat_proxyModel ;
|
||||||
|
ui.remoteDirTreeView->setColumnHidden(3,false) ;
|
||||||
|
ui.filterLabel->show();
|
||||||
|
ui.filterPatternLineEdit->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
model->preMods();
|
||||||
|
model->postMods();
|
||||||
|
|
||||||
|
connect( ui.remoteDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), model, SLOT( collapsed(const QModelIndex & ) ) );
|
||||||
|
connect( ui.remoteDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), model, SLOT( expanded(const QModelIndex & ) ) );
|
||||||
|
|
||||||
|
ui.remoteDirTreeView->setModel(proxyModel);
|
||||||
|
ui.remoteDirTreeView->update();
|
||||||
|
|
||||||
|
ui.remoteDirTreeView->header()->headerDataChanged(Qt::Horizontal,0,4) ;
|
||||||
|
|
||||||
|
if(c == 1)
|
||||||
|
FilterItems();
|
||||||
|
}
|
||||||
|
|
||||||
void SharedFilesDialog::checkUpdate()
|
void SharedFilesDialog::checkUpdate()
|
||||||
{
|
{
|
||||||
/* update */
|
/* update */
|
||||||
@ -667,7 +711,7 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
|
|||||||
if (!midx.isValid())
|
if (!midx.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
currentFile = localModel->data(midx, RemoteDirModel::FileNameRole).toString();
|
currentFile = localModel->data(midx, RetroshareDirModel::FileNameRole).toString();
|
||||||
|
|
||||||
int type = localModel->getType(midx);
|
int type = localModel->getType(midx);
|
||||||
|
|
||||||
@ -873,24 +917,40 @@ void SharedFilesDialog::FilterItems()
|
|||||||
QString text = ui.filterPatternLineEdit->text();
|
QString text = ui.filterPatternLineEdit->text();
|
||||||
|
|
||||||
setCursor(Qt::WaitCursor);
|
setCursor(Qt::WaitCursor);
|
||||||
|
QCoreApplication::processEvents() ;
|
||||||
|
|
||||||
int rowCount = ui.remoteDirTreeView->model()->rowCount();
|
int rowCount = ui.remoteDirTreeView->model()->rowCount();
|
||||||
for (int row = 0; row < rowCount; row++) {
|
for (int row = 0; row < rowCount; row++)
|
||||||
/* Filter name */
|
if(proxyModel == tree_proxyModel)
|
||||||
FilterItem(ui.remoteDirTreeView->model()->index(row, 0), text, 0);
|
tree_FilterItem(ui.remoteDirTreeView->model()->index(row, 0), text, 0);
|
||||||
}
|
else
|
||||||
|
flat_FilterItem(ui.remoteDirTreeView->model()->index(row, 0), text, 0);
|
||||||
|
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharedFilesDialog::FilterItem(const QModelIndex &index, const QString &text, int level)
|
bool SharedFilesDialog::flat_FilterItem(const QModelIndex &index, const QString &text, int level)
|
||||||
|
{
|
||||||
|
if(index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive))
|
||||||
|
{
|
||||||
|
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), false);
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), true);
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString &text, int level)
|
||||||
{
|
{
|
||||||
bool visible = true;
|
bool visible = true;
|
||||||
|
|
||||||
if (text.isEmpty() == false) {
|
if (text.isEmpty() == false) {
|
||||||
// better use RemoteDirModel::getType, but its slow enough
|
// better use RetroshareDirModel::getType, but its slow enough
|
||||||
if (/*index.parent().isValid()*/ level >= 1) {
|
if (/*index.parent().isValid()*/ level >= 1) {
|
||||||
if (index.data(RemoteDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive) == false) {
|
if (index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive) == false) {
|
||||||
visible = false;
|
visible = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -901,7 +961,7 @@ bool SharedFilesDialog::FilterItem(const QModelIndex &index, const QString &text
|
|||||||
int visibleChildCount = 0;
|
int visibleChildCount = 0;
|
||||||
int rowCount = ui.remoteDirTreeView->model()->rowCount(index);
|
int rowCount = ui.remoteDirTreeView->model()->rowCount(index);
|
||||||
for (int row = 0; row < rowCount; row++) {
|
for (int row = 0; row < rowCount; row++) {
|
||||||
if (FilterItem(ui.remoteDirTreeView->model()->index(row, index.column(), index), text, level + 1)) {
|
if (tree_FilterItem(ui.remoteDirTreeView->model()->index(row, index.column(), index), text, level + 1)) {
|
||||||
visibleChildCount++;
|
visibleChildCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -914,3 +974,4 @@ bool SharedFilesDialog::FilterItem(const QModelIndex &index, const QString &text
|
|||||||
|
|
||||||
return (visible || visibleChildCount);
|
return (visible || visibleChildCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "RsAutoUpdatePage.h"
|
#include "RsAutoUpdatePage.h"
|
||||||
#include "ui_SharedFilesDialog.h"
|
#include "ui_SharedFilesDialog.h"
|
||||||
|
|
||||||
class RemoteDirModel;
|
class RetroshareDirModel;
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
|
|
||||||
class SharedFilesDialog : public RsAutoUpdatePage
|
class SharedFilesDialog : public RsAutoUpdatePage
|
||||||
@ -87,6 +87,8 @@ private slots:
|
|||||||
void clearFilter();
|
void clearFilter();
|
||||||
void startFilter();
|
void startFilter();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void changeCurrentViewModel(int) ;
|
||||||
signals:
|
signals:
|
||||||
void playFiles(QStringList files);
|
void playFiles(QStringList files);
|
||||||
|
|
||||||
@ -103,7 +105,8 @@ private:
|
|||||||
void copyLink (const QModelIndexList& lst, bool remote);
|
void copyLink (const QModelIndexList& lst, bool remote);
|
||||||
|
|
||||||
void FilterItems();
|
void FilterItems();
|
||||||
bool FilterItem(const QModelIndex &index, const QString &text, int level);
|
bool tree_FilterItem(const QModelIndex &index, const QString &text, int level);
|
||||||
|
bool flat_FilterItem(const QModelIndex &index, const QString &text, int level);
|
||||||
|
|
||||||
QModelIndexList getRemoteSelected();
|
QModelIndexList getRemoteSelected();
|
||||||
QModelIndexList getLocalSelected();
|
QModelIndexList getLocalSelected();
|
||||||
@ -125,10 +128,15 @@ private:
|
|||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::SharedFilesDialog ui;
|
Ui::SharedFilesDialog ui;
|
||||||
|
|
||||||
/* RemoteDirModel */
|
/* RetroshareDirModel */
|
||||||
RemoteDirModel *model;
|
RetroshareDirModel *tree_model;
|
||||||
|
RetroshareDirModel *flat_model;
|
||||||
|
RetroshareDirModel *model;
|
||||||
|
QSortFilterProxyModel *tree_proxyModel;
|
||||||
|
QSortFilterProxyModel *flat_proxyModel;
|
||||||
QSortFilterProxyModel *proxyModel;
|
QSortFilterProxyModel *proxyModel;
|
||||||
RemoteDirModel *localModel;
|
|
||||||
|
RetroshareDirModel *localModel;
|
||||||
QSortFilterProxyModel *localProxyModel;
|
QSortFilterProxyModel *localProxyModel;
|
||||||
|
|
||||||
QString currentCommand;
|
QString currentCommand;
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>525</width>
|
<width>934</width>
|
||||||
<height>297</height>
|
<height>402</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -584,7 +584,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="5">
|
<item row="0" column="6">
|
||||||
<widget class="QPushButton" name="splittedButton">
|
<widget class="QPushButton" name="splittedButton">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
@ -616,7 +616,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="6">
|
<item row="0" column="7">
|
||||||
<widget class="QPushButton" name="remoteButton">
|
<widget class="QPushButton" name="remoteButton">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
@ -648,7 +648,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="7">
|
<item row="0" column="8">
|
||||||
<widget class="QPushButton" name="localButton">
|
<widget class="QPushButton" name="localButton">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
@ -680,7 +680,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4">
|
<item row="0" column="5">
|
||||||
<widget class="QComboBox" name="indicatorCBox">
|
<widget class="QComboBox" name="indicatorCBox">
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -823,6 +823,20 @@ border-image: url(:/images/closepressed.png)
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QComboBox" name="viewType_CB">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Tree view</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Flat view</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -878,6 +892,12 @@ background: white;}</string>
|
|||||||
<property name="sortingEnabled">
|
<property name="sortingEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<attribute name="headerStretchLastSection">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="headerStretchLastSection">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -926,6 +946,12 @@ background: white;}</string>
|
|||||||
<property name="sortingEnabled">
|
<property name="sortingEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<attribute name="headerStretchLastSection">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="headerStretchLastSection">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user