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

Room_dlg.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 #include "Room_dlg.h"
00021 #define MARGIN 6
00022 
00023 RoomDlg::RoomDlg(int btnAction
00024                 ,RootItem * room
00025                 ,RootItem * institute
00026                 ,QMainWindow *parent
00027                 )
00028 : RootDlg(parent)
00029 {
00030         statusBar = parent->statusBar();
00031         parentItem = static_cast<InstItem*>(institute);
00032         dataItem = dynamic_cast<RoomItem *>(room);
00033 
00034         createWidgets();
00035         createActions();
00036         initialise (btnAction);
00037 }
00038 
00039 void RoomDlg::enableBtn()
00040 {
00041         QString name = getNameOnDB();
00042         QString abbrev = getCodeOnDB();
00043 
00044         NameAbbrevRootDlg::enableBtn(name
00045                                     ,getRoomName()
00046                                     ,abbrev
00047                                     ,getRoomCode()
00048                                     ,getInstItem()->getID()
00049                                     ,getRoomItem()
00050                                     ,Room::uniqueTrue
00051                                     ,Room::uniqueCode
00052                                     ,this
00053                                     );
00054 }
00055 
00056 
00057 
00058 void RoomDlg::okPressed()
00059 {
00060         if (getRoomItem() == 0)
00061         {
00062                 Room * roomObj = new Room(Room::NOT_ON_DB
00063                                                                                  ,getRoomName()
00064                                                                                  ,getRoomCode()
00065                                                                                  ,getRoomCapacity()
00066                                                                                  ,getInstItem()->getInstitute()
00067                                                                                  );
00068                 dataItem = new RoomItem(roomObj,getInstItem());
00069         }
00070         else
00071         {
00072                 getRoomItem()->setRoomName(getRoomName());
00073                 getRoomItem()->setRoomCode(getRoomCode());
00074                 getRoomItem()->setRoomCapacity(getRoomCapacity());
00075         }
00076         accept();
00077 }
00078 
00079 /******************************************************************************
00080  * Private Methods
00081  ******************************************************************************/
00082 void RoomDlg::createWidgets()
00083 {
00084         in_wdgt  = new NameWidget(60, tr("Institute:"), ui.frame, ui.vboxLayout2, this);
00085         in_wdgt->disableName();
00086         rna_wdgt = new NameAbbrevWidget(80, tr("Room Name:")
00087                                        ,12, tr("Room Code:")
00088                                        ,ui.frame, ui.vboxLayout2, this);
00089         cno_wdgt = new NumberWidget(2,tr("Capacity:"), ui.frame, ui.vboxLayout2, this);
00090 }
00091 
00092 void RoomDlg::createActions()
00093 {
00094 
00095         QObject::connect(rna_wdgt->getNameWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00096         QObject::connect(rna_wdgt->getAbbrevWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00097         QObject::connect(cno_wdgt->getNumberWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00098         QObject::connect(ui.okButton, SIGNAL(clicked()), this, SLOT(okPressed()));
00099 
00100 }
00101 
00102 void RoomDlg::initialise (int btnAction)
00103 {
00104         QString name = "";
00105         QString code = "";
00106         int capacity = 0;
00107         
00108         if (getInstItem() != 0)
00109                 setInstName(getInstName());
00110         
00111         if (getRoomItem() != 0)
00112         {
00113                 name = getRoomItem()->getRoomName();
00114                 code = getRoomItem()->getRoomCode();
00115                 capacity = getRoomItem()->getRoomCapacity();
00116         }
00117         
00118         setRoomName(name);
00119         setRoomCode(code);
00120         setRoomCapacity(capacity);
00121         
00122         RootDlg::initialise(btnAction, tr("Room"), name);
00123         getStatusBar()->showMessage(windowTitle());
00124         if (btnAction == ControlPanel::BTN_DELETE)
00125         {
00126                 rna_wdgt->disableControls();
00127                 cno_wdgt->disableControls();
00128 
00129                 ui.okButton->setEnabled(true);
00130         }
00131 
00132 }

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