kexi

kexinamewidget.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KEXINAMEWIDGET_H
00021 #define KEXINAMEWIDGET_H
00022 
00023 #include <qlabel.h>
00024 #include <qlayout.h>
00025 #include <klineedit.h>
00026 
00027 namespace KexiUtils {
00028 class Validator;
00029 class MultiValidator;
00030 }
00031 
00032 class KEXIMAIN_EXPORT KexiNameWidget : public QWidget
00033 {
00034     Q_OBJECT
00035 
00036     public:
00037         KexiNameWidget(const QString& message, 
00038             QWidget * parent = 0, const char * name = 0, WFlags fl = 0);
00039 
00040         KexiNameWidget(const QString& message, 
00041             const QString& nameLabel, const QString& nameText, 
00042             const QString& captionLabel, const QString& captionText, 
00043             QWidget * parent = 0, const char * name = 0, WFlags fl = 0);
00044 
00045         virtual ~KexiNameWidget(); 
00046 
00047         QLabel* captionLabel() const { return lbl_caption; }
00048         QLabel* nameLabel() const { return lbl_name; }
00049         KLineEdit* captionLineEdit() const { return le_caption; }
00050         KLineEdit* nameLineEdit() const { return le_name; }
00051 
00052         QString messageText() const { return lbl_message->text(); }
00053         
00054         void setMessageText(const QString& msg);
00055 
00057         QString captionText() const;
00058 
00059         void setCaptionText(const QString& capt);
00061 
00062         QString nameText() const;
00063 
00064         void setNameText(const QString& name);
00065 
00069         void setWarningForName( const QString& txt ) { m_nameWarning = txt; }
00070 
00074         void setWarningForCaption( const QString& txt ) { m_captionWarning = txt; }
00075 
00077         bool empty() const;
00078 
00079         KexiUtils::Validator *nameValidator() const;
00080 
00084         void addNameSubvalidator( KexiUtils::Validator* validator, bool owned = true );
00085 
00087         bool isNameRequired() const;
00088 
00089         void setNameRequired( bool set );
00090 
00092         bool isCaptionRequired() const { return m_caption_required; }
00093 
00094         void setCaptionRequired(bool set) { m_caption_required = set; }
00095 
00096     public slots:
00098         virtual void clear();
00099 
00103         bool checkValidity();
00104 
00105     signals:
00107         void returnPressed();
00108 
00110         void textChanged();
00111 
00113         void messageChanged();
00114 
00115     protected slots:
00116         void slotNameTxtChanged(const QString&);
00117         void slotCaptionTxtChanged(const QString&);
00118 //      bool eventFilter( QObject *obj, QEvent *ev );
00119     
00120     protected:
00121         void init(
00122             const QString& message, 
00123             const QString& nameLabel, const QString& nameText, 
00124             const QString& captionLabel, const QString& captionText);
00125 
00126         QLabel* lbl_message;
00127         QLabel* lbl_caption;
00128         QLabel* lbl_name;
00129         KLineEdit* le_caption;
00130         KLineEdit* le_name;
00131         QGridLayout* lyr;
00132         KexiUtils::MultiValidator *m_validator;
00133         QString m_nameWarning, m_captionWarning;
00134 
00135         bool m_le_name_txtchanged_disable : 1;
00136         bool m_le_name_autofill : 1;
00137         bool m_caption_required : 1;
00138 
00139         friend class KexiNameDialog;
00140 };
00141 
00142 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys