levaluecombo.h

Go to the documentation of this file.
00001 // OSB library ************************************************ -*- C++ -*-
00006 /*
00007   AUTHOR(S): Stephan Broennimann (vb)
00008 
00009   RCS information
00010    $Name: OSB_060808 $
00011    $Revision: 1.7 $
00012 
00013   License
00014    OSB rating and billing library for communication networks
00015    Copyright (C) 2004, 2005, 2006  OSB systems
00016 
00017    This file may be distributed and/or modify under the terms of the
00018    GNU General Public License (GPL) as published by the Free Software
00019    Foundation which is provided in the file LICENSE.GPL included in the
00020    packaging of this file.
00021 
00022    The file is distributed in the hope that it will be useful, but WITHOUT
00023    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00024    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00025    for more details.
00026 
00027    Holders of a OSB Commercial License may use this file under the terms
00028    and conditions of this commercial license.
00029  */
00030 #ifndef _LEVALUECOMBO_H_
00031 #define _LEVALUECOMBO_H_
00032 
00033 // ************************************************************************
00034 // included header files
00035 // + standard includes
00036 
00037 // + libraries
00038 #include <qlineedit.h>
00039 
00040 // + local headers
00041 #include "osbcombos.h"                  // for template LeValueCombo
00042 
00043 // ************************************************************************
00044 // class declarations
00045 
00046 // ************************************************************************
00047 // namespace extensions
00048 namespace OSB_GUI {
00049 
00050 // ************************************************************************
00051 // forward declarations
00052 
00053 // ************************************************************************
00054 // type definitions
00055 
00056 // ************************************************************************
00057 // class definitions
00058 
00071     class LeCombo : public QLineEdit {
00072         Q_OBJECT                            // for vim ->;
00073     public:
00075         explicit LeCombo(
00076                   QWidget*       parent,
00077             const char*          name  = "leCombo_",
00078                   FocusOutCombo* combo = 0
00079         );
00081         virtual ~LeCombo();
00082     public:
00084         void setCombo(FocusOutCombo* combo);
00085     protected:
00094         virtual void setComboItem() const;
00095     protected slots:
00104         virtual void comboActivated(int index);
00105     private slots:
00109         void comboFocusOut(QFocusEvent* e);
00110     private:
00120         void focusInEvent(QFocusEvent* e);
00121 
00127         void resizeEvent(QResizeEvent* e);
00129         virtual QSize sizeHint() const;
00131         virtual QSize minimumSizeHint() const;
00132     private:
00134         FocusOutCombo* combo_;
00136         QWidget* prevFocus_;
00138         QWidget* nextFocus_;
00139     };                                  // class LeCombo
00140 
00144     template<typename Value>
00145     class LeValueCombo : public LeCombo {
00146     public:
00148         LeValueCombo(
00149                   QWidget*           parent,
00150             const char*              name    = "leValueCombo_",
00151                   ValueCombo<Value>* combo   = 0
00152         );
00153     public:
00155         const Value& getValue() const;
00157         void setCombo(ValueCombo<Value>* combo);
00159         void setValue(
00160             const Value&       value,
00161             const std::string& text
00162         );
00163     private:
00165         void setComboItem() const;
00171         void comboActivated(int index);
00172     private:
00174         Value value_;
00176         ValueCombo<Value>* combo_;
00177     };                                  // class LeValueCombo
00178 }                                       // namespace OSB_GUI
00179 
00180 // ************************************************************************
00181 // template definitions
00182 namespace OSB_GUI {
00183 
00184     // ********************************************************************
00185     // template LeValueCombo
00186     template<typename Value>
00187     LeValueCombo<Value>::LeValueCombo(
00188               QWidget*           parent,
00189         const char*              name,
00190               ValueCombo<Value>* combo
00191     ) : LeCombo(parent, name, 0), combo_(combo)
00192     {
00193         setCombo(combo);
00194     }
00195 
00196     template<typename Value>
00197     const Value& LeValueCombo<Value>::getValue() const
00198     {
00199         return value_;
00200     }
00201 
00202     template<typename Value>
00203     void LeValueCombo<Value>::setCombo(ValueCombo<Value>* combo)
00204     {
00205         combo_ = combo;
00206         LeCombo::setCombo(combo_);
00207         if (0 != combo_) value_ = combo_->getValue();
00208     }
00209 
00210     template<typename Value>
00211     void LeValueCombo<Value>::setValue(
00212         const Value&       value,
00213         const std::string& text
00214     )
00215     {
00216         value_ = value;
00217         setText(text);
00218     }
00219 
00220     template<typename Value>
00221     void LeValueCombo<Value>::setComboItem() const
00222     {
00223         if (0 != combo_) combo_->select(value_);
00224     }
00225 
00226     template<typename Value>
00227     void LeValueCombo<Value>::comboActivated(int index)
00228     {
00229         if (0 == combo_) return;
00230         value_ = combo_->getValue(index);
00231         setText(combo_->text(index));
00232     }
00233 }                                       // namespace OSB_GUI
00234 #endif                                  // #ifndef _LEVALUECOMBO_H_

Generated on Sat Sep 2 14:17:36 2006 for OSB Library by  doxygen 1.4.7