00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "control_panel.h"
00021
00022 #include "Room_dlg.h"
00023
00024 ControlPanel::ControlPanel(dbListManager *pDataLists, QMainWindow *parent)
00025 : QMainWindow(parent)
00026 {
00027 ui.setupUi(this);
00028 QSettings settings;
00029 settings.beginGroup("AppData");
00030 QString welcome = settings.value ("Welcome").toString();
00031 QString title = settings.value ("Title").toString();
00032
00033 statusBar()->showMessage(welcome);
00034 setWindowTitle(title);
00035
00036 selectedItem =0;
00037
00038 readSettings();
00039
00040 dataLists = pDataLists;
00041
00042 initModuleTab();
00043 initStaffTab();
00044 initRoomTab();
00045 initModAllocTab();
00046 initEnrolTab();
00047 initTimeSlotTab();
00048
00049 createActions();
00050 createMenu();
00051 }
00052
00053 void ControlPanel::createMenu()
00054 {
00055 fileMenu = menuBar()->addMenu(tr("&File"));
00056 fileMenu->addAction(saveAsAct);
00057 fileMenu->addAction(printAct);
00058 fileMenu->addSeparator();
00059 fileMenu->addAction(exitAct);
00060
00061 editMenu = menuBar()->addMenu(tr("&Edit"));
00062 editMenu->addAction(cutAct);
00063 editMenu->addAction(copyAct);
00064 editMenu->addAction(pasteAct);
00065 editMenu->addSeparator();
00066 editMenu->addAction(rollbackAct);
00067 editMenu->addSeparator();
00068 editMenu->addAction(preferencesAct);
00069
00070 actionMenu = menuBar()->addMenu(tr("&Action"));
00071 actionMenu->addAction(moduleAct);
00072 actionMenu->addAction(staffAct);
00073
00074 helpMenu = menuBar()->addMenu(tr("&Help"));
00075 helpMenu->addAction(timetableHelpAct);
00076 helpMenu->addSeparator();
00077 helpMenu->addAction(timetableAboutAct);
00078 }
00079
00080 void ControlPanel::createActions()
00081 {
00082 saveAsAct = new QAction(tr("&Save As..."), this);
00083 connect ( saveAsAct, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
00084 printAct = new QAction(tr("&Print..."), this);
00085 connect ( printAct, SIGNAL(triggered()), this, SLOT(filePrint()));
00086 exitAct = new QAction(tr("E&xit"), this);
00087 exitAct->setShortcut(tr("Ctrl+Q"));
00088 exitAct->setStatusTip(tr("Exit the application"));
00089 connect ( exitAct, SIGNAL(triggered()), this, SLOT(fileExit()));
00090
00091 cutAct = new QAction(tr("Cu&t"), this);
00092 cutAct->setShortcut(tr("Ctrl+X"));
00093 connect ( cutAct, SIGNAL(triggered()), this, SLOT(editCut()));
00094 copyAct = new QAction(tr("&Copy"), this);
00095 copyAct->setShortcut(tr("Ctrl+C"));
00096 connect ( copyAct, SIGNAL(triggered()), this, SLOT(editCopy()));
00097 pasteAct = new QAction(tr("&Paste"), this);
00098 pasteAct->setShortcut(tr("Ctrl+V"));
00099 connect ( pasteAct, SIGNAL(triggered()), this, SLOT(editPaste()));
00100 rollbackAct = new QAction(tr("&Rollback..."), this);
00101 connect ( rollbackAct, SIGNAL(triggered()), this, SLOT(editRollback()));
00102 preferencesAct = new QAction(tr("Pre&ferences..."), this);
00103 connect ( preferencesAct, SIGNAL(triggered()), this, SLOT(editPreferences()));
00104
00105 moduleAct = new QAction(tr("&Module"), this);
00106 moduleAct->setShortcut(tr("Ctrl+F1"));
00107 moduleAct->setStatusTip(tr("Browse Modules and Programmes"));
00108 connect ( moduleAct, SIGNAL(triggered()), this, SLOT(actionModule()));
00109 staffAct = new QAction(tr("&Staff"), this);
00110 staffAct->setShortcut(tr("Ctrl+F2"));
00111 staffAct->setStatusTip(tr("Browse Staff details"));
00112 connect ( staffAct, SIGNAL(triggered()), this, SLOT(actionStaff()));
00113
00114 timetableHelpAct = new QAction(tr("Timetable &Help"), this);
00115 connect ( timetableHelpAct, SIGNAL(triggered()), this, SLOT(helpTimetableHelp()));
00116 timetableAboutAct = new QAction(tr("Timetable &About"), this);
00117 connect ( timetableAboutAct, SIGNAL(triggered()), this, SLOT(helpTimetableAbout()));
00118
00119 }
00120
00121 void ControlPanel::readSettings()
00122 {
00123 GUIPref::Instance()->readColours();
00124 }
00125
00126 void ControlPanel::writeSettings()
00127 {
00128 GUIPref::Instance()->writeColours();
00129 }
00130
00131 void ControlPanel::closeEvent(QCloseEvent *event)
00132 {
00133
00134 event->accept();
00135 }
00136
00137 void ControlPanel::fileSaveAs()
00138 {
00139 statusBar()->showMessage(tr("Save As - NOT yet implemented, sorry"));
00140 }
00141
00142 void ControlPanel::filePrint()
00143 {
00144 statusBar()->showMessage(tr("Print - NOT yet implemented, sorry"));
00145 }
00146
00147 void ControlPanel::fileExit()
00148 {
00149 close();
00150 }
00151
00152 void ControlPanel::editCut()
00153 {
00154 statusBar()->showMessage(tr("Cut - NOT yet implemented, sorry"));
00155 }
00156
00157 void ControlPanel::editCopy()
00158 {
00159 statusBar()->showMessage(tr("Copy - NOT yet implemented, sorry"));
00160 }
00161
00162 void ControlPanel::editPaste()
00163 {
00164 statusBar()->showMessage(tr("Paste - NOT yet implemented, sorry"));
00165 }
00166
00167 void ControlPanel::editRollback()
00168 {
00169 statusBar()->showMessage(tr("Rollback - NOT yet implemented, sorry"));
00170 }
00171
00172 void ControlPanel::editPreferences()
00173 {
00174 statusBar()->showMessage(tr("Preferences - NOT yet implemented, sorry"));
00175 }
00176
00177 void ControlPanel::actionModule()
00178 {
00179 ui.tabAction->setCurrentIndex(MODULE_TAB);
00180 statusBar()->showMessage(tr("Module Action - use this to browse through the modules and programmes on offer."));
00181 }
00182
00183 void ControlPanel::actionStaff()
00184 {
00185 ui.tabAction->setCurrentIndex(STAFF_TAB);
00186 statusBar()->showMessage(tr("Staff Action - use this to browse through the staff register."));
00187 }
00188
00189 void ControlPanel::helpTimetableHelp()
00190 {
00191 statusBar()->showMessage(tr("Help - NOT yet implemented, sorry"));
00192 }
00193
00194 void ControlPanel::helpTimetableAbout()
00195 {
00196 statusBar()->showMessage(tr("About - NOT yet implemented, sorry"));
00197 }
00198
00199
00200
00201
00202 void ControlPanel::initModuleTab()
00203 {
00204 QVBoxLayout * vboxLayout = addVLayout(ui.ModuleTab);
00205 module_wdgt = new ModulePageWidget(this,static_cast<QMainWindow *>(this->parent()), vboxLayout,dataLists);
00206 }
00207
00208 void ControlPanel::initStaffTab()
00209 {
00210 QVBoxLayout * vboxLayout = addVLayout(ui.StaffTab);
00211 staff_wdgt = new StaffPageWidget(this,static_cast<QMainWindow *>(this->parent()), vboxLayout,dataLists);
00212 }
00213
00214 void ControlPanel::initRoomTab()
00215 {
00216 QVBoxLayout * vboxLayout = addVLayout(ui.RoomTab);
00217 room_wdgt = new RoomPageWidget(this,static_cast<QMainWindow *>(this->parent()), vboxLayout,dataLists);
00218 }
00219
00220 void ControlPanel::initModAllocTab()
00221 {
00222 QVBoxLayout * vboxLayout = addVLayout(ui.ModAllocTab);
00223 modAlloc_wdgt = new ModuleAllocPageWidget(this
00224 ,static_cast<QMainWindow *>(this->parent())
00225 ,vboxLayout
00226 ,dataLists);
00227 }
00228
00229 void ControlPanel::initEnrolTab()
00230 {
00231
00232 QVBoxLayout * vboxLayout = addVLayout(ui.ModEnrolTab);
00233 modEnrol_wdgt = new ModuleEnrolPageWidget(this,static_cast<QMainWindow *>(this->parent()), vboxLayout,dataLists);
00234 }
00235
00236
00237 QVBoxLayout * ControlPanel::addVLayout(QWidget *wdgt)
00238 {
00239 QVBoxLayout *vboxLayout;
00240
00241 vboxLayout = new QVBoxLayout(wdgt);
00242 vboxLayout->setSpacing(6);
00243 vboxLayout->setMargin(0);
00244 return vboxLayout;
00245 }
00246
00247 void ControlPanel::initTimeSlotTab()
00248 {
00249 QVBoxLayout * vboxLayout = addVLayout(ui.TimeSlotTab);
00250 timeslot_wdgt = new TimeSlotPageWidget(this
00251 ,static_cast<QMainWindow *>(this->parent())
00252 ,vboxLayout
00253 ,dataLists);
00254 }
00255
00256 ControlPanel::TabPage ControlPanel::getTab(QWidget * page)
00257 {
00258
00259 TabPage tab = MODULE_TAB;
00260 if (page == ui.ModuleTab)
00261 tab = MODULE_TAB;
00262 if (page == ui.StaffTab)
00263 tab = STAFF_TAB;
00264 if (page == ui.RoomTab)
00265 tab = ROOM_TAB;
00266 if (page == ui.ModAllocTab)
00267 tab = ALLOCATION_TAB;
00268 if (page == ui.ModEnrolTab)
00269 tab = ENROL_TAB;
00270 return tab;
00271 }
00272