Add finter-enabling to all models
This commit is contained in:
@@ -110,8 +110,22 @@ void DevicesPage::itemDoubleClicked(const QModelIndex &)
|
||||
|
||||
void DevicesPage::searchItems()
|
||||
{
|
||||
proxy.setFilterGenre(0==genreCombo->currentIndex() ? QString() : genreCombo->currentText());
|
||||
proxy.setFilterRegExp(view->searchText());
|
||||
QString genre=0==genreCombo->currentIndex() ? QString() : genreCombo->currentText();
|
||||
QString filter=view->searchText().trimmed();
|
||||
|
||||
if (filter.isEmpty() && genre.isEmpty()) {
|
||||
proxy.setFilterEnabled(false);
|
||||
proxy.setFilterGenre(genre);
|
||||
if (!proxy.filterRegExp().isEmpty()) {
|
||||
proxy.setFilterRegExp(QString());
|
||||
}
|
||||
} else {
|
||||
proxy.setFilterEnabled(true);
|
||||
proxy.setFilterGenre(genre);
|
||||
if (filter!=proxy.filterRegExp().pattern()) {
|
||||
proxy.setFilterRegExp(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DevicesPage::selectionChanged()
|
||||
|
||||
@@ -188,8 +188,22 @@ void AlbumsPage::itemActivated(const QModelIndex &)
|
||||
|
||||
void AlbumsPage::searchItems()
|
||||
{
|
||||
proxy.setFilterGenre(0==genreCombo->currentIndex() ? QString() : genreCombo->currentText());
|
||||
proxy.setFilterRegExp(view->searchText());
|
||||
QString genre=0==genreCombo->currentIndex() ? QString() : genreCombo->currentText();
|
||||
QString filter=view->searchText().trimmed();
|
||||
|
||||
if (filter.isEmpty() && genre.isEmpty()) {
|
||||
proxy.setFilterEnabled(false);
|
||||
proxy.setFilterGenre(genre);
|
||||
if (!proxy.filterRegExp().isEmpty()) {
|
||||
proxy.setFilterRegExp(QString());
|
||||
}
|
||||
} else {
|
||||
proxy.setFilterEnabled(true);
|
||||
proxy.setFilterGenre(genre);
|
||||
if (filter!=proxy.filterRegExp().pattern()) {
|
||||
proxy.setFilterRegExp(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AlbumsPage::updateGenres(const QStringList &genres)
|
||||
|
||||
@@ -107,7 +107,17 @@ void FolderPage::clear()
|
||||
|
||||
void FolderPage::searchItems()
|
||||
{
|
||||
proxy.setFilterRegExp(view->searchText());
|
||||
QString filter=view->searchText().trimmed();
|
||||
|
||||
if (filter.isEmpty() ) {
|
||||
proxy.setFilterEnabled(false);
|
||||
if (!proxy.filterRegExp().isEmpty()) {
|
||||
proxy.setFilterRegExp(QString());
|
||||
}
|
||||
} else if (filter!=proxy.filterRegExp().pattern()) {
|
||||
proxy.setFilterEnabled(true);
|
||||
proxy.setFilterRegExp(filter);
|
||||
}
|
||||
}
|
||||
|
||||
void FolderPage::itemDoubleClicked(const QModelIndex &)
|
||||
|
||||
@@ -197,8 +197,22 @@ void LibraryPage::itemDoubleClicked(const QModelIndex &)
|
||||
|
||||
void LibraryPage::searchItems()
|
||||
{
|
||||
proxy.setFilterGenre(0==genreCombo->currentIndex() ? QString() : genreCombo->currentText());
|
||||
proxy.setFilterRegExp(view->searchText());
|
||||
QString genre=0==genreCombo->currentIndex() ? QString() : genreCombo->currentText();
|
||||
QString filter=view->searchText().trimmed();
|
||||
|
||||
if (filter.isEmpty() && genre.isEmpty()) {
|
||||
proxy.setFilterEnabled(false);
|
||||
proxy.setFilterGenre(genre);
|
||||
if (!proxy.filterRegExp().isEmpty()) {
|
||||
proxy.setFilterRegExp(QString());
|
||||
}
|
||||
} else {
|
||||
proxy.setFilterEnabled(true);
|
||||
proxy.setFilterGenre(genre);
|
||||
if (filter!=proxy.filterRegExp().pattern()) {
|
||||
proxy.setFilterRegExp(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LibraryPage::updateGenres(const QStringList &genres)
|
||||
|
||||
@@ -1120,15 +1120,15 @@ void MainWindow::realSearchPlaylist()
|
||||
if (playlistSearchTimer) {
|
||||
playlistSearchTimer->stop();
|
||||
}
|
||||
QString text=searchPlaylistLineEdit->text().trimmed();
|
||||
if (text.length()<4) {
|
||||
playQueueProxyModel.setEnabled(false);
|
||||
QString filter=searchPlaylistLineEdit->text().trimmed();
|
||||
if (filter.length()<2) {
|
||||
playQueueProxyModel.setFilterEnabled(false);
|
||||
if (!playQueueProxyModel.filterRegExp().isEmpty()) {
|
||||
playQueueProxyModel.setFilterRegExp(QString());
|
||||
}
|
||||
} else if (text!=playQueueProxyModel.filterRegExp().pattern()) {
|
||||
playQueueProxyModel.setEnabled(true);
|
||||
playQueueProxyModel.setFilterRegExp(text);
|
||||
} else if (filter!=playQueueProxyModel.filterRegExp().pattern()) {
|
||||
playQueueProxyModel.setFilterEnabled(true);
|
||||
playQueueProxyModel.setFilterRegExp(filter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -297,5 +297,15 @@ void PlaylistsPage::selectionChanged()
|
||||
|
||||
void PlaylistsPage::searchItems()
|
||||
{
|
||||
proxy.setFilterRegExp(view->searchText());
|
||||
QString filter=view->searchText().trimmed();
|
||||
|
||||
if (filter.isEmpty() ) {
|
||||
proxy.setFilterEnabled(false);
|
||||
if (!proxy.filterRegExp().isEmpty()) {
|
||||
proxy.setFilterRegExp(QString());
|
||||
}
|
||||
} else if (filter!=proxy.filterRegExp().pattern()) {
|
||||
proxy.setFilterEnabled(true);
|
||||
proxy.setFilterRegExp(filter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +396,17 @@ void StreamsPage::controlActions()
|
||||
|
||||
void StreamsPage::searchItems()
|
||||
{
|
||||
proxy.setFilterRegExp(view->searchText());
|
||||
QString filter=view->searchText().trimmed();
|
||||
|
||||
if (filter.isEmpty() ) {
|
||||
proxy.setFilterEnabled(false);
|
||||
if (!proxy.filterRegExp().isEmpty()) {
|
||||
proxy.setFilterRegExp(QString());
|
||||
}
|
||||
} else if (filter!=proxy.filterRegExp().pattern()) {
|
||||
proxy.setFilterEnabled(true);
|
||||
proxy.setFilterRegExp(filter);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList StreamsPage::getCategories()
|
||||
|
||||
@@ -28,18 +28,19 @@
|
||||
#include "playqueueproxymodel.h"
|
||||
#include "playqueuemodel.h"
|
||||
|
||||
PlayQueueProxyModel::PlayQueueProxyModel(QObject *parent) : QSortFilterProxyModel(parent)
|
||||
PlayQueueProxyModel::PlayQueueProxyModel(QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
, filterEnabled(false)
|
||||
{
|
||||
//setDynamicSortFilter(true);
|
||||
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
//setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
//setSortLocaleAware(true);
|
||||
enabled=false;
|
||||
}
|
||||
|
||||
bool PlayQueueProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
if (!enabled) {
|
||||
if (!filterEnabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,10 @@ public:
|
||||
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
||||
void setEnabled(bool e) { enabled=e; }
|
||||
void setFilterEnabled(bool e) { filterEnabled=e; }
|
||||
|
||||
private:
|
||||
bool enabled;
|
||||
bool filterEnabled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,8 @@ class ProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
public:
|
||||
ProxyModel(QObject *parent)
|
||||
: QSortFilterProxyModel(parent) {
|
||||
: QSortFilterProxyModel(parent)
|
||||
, filterEnabled(false) {
|
||||
}
|
||||
virtual ~ProxyModel() {
|
||||
}
|
||||
@@ -54,7 +55,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void setFilterEnabled(bool e) { filterEnabled=e; }
|
||||
|
||||
private:
|
||||
bool filterEnabled;
|
||||
QModelIndex rootIndex;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user