adding a proxyModel
This commit is contained in:
parent
1c1140915e
commit
13c8704bdc
4 changed files with 25 additions and 2 deletions
|
@ -709,3 +709,14 @@ void SongSqlModel::updateFontSize(const int &row, const int &fontSize) {
|
||||||
submitAll();
|
submitAll();
|
||||||
emit fontSizeChanged();
|
emit fontSizeChanged();
|
||||||
}
|
}
|
||||||
|
// SongProxyModel
|
||||||
|
|
||||||
|
SongProxyModel::SongProxyModel(QObject *parent)
|
||||||
|
:QSortFilterProxyModel(parent)
|
||||||
|
{
|
||||||
|
SongSqlModel songModel = new SongSqlModel;
|
||||||
|
setSourceModel(songModel);
|
||||||
|
setDynamicSortFilter(true);
|
||||||
|
setFilterRole(Qt::UserRole + 1);
|
||||||
|
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define SONGSQLMODEL_H
|
#define SONGSQLMODEL_H
|
||||||
|
|
||||||
#include <QSqlTableModel>
|
#include <QSqlTableModel>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
#include <qobjectdefs.h>
|
#include <qobjectdefs.h>
|
||||||
#include <qqml.h>
|
#include <qqml.h>
|
||||||
#include <qvariant.h>
|
#include <qvariant.h>
|
||||||
|
@ -107,4 +108,15 @@ private:
|
||||||
int m_fontSize;
|
int m_fontSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SongProxyModel : public QSortFilterProxyModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SongProxyModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //SONGSQLMODEL_H
|
#endif //SONGSQLMODEL_H
|
||||||
|
|
|
@ -172,7 +172,7 @@ int main(int argc, char *argv[])
|
||||||
qmlRegisterType<MpvObject>("mpv", 1, 0, "MpvObject");
|
qmlRegisterType<MpvObject>("mpv", 1, 0, "MpvObject");
|
||||||
|
|
||||||
//register our models
|
//register our models
|
||||||
qmlRegisterType<SongSqlModel>("org.presenter", 1, 0, "SongSqlModel");
|
qmlRegisterType<SongProxyModel>("org.presenter", 1, 0, "SongSqlModel");
|
||||||
qmlRegisterType<VideoSqlModel>("org.presenter", 1, 0, "VideoSqlModel");
|
qmlRegisterType<VideoSqlModel>("org.presenter", 1, 0, "VideoSqlModel");
|
||||||
qmlRegisterType<ImageSqlModel>("org.presenter", 1, 0, "ImageSqlModel");
|
qmlRegisterType<ImageSqlModel>("org.presenter", 1, 0, "ImageSqlModel");
|
||||||
qmlRegisterType<PresentationSqlModel>("org.presenter", 1, 0, "PresentationSqlModel");
|
qmlRegisterType<PresentationSqlModel>("org.presenter", 1, 0, "PresentationSqlModel");
|
||||||
|
|
|
@ -125,7 +125,7 @@ Item {
|
||||||
id: searchField
|
id: searchField
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: parent.width - 40
|
width: parent.width - 40
|
||||||
onAccepted: showPassiveNotification(searchField.text, 3000)
|
onAccepted: songsqlmodel.setFilterRegExp(searchField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* visible: selectedLibrary == "songs" */
|
/* visible: selectedLibrary == "songs" */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue