Author: sh-sh-sh
Date: Thu Jul 12 16:06:20 2007
New Revision: 39364
URL: http://svn.opensuse.org/viewcvs/yast?rev=39364&view=rev
Log:
new helper class
Added:
branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.cc
branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.h
Modified:
branches/tmp/sh/mod-ui/qt/src/Makefile.am
Modified: branches/tmp/sh/mod-ui/qt/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/Makefile.am?rev=39364&r1=39363&r2=39364&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/Makefile.am (original)
+++ branches/tmp/sh/mod-ui/qt/src/Makefile.am Thu Jul 12 16:06:20 2007
@@ -59,8 +59,8 @@
YQOptionalWidgetFactory.cc \
YQPackageSelectorPlugin.cc \
YQSignalBlocker.cc \
- \
YQIconPool.cc \
+ YQWidgetCaption.cc \
\
YQAlignment.cc \
YQBarGraph.cc \
@@ -128,6 +128,7 @@
BUILT_SOURCES = \
YQUI.moc \
YQApplication.moc \
+ YQWidgetCaption.cc \
\
YQAlignment.moc \
YQBarGraph.moc \
@@ -179,6 +180,7 @@
YQUI_builtins.o YQUI_builtins.lo: YQUI.moc
YQUI_x11.o YQUI_x11.lo: YQUI.moc
YQApplication.o YQApplication.lo: YQApplication.moc
+YQWidgetCaption.o YQWidgetCaption.lo: YQWidgetCaption.moc
YQAlignment.o YQAlignment.lo: YQAlignment.moc
YQBarGraph.o YQBarGraph.lo: YQBarGraph.moc
@@ -230,6 +232,7 @@
YQUI.moc: YQUI.h
YQApplication.moc: YQApplication.h
+YQWidgetCaption.moc: YQWidgetCaption.h
YQAlignment.moc: YQAlignment.h
YQBarGraph.moc: YQBarGraph.h
Added: branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.cc?rev=39364&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.cc (added)
+++ branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.cc Thu Jul 12 16:06:20 2007
@@ -0,0 +1,85 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YQWidgetCaption.cc
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+
+#include "YQWidgetCaption.h"
+#include "utf8.h"
+
+
+YQWidgetCaption::YQWidgetCaption( const string & text, QWidget * parent )
+ : QLabel( fromUTF8( text ), parent )
+{
+ setTextFormat( QLabel::PlainText );
+ handleVisibility( text );
+}
+
+
+YQWidgetCaption::YQWidgetCaption( const QString & text, QWidget * parent )
+ : QLabel( text, parent )
+{
+ handleVisibility( text );
+}
+
+
+YQWidgetCaption::~YQWidgetCaption()
+{
+ // NOP
+}
+
+
+void YQWidgetCaption::setText ( const string & newText )
+{
+ setText( fromUTF8( newText ) );
+}
+
+
+void YQWidgetCaption::setText ( const QString & newText )
+{
+ QLabel::setText( newText );
+ handleVisibility( newText.isEmpty() );
+}
+
+
+void YQWidgetCaption::handleVisibility( const string & text )
+{
+ handleVisibility( text.empty() );
+}
+
+
+void YQWidgetCaption::handleVisibility( const QString & text )
+{
+ handleVisibility( text.isEmpty() );
+}
+
+
+void YQWidgetCaption::handleVisibility( bool textIsEmpty )
+{
+ if ( textIsEmpty )
+ {
+ if ( isVisible() )
+ hide();
+ }
+ else
+ {
+ if ( isHidden() )
+ show();
+ }
+}
+
+
+#include "YQWidgetCaption.moc"
Added: branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.h?rev=39364&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.h (added)
+++ branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.h Thu Jul 12 16:06:20 2007
@@ -0,0 +1,73 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YQWidgetCaption.h
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+
+#ifndef YQWidgetCaption_h
+#define YQWidgetCaption_h
+
+#include
+#include <string>
+using std::string;
+
+
+/**
+ * Helper class for captions (labels) above a widget: Takes care of hiding
+ * itself when its text is empty and showing when its text becomes non-empty.
+ **/
+class YQWidgetCaption: public QLabel
+{
+ Q_OBJECT
+
+public:
+
+ /**
+ * Constuctors.
+ *
+ * If the text is empty, the widget will be created, but hidden right
+ * away. It can later be made visible again with setText() with a non-empty
+ * text.
+ **/
+ YQWidgetCaption( const string & text, QWidget * parent );
+ YQWidgetCaption( const QString & text, QWidget * parent );
+
+ /**
+ * Destructor.
+ **/
+ virtual ~YQWidgetCaption();
+
+ /**
+ * Change the text and handle visibility:
+ * If the new text is empty, hide this widget.
+ * If the new text is non-empty, show this widget.
+ **/
+ virtual void setText ( const string & newText );
+ virtual void setText ( const QString & newText );
+
+private:
+
+ /**
+ * Make the widget visible if the text is non-empty or hide it if it is
+ * empty.
+ **/
+ void handleVisibility( const string & text );
+ void handleVisibility( const QString & text );
+ void handleVisibility( bool textIsEmpty );
+};
+
+
+#endif // YQWidgetCaption_h
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org