00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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:
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
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:
00065 QVBoxLayout * vboxLayout;
00066 Ui::Name_Abbrev_wdgt wdgt;
00067
00068 private:
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