change the order in the browse data tab on header click

if a header is clicked in the browse data view
the sort order of the clicked column is used/changed
This commit is contained in:
Peinthor Rene
2012-07-31 15:55:21 +02:00
parent d45678c551
commit 959e7ccf91
4 changed files with 32 additions and 7 deletions

View File

@@ -411,12 +411,12 @@ bool DBBrowserDB::updateRecord(int wrow, int wcol, const QString & wtext)
}
bool DBBrowserDB::browseTable( const QString & tablename )
bool DBBrowserDB::browseTable( const QString & tablename, const QString& orderby )
{
QStringList testFields = getTableFields( tablename );
if (testFields.count()>0) {//table exists
getTableRecords( tablename );
getTableRecords( tablename, orderby );
browseFields = testFields;
hasValidBrowseSet = true;
curBrowseTableName = tablename;
@@ -442,7 +442,7 @@ bool DBBrowserDB::renameTable(QString from_table, QString to_table){
return true;
}
void DBBrowserDB::getTableRecords( const QString & tablename )
void DBBrowserDB::getTableRecords( const QString & tablename, const QString& orderby )
{
sqlite3_stmt *vm;
const char *tail;
@@ -458,7 +458,9 @@ void DBBrowserDB::getTableRecords( const QString & tablename )
QString statement = "SELECT rowid, * FROM ";
statement.append( GetEncodedQString(tablename) );
statement.append(" ORDER BY rowid; ");
statement.append(" ORDER BY ");
statement.append(orderby);
statement.append(";");
//qDebug(statement);
logSQL(statement, kLogMsg_App);
err=sqlite3_prepare(_db,statement.toUtf8(),statement.length(),