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

Name_Abbrev_wdgt.h

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 
00021 #ifndef __NAME_ABBREV_WDGT_H
00022 #define __NAME_ABBREV_WDGT_H
00023 
00024 #include <QtGui>
00025 
00026 #include "ui_Name_Abbrev_wdgt.h"
00027 
00028 class NameAbbrevWidget : public QWidget
00029 {
00030     Q_OBJECT
00031 
00032 public: // methods
00033         NameAbbrevWidget(int nameWidth
00034                    ,QString nameLabel
00035                    ,int abbrevWidth
00036                    ,QString abbrevLabel
00037                    ,QWidget * widgetParent
00038                    ,QBoxLayout * layoutParent
00039                    ,QDialog * dialogParent);
00040         inline QString getName () {return wdgt.edtName->text();}
00041         inline void setName (QString name) {wdgt.edtName->setText(name);}
00042         inline QString getAbbrev () {return wdgt.edtAbbrev->text();}
00043         inline void setAbbrev (QString name) {wdgt.edtAbbrev->setText(name);}
00044         inline void setNameLabel (QString label) {wdgt.lblName->setText(label);}
00045         inline void setAbbrevLabel (QString label) {wdgt.lblAbbrev->setText(label);}
00046         inline void setNameLength(int len);
00047         inline void setAbbrevLength(int len);
00048 
00049 
00050         inline QWidget * getNameWdgt(){return wdgt.edtName;}
00051         inline QWidget * getAbbrevWdgt(){return wdgt.edtAbbrev;}
00052 //      inline void setMaxNameLength(int len){wdgt.edtName->setMaxLength(len);}
00053         inline void disableControls(){disableName(); disableAbbrev();}
00054         inline void disableName()
00055         {
00056                 wdgt.edtName->setEnabled(false);
00057                 wdgt.edtName->setFrame(false);
00058         }
00059         inline void disableAbbrev()
00060         {
00061                 wdgt.edtAbbrev->setEnabled(false);
00062                 wdgt.edtAbbrev->setFrame(false);
00063         }
00064 protected: // Properties
00065         QVBoxLayout * vboxLayout;
00066         Ui::Name_Abbrev_wdgt wdgt;
00067         
00068 private: // Methods
00069 
00070 private slots:
00071 };
00072 
00073 inline void NameAbbrevWidget::setNameLength(int len)
00074 {
00075         wdgt.edtName->setMaxLength(len);
00076         int newWidth = len * 7;
00077         if (wdgt.edtName->width() < newWidth)
00078         {
00079                 wdgt.edtName->setMinimumSize(newWidth, wdgt.edtName->height());
00080                 wdgt.edtName->setMaximumSize(newWidth, wdgt.edtName->height());
00081                 wdgt.edtName->resize(newWidth, wdgt.edtName->height());
00082         }
00083         if ((newWidth + 105) > width())
00084         {
00085                 resize(newWidth + 105, height());
00086                 setMinimumWidth(newWidth);
00087                 setMaximumWidth(newWidth);
00088         }
00089 }
00090 
00091 inline void NameAbbrevWidget::setAbbrevLength(int len)
00092 {
00093         wdgt.edtAbbrev->setMaxLength(len);
00094         int newWidth = len * 7;
00095         if (wdgt.edtAbbrev->width() < newWidth)
00096         {
00097                 wdgt.edtAbbrev->setMinimumSize(newWidth, wdgt.edtAbbrev->height());
00098                 wdgt.edtAbbrev->setMaximumSize(newWidth, wdgt.edtAbbrev->height());
00099                 wdgt.edtAbbrev->resize(newWidth, wdgt.edtAbbrev->height());
00100         }
00101         if ((newWidth + 105) > width())
00102         {
00103                 resize(newWidth + 105, height());
00104                 setMinimumWidth(newWidth);
00105                 setMaximumWidth(newWidth);
00106         }
00107 }
00108 
00109 #endif

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