From 978ef2a55333bed0816bf595b3a27f70c9b0dae1 Mon Sep 17 00:00:00 2001 From: tabuleiro Date: Wed, 2 Dec 2009 17:26:58 +0000 Subject: [PATCH] Fix port of no longer supported iterators, which are read-only in Qt4. Switch to plain QList structure, using references for access --- sqlitebrowser/sqlitebrowser/form1.cpp | 37 +++++++++---------- sqlitebrowser/sqlitebrowser/importcsvform.cpp | 2 +- sqlitebrowser/sqlitebrowser/sqlitedb.cpp | 12 +++--- sqlitebrowser/sqlitebrowser/sqlitedb.h | 11 ++---- 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/sqlitebrowser/sqlitebrowser/form1.cpp b/sqlitebrowser/sqlitebrowser/form1.cpp index 830e9a76..110672a9 100644 --- a/sqlitebrowser/sqlitebrowser/form1.cpp +++ b/sqlitebrowser/sqlitebrowser/form1.cpp @@ -375,20 +375,23 @@ void mainForm::updateTableView(int lineToSelect) if ( recsThisView > 0 ) { - rowList::iterator rt; int rowNum = 0; int colNum = 0; //int dcols =0; QString rowLabel; - for ( rt = tab.at(recAtTop); rt !=tab.end(); ++rt ) + for (int i = recAtTop; i < tab.size(); ++i) + //for ( int = tab.at(recAtTop); rt !=tab.end(); ++rt ) { rowLabel.setNum(recAtTop+rowNum+1); dataTable->verticalHeader()->setLabel( rowNum, rowLabel ); colNum = 0; - for ( QStringList::Iterator it = (*rt).begin(); it != (*rt).end(); ++it ) { + QStringList& rt = tab[i]; + for (int e = 1; e < rt.size(); ++e) + //for ( QStringList::Iterator it = (*rt).begin(); it != (*rt).end(); ++it ) + { //skip first one (the rowid) - if (it!=(*rt).begin()){ - QString content = *it; + // if (it!=(*rt).begin()){ + QString& content = rt[e]; QString firstline = content.section( '\n', 0,0 ); if (content.length()>MAX_DISPLAY_LENGTH) { @@ -397,7 +400,7 @@ void mainForm::updateTableView(int lineToSelect) } dataTable->setText( rowNum, colNum, firstline); colNum++; - } + //} } rowNum++; if (rowNum==recsThisView) break; @@ -759,9 +762,8 @@ void mainForm::updateRecordText(int row, int col, QString newtext) } rowList tab = db.browseRecs; - rowList::iterator rt = tab.at(row); - QString rowid = (*rt).first(); - QString cv = (*rt).at(col+1);//must account for rowid + QStringList& rt = tab[row]; + QString& cv = rt[col+1];//must account for rowid QString content = cv ; QString firstline = content.section( '\n', 0,0 ); @@ -790,10 +792,8 @@ void mainForm::editWinAway() void mainForm::editText(int row, int col) { rowList tab = db.browseRecs; - rowList::iterator rt = tab.at(row); - QString rowid = (*rt).first(); - QString cv = (*rt).at(col+1);//must account for rowid - //dataTable->setText( row - recAtTop, col, *cv ); + QStringList& rt = tab[row]; + QString cv = rt[col+1];//must account for rowid editWin->loadText(cv , row, col); editWin ->show(); @@ -989,16 +989,14 @@ void mainForm::exportTableToCSV() //now export data rowList tab = db.browseRecs; - rowList::iterator rt; //int dcols =0; QString rowLabel; - for ( rt = tab.at(0); rt !=tab.end(); ++rt ) + for ( int i=0; i #include #include "sqllogform.h" -#include "sqlite_source/sqlite3.h" +#include "sqlite3.h" #include "sqlitebrowsertypes.h" -/*#include "sqlite_source/sqlxtra_util.h" -#include "sqlite_source/encode.h" -#include "sqlite_source/swap.h"*/ -#define MAX_DISPLAY_LENGTH 256 +#define MAX_DISPLAY_LENGTH 255 enum { @@ -30,7 +27,7 @@ kEncodingNONE static QString applicationName = QString("SQLite Database Browser"); static QString applicationIconName = QString("icone16.png"); -static QString aboutText = QString("Version 1.3\n\nSQLite Database Browser is a freeware, public domain, open source visual tool used to create, design and edit database files compatible with SQLite 3.x.\n\nIt has been developed originally by Mauricio Piacentini from Tabuleiro Producoes. \n\nIn the spirit of the original SQLite source code, the author disclaims copyright to this source code."); +static QString aboutText = QString("Version 2.0\n\nSQLite Database Browser is a freeware, public domain, open source visual tool used to create, design and edit database files compatible with SQLite 3.x.\n\nIt has been developed originally by Mauricio Piacentini from Tabuleiro Producoes. \n\nIn the spirit of the original SQLite source code, the author disclaims copyright to this source code."); typedef QMap fieldMap; @@ -38,7 +35,7 @@ typedef QMap tableMap; typedef QMap indexMap; typedef QMap rowIdMap; -typedef Q3ValueList rowList; +typedef QList rowList; typedef QMap resultMap; class DBBrowserField