2 * This file is part of LineMan.
4 * Copyright 2006 Igor Khanin
6 * LiteMan is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * LiteMan is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with LiteMan; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <QCoreApplication>
25 #include <QSqlDatabase>
26 #include <QStringList>
36 typedef QList
<DatabaseTableField
> FieldList
;
39 * @brief An exception indicating %Database error
41 class DatabaseException
44 DatabaseException(QString msg
) { message
= msg
; }
50 * @brief The database manager
52 * The %Database class represents a single database file/object, and provides convinient methods
53 * for accessing specific elements in it (currently only tables and views). Though the application
54 * still doesn't use this capability, it is completly safe to have multipile %Database object managing
55 * diffirent databases in the same time.
57 * Internally, the class uses the QtSQL API for manipulating the database.
61 Q_DECLARE_TR_FUNCTIONS(Database
)
64 Database(const QString
& fileName
);
71 // Table related methods
73 QStringList
getTables();
75 void createTable(const QString
& name
, const FieldList
& fields
);
76 void renameTable(const QString
& table
, const QString
& newName
);
77 void dropTable(const QString
& table
);
79 FieldList
tableFields(const QString
& table
);
82 // View related methods
84 QStringList
getViews();
86 void createView(const QString
& name
, const QString
& sql
);
87 void dropView(const QString
& view
);
92 void exportSql(const QString
& fileName
);