add a check for valid querys

This commit is contained in:
Peinthor Rene
2013-04-15 17:35:28 +02:00
parent b9af3706e7
commit e2d75ff1cf
2 changed files with 14 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ SqliteTableModel::SqliteTableModel(QObject* parent, DBBrowserDB* db)
, m_iSortColumn(0)
, m_sSortOrder("ASC")
, m_chunkSize(50000)
, m_valid(false)
{
}
@@ -55,11 +56,20 @@ void SqliteTableModel::setQuery(const QString& sQuery)
m_rowCount = sCount.toInt();
}
}
else
{
qWarning() << "Count query failed: " << sCountQuery;
sqlite3_finalize(stmt);
m_valid = false;
return;
}
}
sqlite3_finalize(stmt);
// now fetch the first entries
clearCache();
fetchData(0, m_chunkSize);
m_valid = true;
emit layoutChanged();
}

View File

@@ -32,6 +32,8 @@ public:
Qt::ItemFlags flags(const QModelIndex& index) const;
bool valid() const { return m_valid; }
typedef QList<QByteArray> QByteArrayList;
signals:
@@ -65,6 +67,8 @@ private:
* to that row count.
*/
size_t m_chunkSize;
bool m_valid; //! tells if the current query is valid.
};
#endif // SQLITETABLEMODEL_H