[r42]: trunk / sqlitebrowser / sqlitebrowser / sqlitedb.h Maximize Restore History

Download this file

sqlitedb.h    154 lines (127 with data), 4.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#ifndef SQLITEDB_H
#define SQLITEDB_H
#include <stdlib.h>
#include <qstringlist.h>
#include <qmap.h>
#include <q3valuelist.h>
#include <qobject.h>
#include "sqllogform.h"
#include "sqlite3.h"
#include "sqlitebrowsertypes.h"
#define MAX_DISPLAY_LENGTH 255
enum
{
kLogMsg_User,
kLogMsg_App
};
enum
{
kEncodingUTF8,
kEncodingLatin1,
kEncodingNONE
};
static QString applicationName = QString("SQLite Database Browser");
static QString applicationIconName = QString("icone16.png");
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;
typedef QMap<QString, class DBBrowserTable> tableMap;
typedef QMap<QString, class DBBrowserIndex> indexMap;
typedef QMap<int, int> rowIdMap;
typedef QList<QStringList> rowList;
typedef QMap<int, QString> resultMap;
class DBBrowserField
{
public:
DBBrowserField() : name( 0 ) { }
DBBrowserField( const QString& wname,const QString& wtype )
: name( wname), type( wtype )
{ }
QString getname() const { return name; }
QString gettype() const { return type; }
private:
QString name;
QString type;
};
class DBBrowserIndex
{
public:
DBBrowserIndex() : name( 0 ) { }
DBBrowserIndex( const QString& wname,const QString& wsql )
: name( wname), sql( wsql )
{ }
QString getname() const { return name; }
QString getsql() const { return sql; }
private:
QString name;
QString sql;
};
class DBBrowserTable
{
public:
DBBrowserTable() : name( 0 ) { }
DBBrowserTable( const QString& wname,const QString& wsql )
: name( wname), sql( wsql )
{ }
void addField(int order, const QString& wfield,const QString& wtype);
QString getname() const { return name; }
QString getsql() const { return sql; }
fieldMap fldmap;
private:
QString name;
QString sql;
};
class DBBrowserDB
{
public:
DBBrowserDB (): _db( 0 ) , hasValidBrowseSet(false), curEncoding(kEncodingUTF8) {}
~DBBrowserDB (){}
bool open ( const QString & db);
bool create ( const QString & db);
void close ();
bool compact ();
bool setRestorePoint();
bool save ();
bool revert ();
bool dump( const QString & filename);
bool reload( const QString & filename, int * lineErr);
bool executeSQL ( const QString & statement);
bool executeSQLDirect ( const QString & statement);
void updateSchema() ;
bool addRecord();
bool deleteRecord(int wrow);
bool updateRecord(int wrow, int wcol, const QString & wtext);
bool browseTable( const QString & tablename );
QStringList getTableFields(const QString & tablename);
QStringList getTableTypes(const QString & tablename);
QStringList getTableNames();
QStringList getIndexNames();
resultMap getFindResults( const QString & wstatement);
int getRecordCount();
bool isOpen();
void setDirty(bool dirtyval);
void setDirtyDirect(bool dirtyval);
bool getDirty();
void logSQL(QString statement, int msgtype);
void setEncoding( int encoding );
void setDefaultNewData( const QString & data );
QString GetEncodedQString( const QString & input);
QString GetDecodedQString( const QString & input);
sqlite3 * _db;
QStringList decodeCSV(const QString & csvfilename, char sep, char quote, int maxrecords, int * numfields);
tableMap tbmap;
indexMap idxmap;
rowIdMap idmap;
rowList browseRecs;
QStringList browseFields;
bool hasValidBrowseSet;
QString curBrowseTableName;
QString lastErrorMessage;
QString curDBFilename;
int curEncoding;
QString curNewData;
sqlLogForm * logWin;
private:
bool dirty;
void getTableRecords( const QString & tablename );
};
#endif