This commit is contained in:
eelke 2022-01-17 05:53:56 +01:00
parent 50bf4588ce
commit 93a55047b6
2 changed files with 0 additions and 72 deletions

View file

@ -40,8 +40,6 @@ void TablesTableModel::refresh()
// Later afscheiden naar filter functie // Later afscheiden naar filter functie
auto classes = m_catalog->classes(); auto classes = m_catalog->classes();
// How many?
m_tables.clear(); m_tables.clear();
for (const auto &e : *classes) { for (const auto &e : *classes) {
bool add = false; bool add = false;
@ -62,63 +60,8 @@ void TablesTableModel::refresh()
if (add) if (add)
m_tables.push_back(e); m_tables.push_back(e);
} }
// doSort(1);
} }
//void TablesTableModel::setSortOrder(int so)
//{
// beginResetModel();
// doSort(so);
// endResetModel();
//}
//namespace {
// inline bool compareByName(PgClass l, PgClass r)
// {
// return l.objectName() < r.objectName()
// || (l.objectName() == r.objectName() && l.nsName() < r.nsName());
// }
// inline bool compareBySchema(PgClass l, PgClass r)
// {
// return l.nsName() < r.nsName()
// || (l.nsName() == r.nsName() && l.objectName() < r.objectName());
// }
//}
//void TablesTableModel::sort(int column, Qt::SortOrder order)
//{
// if (column == NameCol) {
// if (order == Qt::AscendingOrder)
// std::sort(m_tables.begin(), m_tables.end(), compareByName);
// else
// std::sort(m_tables.begin(), m_tables.end(), [] (auto l, auto r) { return !compareByName(l, r); });
// }
// else if (column == NamespaceCol) {
// if (order == Qt::AscendingOrder)
// std::sort(m_tables.begin(), m_tables.end(), compareBySchema);
// else
// std::sort(m_tables.begin(), m_tables.end(), [] (auto l, auto r) { return !compareBySchema(l, r); });
// }
// emit layoutChanged();
//}
//void TablesTableModel::doSort(int )
//{
//// if (so == 1)
//// std::sort(m_tables.begin(), m_tables.end(),
//// [] (auto l, auto r) -> bool { return l.relnamespace_name < r.relnamespace_name
//// || (l.relnamespace_name == r.relnamespace_name && l.name < r.name); });
//// else
//// std::sort(m_tables.begin(), m_tables.end(),
//// [] (auto l, auto r) -> bool { return l.name < r.name; });
//}
QVariant TablesTableModel::headerData(int section, Qt::Orientation orientation, int role) const QVariant TablesTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{ {
if (orientation == Qt::Horizontal) { if (orientation == Qt::Horizontal) {
@ -142,7 +85,6 @@ QVariant TablesTableModel::headerData(int section, Qt::Orientation orientation,
return QVariant(); return QVariant();
} }
// Basic functionality:
int TablesTableModel::rowCount(const QModelIndex &) const int TablesTableModel::rowCount(const QModelIndex &) const
{ {
return static_cast<int>(m_tables.size()); return static_cast<int>(m_tables.size());
@ -208,13 +150,6 @@ Oid TablesTableModel::getTableOid(int row) const
return m_tables[row].oid(); return m_tables[row].oid();
} }
//QString TablesTableModel::formatTableName(const PgClass &cls) const
//{
// const char * format = "%2 (%1)";
// QString ns_name = getNamespaceDisplayString(*m_catalog, cls.relnamespace);
// return QString(format).arg(ns_name).arg(cls.objectName());
//}
QVariant TablesTableModel::data(const QModelIndex &index, int role) const QVariant TablesTableModel::data(const QModelIndex &index, int role) const
{ {
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)

View file

@ -36,13 +36,8 @@ public:
void setNamespaceFilter(NamespaceFilter nsf); void setNamespaceFilter(NamespaceFilter nsf);
void setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat); void setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat);
// virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
// void setSortOrder(int so);
// Header:
QVariant headerData(int section, Qt::Orientation orientation, int role) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
// Basic functionality:
int rowCount(const QModelIndex &parent) const override; int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override; int columnCount(const QModelIndex &parent) const override;
@ -65,8 +60,6 @@ private:
Oid getType(int column) const; Oid getType(int column) const;
QVariant getData(const QModelIndex &index) const; QVariant getData(const QModelIndex &index) const;
// QString formatTableName(const PgClass &cls) const;
// void doSort(int so);
private slots: private slots:
void refresh(); void refresh();