Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

main.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Graeme Foster                                   *
00003  *   email    foster.graeme@gmail.com                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00023 #include "dbListManager.h"
00024 sql * initDB();
00025 
00026 int main(int argc, char *argv[])
00027 {
00028         bool details = false;
00029         if (argc > 1) // Just a quick test for the details
00030                 if (argv[1][0] == 't')
00031                         details = true;
00032 
00033         try
00034         {
00035                 sql * myDBConn = initDB();
00036                 dbListManager allLists = dbListManager(myDBConn);
00037                 allLists.dump(details);
00038                 
00039                 QList<Institute * > * instList = allLists.getInstituteList();
00040                 QList<Programme * > * progList = allLists.getProgrammeList();
00041                 QList<Programme * > * selectProgList = allLists.getProgrammeList(instList->at(15));
00042                 QList<Module * >    * selectModuleList = allLists.getModuleList(selectProgList->at(2));
00043                 for (int i = 0; i < instList->size(); i++)
00044                 {
00045                         std::cout << i << ":" << instList->at(i)->getDescription().toStdString() <<"\n";
00046                 }
00047                 for (int i = 0; i < progList->size(); i++)
00048                 {
00049                         std::cout << i << ":" << progList->at(i)->getDescription().toStdString() <<"\n";
00050                 }
00051                 std::cout << "selectProgList:["<< selectProgList->size() << "]\n";
00052                 for (int i = 0; i < selectProgList->size(); i++)
00053                 {
00054                         std::cout << i << ":" << selectProgList->at(i)->getDescription().toStdString() <<"\n";
00055                 }
00056                 std::cout << "selectModuleList:["<< selectModuleList->size() << "]\n";
00057                 for (int i = 0; i < selectModuleList->size(); i++)
00058                 {
00059                         std::cout << i << ":" << selectModuleList->at(i)->getDescription().toStdString() <<"\n";
00060                 }
00061 
00062         }
00063         catch (sqlE &e)
00064         {
00065                 QString errMsg = "Please record this error & inform the system administrator.\nThe program is about to close.\nSorry it didn't work out.\nThe error is:\n" + e.getErrorMessage();
00066                 std::cout << errMsg.toStdString();
00067         }
00068 
00069 }
00070 
00071 
00072 sql * initDB()
00073 {
00074         QSettings settings("RUB","RUBic");
00075         settings.beginGroup("Database");
00076         QString username = settings.value ("UserName").toString();
00077         QString host = settings.value ("Host").toString();
00078         QString db = settings.value ("dbName").toString();
00079         QString type = settings.value ("dbType").toString();
00080         settings.endGroup();
00081 
00082         QString password ("");
00083         password = settings.value ("Password").toString(); 
00084         return new sql(username, db, password, *sql::DefaultConnectionName, host, type);
00085 }

Generated on Thu Apr 6 16:27:17 2006 for time-table by  doxygen 1.4.4