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

Programme_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 "Programme_dlg.h"
00021 
00022 #include "control_panel.h"
00023 
00024 ProgrammeDlg::ProgrammeDlg(int btnAction
00025                                                                   ,RootItem * programme
00026                                                                   ,RootItem * institute
00027                                                                   ,QMainWindow *parent)
00028         : NameRootDlg(60, tr("Institute Name:"), parent)
00029         , NameAbbrevRootDlg(80, tr("Prog. Name:"), 12, tr("Abbreviation:"), parent)
00030 {
00031         dataItem = dynamic_cast<ProgItem *>(programme);
00032         parentItem = dynamic_cast<InstItem *>(institute);
00033         
00034         if (parentItem != 0)
00035                 setInstName(getInstName());
00036 
00037         createActions();
00038         initialise (btnAction);
00039 }
00040 
00041 
00042 void ProgrammeDlg::enableBtn()
00043 {
00044         QString name = getNameOnDB();
00045         QString abbrev = getAbbrevOnDB();
00046         NameAbbrevRootDlg::enableBtn(name
00047                                     ,abbrev
00048                                     ,parentItem->getID()
00049                                     ,getProgItem()
00050                                     ,Programme::uniqueName
00051                                     ,Programme::uniqueAbbrev);
00052 }
00053 
00054 
00055 
00056 void ProgrammeDlg::okPressed()
00057 {
00058         if (dataItem == 0)
00059         {
00060                 Programme * progObj = new Programme(Programme::NOT_ON_DB
00061                                                    ,NameAbbrevRootDlg::getName()
00062                                                    ,getAbbrev()
00063                                                    ,getInstItem()->getInstitute()
00064                                                    );
00065                 dataItem = new ProgItem(progObj,getInstItem());
00066         }
00067         else
00068         {
00069                 getProgItem()->setProgName(NameAbbrevRootDlg::getName());
00070                 getProgItem()->setProgAbbrev(getAbbrev());
00071         }
00072         accept();
00073 }
00074 
00075 /******************************************************************************
00076  * Private Methods
00077  ******************************************************************************/
00078 
00079 void ProgrammeDlg::createActions()
00080 {
00081         QObject::connect(na_wdgt->getNameWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00082         QObject::connect(na_wdgt->getAbbrevWdgt(), SIGNAL(textEdited(const QString & )), this, SLOT(enableBtn()));
00083         QObject::connect(ui.okButton, SIGNAL(clicked()), this, SLOT(okPressed()));
00084 }
00085 
00086 void ProgrammeDlg::initialise (int btnAction)
00087 {
00088         QString name = "";
00089         QString abbrev = "";
00090         if (dataItem != 0)
00091         {
00092                 name = getProgItem()->getProgName();
00093                 abbrev = getProgItem()->getProgAbbrev();
00094         }
00095         n_wdgt->disableName();
00096         
00097         na_wdgt->setName(name);
00098         na_wdgt->setAbbrev(abbrev);
00099         
00100         RootDlg::initialise(btnAction, tr("programme"), name);
00101 
00102         getStatusBar()->showMessage(windowTitle());
00103 
00104         if (btnAction == ControlPanel::BTN_DELETE)
00105         {
00106                 NameAbbrevRootDlg::disableControls();
00107                 ui.okButton->setEnabled(true);
00108         }
00109 }

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