SqliteTableModel: Notify view and parent class code when clearing cache

Call beginRemoveRows() and endRemoveRows() when emptying the cache. This
silences those warnings from QAbstractItemModel::endInsertRows() and
fixes a crash when exiting the program both ocurring when the data was
resorted.
This commit is contained in:
Martin Kleusberg
2013-04-11 16:00:54 +02:00
parent 7145872f66
commit ae6e452f36
2 changed files with 9 additions and 1 deletions

View File

@@ -58,7 +58,7 @@ void SqliteTableModel::setQuery(const QString& sQuery)
sqlite3_finalize(stmt);
// now fetch the first entries
m_data.clear();
clearCache();
fetchData(0, m_chunkSize);
emit layoutChanged();
@@ -282,3 +282,10 @@ void SqliteTableModel::updateFilter(int column, const QString& value)
// Build the new query
buildQuery();
}
void SqliteTableModel::clearCache()
{
beginRemoveRows(QModelIndex(), 0, m_data.size()-1);
m_data.clear();
endRemoveRows();
}

View File

@@ -41,6 +41,7 @@ public slots:
private:
void fetchData(unsigned int from, unsigned to);
void clearCache();
void buildQuery();