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

Name_Root_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 "Name_Root_dlg.h"
00021 #define SPACE 8
00022 #define MARGIN 6
00023 
00024 NameRootDlg::NameRootDlg(int textWidth, QString textLabel, QMainWindow *parent)
00025         : RootDlg()
00026 {
00027         // The status bar must be set up here because RootDlg is a virtual parent
00028         statusBar = parent->statusBar();
00029         n_wdgt = new NameWidget(textWidth, textLabel, ui.frame, ui.vboxLayout2, this);
00030 }
00031 
00032 bool NameRootDlg::enableBtn(QString oldName
00033                            ,int parentID
00034                            ,RootItem * rootItem
00035                            ,sql * dbConn
00036                            ,bool (*pUniqueName)(QString, int, sql*)
00037                            )
00038 {
00039         if(getName().isEmpty())
00040         {
00041                 ui.okButton->setEnabled(false);
00042                 return false;
00043         }
00044         
00045         if (rootItem != 0) // existing object
00046         {
00047                 if (oldName == getName())
00048                 {
00049                         ui.okButton->setEnabled(false);
00050                         return true;
00051                 }
00052                 else
00053                 {
00054                         if(oldName != getName() && !pUniqueName(getName(),parentID, dbConn) )
00055                         {
00056                                 ui.okButton->setEnabled(false);
00057                                 return false;
00058                         }
00059                         else
00060                         {
00061                                 ui.okButton->setEnabled(true);
00062                                 return true;
00063                         }
00064                 }
00065         }
00066         else // new object
00067         {
00068                 if (pUniqueName(getName(), parentID, dbConn))
00069                 {
00070                         ui.okButton->setEnabled(true);
00071                         return true;
00072                 }
00073                 else
00074                 {
00075                         ui.okButton->setEnabled(false);
00076                         return false;
00077                 }
00078         }
00079         return true;
00080 }

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