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

institute_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 "institute_dlg.h"
00021 
00022 InstituteDlg::InstituteDlg(int btnAction, RootItem * inst, RootItem *, QMainWindow *parent)
00023         : NameAbbrevRootDlg(60, tr("Institute Name:"), 10, tr("Abbreviation:"), parent)
00024 {
00025         statusBar = parent->statusBar();
00026         setInstitute(inst);
00027         
00028         createActions();
00029         initialise (btnAction);
00030 }
00031 
00032 void InstituteDlg::enableBtn()
00033 {
00034         QString name = getNameOnDB();
00035         QString abbrev = getAbbrevOnDB();
00036         
00037         NameAbbrevRootDlg::enableBtn(name
00038                                     ,abbrev
00039                                     ,0
00040                                     ,dataItem
00041                                     ,Institute::uniqueName
00042                                     ,Institute::uniqueAbbrev);
00043 }
00044 
00045 void InstituteDlg::okPressed()
00046 {
00047         if (dataItem == 0)
00048         {
00052                 Institute * instObj = new Institute(Institute::NOT_ON_DB,getName(), getAbbrev());
00053                 dataItem = new InstItem(instObj,0);
00054         }
00055         else
00056         {
00057                 getInstItem()->setData(0,getName());
00058                 getInstItem()->setData(1,getAbbrev());
00059         }
00060         accept();
00061 }
00062 
00063 /******************************************************************************
00064  * Private Methods
00065  ******************************************************************************/
00066 void InstituteDlg::createActions()
00067 {
00068         QObject::connect(na_wdgt->getNameWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00069         QObject::connect(na_wdgt->getAbbrevWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00070         QObject::connect(ui.okButton, SIGNAL(clicked()), this, SLOT(okPressed()));
00071 }
00072 
00073 void InstituteDlg::initialise (int btnAction)
00074 {
00075         QString name = "";
00076         QString abbrev = "";
00077         if (dataItem != 0)
00078         {
00079                 name = getInstItem()->getInstName();
00080                 abbrev = getInstItem()->getInstAbbrev();
00081         }
00082         setName(name);
00083         setAbbrev(abbrev);
00084         
00085         RootDlg::initialise(btnAction, tr("institute"), name);
00086         if (btnAction == ControlPanel::BTN_DELETE)
00087         {
00088                 disableControls();
00089                 ui.okButton->setEnabled(true);
00090         }
00091 //      getStatusBar()->showMessage(windowTitle());
00092 }

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