libyui-qt
2.43.5
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YQWidgetCaption.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 00026 #ifndef YQWidgetCaption_h 00027 #define YQWidgetCaption_h 00028 00029 #include <qlabel.h> 00030 #include <string> 00031 using std::string; 00032 00033 00034 /** 00035 * Helper class for captions (labels) above a widget: Takes care of hiding 00036 * itself when its text is empty and showing when its text becomes non-empty. 00037 **/ 00038 class YQWidgetCaption: public QLabel 00039 { 00040 Q_OBJECT 00041 00042 public: 00043 00044 /** 00045 * Constuctors. 00046 * 00047 * If the text is empty, the widget will be created, but hidden right 00048 * away. It can later be made visible again with setText() with a non-empty 00049 * text. 00050 **/ 00051 YQWidgetCaption( QWidget * parent, const std::string & text ); 00052 YQWidgetCaption( QWidget * parent, const QString & text ); 00053 00054 /** 00055 * Destructor. 00056 **/ 00057 virtual ~YQWidgetCaption(); 00058 00059 /** 00060 * Change the text and handle visibility: 00061 * If the new text is empty, hide this widget. 00062 * If the new text is non-empty, show this widget. 00063 **/ 00064 virtual void setText ( const std::string & newText ); 00065 virtual void setText ( const QString & newText ); 00066 00067 private: 00068 00069 /** 00070 * Make the widget visible if the text is non-empty or hide it if it is 00071 * empty. 00072 **/ 00073 void handleVisibility( const std::string & text ); 00074 void handleVisibility( const QString & text ); 00075 void handleVisibility( bool textIsEmpty ); 00076 }; 00077 00078 00079 #endif // YQWidgetCaption_h