Make fileview always filter incompatible files.

This commit is contained in:
Tyler Rhodes 2011-06-14 16:07:17 +00:00
parent ccd7afed17
commit e67725265d
6 changed files with 9 additions and 40 deletions

View File

@ -322,8 +322,6 @@
<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>
<file>pythonlibs/uic/driver.py</file>
<file>pythonlibs/uic/exceptions.py</file>
<file>pythonlibs/uic/icon_cache.py</file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

View File

@ -29,6 +29,10 @@
#include <QMessageBox>
#include <QScrollBar>
const char* FileView::kFileFilter = "*.mp3 *.ogg *.flac *.mpc *.m4a *.aac *.wma \
*.mp4 *.spx *.wav *.m3u *.m3u8 *.pls *.xspf \
*.asx *.asxini *.cue";
FileView::FileView(QWidget* parent)
: QWidget(parent),
ui_(new Ui_FileView),
@ -44,16 +48,12 @@ 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)));
@ -66,11 +66,8 @@ FileView::FileView(QWidget* parent)
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(" ");
QString filter(FileView::kFileFilter);
filter_list_ << filter.split(" ");
}
FileView::~FileView() {
@ -110,14 +107,6 @@ 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);
@ -220,7 +209,7 @@ void FileView::showEvent(QShowEvent* e) {
model_ = new QFileSystemModel(this);
model_->setNameFilters(QStringList("*"));
model_->setNameFilters(filter_list_);
// if an item fails the filter, hide it
model_->setNameFilterDisables(false);

View File

@ -42,6 +42,8 @@ class FileView : public QWidget {
FileView(QWidget* parent = 0);
~FileView();
static const char* kFileFilter;
void SetPath(const QString& path);
void SetTaskManager(TaskManager* task_manager);
@ -59,7 +61,6 @@ 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);

View File

@ -86,25 +86,6 @@
<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>