SqliteTableModel: Inserting and deleting rows, clean up, bug fixes

Add some basic code to support inserting and deleting rows again.

Fix a few bugs here and there.

Do some general code clean up.
This commit is contained in:
Martin Kleusberg
2013-04-07 19:08:40 +02:00
parent 73bda97ce9
commit 77cf98fd53
6 changed files with 68 additions and 115 deletions

View File

@@ -12,7 +12,7 @@ class SqliteTableModel : public QAbstractTableModel
public:
explicit SqliteTableModel(QObject *parent = 0, DBBrowserDB* db = 0);
int rowCount(const QModelIndex &parent) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int totalRowCount() const;
int columnCount(const QModelIndex &parent) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
@@ -22,6 +22,9 @@ public:
void fetchMore(const QModelIndex &parent);
size_t queryMore(size_t offset);
bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());
bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
void setQuery(const QString& sQuery);
void setTable(const QString& table);
void setChunkSize(size_t chunksize);
@@ -38,7 +41,7 @@ private:
int m_rowCount;
int m_columnCount;
QStringList m_headers;
QMap<int, QStringList> m_data;
QList<QStringList> m_data;
QString m_sQuery;
QString m_sTable;