mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-01 09:36:46 -04:00
Added filter for files in SharedFilesDialog.
It is hidden for the release version (RS_RELEASE_VERSION), because the RemoteDirModel is slow with many files. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3882 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
73f22ad897
commit
bd319d2357
5 changed files with 1122 additions and 905 deletions
|
@ -149,6 +149,11 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
||||||
connect( localModel, SIGNAL( layoutAboutToBeChanged() ), ui.localDirTreeView, SLOT( reset() ) );
|
connect( localModel, SIGNAL( layoutAboutToBeChanged() ), ui.localDirTreeView, SLOT( reset() ) );
|
||||||
connect( localModel, SIGNAL( layoutChanged() ), ui.localDirTreeView, SLOT( update() ) );
|
connect( localModel, SIGNAL( layoutChanged() ), ui.localDirTreeView, SLOT( update() ) );
|
||||||
|
|
||||||
|
connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||||
|
connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter()));
|
||||||
|
connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter()));
|
||||||
|
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||||
|
|
||||||
/* 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);
|
||||||
|
@ -189,6 +194,13 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
||||||
ui.remoteDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
ui.remoteDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
ui.localDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
ui.localDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
|
||||||
|
#ifdef RS_RELEASE_VERSION
|
||||||
|
ui.filterLabel->hide();
|
||||||
|
ui.filterPatternLineEdit->hide();
|
||||||
|
#endif
|
||||||
|
ui.filterStartButton->hide();
|
||||||
|
ui.filterClearButton->hide();
|
||||||
|
|
||||||
// load settings
|
// load settings
|
||||||
processSettings(true);
|
processSettings(true);
|
||||||
|
|
||||||
|
@ -631,6 +643,10 @@ void SharedFilesDialog::postModDirectories(bool update_local)
|
||||||
{
|
{
|
||||||
model->postMods();
|
model->postMods();
|
||||||
ui.remoteDirTreeView->update() ;
|
ui.remoteDirTreeView->update() ;
|
||||||
|
|
||||||
|
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
||||||
|
FilterItems();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QCoreApplication::flush();
|
QCoreApplication::flush();
|
||||||
|
@ -817,3 +833,84 @@ void SharedFilesDialog::indicatorChanged(int index)
|
||||||
updateDisplay() ;
|
updateDisplay() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SharedFilesDialog::filterRegExpChanged()
|
||||||
|
{
|
||||||
|
QString text = ui.filterPatternLineEdit->text();
|
||||||
|
|
||||||
|
if (text.isEmpty()) {
|
||||||
|
ui.filterClearButton->hide();
|
||||||
|
} else {
|
||||||
|
ui.filterClearButton->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text == lastFilterString) {
|
||||||
|
ui.filterStartButton->hide();
|
||||||
|
} else {
|
||||||
|
ui.filterStartButton->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clear Filter */
|
||||||
|
void SharedFilesDialog::clearFilter()
|
||||||
|
{
|
||||||
|
ui.filterPatternLineEdit->clear();
|
||||||
|
ui.filterPatternLineEdit->setFocus();
|
||||||
|
|
||||||
|
startFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clear Filter */
|
||||||
|
void SharedFilesDialog::startFilter()
|
||||||
|
{
|
||||||
|
ui.filterStartButton->hide();
|
||||||
|
lastFilterString = ui.filterPatternLineEdit->text();
|
||||||
|
|
||||||
|
FilterItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SharedFilesDialog::FilterItems()
|
||||||
|
{
|
||||||
|
QString text = ui.filterPatternLineEdit->text();
|
||||||
|
|
||||||
|
setCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
|
int rowCount = ui.remoteDirTreeView->model()->rowCount();
|
||||||
|
for (int row = 0; row < rowCount; row++) {
|
||||||
|
/* Filter name */
|
||||||
|
FilterItem(ui.remoteDirTreeView->model()->index(row, 0), text, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SharedFilesDialog::FilterItem(const QModelIndex &index, const QString &text, int level)
|
||||||
|
{
|
||||||
|
bool visible = true;
|
||||||
|
|
||||||
|
if (text.isEmpty() == false) {
|
||||||
|
// better use RemoteDirModel::getType, but its slow enough
|
||||||
|
if (/*index.parent().isValid()*/ level >= 1) {
|
||||||
|
if (index.data(RemoteDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive) == false) {
|
||||||
|
visible = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int visibleChildCount = 0;
|
||||||
|
int rowCount = ui.remoteDirTreeView->model()->rowCount(index);
|
||||||
|
for (int row = 0; row < rowCount; row++) {
|
||||||
|
if (FilterItem(ui.remoteDirTreeView->model()->index(row, index.column(), index), text, level + 1)) {
|
||||||
|
visibleChildCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visible || visibleChildCount) {
|
||||||
|
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), false);
|
||||||
|
} else {
|
||||||
|
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (visible || visibleChildCount);
|
||||||
|
}
|
||||||
|
|
|
@ -83,6 +83,10 @@ private slots:
|
||||||
|
|
||||||
void indicatorChanged(int index);
|
void indicatorChanged(int index);
|
||||||
|
|
||||||
|
void filterRegExpChanged();
|
||||||
|
void clearFilter();
|
||||||
|
void startFilter();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void playFiles(QStringList files);
|
void playFiles(QStringList files);
|
||||||
|
|
||||||
|
@ -96,7 +100,10 @@ private:
|
||||||
|
|
||||||
void processSettings(bool bLoad);
|
void processSettings(bool bLoad);
|
||||||
|
|
||||||
void copyLink (const QModelIndexList& lst, bool remote);
|
void copyLink (const QModelIndexList& lst, bool remote);
|
||||||
|
|
||||||
|
void FilterItems();
|
||||||
|
bool FilterItem(const QModelIndex &index, const QString &text, int level);
|
||||||
|
|
||||||
QModelIndexList getRemoteSelected();
|
QModelIndexList getRemoteSelected();
|
||||||
QModelIndexList getLocalSelected();
|
QModelIndexList getLocalSelected();
|
||||||
|
@ -115,7 +122,6 @@ private:
|
||||||
QAction* sendchatlinkAct;
|
QAction* sendchatlinkAct;
|
||||||
QAction* copylinklocalhtmlAct;
|
QAction* copylinklocalhtmlAct;
|
||||||
|
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::SharedFilesDialog ui;
|
Ui::SharedFilesDialog ui;
|
||||||
|
|
||||||
|
@ -128,6 +134,8 @@ private:
|
||||||
QString currentCommand;
|
QString currentCommand;
|
||||||
QString currentFile;
|
QString currentFile;
|
||||||
|
|
||||||
|
QString lastFilterString;
|
||||||
|
|
||||||
QAction* fileAssotiationAction(const QString fileName);
|
QAction* fileAssotiationAction(const QString fileName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
@ -2290,7 +2290,7 @@ p, li { white-space: pre-wrap; }
|
||||||
<translation>Zusätzlich eine Datei hinzufügen</translation>
|
<translation>Zusätzlich eine Datei hinzufügen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+26"/>
|
<location line="+29"/>
|
||||||
<location line="+202"/>
|
<location line="+202"/>
|
||||||
<source>RetroShare</source>
|
<source>RetroShare</source>
|
||||||
<translation></translation>
|
<translation></translation>
|
||||||
|
@ -8329,7 +8329,7 @@ Do you want to send them a Message instead</source>
|
||||||
<context>
|
<context>
|
||||||
<name>ProfileView</name>
|
<name>ProfileView</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/profile/ProfileView.cpp" line="+72"/>
|
<location filename="../gui/profile/ProfileView.cpp" line="+70"/>
|
||||||
<source>Clear Photo</source>
|
<source>Clear Photo</source>
|
||||||
<translation>Photo entfernen</translation>
|
<translation>Photo entfernen</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -9981,13 +9981,13 @@ p, li { white-space: pre-wrap; }
|
||||||
<context>
|
<context>
|
||||||
<name>SharedFilesDialog</name>
|
<name>SharedFilesDialog</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/SharedFilesDialog.ui" line="+846"/>
|
<location filename="../gui/SharedFilesDialog.ui" line="+943"/>
|
||||||
<location filename="../gui/SharedFilesDialog.cpp" line="+293"/>
|
<location filename="../gui/SharedFilesDialog.cpp" line="+305"/>
|
||||||
<source>Download</source>
|
<source>Download</source>
|
||||||
<translation>Herunterladen</translation>
|
<translation>Herunterladen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="-250"/>
|
<location line="-347"/>
|
||||||
<source>Splitted View</source>
|
<source>Splitted View</source>
|
||||||
<translation>Geteiltes Fenster</translation>
|
<translation>Geteiltes Fenster</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -10035,28 +10035,43 @@ p, li { white-space: pre-wrap; }
|
||||||
<translation>Einen Monat alt</translation>
|
<translation>Einen Monat alt</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+165"/>
|
<location line="+27"/>
|
||||||
|
<source>Search files</source>
|
||||||
|
<translation>Suche Dateien</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+24"/>
|
||||||
|
<source>Start Search</source>
|
||||||
|
<translation>Starte Suche</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+31"/>
|
||||||
|
<source>Reset</source>
|
||||||
|
<translation>Zurücksetzen</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+180"/>
|
||||||
<source>check files</source>
|
<source>check files</source>
|
||||||
<translation>Prüfe Dateien</translation>
|
<translation>Prüfe Dateien</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/SharedFilesDialog.cpp" line="-80"/>
|
<location filename="../gui/SharedFilesDialog.cpp" line="-80"/>
|
||||||
<location line="+492"/>
|
<location line="+496"/>
|
||||||
<source>Open File</source>
|
<source>Open File</source>
|
||||||
<translation>Datei öffnen</translation>
|
<translation>Datei öffnen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="-490"/>
|
<location line="-494"/>
|
||||||
<source>Open Folder</source>
|
<source>Open Folder</source>
|
||||||
<translation>Ordner öffnen</translation>
|
<translation>Ordner öffnen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+499"/>
|
<location line="+503"/>
|
||||||
<source>Set command for opening this file</source>
|
<source>Set command for opening this file</source>
|
||||||
<translation>Setze eine Regel zum Öffnen dieser Datei</translation>
|
<translation>Setze eine Regel zum Öffnen dieser Datei</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="-416"/>
|
<location line="-420"/>
|
||||||
<source>Copy retroshare Link</source>
|
<source>Copy retroshare Link</source>
|
||||||
<translation>Kopiere RetroShare Link</translation>
|
<translation>Kopiere RetroShare Link</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -10107,12 +10122,12 @@ p, li { white-space: pre-wrap; }
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+98"/>
|
<location line="+98"/>
|
||||||
<location line="+376"/>
|
<location line="+380"/>
|
||||||
<source>Recommend in a message to</source>
|
<source>Recommend in a message to</source>
|
||||||
<translation>Empfehle in einer Nachricht an</translation>
|
<translation>Empfehle in einer Nachricht an</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="-250"/>
|
<location line="-254"/>
|
||||||
<location line="+23"/>
|
<location line="+23"/>
|
||||||
<location line="+24"/>
|
<location line="+24"/>
|
||||||
<source>RetroShare Link</source>
|
<source>RetroShare Link</source>
|
||||||
|
@ -10127,7 +10142,7 @@ p, li { white-space: pre-wrap; }
|
||||||
<translation>Empfehlung(en)</translation>
|
<translation>Empfehlung(en)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+188"/>
|
<location line="+192"/>
|
||||||
<source><strong>My Shared Files</strong></source>
|
<source><strong>My Shared Files</strong></source>
|
||||||
<translation><strong>Meine Dateien</strong></translation>
|
<translation><strong>Meine Dateien</strong></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -10672,7 +10687,7 @@ p, li { white-space: pre-wrap; }
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+26"/>
|
<location line="+26"/>
|
||||||
<location filename="../gui/feeds/SubFileItem.cpp" line="+578"/>
|
<location filename="../gui/feeds/SubFileItem.cpp" line="+576"/>
|
||||||
<location line="+6"/>
|
<location line="+6"/>
|
||||||
<source>Play File</source>
|
<source>Play File</source>
|
||||||
<translation>Datei abspielen</translation>
|
<translation>Datei abspielen</translation>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue