From 11bac33c756eaccf9f7000b61d288562038784e6 Mon Sep 17 00:00:00 2001 From: san Date: Tue, 30 Nov 2010 10:50:02 +0000 Subject: [PATCH] Option "show_single" was added in QtxPageListPrefItem. --- src/Qtx/QtxPagePrefMgr.cxx | 36 ++++++++++++++++++++++++++++++++++-- src/Qtx/QtxPagePrefMgr.h | 4 ++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/Qtx/QtxPagePrefMgr.cxx b/src/Qtx/QtxPagePrefMgr.cxx index 5ace6c4d7..d7522d4de 100644 --- a/src/Qtx/QtxPagePrefMgr.cxx +++ b/src/Qtx/QtxPagePrefMgr.cxx @@ -569,7 +569,8 @@ void QtxPageNamedPrefItem::adjustLabels( QtxPagePrefItem* parent ) QtxPagePrefListItem::QtxPagePrefListItem( const QString& title, QtxPreferenceItem* parent, const QString& sect, const QString& param ) : QtxPagePrefItem( title, parent, sect, param ), - myFix( false ) + myFix( false ), + mySingle( true ) { QSplitter* main = new QSplitter( Qt::Horizontal ); main->setChildrenCollapsible( false ); @@ -644,6 +645,30 @@ void QtxPagePrefListItem::setFixedSize( const bool on ) updateGeom(); } +/*! + \brief Check if the list will be shown even has only 1 item. + \return \c true if the list has be shown with 1 item. + \sa setShowSingle() +*/ +bool QtxPagePrefListItem::isShowSingle() const +{ + return mySingle; +} + +/*! + \brief Set the list will be shown even has only 1 item. + \param on if \c true, the list will be shown always (even has only 1 item). + \sa isShowSingle() +*/ +void QtxPagePrefListItem::setShowSingle( const bool on ) +{ + if ( mySingle == on ) + return; + + mySingle = on; + updateVisible(); +} + /*! \brief Update widget contents. */ @@ -663,6 +688,8 @@ QVariant QtxPagePrefListItem::optionValue( const QString& name ) const { if ( name == "fixed_size" ) return isFixedSize(); + else if ( name == "show_single" ) + return isShowSingle(); else if ( name == "empty_info" || name == "info" ) return emptyInfo(); else @@ -682,6 +709,11 @@ void QtxPagePrefListItem::setOptionValue( const QString& name, const QVariant& v if ( val.canConvert( QVariant::Bool ) ) setFixedSize( val.toBool() ); } + else if ( name == "show_single" ) + { + if ( val.canConvert( QVariant::Bool ) ) + setShowSingle( val.toBool() ); + } else if ( name == "empty_info" || name == "info" ) { if ( val.canConvert( QVariant::String ) ) @@ -791,7 +823,7 @@ void QtxPagePrefListItem::updateVisible() if ( selected() == -1 && myList->count() ) setSelected( myList->item( 0 )->data( Qt::UserRole ).toInt() ); - //myList->setVisible( myList->count() > 1 ); + myList->setVisible( myList->count() > 1 || isShowSingle() ); updateState(); updateGeom(); diff --git a/src/Qtx/QtxPagePrefMgr.h b/src/Qtx/QtxPagePrefMgr.h index 2169bfe42..c2b3bccea 100644 --- a/src/Qtx/QtxPagePrefMgr.h +++ b/src/Qtx/QtxPagePrefMgr.h @@ -163,6 +163,9 @@ public: bool isFixedSize() const; void setFixedSize( const bool ); + bool isShowSingle() const; + void setShowSingle( const bool ); + private slots: void onItemSelectionChanged(); @@ -187,6 +190,7 @@ private: bool myFix; QListWidget* myList; QStackedWidget* myStack; + bool mySingle; QString myInfText; QLabel* myInfLabel; -- 2.39.2