Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+100
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManangement - Script Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <LtsUtils/LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
|
||||
class QSqlDatabase;
|
||||
|
||||
namespace AARApplication
|
||||
{
|
||||
|
||||
struct Exercise
|
||||
{
|
||||
qint32 id = 0;
|
||||
QString name;
|
||||
QString dbName;
|
||||
qint64 startTime = 0;
|
||||
qint64 endTime = 0;
|
||||
qint32 stateId = 0;
|
||||
|
||||
bool operator == (const Exercise &other) { return id == other.id; }
|
||||
bool operator != (const Exercise &other) { return id != other.id; }
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// DatabasesModel
|
||||
//
|
||||
class DatabasesModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id = 0,
|
||||
Name,
|
||||
StartTime,
|
||||
EndTime
|
||||
};
|
||||
|
||||
explicit DatabasesModel(QObject *parent = nullptr);
|
||||
~DatabasesModel() = default;
|
||||
|
||||
bool initModel(const QSqlDatabase &db);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
|
||||
int rowCount(const QModelIndex &parent) const override final;
|
||||
int columnCount(const QModelIndex &parent) const override final;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
|
||||
Exercise getRowData(int row) const;
|
||||
bool insertRow(const Exercise &item);
|
||||
bool removeRow(const int &row);
|
||||
|
||||
friend class DatabasesProxyModel;
|
||||
|
||||
protected:
|
||||
|
||||
public slots:
|
||||
void onDataChanged(const Exercise &data, DataModification modType);
|
||||
|
||||
private:
|
||||
QVector<Exercise> m_vecData;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// DatabasesProxyModel
|
||||
//
|
||||
class DatabasesProxyModel final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using QSortFilterProxyModel::QSortFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
|
||||
private:
|
||||
DatabasesModel *m_sourceModel = nullptr;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user