Add file type filtering to File view.
Fixes issue #361 Thanks to: tyler.s.rhodes@gmail.com
This commit is contained in:
parent
d15c6ac495
commit
b175c36431
@ -323,5 +323,7 @@
|
||||
<file>icons/22x22/task-complete.png</file>
|
||||
<file>icons/22x22/task-reject.png</file>
|
||||
<file>schema/schema-34.sql</file>
|
||||
<file>icons/22x22/audio-x-generic.png</file>
|
||||
<file>icons/22x22/audio-x-disabled.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
data/icons/22x22/audio-x-disabled.png
Normal file
BIN
data/icons/22x22/audio-x-disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
BIN
data/icons/22x22/audio-x-generic.png
Normal file
BIN
data/icons/22x22/audio-x-generic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 625 B |
@ -21,6 +21,7 @@
|
||||
#include "core/filesystemmusicstorage.h"
|
||||
#include "core/mimedata.h"
|
||||
#include "ui/iconloader.h"
|
||||
#include "ui/mainwindow.h" // for filter information
|
||||
#include "ui/organiseerrordialog.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
@ -43,12 +44,16 @@ FileView::FileView(QWidget* parent)
|
||||
ui_->forward->setIcon(IconLoader::Load("go-next"));
|
||||
ui_->home->setIcon(IconLoader::Load("go-home"));
|
||||
ui_->up->setIcon(IconLoader::Load("go-up"));
|
||||
QIcon toggle_icon(IconLoader::Load("audio-x-disabled"));
|
||||
toggle_icon.addPixmap(IconLoader::Load("audio-x-generic").pixmap(22), QIcon::Normal, QIcon::On);
|
||||
ui_->toggle_filter->setIcon(toggle_icon);
|
||||
|
||||
connect(ui_->back, SIGNAL(clicked()), undo_stack_, SLOT(undo()));
|
||||
connect(ui_->forward, SIGNAL(clicked()), undo_stack_, SLOT(redo()));
|
||||
connect(ui_->home, SIGNAL(clicked()), SLOT(FileHome()));
|
||||
connect(ui_->up, SIGNAL(clicked()), SLOT(FileUp()));
|
||||
connect(ui_->path, SIGNAL(textChanged(QString)), SLOT(ChangeFilePath(QString)));
|
||||
connect(ui_->toggle_filter, SIGNAL(clicked()), SLOT(ToggleFilter()));
|
||||
|
||||
connect(undo_stack_, SIGNAL(canUndoChanged(bool)), ui_->back, SLOT(setEnabled(bool)));
|
||||
connect(undo_stack_, SIGNAL(canRedoChanged(bool)), ui_->forward, SLOT(setEnabled(bool)));
|
||||
@ -60,6 +65,12 @@ FileView::FileView(QWidget* parent)
|
||||
connect(ui_->list, SIGNAL(MoveToLibrary(QList<QUrl>)), SIGNAL(MoveToLibrary(QList<QUrl>)));
|
||||
connect(ui_->list, SIGNAL(CopyToDevice(QList<QUrl>)), SIGNAL(CopyToDevice(QList<QUrl>)));
|
||||
connect(ui_->list, SIGNAL(Delete(QStringList)), SLOT(Delete(QStringList)));
|
||||
|
||||
QString filter(MainWindow::kMusicFilterSpec);
|
||||
// filter list strings are formatted as such: 'text (filters separated by spaces)'
|
||||
filter.replace(QRegExp(".*[(]"), "");
|
||||
filter.replace(QRegExp("[)].*"), "");
|
||||
filter_list_ = filter.split(" ");
|
||||
}
|
||||
|
||||
FileView::~FileView() {
|
||||
@ -99,6 +110,14 @@ void FileView::FileHome() {
|
||||
ChangeFilePath(QDir::homePath());
|
||||
}
|
||||
|
||||
void FileView::ToggleFilter() {
|
||||
if(ui_->toggle_filter->isChecked()) {
|
||||
model_->setNameFilters(filter_list_);
|
||||
} else {
|
||||
model_->setNameFilters(QStringList("*"));
|
||||
}
|
||||
}
|
||||
|
||||
void FileView::ChangeFilePath(const QString& new_path_native) {
|
||||
QString new_path = QDir::fromNativeSeparators(new_path_native);
|
||||
|
||||
@ -200,6 +219,11 @@ void FileView::showEvent(QShowEvent* e) {
|
||||
return;
|
||||
|
||||
model_ = new QFileSystemModel(this);
|
||||
|
||||
model_->setNameFilters(QStringList("*"));
|
||||
// if an item fails the filter, hide it
|
||||
model_->setNameFilterDisables(false);
|
||||
|
||||
ui_->list->setModel(model_);
|
||||
ChangeFilePathWithoutUndo(QDir::homePath());
|
||||
|
||||
|
@ -59,6 +59,7 @@ class FileView : public QWidget {
|
||||
private slots:
|
||||
void FileUp();
|
||||
void FileHome();
|
||||
void ToggleFilter();
|
||||
void ChangeFilePath(const QString& new_path);
|
||||
void ItemActivated(const QModelIndex& index);
|
||||
void ItemDoubleClick(const QModelIndex& index);
|
||||
@ -102,6 +103,8 @@ class FileView : public QWidget {
|
||||
boost::shared_ptr<MusicStorage> storage_;
|
||||
|
||||
QString lazy_set_path_;
|
||||
|
||||
QStringList filter_list_;
|
||||
};
|
||||
|
||||
#endif // FILEVIEW_H
|
||||
|
@ -86,6 +86,25 @@
|
||||
<item>
|
||||
<widget class="QLineEdit" name="path"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toggle_filter">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user