Fix port of no longer supported iterators, which are read-only in Qt4. Switch to plain QList<QStringList> structure, using references for access

This commit is contained in:
tabuleiro
2009-12-02 17:26:58 +00:00
parent 92f2822778
commit 978ef2a553
4 changed files with 28 additions and 34 deletions

View File

@@ -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<tab.size(); ++i )
{
for ( QStringList::Iterator it = (*rt).begin(); it != (*rt).end(); ++it ) {
//skip first one (the rowid)
if (it!=(*rt).begin()){
QString content = *it;
QStringList& rt = tab[i];
for ( int e=1; e<rt.size(); ++e ) {
QString content = rt[e];
stream<< quote;
QChar qquote = quote;
content.replace(quote, QString(qquote).append(qquote));
@@ -1014,7 +1012,6 @@ void mainForm::exportTableToCSV()
}
}
}
}
file.close();
QMessageBox::information( this, applicationName, "Export completed" );

View File

@@ -114,7 +114,7 @@ void importCSVForm::createButtonPressed()
sql.append(tabname);
sql.append(" (");
for (int r=0; r<numfields;r++){
sql.append(*fieldList.at(r));
sql.append(fieldList[r]);
//createStatement.append(" text");
if (r<(numfields - 1))
sql.append(", ");

View File

@@ -352,8 +352,8 @@ bool DBBrowserDB::deleteRecord( int wrow)
if (!isOpen()) return false;
bool ok = false;
rowList tab = browseRecs;
rowList::iterator rt = tab.at(wrow);
QString rowid = (*rt).first();
QStringList& rt = tab[wrow];
QString& rowid = rt[0];
lastErrorMessage = QString("no error");
QString statement = "DELETE FROM ";
@@ -384,9 +384,9 @@ bool DBBrowserDB::updateRecord(int wrow, int wcol, const QString & wtext)
lastErrorMessage = QString("no error");
rowList::iterator rt = browseRecs.at(wrow);
QString rowid = (*rt).first();
QString cv = (*rt).at(wcol+1);//must account for rowid
QStringList& rt = browseRecs[wrow];
QString& rowid = rt[0];
QString& cv = rt[wcol+1];//must account for rowid
QString ct = browseFields.at(wcol);
QString statement = "UPDATE ";
@@ -411,7 +411,7 @@ bool DBBrowserDB::updateRecord(int wrow, int wcol, const QString & wtext)
NULL,NULL,&errmsg)){
ok=true;
/*update local copy*/
(cv) = wtext;
cv = wtext;
} else {
lastErrorMessage = QString(errmsg);
}

View File

@@ -7,13 +7,10 @@
#include <q3valuelist.h>
#include <qobject.h>
#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<int, class DBBrowserField> fieldMap;
@@ -38,7 +35,7 @@ typedef QMap<QString, class DBBrowserTable> tableMap;
typedef QMap<QString, class DBBrowserIndex> indexMap;
typedef QMap<int, int> rowIdMap;
typedef Q3ValueList<QStringList> rowList;
typedef QList<QStringList> rowList;
typedef QMap<int, QString> resultMap;
class DBBrowserField