sAlarm 0.5
salarm/database.h
00001 /*
00002  * sAlarm - Scheduler
00003  * http://salarm.seberm.com
00004  *
00005  * Copyright (C) 2009-2010 Otto Sabart <seberm[at]gmail[dot]com>
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * version 3 as published by the Free Software Foundation.
00010  * 
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019  */
00020 
00021 
00022 #ifndef DATABASE_H
00023 #define DATABASE_H
00024 
00025 #include <QObject>
00026 #include <QtSql/QSqlDatabase>
00027 #include <QtSql/QSqlError>
00028 #include <QtSql/QSqlQuery>
00029 
00030 
00032 
00035 class Database : public QObject {
00036         
00037         Q_OBJECT
00038         Q_ENUMS(DriverTypes)
00039                         
00040         public:
00041                 
00043 
00047                 enum DriverTypes { SQLite, MySQL };
00048                 
00050 
00055                 Database(QString connName = "");
00056                 
00058                 ~Database();
00059                 
00061 
00064                 bool connect();
00065                 
00067 
00070                 inline QString connectionName() const { return m_dbName; }
00071                 
00073 
00076                 inline DriverTypes driverType() const { return m_driverType; }
00077                 
00079 
00082                 inline QSqlDatabase sqlDb() { return *m_sqlDb; }
00083 
00084                 
00085         private:
00086                 
00088 
00091                 void dbInit();
00092                 
00093                 
00095                 QString m_dbName;
00096                 
00098                 QString m_hostname;
00099                 
00101                 QString m_username;
00102                 
00104                 QString m_password;
00105                 
00107                 QString m_database;
00108                 
00110                 DriverTypes m_driverType;
00111                 
00113                 QSqlDatabase *m_sqlDb;
00114 };
00115 
00116 #endif // DATABASE_H
 All Classes Functions Enumerations