2018-01-06 21:22:22 +01:00
|
|
|
|
#ifndef INDEXMODEL_H
|
|
|
|
|
|
#define INDEXMODEL_H
|
|
|
|
|
|
|
2018-01-15 13:31:37 +01:00
|
|
|
|
#include <QAbstractTableModel>
|
2018-01-06 21:22:22 +01:00
|
|
|
|
#include "PgClass.h"
|
|
|
|
|
|
#include "PgIndex.h"
|
|
|
|
|
|
#include <memory>
|
2018-11-18 20:24:27 +01:00
|
|
|
|
#include <optional>
|
2018-01-06 21:22:22 +01:00
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PgDatabaseCatalog;
|
|
|
|
|
|
|
2018-01-15 13:31:37 +01:00
|
|
|
|
class IndexModel: public QAbstractTableModel {
|
2018-01-06 21:22:22 +01:00
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
2018-01-15 13:31:37 +01:00
|
|
|
|
using QAbstractTableModel::QAbstractTableModel;
|
2018-01-06 21:22:22 +01:00
|
|
|
|
|
|
|
|
|
|
enum e_Columns : int {
|
|
|
|
|
|
TypeCol, /// primary/unique/normal
|
|
|
|
|
|
NameCol, ///
|
2018-08-25 18:11:12 +02:00
|
|
|
|
AmCol, ///< Access Method
|
2018-01-06 21:22:22 +01:00
|
|
|
|
ColumnsCol, ///
|
|
|
|
|
|
ConditionCol,
|
|
|
|
|
|
colCount };
|
|
|
|
|
|
|
2018-08-25 18:11:12 +02:00
|
|
|
|
// oid
|
|
|
|
|
|
// tablespace
|
|
|
|
|
|
// operator class
|
|
|
|
|
|
// unique
|
|
|
|
|
|
// primary
|
|
|
|
|
|
// clustered
|
|
|
|
|
|
// valid
|
|
|
|
|
|
// constraint
|
|
|
|
|
|
// system index
|
|
|
|
|
|
// fill factor
|
|
|
|
|
|
// comment
|
|
|
|
|
|
|
2018-01-06 21:22:22 +01:00
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
2018-11-18 20:24:27 +01:00
|
|
|
|
void setData(std::shared_ptr<const PgDatabaseCatalog> cat, const std::optional<PgClass> &table);
|
2018-01-06 21:22:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Basic functionality:
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
|
|
|
2018-01-15 13:31:37 +01:00
|
|
|
|
virtual QVariant data(const QModelIndex &index, int role) const override;
|
2018-04-08 09:02:22 +02:00
|
|
|
|
|
|
|
|
|
|
PgIndex getIndex(int row) const { return m_indexes[row]; }
|
2018-01-06 21:22:22 +01:00
|
|
|
|
protected:
|
2018-01-15 13:31:37 +01:00
|
|
|
|
Oid getType(int column) const;
|
|
|
|
|
|
QVariant getData(const QModelIndex &index) const;
|
2018-01-06 21:22:22 +01:00
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
std::shared_ptr<const PgDatabaseCatalog> m_catalog;
|
2018-11-18 20:24:27 +01:00
|
|
|
|
std::optional<PgClass> m_table;
|
2018-01-06 21:22:22 +01:00
|
|
|
|
|
|
|
|
|
|
using t_Indexes = std::vector<PgIndex>;
|
|
|
|
|
|
t_Indexes m_indexes;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // INDEXMODEL_H
|