Added CollationModel + factory for editing and added to EditTableWidget
This commit is contained in:
parent
f0c1035378
commit
e75b0f1a71
7 changed files with 107 additions and 19 deletions
|
|
@ -1,6 +1,45 @@
|
|||
#include "CollationModel.h"
|
||||
#include "CollationModel.h"
|
||||
|
||||
CollationModel::CollationModel()
|
||||
#include "catalog/PgCollationContainer.h"
|
||||
#include <algorithm>
|
||||
|
||||
CollationModel::CollationModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int CollationModel::rowCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
if (m_collations)
|
||||
return static_cast<int>(m_collations->count());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CollationModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return colCount;
|
||||
}
|
||||
|
||||
QVariant CollationModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.isValid()) {
|
||||
int row = index.row();
|
||||
int column = index.column();
|
||||
if (role == Qt::DisplayRole) {
|
||||
auto elem = m_collations->getByIdx(row);
|
||||
switch (column) {
|
||||
case OidCol: return elem.oid();
|
||||
case NameCol: return elem.objectName();
|
||||
}
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void CollationModel::setCollationList(std::shared_ptr<const PgCollationContainer> collations)
|
||||
{
|
||||
beginResetModel();
|
||||
m_collations = collations;
|
||||
endResetModel();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue