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;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
#include <QSqlTableModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <qobject.h>
|
||||
#include <qobjectdefs.h>
|
||||
#include <qqml.h>
|
||||
|
@ -46,4 +47,15 @@ private:
|
|||
QUrl m_filePath;
|
||||
};
|
||||
|
||||
class ImageProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImageProxyModel(QObject *parent = nullptr);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //IMAGESQLMODEL_H
|
||||
|
|
|
@ -238,3 +238,14 @@ QVariantMap PresentationSqlModel::getPresentation(const int &row) {
|
|||
}
|
||||
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
|
||||
|
||||
#include <QSqlTableModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <qobject.h>
|
||||
#include <qobjectdefs.h>
|
||||
#include <qqml.h>
|
||||
|
@ -52,4 +53,14 @@ private:
|
|||
int m_pageCount;
|
||||
};
|
||||
|
||||
class PresentationProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PresentationProxyModel(QObject *parent = nullptr);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //PRESENTATIONSQLMODEL_H
|
||||
|
|
|
@ -314,3 +314,15 @@ QVariantMap VideoSqlModel::getVideo(const int &row) {
|
|||
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
|
||||
|
||||
#include <QSqlTableModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <qobject.h>
|
||||
#include <qobjectdefs.h>
|
||||
#include <qqml.h>
|
||||
|
@ -64,4 +65,14 @@ private:
|
|||
bool m_loop;
|
||||
};
|
||||
|
||||
class VideoProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VideoProxyModel(QObject *parent = nullptr);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //VIDEOSQLMODEL_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue