adding proxy models and search to all sql models
This commit is contained in:
parent
45fbbde792
commit
57ffdc3ff0
8 changed files with 75 additions and 6 deletions
|
@ -202,3 +202,15 @@ QVariantMap ImageSqlModel::getImage(const int &row) {
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ImageProxyModel
|
||||||
|
|
||||||
|
ImageProxyModel::ImageProxyModel(QObject *parent)
|
||||||
|
:QSortFilterProxyModel(parent)
|
||||||
|
{
|
||||||
|
ImageSqlModel *imageModel = new ImageSqlModel;
|
||||||
|
setSourceModel(imageModel);
|
||||||
|
setDynamicSortFilter(true);
|
||||||
|
setFilterRole(Qt::UserRole + 1);
|
||||||
|
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define IMAGESQLMODEL_H
|
#define IMAGESQLMODEL_H
|
||||||
|
|
||||||
#include <QSqlTableModel>
|
#include <QSqlTableModel>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qobjectdefs.h>
|
#include <qobjectdefs.h>
|
||||||
#include <qqml.h>
|
#include <qqml.h>
|
||||||
|
@ -46,4 +47,15 @@ private:
|
||||||
QUrl m_filePath;
|
QUrl m_filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ImageProxyModel : public QSortFilterProxyModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ImageProxyModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //IMAGESQLMODEL_H
|
#endif //IMAGESQLMODEL_H
|
||||||
|
|
|
@ -238,3 +238,14 @@ QVariantMap PresentationSqlModel::getPresentation(const int &row) {
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
// PresentationProxyModel
|
||||||
|
|
||||||
|
PresentationProxyModel::PresentationProxyModel(QObject *parent)
|
||||||
|
:QSortFilterProxyModel(parent)
|
||||||
|
{
|
||||||
|
PresentationSqlModel *presentationModel = new PresentationSqlModel;
|
||||||
|
setSourceModel(presentationModel);
|
||||||
|
setDynamicSortFilter(true);
|
||||||
|
setFilterRole(Qt::UserRole + 1);
|
||||||
|
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define PRESENTATIONSQLMODEL_H
|
#define PRESENTATIONSQLMODEL_H
|
||||||
|
|
||||||
#include <QSqlTableModel>
|
#include <QSqlTableModel>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qobjectdefs.h>
|
#include <qobjectdefs.h>
|
||||||
#include <qqml.h>
|
#include <qqml.h>
|
||||||
|
@ -52,4 +53,14 @@ private:
|
||||||
int m_pageCount;
|
int m_pageCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PresentationProxyModel : public QSortFilterProxyModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PresentationProxyModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
#endif //PRESENTATIONSQLMODEL_H
|
#endif //PRESENTATIONSQLMODEL_H
|
||||||
|
|
|
@ -314,3 +314,15 @@ QVariantMap VideoSqlModel::getVideo(const int &row) {
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VideoProxyModel
|
||||||
|
|
||||||
|
VideoProxyModel::VideoProxyModel(QObject *parent)
|
||||||
|
:QSortFilterProxyModel(parent)
|
||||||
|
{
|
||||||
|
VideoSqlModel *videoModel = new VideoSqlModel;
|
||||||
|
setSourceModel(videoModel);
|
||||||
|
setDynamicSortFilter(true);
|
||||||
|
setFilterRole(Qt::UserRole + 1);
|
||||||
|
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define VIDEOSQLMODEL_H
|
#define VIDEOSQLMODEL_H
|
||||||
|
|
||||||
#include <QSqlTableModel>
|
#include <QSqlTableModel>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qobjectdefs.h>
|
#include <qobjectdefs.h>
|
||||||
#include <qqml.h>
|
#include <qqml.h>
|
||||||
|
@ -64,4 +65,14 @@ private:
|
||||||
bool m_loop;
|
bool m_loop;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VideoProxyModel : public QSortFilterProxyModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit VideoProxyModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
#endif //VIDEOSQLMODEL_H
|
#endif //VIDEOSQLMODEL_H
|
||||||
|
|
|
@ -173,9 +173,9 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
//register our models
|
//register our models
|
||||||
qmlRegisterType<SongProxyModel>("org.presenter", 1, 0, "SongSqlModel");
|
qmlRegisterType<SongProxyModel>("org.presenter", 1, 0, "SongSqlModel");
|
||||||
qmlRegisterType<VideoSqlModel>("org.presenter", 1, 0, "VideoSqlModel");
|
qmlRegisterType<VideoProxyModel>("org.presenter", 1, 0, "VideoSqlModel");
|
||||||
qmlRegisterType<ImageSqlModel>("org.presenter", 1, 0, "ImageSqlModel");
|
qmlRegisterType<ImageProxyModel>("org.presenter", 1, 0, "ImageSqlModel");
|
||||||
qmlRegisterType<PresentationSqlModel>("org.presenter", 1, 0, "PresentationSqlModel");
|
qmlRegisterType<PresentationProxyModel>("org.presenter", 1, 0, "PresentationSqlModel");
|
||||||
qmlRegisterType<FileHelper>("org.presenter", 1, 0, "FileHelper");
|
qmlRegisterType<FileHelper>("org.presenter", 1, 0, "FileHelper");
|
||||||
qmlRegisterType<ServiceThing>("org.presenter", 1, 0, "ServiceThing");
|
qmlRegisterType<ServiceThing>("org.presenter", 1, 0, "ServiceThing");
|
||||||
qmlRegisterSingletonInstance("org.presenter", 1, 0,
|
qmlRegisterSingletonInstance("org.presenter", 1, 0,
|
||||||
|
|
|
@ -429,7 +429,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: videosqlmodel.setFilterRegExp(searchField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* visible: selectedLibrary == "videos" */
|
/* visible: selectedLibrary == "videos" */
|
||||||
|
@ -712,7 +712,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: imagesqlmodel.setFilterRegExp(searchField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* visible: selectedLibrary == "images" */
|
/* visible: selectedLibrary == "images" */
|
||||||
|
@ -994,7 +994,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: pressqlmodel.setFilterRegExp(searchField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* visible: selectedLibrary == "presentations" */
|
/* visible: selectedLibrary == "presentations" */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue