From 09fbde99ce5974c6f3c9022c1d769ecb51162839 Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 21 Jul 2005 10:34:26 +0000 Subject: [PATCH] Methods setIsSystem, isSystem, setWidgetFlags, widgetFlags are removed. The according values can be accessed through common setProperty/property methods with names: "system" and "widget_flags" --- src/Qtx/QtxListResourceEdit.cxx | 104 +++++++++++++++++--------------- src/Qtx/QtxListResourceEdit.h | 8 +-- 2 files changed, 58 insertions(+), 54 deletions(-) diff --git a/src/Qtx/QtxListResourceEdit.cxx b/src/Qtx/QtxListResourceEdit.cxx index 94d2f6d61..2b8435733 100644 --- a/src/Qtx/QtxListResourceEdit.cxx +++ b/src/Qtx/QtxListResourceEdit.cxx @@ -935,11 +935,12 @@ QtxListResourceEdit::FontItem::FontItem( const QString& title, QtxResourceEdit* myBold = new QCheckBox( tr( "Bold" ), this ); myItalic = new QCheckBox( tr( "Italic" ), this ); myUnderline = new QCheckBox( tr( "Underline" ), this ); + ( new QFrame( this ) )->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); connect( myFamilies, SIGNAL( activated( int ) ), this, SLOT( onActivateFamily( int ) ) ); - setWidgetFlags( All ); - setIsSystem( true ); + setProperty( "widget_flags", ( int )All ); + setProperty( "system", ( bool )true ); } QtxListResourceEdit::FontItem::~FontItem() @@ -965,52 +966,15 @@ void QtxListResourceEdit::FontItem::retrieve() setParams( f.bold(), f.italic(), f.underline() ); } -void QtxListResourceEdit::FontItem::setWidgetFlags( const WidgetFlags wf ) -{ - myFlags = wf; - myFamilies ->setShown( wf & Family ); - mySizes ->setShown( wf & Size ); - mySizes->lineEdit()->setReadOnly( ( wf & UserSize )==0 ); - myBold ->setShown( wf & Bold ); - myItalic ->setShown( wf & Italic ); - myUnderline->setShown( wf & Underline ); - - internalUpdate(); -} - -QtxListResourceEdit::FontItem::WidgetFlags QtxListResourceEdit::FontItem::widgetFlags() const -{ - return myFlags; -} - -void QtxListResourceEdit::FontItem::setIsSystem( const bool isSystem ) -{ - if( myIsSystem==isSystem ) - return; - - myIsSystem = isSystem; - - QVariant families = property( "families" ); - QString fam = family(); - - myFamilies->clear(); - if( families.canCast( QVariant::StringList ) ) - { - QStringList list = families.toStringList(); - myFamilies->insertStringList( list ); - } - - setFamily( fam ); -} - -bool QtxListResourceEdit::FontItem::isSystem() const -{ - return myIsSystem; -} - QVariant QtxListResourceEdit::FontItem::property( const QString& name ) const { - if( isSystem() ) + if( name=="system" ) + return myIsSystem; + + else if( name=="widget_flags" ) + return ( int )myFlags; + + if( myIsSystem ) { if( name=="families" ) { @@ -1051,6 +1015,9 @@ QVariant QtxListResourceEdit::FontItem::property( const QString& name ) const else if( parts[1]=="default_size" ) { + if( parts[0].isEmpty() ) + return 0; + QFontDatabase fdb; QValueList sizes = fdb.pointSizes( parts[0] ); if( sizes.count()>0 ) @@ -1070,7 +1037,50 @@ QVariant QtxListResourceEdit::FontItem::property( const QString& name ) const void QtxListResourceEdit::FontItem::setProperty( const QString& name, const QVariant& value ) { - myProperties[ name ] = value; + if( name=="system" ) + { + if( !value.canCast( QVariant::Bool ) ) + return; + + bool isSystem = value.toBool(); + if( myIsSystem==isSystem ) + return; + + myIsSystem = isSystem; + + QVariant families = property( "families" ); + QString fam = family(); + + myFamilies->clear(); + if( families.canCast( QVariant::StringList ) ) + { + QStringList list = families.toStringList(); + myFamilies->insertStringList( list ); + } + + setFamily( fam ); + } + + else if( name=="widget_flags" ) + { + if( !value.canCast( QVariant::Int ) ) + return; + + int wf = value.toInt(); + + myFlags = wf; + myFamilies ->setShown( wf & Family ); + mySizes ->setShown( wf & Size ); + mySizes->lineEdit()->setReadOnly( ( wf & UserSize )==0 ); + myBold ->setShown( wf & Bold ); + myItalic ->setShown( wf & Italic ); + myUnderline->setShown( wf & Underline ); + + internalUpdate(); + } + + else + myProperties[ name ] = value; } void QtxListResourceEdit::FontItem::setFamily( const QString& f ) diff --git a/src/Qtx/QtxListResourceEdit.h b/src/Qtx/QtxListResourceEdit.h index acc6e9ca8..99ddfb75d 100644 --- a/src/Qtx/QtxListResourceEdit.h +++ b/src/Qtx/QtxListResourceEdit.h @@ -389,12 +389,6 @@ public: FontItem( const QString&, QtxResourceEdit*, Item*, QWidget* = 0 ); virtual ~FontItem(); - void setWidgetFlags( const WidgetFlags ); - WidgetFlags widgetFlags() const; - - void setIsSystem( const bool ); - bool isSystem() const; - virtual void store(); virtual void retrieve(); @@ -414,7 +408,7 @@ private: void internalUpdate(); private: - WidgetFlags myFlags; + int myFlags; bool myIsSystem; QtxComboBox *myFamilies, *mySizes; QCheckBox *myBold, *myItalic, *myUnderline; -- 2.39.2