|
|
@ -24,6 +24,7 @@ public:
|
|
|
|
:ITableModel(parent)
|
|
|
|
:ITableModel(parent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
filtered = false;
|
|
|
|
filtered = false;
|
|
|
|
|
|
|
|
m_checkboxSelect = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual ~AutoTableModel() {}
|
|
|
|
virtual ~AutoTableModel() {}
|
|
|
@ -50,6 +51,21 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role) const
|
|
|
|
QVariant data(const QModelIndex &index, int role) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (index.column() == 0 && m_checkboxSelect)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (role == Qt::CheckStateRole)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (m_selectedRows.contains(index.row()))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Qt::Checked;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Qt::Unchecked;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QSharedPointer<T> entity = m_list.at(index.row());
|
|
|
|
QSharedPointer<T> entity = m_list.at(index.row());
|
|
|
|
QObject *rawEntity = (QObject*)entity.data();
|
|
|
|
QObject *rawEntity = (QObject*)entity.data();
|
|
|
|
|
|
|
|
|
|
|
@ -189,6 +205,21 @@ public:
|
|
|
|
m_translations = translations;
|
|
|
|
m_translations = translations;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<int> selectedRows() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return m_selectedRows;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QSharedPointer<T> > selectedItems()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QList<QSharedPointer<T> > ret;
|
|
|
|
|
|
|
|
foreach (int row, m_selectedRows) {
|
|
|
|
|
|
|
|
ret.append(m_list[row]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
void handleFilter(const QString &filter) override
|
|
|
|
void handleFilter(const QString &filter) override
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -220,10 +251,10 @@ protected:
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
QList<QSharedPointer<T> > m_list;
|
|
|
|
QList<QSharedPointer<T> > m_list;
|
|
|
|
QList<QSharedPointer<T> > m_fullList;
|
|
|
|
QList<QSharedPointer<T> > m_fullList;
|
|
|
|
|
|
|
|
QList<int> m_selectedRows;
|
|
|
|
QMap<QString, QString> m_translations;
|
|
|
|
QMap<QString, QString> m_translations;
|
|
|
|
bool filtered;
|
|
|
|
bool filtered;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// QAbstractItemModel interface
|
|
|
|
// QAbstractItemModel interface
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override
|
|
|
|
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override
|
|
|
@ -236,10 +267,21 @@ public:
|
|
|
|
rawEntity->setProperty(rawEntity->metaObject()->property(index.column() + 1).name(), value);
|
|
|
|
rawEntity->setProperty(rawEntity->metaObject()->property(index.column() + 1).name(), value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (role == Qt::CheckStateRole)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (m_selectedRows.contains(index.row()))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_selectedRows.removeOne(index.row());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_selectedRows.append(index.row());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
emit editCompleted();
|
|
|
|
emit editCompleted();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // ODBTABLEMODEL_H
|
|
|
|
#endif // ODBTABLEMODEL_H
|
|
|
|
|
|
|
|
|
|
|
|