mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-12 23:09:25 -05:00
Partially revert 7073230 to fix filter row
This commit is contained in:
+19
-11
@@ -23,6 +23,10 @@ void SqliteTableModel::setTable(const QString& table)
|
||||
{
|
||||
m_sTable = table;
|
||||
|
||||
m_headers.clear();
|
||||
m_headers.push_back("rowid");
|
||||
m_headers.append(m_db->getTableFields(table));
|
||||
|
||||
m_mWhere.clear();
|
||||
|
||||
buildQuery();
|
||||
@@ -37,11 +41,12 @@ QString rtrimChar(const QString& s, QChar c) {
|
||||
}
|
||||
}
|
||||
|
||||
void SqliteTableModel::setQuery(const QString& sQuery)
|
||||
void SqliteTableModel::setQuery(const QString& sQuery, bool dontClearHeaders)
|
||||
{
|
||||
// clear
|
||||
m_mWhere.clear();
|
||||
m_headers.clear();
|
||||
if(!dontClearHeaders)
|
||||
m_headers.clear();
|
||||
|
||||
if(!m_db->isOpen())
|
||||
return;
|
||||
@@ -75,16 +80,19 @@ void SqliteTableModel::setQuery(const QString& sQuery)
|
||||
}
|
||||
|
||||
// headers
|
||||
utf8Query = sQuery.toUtf8();
|
||||
status = sqlite3_prepare_v2(m_db->_db, utf8Query, utf8Query.size(), &stmt, NULL);
|
||||
if(SQLITE_OK == status)
|
||||
if(!dontClearHeaders)
|
||||
{
|
||||
status = sqlite3_step(stmt);
|
||||
int columns = sqlite3_data_count(stmt);
|
||||
for(int i = 0; i < columns; ++i)
|
||||
m_headers.append(QString::fromUtf8((const char*)sqlite3_column_name(stmt, i)));
|
||||
utf8Query = sQuery.toUtf8();
|
||||
status = sqlite3_prepare_v2(m_db->_db, utf8Query, utf8Query.size(), &stmt, NULL);
|
||||
if(SQLITE_OK == status)
|
||||
{
|
||||
status = sqlite3_step(stmt);
|
||||
int columns = sqlite3_data_count(stmt);
|
||||
for(int i = 0; i < columns; ++i)
|
||||
m_headers.append(QString::fromUtf8((const char*)sqlite3_column_name(stmt, i)));
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
// now fetch the first entries
|
||||
clearCache();
|
||||
@@ -272,7 +280,7 @@ void SqliteTableModel::buildQuery()
|
||||
}
|
||||
|
||||
QString sql = QString("SELECT rowid,* FROM `%1` %2 ORDER BY `%3` %4").arg(m_sTable).arg(where).arg(headers.at(m_iSortColumn)).arg(m_sSortOrder);
|
||||
setQuery(sql);
|
||||
setQuery(sql, true);
|
||||
}
|
||||
|
||||
void SqliteTableModel::updateFilter(int column, const QString& value)
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
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 setQuery(const QString& sQuery, bool dontClearHeaders = false);
|
||||
void setTable(const QString& table);
|
||||
void setChunkSize(size_t chunksize);
|
||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||
|
||||
Reference in New Issue
Block a user