1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: QtxPagePrefMgr.cxx
21 // Author: Sergey TELKOV
23 #include "QtxPagePrefMgr.h"
25 #include "QtxGridBox.h"
26 #include "QtxFontEdit.h"
27 #include "QtxGroupBox.h"
28 #include "QtxComboBox.h"
29 #include "QtxIntSpinBox.h"
30 #include "QtxColorButton.h"
31 #include "QtxBiColorTool.h"
32 #include "QtxDoubleSpinBox.h"
33 #include "QtxBackgroundTool.h"
34 #include "QtxResourceMgr.h"
44 #include <QListWidget>
45 #include <QApplication>
46 #include <QDateTimeEdit>
47 #include <QStackedWidget>
49 #include <QScrollArea>
55 bool toStringList(const QVariant& value, QStringList& result)
58 if ( value.type() == QVariant::StringList )
60 result = value.toStringList();
63 else if ( value.type() == QVariant::List )
65 QList<QVariant> valueList = value.toList();
66 for ( QList<QVariant>::const_iterator it = valueList.begin(); it != valueList.end(); ++it )
68 if ( (*it).canConvert( QVariant::String ) )
69 result.append( (*it).toString() );
79 \brief GUI implementation of the QtxPreferenceMgr class: preferences manager.
84 \param resMgr resource manager
85 \param parent parent widget
87 QtxPagePrefMgr::QtxPagePrefMgr( QtxResourceMgr* resMgr, QWidget* parent )
89 QtxPreferenceMgr( resMgr ),
92 myBox = new QtxGridBox( 1, Qt::Horizontal, this, 0 );
93 QVBoxLayout* base = new QVBoxLayout( this );
95 base->setSpacing( 0 );
96 base->addWidget( myBox );
102 QtxPagePrefMgr::~QtxPagePrefMgr()
107 \brief Get recommended size for the widget.
108 \return recommended widget size
110 QSize QtxPagePrefMgr::sizeHint() const
112 return QFrame::sizeHint();
116 \brief Get recommended minimum size for the widget.
117 \return recommended minimum widget size
119 QSize QtxPagePrefMgr::minimumSizeHint() const
121 return QFrame::minimumSizeHint();
125 \brief Customize show/hide widget operation.
126 \param on if \c true the widget is being shown, otherswise
129 void QtxPagePrefMgr::setVisible( bool on )
134 QApplication::instance()->processEvents();
136 QFrame::setVisible( on );
140 \brief Update widget contents.
142 void QtxPagePrefMgr::updateContents()
144 QtxPreferenceMgr::updateContents();
146 QList<QtxPreferenceItem*> lst = childItems();
147 for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
149 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
150 if ( item && item->widget() && item->widget()->parent() != myBox )
151 item->widget()->setParent( myBox );
154 setWindowIcon( icon() );
158 \brief Callback function which is called when the child
159 preference item is added.
160 \param item child item being added
161 \sa itemRemoved(), itemChanged()
163 void QtxPagePrefMgr::itemAdded( QtxPreferenceItem* /*item*/ )
169 \brief Callback function which is called when the child
170 preference item is removed.
171 \param item child item being removed
172 \sa itemAdded(), itemChanged()
174 void QtxPagePrefMgr::itemRemoved( QtxPreferenceItem* /*item*/ )
180 \brief Callback function which is called when the child
181 preference item is modified.
182 \param item child item being modified
183 \sa itemAdded(), itemRemoved()
185 void QtxPagePrefMgr::itemChanged( QtxPreferenceItem* /*item*/ )
191 \brief Get preference item option value.
192 \param name option name
193 \return property value or null QVariant if option is not set
196 QVariant QtxPagePrefMgr::optionValue( const QString& name ) const
198 if ( name == "orientation" )
199 return myBox->orientation() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
201 return QtxPreferenceMgr::optionValue( name );
205 \brief Set preference item option value.
206 \param name option name
207 \param val new property value
210 void QtxPagePrefMgr::setOptionValue( const QString& name, const QVariant& val )
212 if ( name == "orientation" )
214 if ( val.canConvert( QVariant::Int ) )
215 myBox->setOrientation( val.toInt() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal );
218 QtxPreferenceMgr::setOptionValue( name, val );
222 \brief Perform internal initialization.
224 void QtxPagePrefMgr::initialize() const
229 QtxPagePrefMgr* that = (QtxPagePrefMgr*)this;
230 that->initialize( that );
232 // that->myInit = true;
235 void QtxPagePrefMgr::initialize( QtxPreferenceItem* item )
240 QList<QtxPreferenceItem*> lst = item->childItems( false );
241 for ( QList<QtxPreferenceItem*>::iterator it = lst.begin(); it != lst.end(); ++it )
248 \class QtxPagePrefItem
249 \brief Base class for implementation of all the widget-based
253 class QtxPagePrefItem::Listener : public QObject
256 Listener( QtxPagePrefItem* );
259 virtual bool eventFilter( QObject*, QEvent* );
262 QtxPagePrefItem* myItem;
265 QtxPagePrefItem::Listener::Listener( QtxPagePrefItem* item )
271 QtxPagePrefItem::Listener::~Listener()
275 bool QtxPagePrefItem::Listener::eventFilter( QObject* o, QEvent* e )
277 if ( !myItem || myItem->widget() != o )
280 if ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent )
281 myItem->widgetShown();
282 if ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent )
283 myItem->widgetHided();
290 \param title preference item title
291 \param parent parent preference item
292 \param sect resource file section associated with the preference item
293 \param param resource file parameter associated with the preference item
295 QtxPagePrefItem::QtxPagePrefItem( const QString& title, QtxPreferenceItem* parent,
296 const QString& sect, const QString& param )
297 : QtxPreferenceItem( title, sect, param, parent ),
306 QtxPagePrefItem::~QtxPagePrefItem()
312 void QtxPagePrefItem::activate()
314 QtxPreferenceItem::activate();
317 widget()->setFocus();
321 \brief Get preference item editor widget.
322 \return editor widget
325 QWidget* QtxPagePrefItem::widget() const
331 \brief Set preference item editor widget.
332 \param wid editor widget
335 void QtxPagePrefItem::setWidget( QWidget* wid )
337 if ( myWidget && myListener )
338 myWidget->removeEventFilter( myListener );
345 myListener = new Listener( this );
346 myWidget->installEventFilter( myListener );
353 \brief Callback function which is called when the child
354 preference item is added.
355 \param item child item being added
356 \sa itemRemoved(), itemChanged()
358 void QtxPagePrefItem::itemAdded( QtxPreferenceItem* /*item*/ )
364 \brief Callback function which is called when the child
365 preference item is removed.
366 \param item child item being removed
367 \sa itemAdded(), itemChanged()
369 void QtxPagePrefItem::itemRemoved( QtxPreferenceItem* /*item*/ )
375 \brief Callback function which is called when the child
376 preference item is modified.
377 \param item child item being modified
378 \sa itemAdded(), itemRemoved()
380 void QtxPagePrefItem::itemChanged( QtxPreferenceItem* /*item*/ )
386 \brief Store preference item to the resource manager.
388 This method should be reimplemented in the subclasses.
389 Base implementation does nothing.
393 void QtxPagePrefItem::store()
398 \brief Retrieve preference item from the resource manager.
400 This method should be reimplemented in the subclasses.
401 Base implementation does nothing.
405 void QtxPagePrefItem::retrieve()
410 \brief Invoked when preference item widget is shown.
412 void QtxPagePrefItem::widgetShown()
417 \brief Invoked when preference item widget is hided.
419 void QtxPagePrefItem::widgetHided()
423 void QtxPagePrefItem::ensureVisible( QtxPreferenceItem* i )
425 QtxPreferenceItem::ensureVisible();
427 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
428 if ( item && item->widget() )
429 item->widget()->setVisible( true );
433 \brief Find all child items of the QtxPagePrefItem type.
434 \param list used to return list of child items
435 \param rec if \c true, perform recursive search
437 void QtxPagePrefItem::pageChildItems( QList<QtxPagePrefItem*>& list, const bool rec ) const
439 QList<QtxPreferenceItem*> lst = childItems( rec );
440 for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
442 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
449 \brief Called when contents is changed (item is added, removed or modified).
451 Triggers the item update.
453 void QtxPagePrefItem::contentChanged()
459 \class QtxPageNamedPrefItem
460 \brief Base class for implementation of the named preference items
461 (items with text labels).
466 \param title preference item title
467 \param parent parent preference item
468 \param sect resource file section associated with the preference item
469 \param param resource file parameter associated with the preference item
471 QtxPageNamedPrefItem::QtxPageNamedPrefItem( const QString& title, QtxPreferenceItem* parent,
472 const QString& sect, const QString& param )
473 : QtxPagePrefItem( title, parent, sect, param ),
476 QWidget* main = new QWidget();
478 // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parent);
481 QHBoxLayout* base = new QHBoxLayout( main );
482 base->setMargin( 0 );
483 base->setSpacing( 5 );
485 myLabel = new QLabel( title, main );
486 base->addWidget( myLabel );
489 // myLabel = new QLabel( title, aGroup->gridBox() );
493 myLabel->setVisible( !title.isEmpty() );
499 QtxPageNamedPrefItem::~QtxPageNamedPrefItem()
504 \brief Set preference title.
505 \param txt new preference title.
507 void QtxPageNamedPrefItem::setTitle( const QString& txt )
509 QtxPagePrefItem::setTitle( txt );
511 label()->setText( title() );
512 if ( !title().isEmpty() )
513 label()->setVisible( true );
517 \brief Get label widget corresponding to the preference item.
520 QLabel* QtxPageNamedPrefItem::label() const
526 \brief Get control widget corresponding to the preference item.
527 \return control widget
530 QWidget* QtxPageNamedPrefItem::control() const
536 \brief Set control widget corresponding to the preference item.
537 \param wid control widget
540 void QtxPageNamedPrefItem::setControl( QWidget* wid )
542 if ( myControl == wid )
550 // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parentItem());
552 widget()->layout()->addWidget( myControl );
553 widget()->setFocusProxy( myControl );
554 // else myControl->setParent( aGroup->gridBox() );
558 void QtxPageNamedPrefItem::adjustLabels( QtxPagePrefItem* parent )
563 QList<QtxPreferenceItem*> childList = parent->childItems();
565 QList<QtxPageNamedPrefItem*> namedItems;
566 for ( QList<QtxPreferenceItem*>::iterator it = childList.begin(); it != childList.end(); ++it )
568 QtxPageNamedPrefItem* item = dynamic_cast<QtxPageNamedPrefItem*>( *it );
570 namedItems.append( item );
574 for ( QList<QtxPageNamedPrefItem*>::iterator it1 = namedItems.begin(); it1 != namedItems.end(); ++it1 )
576 QtxPageNamedPrefItem* item = *it1;
578 sz = qMax( sz, item->label()->sizeHint().width() );
581 for ( QList<QtxPageNamedPrefItem*>::iterator it2 = namedItems.begin(); it2 != namedItems.end(); ++it2 )
583 QtxPageNamedPrefItem* item = *it2;
585 item->label()->setMinimumWidth( sz );
590 \class QtxPagePrefListItem
591 \brief GUI implementation of the list container preference item.
596 \param title preference item title
597 \param parent parent preference item
598 \param sect resource file section associated with the preference item
599 \param param resource file parameter associated with the preference item
601 QtxPagePrefListItem::QtxPagePrefListItem( const QString& title, QtxPreferenceItem* parent,
602 const QString& sect, const QString& param )
603 : QtxPagePrefItem( title, parent, sect, param ),
606 QSplitter* main = new QSplitter( Qt::Horizontal );
607 main->setChildrenCollapsible( false );
609 main->addWidget( myList = new QListWidget( main ) );
610 main->addWidget( myStack = new QStackedWidget( main ) );
612 myList->setSelectionMode( QListWidget::SingleSelection );
614 myStack->addWidget( myInfLabel = new QLabel( myStack ) );
615 myInfLabel->setAlignment( Qt::AlignCenter );
617 connect( myList, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) );
625 QtxPagePrefListItem::~QtxPagePrefListItem()
630 \brief Get message text which is shown if the container is empty.
634 QString QtxPagePrefListItem::emptyInfo() const
640 \brief Set message text which is shown if the container is empty.
641 \param new message text
644 void QtxPagePrefListItem::setEmptyInfo( const QString& inf )
646 if ( myInfText == inf )
655 \brief Check if the preference item widget is of fixed size.
656 \return \c true if the widget has the fixed size
659 bool QtxPagePrefListItem::isFixedSize() const
665 \brief Set the preference item widget to be of fixed size.
666 \param on if \c true, the widget will have the fixed size
669 void QtxPagePrefListItem::setFixedSize( const bool on )
680 \brief Update widget contents.
682 void QtxPagePrefListItem::updateContents()
684 QtxPagePrefItem::updateContents();
689 \brief Get preference item option value.
690 \param name option name
691 \return property value or null QVariant if option is not set
694 QVariant QtxPagePrefListItem::optionValue( const QString& name ) const
696 if ( name == "fixed_size" )
697 return isFixedSize();
698 else if ( name == "empty_info" || name == "info" )
701 return QtxPagePrefItem::optionValue( name );
705 \brief Set preference item option value.
706 \param name option name
707 \param val new property value
710 void QtxPagePrefListItem::setOptionValue( const QString& name, const QVariant& val )
712 if ( name == "fixed_size" )
714 if ( val.canConvert( QVariant::Bool ) )
715 setFixedSize( val.toBool() );
717 else if ( name == "empty_info" || name == "info" )
719 if ( val.canConvert( QVariant::String ) )
720 setEmptyInfo( val.toString() );
723 QtxPagePrefItem::setOptionValue( name, val );
726 void QtxPagePrefListItem::widgetShown()
731 void QtxPagePrefListItem::ensureVisible( QtxPreferenceItem* i )
736 QtxPreferenceItem::ensureVisible( i );
738 setSelected( i->id() );
743 \brief Called when the selection in the list box is changed.
745 void QtxPagePrefListItem::onItemSelectionChanged()
751 \brief Update information label widget.
753 void QtxPagePrefListItem::updateInfo()
756 QtxPagePrefItem* item = selectedItem();
759 infoText = emptyInfo();
760 QRegExp rx( "%([%|N])" );
763 while ( ( idx = rx.indexIn( infoText ) ) != -1 )
765 if ( rx.cap() == QString( "%%" ) )
766 infoText.replace( idx, rx.matchedLength(), "%" );
767 else if ( rx.cap() == QString( "%N" ) )
768 infoText.replace( idx, rx.matchedLength(), item->title() );
771 myInfLabel->setText( infoText );
775 \brief Update widget state.
777 void QtxPagePrefListItem::updateState()
779 QtxPagePrefItem* item = selectedItem();
780 QWidget* wid = item && !item->isEmpty() ? item->widget() : myInfLabel;
782 myStack->setCurrentWidget( wid );
788 \brief Update visibile child widgets.
790 void QtxPagePrefListItem::updateVisible()
792 QList<QtxPagePrefItem*> items;
793 pageChildItems( items );
795 QMap<QWidget*, int> map;
796 for ( int i = 0; i < (int)myStack->count(); i++ )
797 map.insert( myStack->widget( i ), 0 );
799 int selId = selected();
801 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
803 if ( (*it)->isEmpty() && myInfText.isEmpty() )
806 myList->addItem( (*it)->title() );
807 myList->item( myList->count() - 1 )->setIcon( (*it)->icon() );
808 myList->item( myList->count() - 1 )->setData( Qt::UserRole, (*it)->id() );
810 QWidget* wid = (*it)->widget();
811 if ( !map.contains( wid ) )
812 myStack->addWidget( wid );
817 map.remove( myInfLabel );
819 for ( QMap<QWidget*, int>::const_iterator it = map.begin(); it != map.end(); ++it )
820 myStack->removeWidget( it.key() );
822 setSelected( selId );
823 if ( selected() == -1 && myList->count() )
824 setSelected( myList->item( 0 )->data( Qt::UserRole ).toInt() );
826 //myList->setVisible( myList->count() > 1 );
833 \brief Update widget geometry.
835 void QtxPagePrefListItem::updateGeom()
838 myList->setFixedWidth( myList->minimumSizeHint().width() + 10 );
841 myList->setMinimumWidth( 0 );
842 myList->setMaximumWidth( 16777215 );
844 QSplitter* s = ::qobject_cast<QSplitter*>( widget() );
847 int w = myList->minimumSizeHint().width() + 30;
850 szList.append( s->width() - w );
851 s->setSizes( szList );
857 \brief Get identifier of the currently selected preference item.
858 \return identifier of the currently selected item or -1 if no item is selected
861 int QtxPagePrefListItem::selected() const
863 QList<QListWidgetItem*> selList = myList->selectedItems();
864 if ( selList.isEmpty() )
867 QVariant v = selList.first()->data( Qt::UserRole );
868 return v.canConvert( QVariant::Int ) ? v.toInt() : -1;
872 \brief Get currently selected preference item.
873 \return currently selected item or 0 if no item is selected
876 QtxPagePrefItem* QtxPagePrefListItem::selectedItem() const
878 int selId = selected();
880 QList<QtxPagePrefItem*> items;
881 pageChildItems( items );
883 QtxPagePrefItem* item = 0;
884 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end() && !item; ++it )
886 if ( (*it)->id() == selId )
893 \brief Set currently selected preference item.
894 \param id identifier of the preference item to make selected
896 void QtxPagePrefListItem::setSelected( const int id )
899 for ( int i = 0; i < (int)myList->count() && idx < 0; i++ )
901 QVariant v = myList->item( i )->data( Qt::UserRole );
902 if ( v.canConvert( QVariant::Int ) && v.toInt() == id )
907 QItemSelectionModel* selModel = myList->selectionModel();
910 sel.select( myList->model()->index( idx, 0 ), myList->model()->index( idx, 0 ) );
912 selModel->select( sel, QItemSelectionModel::ClearAndSelect );
916 \class QtxPagePrefToolBoxItem
917 \brief GUI implementation of the tool box container preference item.
922 \param title preference item title
923 \param parent parent preference item
924 \param sect resource file section associated with the preference item
925 \param param resource file parameter associated with the preference item
927 QtxPagePrefToolBoxItem::QtxPagePrefToolBoxItem( const QString& title, QtxPreferenceItem* parent,
928 const QString& sect, const QString& param )
929 : QtxPagePrefItem( title, parent, sect, param )
931 setWidget( myToolBox = new QToolBox( 0 ) );
937 QtxPagePrefToolBoxItem::~QtxPagePrefToolBoxItem()
942 \brief Update widget contents.
944 void QtxPagePrefToolBoxItem::updateContents()
946 QtxPagePrefItem::updateContents();
951 \brief Update tool box widget.
953 void QtxPagePrefToolBoxItem::updateToolBox()
955 QList<QtxPagePrefItem*> items;
956 pageChildItems( items );
958 QWidget* cur = myToolBox->currentWidget();
961 QMap<QWidget*, int> map;
962 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
964 QWidget* wid = (*it)->widget();
968 if ( myToolBox->widget( i ) != wid )
970 if ( myToolBox->indexOf( wid ) != -1 )
971 myToolBox->removeItem( myToolBox->indexOf( wid ) );
973 myToolBox->insertItem( i, wid, (*it)->title() );
976 myToolBox->setItemText( i, (*it)->title() );
978 myToolBox->setItemIcon( i, (*it)->icon() );
981 map.insert( wid, 0 );
985 for ( int idx = 0; idx < (int)myToolBox->count(); idx++ )
987 QWidget* w = myToolBox->widget( idx );
988 if ( !map.contains( w ) )
992 for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
993 myToolBox->removeItem( myToolBox->indexOf( *itr ) );
996 myToolBox->setCurrentWidget( cur );
999 void QtxPagePrefToolBoxItem::ensureVisible( QtxPreferenceItem* i )
1004 QtxPreferenceItem::ensureVisible( i );
1006 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
1007 if ( item && item->widget() )
1008 myToolBox->setCurrentWidget( item->widget() );
1012 \class QtxPagePrefTabsItem
1013 \brief GUI implementation of the tab widget container.
1018 \param title preference item title
1019 \param parent parent preference item
1020 \param sect resource file section associated with the preference item
1021 \param param resource file parameter associated with the preference item
1023 QtxPagePrefTabsItem::QtxPagePrefTabsItem( const QString& title, QtxPreferenceItem* parent,
1024 const QString& sect, const QString& param )
1025 : QtxPagePrefItem( title, parent, sect, param )
1027 setWidget( myTabs = new QTabWidget( 0 ) );
1033 QtxPagePrefTabsItem::~QtxPagePrefTabsItem()
1038 \brief Update widget contents.
1040 void QtxPagePrefTabsItem::updateContents()
1042 QtxPagePrefItem::updateContents();
1047 \brief Get tabs position.
1048 \return current tabs position (QTabWidget::TabPosition)
1049 \sa setTabPosition()
1051 int QtxPagePrefTabsItem::tabPosition() const
1053 return myTabs->tabPosition();
1057 \brief Set tabs position.
1058 \param tp new tabs position (QTabWidget::TabPosition)
1061 void QtxPagePrefTabsItem::setTabPosition( const int tp )
1063 myTabs->setTabPosition( (QTabWidget::TabPosition)tp );
1067 \brief Get tabs shape.
1068 \return current tabs shape (QTabWidget::TabShape)
1071 int QtxPagePrefTabsItem::tabShape() const
1073 return myTabs->tabShape();
1077 \brief Set tabs shape.
1078 \param ts new tabs shape (QTabWidget::TabShape)
1081 void QtxPagePrefTabsItem::setTabShape( const int ts )
1083 myTabs->setTabShape( (QTabWidget::TabShape)ts );
1087 \brief Get tabs icon size.
1088 \return current tabs icon size
1089 \sa setTabIconSize()
1091 QSize QtxPagePrefTabsItem::tabIconSize() const
1093 return myTabs->iconSize();
1097 \brief Set tabs icon size.
1098 \param sz new tabs icon size
1101 void QtxPagePrefTabsItem::setTabIconSize( const QSize& sz )
1103 myTabs->setIconSize( sz );
1107 \brief Get preference item option value.
1108 \param name option name
1109 \return property value or null QVariant if option is not set
1110 \sa setOptionValue()
1112 QVariant QtxPagePrefTabsItem::optionValue( const QString& name ) const
1114 if ( name == "position" )
1115 return tabPosition();
1116 else if ( name == "shape" )
1118 else if ( name == "icon_size" )
1119 return tabIconSize();
1121 return QtxPagePrefItem::optionValue( name );
1125 \brief Set preference item option value.
1126 \param name option name
1127 \param val new property value
1130 void QtxPagePrefTabsItem::setOptionValue( const QString& name, const QVariant& val )
1132 if ( name == "position" )
1134 if ( val.canConvert( QVariant::Int ) )
1135 setTabPosition( val.toInt() );
1137 else if ( name == "shape" )
1139 if ( val.canConvert( QVariant::Int ) )
1140 setTabShape( val.toInt() );
1142 else if ( name == "icon_size" )
1144 if ( val.canConvert( QVariant::Size ) )
1145 setTabIconSize( val.toSize() );
1148 QtxPagePrefItem::setOptionValue( name, val );
1151 void QtxPagePrefTabsItem::ensureVisible( QtxPreferenceItem* i )
1156 QtxPreferenceItem::ensureVisible( i );
1158 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
1159 if ( item && item->widget() )
1160 myTabs->setCurrentWidget( item->widget() );
1166 void QtxPagePrefTabsItem::updateTabs()
1168 QList<QtxPagePrefItem*> items;
1169 pageChildItems( items );
1171 QWidget* cur = myTabs->currentWidget();
1174 QMap<QWidget*, int> map;
1175 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1177 QWidget* wid = (*it)->widget();
1181 if ( myTabs->widget( i ) != wid )
1183 if ( myTabs->indexOf( wid ) != -1 )
1184 myTabs->removeTab( myTabs->indexOf( wid ) );
1186 myTabs->insertTab( i, wid, (*it)->title() );
1189 myTabs->setTabText( i, (*it)->title() );
1191 myTabs->setTabIcon( i, (*it)->icon() );
1194 map.insert( wid, 0 );
1197 QList<QWidget*> del;
1198 for ( int idx = 0; idx < (int)myTabs->count(); idx++ )
1200 QWidget* w = myTabs->widget( idx );
1201 if ( !map.contains( w ) )
1205 for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
1206 myTabs->removeTab( myTabs->indexOf( *itr ) );
1209 myTabs->setCurrentWidget( cur );
1213 \class QtxPagePrefFrameItem
1214 \brief GUI implementation of the frame widget container.
1219 \param title preference item title
1220 \param parent parent preference item
1221 \param sect resource file section associated with the preference item
1222 \param param resource file parameter associated with the preference item
1224 QtxPagePrefFrameItem::QtxPagePrefFrameItem( const QString& title, QtxPreferenceItem* parent,
1225 const QString& sect, const QString& param, const bool scrollable )
1226 : QtxPagePrefItem( title, parent, sect, param )
1228 QWidget* main = new QWidget();
1229 QVBoxLayout* base = new QVBoxLayout( main );
1230 base->setMargin( 0 );
1231 base->setSpacing( 0 );
1233 base->addWidget( myBox = new QtxGridBox( 1, Qt::Horizontal, main, 5, 5 ) );
1237 QScrollArea* scroll = new QScrollArea();
1238 scroll->setWidget( main );
1239 scroll->setWidgetResizable( true );
1240 base->layout()->setSizeConstraint(QLayout::SetMinAndMaxSize);
1250 QtxPagePrefFrameItem::~QtxPagePrefFrameItem()
1255 \brief Update widget contents.
1257 void QtxPagePrefFrameItem::updateContents()
1259 QtxPagePrefItem::updateContents();
1263 QtxPageNamedPrefItem::adjustLabels( this );
1267 \brief Get frame margin.
1268 \return current frame margin
1271 int QtxPagePrefFrameItem::margin() const
1273 return myBox->insideMargin();
1277 \brief Get frame margin.
1278 \param m new frame margin
1281 void QtxPagePrefFrameItem::setMargin( const int m )
1283 myBox->setInsideMargin( m );
1287 \brief Get frame spacing.
1288 \return current frame spacing
1291 int QtxPagePrefFrameItem::spacing() const
1293 return myBox->insideSpacing();
1297 \brief Set frame spacing.
1298 \param s new frame spacing
1301 void QtxPagePrefFrameItem::setSpacing( const int s )
1303 myBox->setInsideSpacing( s );
1307 \brief Get number of frame columns.
1308 \return current columns number
1311 int QtxPagePrefFrameItem::columns() const
1313 return myBox->columns();
1317 \brief Set number of frame columns.
1318 \param c new columns number
1321 void QtxPagePrefFrameItem::setColumns( const int c )
1323 myBox->setColumns( c );
1327 \brief Get frame box orientation.
1328 \return current frame orientation
1329 \sa setOrientation()
1331 Qt::Orientation QtxPagePrefFrameItem::orientation() const
1333 return myBox->orientation();
1337 \brief Set frame box orientation.
1338 \param o new frame orientation
1341 void QtxPagePrefFrameItem::setOrientation( const Qt::Orientation o )
1343 myBox->setOrientation( o );
1347 \brief Check if the frame widget stretching is enabled.
1348 \return \c true if the widget is stretchable
1351 bool QtxPagePrefFrameItem::stretch() const
1354 QLayout* l = widget() ? widget()->layout() : 0;
1355 for ( int i = 0; l && i < l->count() && !s; i++ )
1356 s = l->itemAt( i )->spacerItem();
1358 return s ? (bool)( s->expandingDirections() & Qt::Vertical ) : false;
1362 \brief Enable/disable frame widget stretching.
1363 \param on new stretchable state
1366 void QtxPagePrefFrameItem::setStretch( const bool on )
1369 QWidget* w = widget();
1370 if ( qobject_cast<QScrollArea*>( w ) )
1371 w = qobject_cast<QScrollArea*>( w )->widget();
1372 QLayout* l = w ? w->layout() : 0;
1373 for ( int i = 0; l && i < l->count() && !s; i++ )
1374 s = l->itemAt( i )->spacerItem();
1377 s->changeSize( 0, 0, QSizePolicy::Minimum, on ? QSizePolicy::Expanding : QSizePolicy::Minimum );
1381 \brief Get preference item option value.
1382 \param name option name
1383 \return property value or null QVariant if option is not set
1384 \sa setOptionValue()
1386 QVariant QtxPagePrefFrameItem::optionValue( const QString& name ) const
1388 if ( name == "margin" )
1390 else if ( name == "spacing" )
1392 else if ( name == "columns" )
1394 else if ( name == "orientation" )
1395 return orientation();
1396 else if ( name == "stretch" )
1399 return QtxPagePrefItem::optionValue( name );
1403 \brief Set preference item option value.
1404 \param name option name
1405 \param val new property value
1408 void QtxPagePrefFrameItem::setOptionValue( const QString& name, const QVariant& val )
1410 if ( name == "margin" )
1412 if ( val.canConvert( QVariant::Int ) )
1413 setMargin( val.toInt() );
1415 else if ( name == "spacing" )
1417 if ( val.canConvert( QVariant::Int ) )
1418 setSpacing( val.toInt() );
1420 else if ( name == "columns" )
1422 if ( val.canConvert( QVariant::Int ) )
1423 setColumns( val.toInt() );
1425 else if ( name == "orientation" )
1427 if ( val.canConvert( QVariant::Int ) )
1428 setOrientation( (Qt::Orientation)val.toInt() );
1430 else if ( name == "stretch" )
1432 if ( val.canConvert( QVariant::Bool ) )
1433 setStretch( val.toBool() );
1436 QtxPagePrefItem::setOptionValue( name, val );
1439 void QtxPagePrefFrameItem::widgetShown()
1441 QtxPagePrefItem::widgetShown();
1443 QtxPageNamedPrefItem::adjustLabels( this );
1447 \brief Update frame widget.
1449 void QtxPagePrefFrameItem::updateFrame()
1451 QList<QtxPagePrefItem*> items;
1452 pageChildItems( items );
1454 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1456 QWidget* wid = (*it)->widget();
1460 if ( wid->parent() != myBox )
1461 wid->setParent( myBox );
1466 \class QtxPagePrefGroupItem
1467 \brief GUI implementation of the group widget container.
1472 \param title preference item title
1473 \param parent parent preference item
1474 \param sect resource file section associated with the preference item
1475 \param param resource file parameter associated with the preference item
1477 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const QString& title, QtxPreferenceItem* parent,
1478 const QString& sect, const QString& param )
1479 : QtxPagePrefItem( title, parent, sect, param )
1481 myGroup = new QtxGroupBox( title, 0 );
1482 myBox = new QtxGridBox( 1, Qt::Horizontal, myGroup, 5, 5 );
1483 myGroup->setWidget( myBox );
1485 setWidget( myGroup );
1492 \param cols columns number
1493 \param title preference item title
1494 \param parent parent preference item
1495 \param sect resource file section associated with the preference item
1496 \param param resource file parameter associated with the preference item
1498 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const int cols, const QString& title, QtxPreferenceItem* parent,
1499 const QString& sect, const QString& param )
1500 : QtxPagePrefItem( title, parent, sect, param )
1502 myGroup = new QtxGroupBox( title, 0 );
1503 myBox = new QtxGridBox( cols, Qt::Horizontal, myGroup, 5, 5 );
1504 myGroup->setWidget( myBox );
1506 setWidget( myGroup );
1514 QtxPagePrefGroupItem::~QtxPagePrefGroupItem()
1519 \brief Assign resource file settings to the preference item.
1520 \param sect resource file section name
1521 \param param resource file parameter name
1524 void QtxPagePrefGroupItem::setResource( const QString& sect, const QString& param )
1526 QtxPagePrefItem::setResource( sect, param );
1531 \brief Update widget contents.
1533 void QtxPagePrefGroupItem::updateContents()
1535 QtxPagePrefItem::updateContents();
1537 myGroup->setTitle( title() );
1542 QtxPageNamedPrefItem::adjustLabels( this );
1546 \brief Get group box margin.
1547 \return current group box margin
1550 int QtxPagePrefGroupItem::margin() const
1552 return myBox->insideMargin();
1556 \brief Get group box margin.
1557 \param m new group box margin
1560 void QtxPagePrefGroupItem::setMargin( const int m )
1562 myBox->setInsideMargin( m );
1566 \brief Get group box spacing.
1567 \return current group box spacing
1570 int QtxPagePrefGroupItem::spacing() const
1572 return myBox->insideSpacing();
1576 \brief Set group box spacing.
1577 \param s new group box spacing
1580 void QtxPagePrefGroupItem::setSpacing( const int s )
1582 myBox->setInsideSpacing( s );
1586 \brief Get number of group box columns.
1587 \return current columns number
1590 int QtxPagePrefGroupItem::columns() const
1592 return myBox->columns();
1596 \brief Set number of group box columns.
1597 \param c new columns number
1600 void QtxPagePrefGroupItem::setColumns( const int c )
1602 myBox->setColumns( c );
1606 \brief Get group box orientation.
1607 \return current group box orientation
1608 \sa setOrientation()
1610 Qt::Orientation QtxPagePrefGroupItem::orientation() const
1612 return myBox->orientation();
1616 \brief Set group box orientation.
1617 \param o new group box orientation
1620 void QtxPagePrefGroupItem::setOrientation( const Qt::Orientation o )
1622 myBox->setOrientation( o );
1626 \brief Get 'flat' flag of the group box widget.
1627 \return \c true if the group box is flat
1629 bool QtxPagePrefGroupItem::isFlat() const
1631 return myGroup->isFlat();
1635 \brief Get 'flat' flag of the group box widget.
1636 \param on if \c true the group box will be made flat
1638 void QtxPagePrefGroupItem::setFlat( const bool on )
1640 myGroup->setFlat( on );
1644 \brief Store preference item to the resource manager.
1647 void QtxPagePrefGroupItem::store()
1649 if ( myGroup->isCheckable() )
1650 setBoolean( myGroup->isChecked() );
1654 \brief Return widget contained grid layout of this group.
1656 QtxGridBox* QtxPagePrefGroupItem::gridBox() const
1662 \brief Retrieve preference item from the resource manager.
1665 void QtxPagePrefGroupItem::retrieve()
1667 if ( myGroup->isCheckable() )
1668 myGroup->setChecked( getBoolean() );
1672 \brief Get preference item option value.
1673 \param name option name
1674 \return property value or null QVariant if option is not set
1675 \sa setOptionValue()
1677 QVariant QtxPagePrefGroupItem::optionValue( const QString& name ) const
1679 if ( name == "margin" )
1681 else if ( name == "spacing" )
1683 else if ( name == "columns" )
1685 else if ( name == "orientation" )
1686 return orientation();
1687 else if ( name == "flat" )
1690 return QtxPagePrefItem::optionValue( name );
1694 \brief Set preference item option value.
1695 \param name option name
1696 \param val new property value
1699 void QtxPagePrefGroupItem::setOptionValue( const QString& name, const QVariant& val )
1701 if ( name == "margin" )
1703 if ( val.canConvert( QVariant::Int ) )
1704 setMargin( val.toInt() );
1706 else if ( name == "spacing" )
1708 if ( val.canConvert( QVariant::Int ) )
1709 setSpacing( val.toInt() );
1711 else if ( name == "columns" )
1713 if ( val.canConvert( QVariant::Int ) )
1714 setColumns( val.toInt() );
1716 else if ( name == "orientation" )
1718 if ( val.canConvert( QVariant::Int ) )
1719 setOrientation( (Qt::Orientation)val.toInt() );
1721 else if ( name == "flat" )
1723 if ( val.canConvert( QVariant::Bool ) )
1724 setFlat( val.toBool() );
1727 QtxPagePrefItem::setOptionValue( name, val );
1730 void QtxPagePrefGroupItem::widgetShown()
1732 QtxPagePrefItem::widgetShown();
1734 QtxPageNamedPrefItem::adjustLabels( this );
1738 \brief Update widget state.
1740 void QtxPagePrefGroupItem::updateState()
1742 QString section, param;
1743 resource( section, param );
1744 myGroup->setCheckable( !title().isEmpty() && !section.isEmpty() && !param.isEmpty() );
1748 \brief Update group box widget.
1750 void QtxPagePrefGroupItem::updateGroup()
1752 QList<QtxPagePrefItem*> items;
1753 pageChildItems( items );
1755 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1757 QWidget* wid = (*it)->widget();
1761 if ( wid->parent() != myBox )
1762 wid->setParent( myBox );
1767 \class QtxPagePrefLabelItem
1768 \brief Label item which can be used in the preferences editor dialog box.
1774 Creates label item with specified title.
1776 \param text label text
1777 \param parent parent preference item
1779 QtxPagePrefLabelItem::QtxPagePrefLabelItem( const QString& text, QtxPreferenceItem* parent )
1780 : QtxPagePrefItem( text, parent )
1782 setWidget( myLabel = new QLabel( text ) );
1785 QtxPagePrefLabelItem::QtxPagePrefLabelItem( Qt::Alignment align, const QString& text, QtxPreferenceItem* parent )
1786 : QtxPagePrefItem( text, parent )
1788 setWidget( myLabel = new QLabel( text ) );
1789 myLabel->setAlignment( align );
1792 QtxPagePrefLabelItem::~QtxPagePrefLabelItem()
1796 void QtxPagePrefLabelItem::setTitle( const QString& text )
1798 QtxPagePrefItem::setTitle( text );
1801 myLabel->setText( text );
1804 Qt::Alignment QtxPagePrefLabelItem::alignment() const
1806 return myLabel->alignment();
1809 void QtxPagePrefLabelItem::setAlignment( Qt::Alignment align )
1811 myLabel->setAlignment( align );
1814 QVariant QtxPagePrefLabelItem::optionValue( const QString& name ) const
1817 if ( name == "alignment" )
1818 val = (int)alignment();
1822 void QtxPagePrefLabelItem::setOptionValue( const QString& name, const QVariant& val )
1824 if ( name == "alignment" )
1826 if ( val.canConvert( QVariant::Int ) )
1827 setAlignment( (Qt::Alignment)val.toInt() );
1832 \class QtxPagePrefSpaceItem
1833 \brief Simple spacer item which can be used in the preferences
1840 Creates spacer item with zero width and height and expanding
1841 on both directions (by height and width).
1843 \param parent parent preference item
1845 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( QtxPreferenceItem* parent )
1846 : QtxPagePrefItem( QString(), parent )
1848 initialize( 0, 0, 1, 1 );
1854 Creates spacer item with zero width and height and expanding
1855 according to the specified orientation.
1857 \param o spacer orientation
1858 \param parent parent preference item
1860 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( Qt::Orientation o, QtxPreferenceItem* parent )
1861 : QtxPagePrefItem( QString(), parent )
1863 if ( o == Qt::Horizontal )
1864 initialize( 0, 0, 1, 0 );
1866 initialize( 0, 0, 0, 1 );
1872 Creates spacer item with specified width and height. The spacing
1873 item is expanding horizontally if \a w <= 0 and vertically
1876 \param w spacer width
1877 \param h spacer height
1878 \param parent parent preference item
1880 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( const int w, const int h, QtxPreferenceItem* parent )
1881 : QtxPagePrefItem( QString(), parent )
1883 initialize( w, h, w > 0 ? 0 : 1, h > 0 ? 0 : 1 );
1889 QtxPagePrefSpaceItem::~QtxPagePrefSpaceItem()
1894 \brief Get spacer item size for the specified direction.
1896 \return size for the specified direction
1899 int QtxPagePrefSpaceItem::size( Qt::Orientation o ) const
1901 return o == Qt::Horizontal ? widget()->minimumWidth() : widget()->minimumHeight();
1905 \brief Set spacer item size for the specified direction.
1907 \param sz new size for the specified direction
1910 void QtxPagePrefSpaceItem::setSize( Qt::Orientation o, const int sz )
1912 if ( o == Qt::Horizontal )
1913 widget()->setMinimumWidth( sz );
1915 widget()->setMinimumHeight( sz );
1919 \brief Get spacer item stretch factor for the specified direction.
1921 \return stretch factor for the specified direction
1924 int QtxPagePrefSpaceItem::stretch( Qt::Orientation o ) const
1926 QSizePolicy sp = widget()->sizePolicy();
1927 return o == Qt::Horizontal ? sp.horizontalStretch() : sp.verticalStretch();
1931 \brief Set spacer item stretch factor for the specified direction.
1933 \param sf new stretch factor for the specified direction
1936 void QtxPagePrefSpaceItem::setStretch( Qt::Orientation o, const int sf )
1938 QSizePolicy sp = widget()->sizePolicy();
1939 if ( o == Qt::Horizontal )
1941 sp.setHorizontalStretch( sf );
1942 sp.setHorizontalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1946 sp.setVerticalStretch( sf );
1947 sp.setVerticalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1950 widget()->setSizePolicy( sp );
1954 \brief Get preference item option value.
1955 \param name option name
1956 \return property value or null QVariant if option is not set
1957 \sa setOptionValue()
1959 QVariant QtxPagePrefSpaceItem::optionValue( const QString& name ) const
1961 if ( name == "horizontal_size" || name == "hsize" )
1962 return size( Qt::Horizontal );
1963 else if ( name == "vertical_size" || name == "vsize" )
1964 return size( Qt::Vertical );
1965 else if ( name == "horizontal_stretch" || name == "hstretch" )
1966 return stretch( Qt::Horizontal );
1967 else if ( name == "vertical_stretch" || name == "vstretch" )
1968 return stretch( Qt::Vertical );
1970 return QtxPagePrefItem::optionValue( name );
1974 \brief Set preference item option value.
1975 \param name option name
1976 \param val new property value
1979 void QtxPagePrefSpaceItem::setOptionValue( const QString& name, const QVariant& val )
1981 if ( name == "horizontal_size" || name == "hsize" )
1983 if ( val.canConvert( QVariant::Int ) )
1984 setSize( Qt::Horizontal, val.toInt() );
1986 else if ( name == "vertical_size" || name == "vsize" )
1988 if ( val.canConvert( QVariant::Int ) )
1989 setSize( Qt::Vertical, val.toInt() );
1991 else if ( name == "horizontal_stretch" || name == "hstretch" )
1993 if ( val.canConvert( QVariant::Int ) )
1994 setStretch( Qt::Horizontal, val.toInt() );
1996 else if ( name == "vertical_stretch" || name == "vstretch" )
1998 if ( val.canConvert( QVariant::Int ) )
1999 setStretch( Qt::Vertical, val.toInt() );
2002 QtxPagePrefItem::setOptionValue( name, val );
2006 \brief Perform internal initialization.
2007 \param w spacer item width
2008 \param h spacer item height
2009 \param ws spacer item horizontal stretch factor
2010 \param hs spacer item vertical stretch factor
2012 void QtxPagePrefSpaceItem::initialize( const int w, const int h, const int hs, const int vs )
2015 sp.setHorizontalPolicy( hs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
2016 sp.setVerticalPolicy( vs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
2018 sp.setHorizontalStretch( hs );
2019 sp.setVerticalStretch( vs );
2021 QWidget* wid = new QWidget();
2022 wid->setSizePolicy( sp );
2024 wid->setMinimumSize( w, h );
2030 \class QtxPagePrefCheckItem
2031 \brief GUI implementation of the resources check box item (boolean).
2036 \param title preference item title
2037 \param parent parent preference item
2038 \param sect resource file section associated with the preference item
2039 \param param resource file parameter associated with the preference item
2041 QtxPagePrefCheckItem::QtxPagePrefCheckItem( const QString& title, QtxPreferenceItem* parent,
2042 const QString& sect, const QString& param )
2044 : QtxPagePrefItem( title, parent, sect, param )
2046 myCheck = new QCheckBox( title );
2047 myCheck->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
2048 setWidget( myCheck );
2054 QtxPagePrefCheckItem::~QtxPagePrefCheckItem()
2059 \brief Set preference item title.
2060 \param txt new preference title.
2062 void QtxPagePrefCheckItem::setTitle( const QString& txt )
2064 QtxPagePrefItem::setTitle( txt );
2066 myCheck->setText( title() );
2070 \brief Store preference item to the resource manager.
2073 void QtxPagePrefCheckItem::store()
2075 setBoolean( myCheck->isChecked() );
2079 \brief Retrieve preference item from the resource manager.
2082 void QtxPagePrefCheckItem::retrieve()
2084 myCheck->setChecked( getBoolean() );
2088 \class QtxPagePrefEditItem
2089 \brief GUI implementation of the resources line edit box item
2090 for string, integer and double values.
2093 static void fixupAndSet( QLineEdit* le, const QString& txt )
2097 if ( le->validator() ) {
2098 const QDoubleValidator* de = dynamic_cast<const QDoubleValidator*>( le->validator() );
2100 int dec = de->decimals();
2101 int idx = val.lastIndexOf( QRegExp( QString("[.|%1]").arg( le->locale().decimalPoint () ) ) );
2103 QString tmp = val.mid( idx+1 );
2105 val = val.left( idx+1 );
2106 idx = tmp.indexOf( QRegExp( QString("[e|E]") ) );
2108 exp = tmp.mid( idx );
2109 tmp = tmp.left( idx );
2111 tmp.truncate( dec );
2112 val = val + tmp + exp;
2116 if ( le->validator()->validate( val, pos ) == QValidator::Invalid )
2126 Creates preference item for string value editing.
2128 \param title preference item title
2129 \param parent parent preference item
2130 \param sect resource file section associated with the preference item
2131 \param param resource file parameter associated with the preference item
2133 QtxPagePrefEditItem::QtxPagePrefEditItem( const QString& title, QtxPreferenceItem* parent,
2134 const QString& sect, const QString& param )
2135 : QtxPageNamedPrefItem( title, parent, sect, param ),
2140 setControl( myEditor = new QLineEdit() );
2147 Creates preference item for editing of the value which type
2148 is specified by parameter \a type.
2150 \param type preference item input type (QtxPagePrefEditItem::InputType)
2151 \param title preference item title
2152 \param parent parent preference item
2153 \param sect resource file section associated with the preference item
2154 \param param resource file parameter associated with the preference item
2156 QtxPagePrefEditItem::QtxPagePrefEditItem( const int type, const QString& title,
2157 QtxPreferenceItem* parent, const QString& sect,
2158 const QString& param )
2159 : QtxPageNamedPrefItem( title, parent, sect, param ),
2164 setControl( myEditor = new QLineEdit() );
2171 QtxPagePrefEditItem::~QtxPagePrefEditItem()
2176 \brief Get edit box preference item input type.
2177 \return preference item input type (QtxPagePrefEditItem::InputType)
2180 int QtxPagePrefEditItem::inputType() const
2186 \brief Set edit box preference item input type.
2187 \param type new preference item input type (QtxPagePrefEditItem::InputType)
2190 void QtxPagePrefEditItem::setInputType( const int type )
2192 if ( myType == type )
2200 \brief Get number of digits after decimal point (for Double input type)
2201 \return preference item decimals value
2204 int QtxPagePrefEditItem::decimals() const
2210 \brief Set number of digits after decimal point (for Double input type)
2211 \param dec new preference item decimals value
2214 void QtxPagePrefEditItem::setDecimals( const int dec )
2216 if ( myDecimals == dec )
2224 \brief Get the line edit's echo mode
2225 \return preference item echo mode value
2228 int QtxPagePrefEditItem::echoMode() const
2234 \brief Set the line edit's echo mode
2235 \param echo new preference item echo mode value
2238 void QtxPagePrefEditItem::setEchoMode( const int echo )
2240 if ( myEchoMode == echo )
2248 \brief Store preference item to the resource manager.
2251 void QtxPagePrefEditItem::store()
2253 setString( myEditor->text() );
2257 \brief Retrieve preference item from the resource manager.
2260 void QtxPagePrefEditItem::retrieve()
2262 QString txt = getString();
2263 fixupAndSet( myEditor, txt );
2267 \brief Get preference item option value.
2268 \param name option name
2269 \return property value or null QVariant if option is not set
2270 \sa setOptionValue()
2272 QVariant QtxPagePrefEditItem::optionValue( const QString& name ) const
2274 if ( name == "input_type" || name == "type" )
2276 else if ( name == "precision" || name == "prec" || name == "decimals" )
2278 else if ( name == "echo" || name == "echo_mode" || name == "echomode")
2281 return QtxPageNamedPrefItem::optionValue( name );
2285 \brief Set preference item option value.
2286 \param name option name
2287 \param val new property value
2290 void QtxPagePrefEditItem::setOptionValue( const QString& name, const QVariant& val )
2292 if ( name == "input_type" || name == "type" )
2294 if ( val.canConvert( QVariant::Int ) )
2295 setInputType( val.toInt() );
2297 else if ( name == "precision" || name == "prec" || name == "decimals" ) {
2298 if ( val.canConvert( QVariant::Int ) )
2299 setDecimals( val.toInt() );
2301 else if ( name == "echo" || name == "echo_mode" || name == "echomode") {
2302 if ( val.canConvert( QVariant::Int ) )
2303 setEchoMode( val.toInt() );
2306 QtxPageNamedPrefItem::setOptionValue( name, val );
2310 \brief Update edit box widget.
2312 void QtxPagePrefEditItem::updateEditor()
2317 myEditor->setEchoMode(QLineEdit::Normal);
2320 myEditor->setEchoMode(QLineEdit::NoEcho);
2323 myEditor->setEchoMode(QLineEdit::Password);
2326 myEditor->setEchoMode(QLineEdit::PasswordEchoOnEdit);
2329 myEditor->setEchoMode(QLineEdit::Normal);
2332 QValidator* val = 0;
2333 switch ( inputType() )
2336 val = new QIntValidator( myEditor );
2339 val = new QDoubleValidator( myEditor );
2340 dynamic_cast<QDoubleValidator*>( val )->setDecimals( myDecimals < 0 ? 1000 : myDecimals );
2346 QString txt = myEditor->text();
2347 delete myEditor->validator();
2348 myEditor->setValidator( val );
2349 fixupAndSet( myEditor, txt );
2353 \class QtxPagePrefSliderItem
2359 Creates preference item with slider widget
2361 \param title preference item title
2362 \param parent parent preference item
2363 \param sect resource file section associated with the preference item
2364 \param param resource file parameter associated with the preference item
2366 QtxPagePrefSliderItem::QtxPagePrefSliderItem( const QString& title, QtxPreferenceItem* parent,
2367 const QString& sect, const QString& param )
2368 : QtxPageNamedPrefItem( title, parent, sect, param )
2370 setControl( mySlider = new QSlider( Qt::Horizontal ) );
2371 widget()->layout()->addWidget( myLabel = new QLabel( ) );
2378 mySlider->setTickPosition( QSlider::TicksBothSides );
2380 connect (mySlider, SIGNAL(valueChanged(int)), this, SLOT(setIcon(int)));
2387 QtxPagePrefSliderItem::~QtxPagePrefSliderItem()
2392 \brief Get slider preference item step value.
2393 \return slider single step value
2396 int QtxPagePrefSliderItem::singleStep() const
2398 return mySlider->singleStep();
2402 \brief Get slider preference item step value.
2403 \return slider page step value
2406 int QtxPagePrefSliderItem::pageStep() const
2408 return mySlider->pageStep();
2412 \brief Get slider preference item minimum value.
2413 \return slider minimum value
2416 int QtxPagePrefSliderItem::minimum() const
2418 return mySlider->minimum();
2422 \brief Get slider preference item maximum value.
2423 \return slider maximum value
2426 int QtxPagePrefSliderItem::maximum() const
2428 return mySlider->maximum();
2432 \brief Get the list of the icons associated with the selection widget items
2433 \return list of icons
2436 QList<QIcon> QtxPagePrefSliderItem::icons() const
2442 \brief Set slider preference item step value.
2443 \param step new slider single step value
2446 void QtxPagePrefSliderItem::setSingleStep( const int& step )
2448 mySlider->setSingleStep( step );
2452 \brief Set slider preference item step value.
2453 \param step new slider single step value
2456 void QtxPagePrefSliderItem::setPageStep( const int& step )
2458 mySlider->setPageStep( step );
2462 \brief Set slider preference item minimum value.
2463 \param min new slider minimum value
2466 void QtxPagePrefSliderItem::setMinimum( const int& min )
2468 mySlider->setMinimum( min );
2469 setIcon( mySlider->value() );
2473 \brief Set slider preference item maximum value.
2474 \param max new slider maximum value
2477 void QtxPagePrefSliderItem::setMaximum( const int& max )
2479 mySlider->setMaximum( max );
2480 setIcon( mySlider->value() );
2484 \brief Set the list of the icons to the selection widget items
2485 \param icns new list of icons
2488 void QtxPagePrefSliderItem::setIcons( const QList<QIcon>& icns )
2490 if ( icns.isEmpty() )
2494 QSize maxsize(0, 0);
2495 for ( QList<QIcon>::const_iterator it = myIcons.begin(); it != myIcons.end(); ++it ) {
2496 if ( (*it).isNull() ) continue;
2497 maxsize = maxsize.expandedTo( (*it).availableSizes().first() );
2499 myLabel->setFixedSize( maxsize );
2505 \brief Store preference item to the resource manager.
2508 void QtxPagePrefSliderItem::store()
2510 setInteger( mySlider->value() );
2514 \brief Retrieve preference item from the resource manager.
2517 void QtxPagePrefSliderItem::retrieve()
2519 mySlider->setValue( getInteger( mySlider->value() ) );
2523 \brief Get preference item option value.
2524 \param name option name
2525 \return property value or null integer if option is not set
2526 \sa setOptionValue()
2528 QVariant QtxPagePrefSliderItem::optionValue( const QString& name ) const
2530 if ( name == "minimum" || name == "min" )
2532 else if ( name == "maximum" || name == "max" )
2534 else if ( name == "single_step" )
2535 return singleStep();
2536 else if ( name == "page_step" )
2538 else if ( name == "icons" || name == "pixmaps" )
2540 QList<QVariant> lst;
2541 QList<QIcon> ics = icons();
2542 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2547 return QtxPageNamedPrefItem::optionValue( name );
2551 \brief Set preference item option value.
2552 \param name option name
2553 \param val new property value
2556 void QtxPagePrefSliderItem::setOptionValue( const QString& name, const QVariant& val )
2558 if ( val.canConvert( QVariant::Int ) )
2560 if ( name == "minimum" || name == "min" )
2561 setMinimum( val.toInt() );
2562 else if ( name == "maximum" || name == "max" )
2563 setMaximum( val.toInt() );
2564 else if ( name == "single_step" )
2565 setSingleStep( val.toInt() );
2566 else if ( name == "page_step" )
2567 setPageStep( val.toInt() );
2569 QtxPageNamedPrefItem::setOptionValue( name, val );
2571 else if ( name == "icons" || name == "pixmaps" )
2574 QtxPageNamedPrefItem::setOptionValue( name, val );
2577 void QtxPagePrefSliderItem::setIcon( int pos )
2579 int index = pos - mySlider->minimum();
2580 if ( !myIcons.isEmpty() && index >= 0 && index < myIcons.size() && !myIcons[index].isNull() )
2581 myLabel->setPixmap( myIcons[index].pixmap( myIcons[index].availableSizes().first() ) );
2587 \brief Update slider widget.
2589 void QtxPagePrefSliderItem::updateSlider()
2591 int val = mySlider->value();
2592 int stp = singleStep();
2593 int ptp = pageStep();
2594 int min = minimum();
2595 int max = maximum();
2597 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2598 mySlider->setFocusPolicy(Qt::StrongFocus);
2600 mySlider->setValue( val );
2601 setSingleStep( stp );
2606 myLabel->setVisible( !myIcons.empty() );
2607 widget()->layout()->setSpacing( !myIcons.empty() ? 6 : 0 );
2611 \brief Set the list of the icons from the resource manager.
2612 \param var new icons list
2615 void QtxPagePrefSliderItem::setIcons( const QVariant& var )
2617 if ( var.type() != QVariant::List )
2621 QList<QVariant> varList = var.toList();
2622 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2624 if ( (*it).canConvert<QIcon>() )
2625 lst.append( (*it).value<QIcon>() );
2626 else if ( (*it).canConvert<QPixmap>() )
2627 lst.append( (*it).value<QPixmap>() );
2629 lst.append( QIcon() );
2635 \class QtxPagePrefSelectItem
2636 \brief GUI implementation of the resources selector item
2637 (string, integer or double values list).
2639 All items in the list (represented as combo box) should be specified
2640 by the unique identifier which is stored to the resource file instead
2641 of the value itself.
2647 Creates preference item with combo box widget which is not editable
2648 (direct value entering is disabled).
2650 \param title preference item title
2651 \param parent parent preference item
2652 \param sect resource file section associated with the preference item
2653 \param param resource file parameter associated with the preference item
2655 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const QString& title, QtxPreferenceItem* parent,
2656 const QString& sect, const QString& param )
2657 : QtxPageNamedPrefItem( title, parent, sect, param ),
2660 setControl( mySelector = new QtxComboBox() );
2661 mySelector->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2662 mySelector->setDuplicatesEnabled( false );
2669 Creates preference item with combo box widget which is editable
2670 according to the specified input type (integer, double or string values).
2672 \param type input type (QtxPagePrefSelectItem::InputType)
2673 \param title preference item title
2674 \param parent parent preference item
2675 \param sect resource file section associated with the preference item
2676 \param param resource file parameter associated with the preference item
2678 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const int type, const QString& title, QtxPreferenceItem* parent,
2679 const QString& sect, const QString& param )
2680 : QtxPageNamedPrefItem( title, parent, sect, param ),
2683 setControl( mySelector = new QtxComboBox() );
2684 mySelector->setDuplicatesEnabled( false );
2691 QtxPagePrefSelectItem::~QtxPagePrefSelectItem()
2696 \brief Get edit box preference item input type.
2697 \return preference item input type (QtxPagePrefSelectItem::InputType)
2700 int QtxPagePrefSelectItem::inputType() const
2706 \brief Set edit box preference item input type.
2707 \param type new preference item input type (QtxPagePrefSelectItem::InputType)
2710 void QtxPagePrefSelectItem::setInputType( const int type )
2712 if ( myType == type )
2720 \brief Get the list of the values from the selection widget.
2721 \return list of values
2722 \sa numbers(), icons(), setStrings()
2724 QStringList QtxPagePrefSelectItem::strings() const
2727 for ( int i = 0; i < mySelector->count(); i++ )
2728 res.append( mySelector->itemText( i ) );
2733 \brief Get the list of the values identifiers from the selection widget.
2734 \return list of values IDs
2735 \sa strings(), icons(), setNumbers()
2737 QList<QVariant> QtxPagePrefSelectItem::numbers() const
2739 QList<QVariant> res;
2740 for ( int i = 0; i < mySelector->count(); i++ )
2742 if ( mySelector->hasId( i ) )
2743 res.append( mySelector->id( i ) );
2749 \brief Get the list of the icons associated with the selection widget.items
2750 \return list of icons
2751 \sa strings(), numbers(), setIcons()
2753 QList<QIcon> QtxPagePrefSelectItem::icons() const
2756 for ( int i = 0; i < mySelector->count(); i++ )
2757 res.append( mySelector->itemIcon( i ) );
2762 \brief Set the list of the values to the selection widget.
2763 \param lst new list of values
2764 \sa strings(), setNumbers(), setIcons()
2766 void QtxPagePrefSelectItem::setStrings( const QStringList& lst )
2768 mySelector->clear();
2769 mySelector->addItems( lst );
2773 \brief Set the list of the values identifiers to the selection widget
2774 \param ids new list of values IDs
2775 \sa numbers(), setStrings(), setIcons()
2777 void QtxPagePrefSelectItem::setNumbers( const QList<QVariant>& ids )
2780 for ( QList<QVariant>::const_iterator it = ids.begin(); it != ids.end(); ++it, i++ ) {
2781 if ( i >= mySelector->count() )
2782 mySelector->addItem(QString("") );
2784 mySelector->setId( i, *it );
2789 \brief Set the list of the icons to the selection widget items
2791 Important: call this method after setStrings() or setNumbers()
2793 \param icns new list of icons
2794 \sa icons(), setStrings(), setNumbers()
2796 void QtxPagePrefSelectItem::setIcons( const QList<QIcon>& icns )
2799 for ( QList<QIcon>::const_iterator it = icns.begin(); it != icns.end() && i < mySelector->count(); ++it, i++ )
2800 mySelector->setItemIcon( i, *it );
2804 \brief Store preference item to the resource manager.
2807 void QtxPagePrefSelectItem::store()
2809 if ( mySelector->isCleared() )
2812 int idx = mySelector->currentIndex();
2814 if ( mySelector->hasId( idx ) ) {
2815 QVariant id = mySelector->id( idx );
2816 if ( id.type() == QVariant::Int )
2817 setInteger( id.toInt() );
2818 else if ( id.type() == QVariant::String )
2819 setString( id.toString() );
2821 else if ( idx >= 0 ) {
2822 setString( mySelector->itemText( idx ) );
2827 \brief Retrieve preference item from the resource manager.
2830 void QtxPagePrefSelectItem::retrieve()
2832 QString txt = getString();
2834 // try to find via the id
2835 int idx = mySelector->index( txt );
2838 for ( int i = 0; i < mySelector->count() && idx == -1; i++ )
2840 if ( mySelector->itemText( i ) == txt )
2846 mySelector->setCurrentIndex( idx );
2847 else if ( mySelector->isEditable() )
2850 if ( mySelector->validator() &&
2851 mySelector->validator()->validate( txt, pos ) == QValidator::Invalid )
2852 mySelector->setCleared( true );
2855 mySelector->setCleared( false );
2856 mySelector->addItem( txt );
2857 mySelector->setCurrentIndex( mySelector->count() - 1 );
2863 \brief Get preference item option value.
2864 \param name option name
2865 \return property value or null QVariant if option is not set
2866 \sa setOptionValue()
2868 QVariant QtxPagePrefSelectItem::optionValue( const QString& name ) const
2870 if ( name == "input_type" || name == "type" )
2872 else if ( name == "strings" || name == "labels" )
2874 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2878 else if ( name == "icons" || name == "pixmaps" )
2880 QList<QVariant> lst;
2881 QList<QIcon> ics = icons();
2882 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2887 return QtxPageNamedPrefItem::optionValue( name );
2891 \brief Set preference item option value.
2892 \param name option name
2893 \param val new property value
2896 void QtxPagePrefSelectItem::setOptionValue( const QString& name, const QVariant& val )
2898 if ( name == "input_type" || name == "type" )
2900 if ( val.canConvert( QVariant::Int ) )
2901 setInputType( val.toInt() );
2903 else if ( name == "strings" || name == "labels" )
2905 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2907 else if ( name == "icons" || name == "pixmaps" )
2910 QtxPageNamedPrefItem::setOptionValue( name, val );
2914 \brief Set the list of the values from the resource manager.
2915 \param var new values list
2918 void QtxPagePrefSelectItem::setStrings( const QVariant& var )
2921 if ( toStringList( var, values ) )
2922 setStrings( values );
2926 \brief Set the list of the values identifiers from the resource manager.
2927 \param var new values IDs list
2930 void QtxPagePrefSelectItem::setNumbers( const QVariant& var )
2932 if ( var.type() != QVariant::List )
2935 setNumbers( var.toList() );
2939 \brief Set the list of the icons from the resource manager.
2940 \param var new icons list
2943 void QtxPagePrefSelectItem::setIcons( const QVariant& var )
2945 if ( var.type() != QVariant::List )
2949 QList<QVariant> varList = var.toList();
2950 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2952 if ( (*it).canConvert<QIcon>() )
2953 lst.append( (*it).value<QIcon>() );
2954 else if ( (*it).canConvert<QPixmap>() )
2955 lst.append( (*it).value<QPixmap>() );
2957 lst.append( QIcon() );
2963 \brief Update selector widget.
2965 void QtxPagePrefSelectItem::updateSelector()
2967 QValidator* val = 0;
2968 switch ( inputType() )
2971 val = new QIntValidator( mySelector );
2974 val = new QDoubleValidator( mySelector );
2980 mySelector->setEditable( inputType() != NoInput );
2982 if ( mySelector->isEditable() && !mySelector->currentText().isEmpty() && val )
2985 QString str = mySelector->currentText();
2986 if ( val->validate( str, pos ) == QValidator::Invalid )
2987 mySelector->clearEditText();
2990 delete mySelector->validator();
2991 mySelector->setValidator( val );
2995 \class QtxPagePrefSpinItem
2996 \brief GUI implementation of the resources spin box item
2997 (for integer or double value).
3003 Creates spin box preference item for the entering integer values.
3005 \param title preference item title
3006 \param parent parent preference item
3007 \param sect resource file section associated with the preference item
3008 \param param resource file parameter associated with the preference item
3010 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const QString& title, QtxPreferenceItem* parent,
3011 const QString& sect, const QString& param )
3012 : QtxPageNamedPrefItem( title, parent, sect, param ),
3021 Creates spin box preference item for the entering values which type
3022 is specified by the parameter \a type.
3024 \param type input type (QtxPagePrefSpinItem::InputType).
3025 \param title preference item title
3026 \param parent parent preference item
3027 \param sect resource file section associated with the preference item
3028 \param param resource file parameter associated with the preference item
3030 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const int type, const QString& title,
3031 QtxPreferenceItem* parent, const QString& sect,
3032 const QString& param )
3033 : QtxPageNamedPrefItem( title, parent, sect, param ),
3042 QtxPagePrefSpinItem::~QtxPagePrefSpinItem()
3047 \brief Get spin box preference item input type.
3048 \return preference item input type (QtxPagePrefSpinItem::InputType)
3051 int QtxPagePrefSpinItem::inputType() const
3057 \brief Set spin box preference item input type.
3058 \param type new preference item input type (QtxPagePrefSpinItem::InputType)
3061 void QtxPagePrefSpinItem::setInputType( const int type )
3063 if ( myType == type )
3071 \brief Get spin box preference item step value.
3072 \return spin box single step value
3075 QVariant QtxPagePrefSpinItem::step() const
3077 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3078 return isb->singleStep();
3079 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3080 return dsb->singleStep();
3086 \brief Get double spin box preference item precision value.
3087 \return double spin box precision
3090 QVariant QtxPagePrefSpinItem::precision() const
3092 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3093 return dsb->decimals();
3099 \brief Get spin box preference item minimum value.
3100 \return spin box minimum value
3103 QVariant QtxPagePrefSpinItem::minimum() const
3105 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3106 return isb->minimum();
3107 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3108 return dsb->minimum();
3114 \brief Get spin box preference item maximum value.
3115 \return spin box maximum value
3118 QVariant QtxPagePrefSpinItem::maximum() const
3120 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3121 return isb->maximum();
3122 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3123 return dsb->maximum();
3129 \brief Get spin box preference item prefix string.
3130 \return spin box prefix string
3133 QString QtxPagePrefSpinItem::prefix() const
3135 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3136 return isb->prefix();
3137 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3138 return dsb->prefix();
3144 \brief Get spin box preference item suffix string.
3145 \return spin box suffix string
3148 QString QtxPagePrefSpinItem::suffix() const
3150 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3151 return isb->suffix();
3152 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3153 return dsb->suffix();
3159 \brief Get spin box preference item special value text (which is shown
3160 when the spin box reaches minimum value).
3161 \return spin box special value text
3162 \sa setSpecialValueText()
3164 QString QtxPagePrefSpinItem::specialValueText() const
3166 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3168 return sb->specialValueText();
3174 \brief Set spin box preference item step value.
3175 \param step new spin box single step value
3178 void QtxPagePrefSpinItem::setStep( const QVariant& step )
3180 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3182 if ( step.canConvert( QVariant::Int ) )
3183 isb->setSingleStep( step.toInt() );
3185 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3187 if ( step.canConvert( QVariant::Double ) )
3188 dsb->setSingleStep( step.toDouble() );
3193 \brief Set double spin box preference item precision value.
3194 \param step new double spin box precision value
3197 void QtxPagePrefSpinItem::setPrecision( const QVariant& prec )
3199 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3201 if ( prec.canConvert( QVariant::Int ) ) {
3202 dsb->setDecimals( qAbs( prec.toInt() ) );
3203 dsb->setPrecision( prec.toInt() );
3209 \brief Set spin box preference item minimum value.
3210 \param min new spin box minimum value
3213 void QtxPagePrefSpinItem::setMinimum( const QVariant& min )
3215 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3217 if ( min.canConvert( QVariant::Int ) )
3218 isb->setMinimum( min.toInt() );
3220 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3222 if ( min.canConvert( QVariant::Double ) )
3223 dsb->setMinimum( min.toDouble() );
3228 \brief Set spin box preference item maximum value.
3229 \param min new spin box maximum value
3232 void QtxPagePrefSpinItem::setMaximum( const QVariant& max )
3234 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3236 if ( max.canConvert( QVariant::Int ) )
3237 isb->setMaximum( max.toInt() );
3239 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3241 if ( max.canConvert( QVariant::Double ) )
3242 dsb->setMaximum( max.toDouble() );
3247 \brief Set spin box preference item prefix string.
3248 \param txt new spin box prefix string
3251 void QtxPagePrefSpinItem::setPrefix( const QString& txt )
3253 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3254 isb->setPrefix( txt );
3255 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3256 dsb->setPrefix( txt );
3260 \brief Set spin box preference item suffix string.
3261 \param txt new spin box suffix string
3264 void QtxPagePrefSpinItem::setSuffix( const QString& txt )
3266 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3267 isb->setSuffix( txt );
3268 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3269 dsb->setSuffix( txt );
3273 \brief Set spin box preference item special value text (which is shown
3274 when the spin box reaches minimum value).
3275 \param txt new spin box special value text
3276 \sa specialValueText()
3278 void QtxPagePrefSpinItem::setSpecialValueText( const QString& txt )
3280 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3282 sb->setSpecialValueText( txt );
3286 \brief Store preference item to the resource manager.
3289 void QtxPagePrefSpinItem::store()
3291 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3292 setInteger( isb->value() );
3293 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3294 setDouble( dsb->value() );
3298 \brief Retrieve preference item from the resource manager.
3301 void QtxPagePrefSpinItem::retrieve()
3303 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3304 isb->setValue( getInteger( isb->value() ) );
3305 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3306 dsb->setValue( getDouble( dsb->value() ) );
3310 \brief Get preference item option value.
3311 \param name option name
3312 \return property value or null QVariant if option is not set
3313 \sa setOptionValue()
3315 QVariant QtxPagePrefSpinItem::optionValue( const QString& name ) const
3317 if ( name == "input_type" || name == "type" )
3319 else if ( name == "minimum" || name == "min" )
3321 else if ( name == "maximum" || name == "max" )
3323 else if ( name == "step" )
3325 else if ( name == "precision" )
3327 else if ( name == "prefix" )
3329 else if ( name == "suffix" )
3331 else if ( name == "special" )
3332 return specialValueText();
3334 return QtxPageNamedPrefItem::optionValue( name );
3338 \brief Set preference item option value.
3339 \param name option name
3340 \param val new property value
3343 void QtxPagePrefSpinItem::setOptionValue( const QString& name, const QVariant& val )
3345 if ( name == "input_type" || name == "type" )
3347 if ( val.canConvert( QVariant::Int ) )
3348 setInputType( val.toInt() );
3350 else if ( name == "minimum" || name == "min" )
3352 else if ( name == "maximum" || name == "max" )
3354 else if ( name == "step" )
3356 else if ( name == "precision" )
3357 setPrecision( val );
3358 else if ( name == "prefix" )
3360 if ( val.canConvert( QVariant::String ) )
3361 setPrefix( val.toString() );
3363 else if ( name == "suffix" )
3365 if ( val.canConvert( QVariant::String ) )
3366 setSuffix( val.toString() );
3368 else if ( name == "special" )
3370 if ( val.canConvert( QVariant::String ) )
3371 setSpecialValueText( val.toString() );
3374 QtxPageNamedPrefItem::setOptionValue( name, val );
3378 \brief Update spin box widget.
3380 void QtxPagePrefSpinItem::updateSpinBox()
3383 QVariant stp = step();
3384 QVariant prec = precision();
3385 QVariant min = minimum();
3386 QVariant max = maximum();
3388 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3390 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3393 switch ( inputType() )
3396 setControl( new QtxIntSpinBox() );
3399 setControl( new QtxDoubleSpinBox() );
3405 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3408 setPrecision( prec );
3412 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3414 if ( val.canConvert( QVariant::Int ) )
3415 isb->setValue( val.toInt() );
3417 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3419 if ( val.canConvert( QVariant::Double ) )
3420 dsb->setValue( val.toDouble() );
3425 \class QtxPagePrefTextItem
3426 \brief GUI implementation of the resources text box edit item
3427 (for large text data).
3432 \param parent parent preference item
3433 \param sect resource file section associated with the preference item
3434 \param param resource file parameter associated with the preference item
3436 QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect,
3437 const QString& param )
3438 : QtxPageNamedPrefItem( QString(), parent, sect, param )
3440 myEditor = new QTextEdit();
3441 myEditor->setAcceptRichText( false );
3443 setControl( myEditor );
3448 \param title preference item title
3449 \param parent parent preference item
3450 \param sect resource file section associated with the preference item
3451 \param param resource file parameter associated with the preference item
3453 QtxPagePrefTextItem::QtxPagePrefTextItem( const QString& title, QtxPreferenceItem* parent,
3454 const QString& sect, const QString& param )
3455 : QtxPageNamedPrefItem( title, parent, sect, param )
3457 myEditor = new QTextEdit();
3458 myEditor->setAcceptRichText( false );
3460 setControl( myEditor );
3466 QtxPagePrefTextItem::~QtxPagePrefTextItem()
3471 \brief Store preference item to the resource manager.
3474 void QtxPagePrefTextItem::store()
3476 setString( myEditor->toPlainText() );
3480 \brief Retrieve preference item from the resource manager.
3483 void QtxPagePrefTextItem::retrieve()
3485 myEditor->setPlainText( getString() );
3489 \class QtxPagePrefColorItem
3490 \brief GUI implementation of the resources color item.
3495 \param title preference item title
3496 \param parent parent preference item
3497 \param sect resource file section associated with the preference item
3498 \param param resource file parameter associated with the preference item
3500 QtxPagePrefColorItem::QtxPagePrefColorItem( const QString& title, QtxPreferenceItem* parent,
3501 const QString& sect, const QString& param )
3502 : QtxPageNamedPrefItem( title, parent, sect, param )
3504 // QtxPagePrefGroupItem* aGroup 0; //= dynamic_cast<QtxPagePrefGroupItem*>( parent );
3506 // setControl( myColor = new QtxColorButton( aGroup ? aGroup->gridBox() : 0 ) );
3507 setControl( myColor = new QtxColorButton( 0 ) );
3508 myColor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3514 QtxPagePrefColorItem::~QtxPagePrefColorItem()
3519 \brief Store preference item to the resource manager.
3522 void QtxPagePrefColorItem::store()
3524 setColor( myColor->color() );
3528 \brief Retrieve preference item from the resource manager.
3531 void QtxPagePrefColorItem::retrieve()
3533 myColor->setColor( getColor() );
3537 \class QtxPagePrefBiColorItem
3538 \brief GUI implementation of the resources item to store a bi-color value.
3540 The main color is specified explicitly. The secondary color is calculated
3541 by changing "value" and "saturation" parameters of the main color in the
3542 HSV notation using specified delta.
3547 \param title preference item title
3548 \param parent parent preference item
3549 \param sect resource file section associated with the preference item
3550 \param param resource file parameter associated with the preference item
3552 QtxPagePrefBiColorItem::QtxPagePrefBiColorItem( const QString& title, QtxPreferenceItem* parent,
3553 const QString& sect, const QString& param )
3554 : QtxPageNamedPrefItem( title, parent, sect, param )
3556 setControl( myColors = new QtxBiColorTool( 0 ) );
3562 QtxPagePrefBiColorItem::~QtxPagePrefBiColorItem()
3567 \bried Get auxiliary text
3568 \return text assigned to the item
3571 QString QtxPagePrefBiColorItem::text() const
3573 return myColors->text();
3577 \bried Set auxiliary text
3578 \param t text being assigned to the item
3581 void QtxPagePrefBiColorItem::setText( const QString& t )
3583 myColors->setText( t );
3587 \brief Store preference item to the resource manager.
3590 void QtxPagePrefBiColorItem::store()
3592 setString( Qtx::biColorToString( myColors->mainColor(), myColors->delta() ) );
3596 \brief Retrieve preference item from the resource manager.
3599 void QtxPagePrefBiColorItem::retrieve()
3603 Qtx::stringToBiColor( getString(), c, d );
3604 myColors->setMainColor( c );
3605 myColors->setDelta( d );
3609 \brief Get preference item option value.
3610 \param name option name
3611 \return property value or null QVariant if option is not set
3612 \sa setOptionValue()
3614 QVariant QtxPagePrefBiColorItem::optionValue( const QString& name ) const
3616 if ( name == "text" )
3619 return QtxPageNamedPrefItem::optionValue( name );
3623 \brief Set preference item option value.
3624 \param name option name
3625 \param val new property value
3628 void QtxPagePrefBiColorItem::setOptionValue( const QString& name, const QVariant& val )
3630 if ( name == "text" )
3632 if ( val.canConvert( QVariant::String ) )
3633 setText( val.toString() );
3636 QtxPageNamedPrefItem::setOptionValue( name, val );
3640 \class QtxPagePrefFontItem
3641 \brief GUI implementation of the resources font item.
3646 \param feat font editor widget features (QtxFontEdit::Features)
3647 \param title preference item title
3648 \param parent parent preference item
3649 \param sect resource file section associated with the preference item
3650 \param param resource file parameter associated with the preference item
3652 QtxPagePrefFontItem::QtxPagePrefFontItem( const int feat, const QString& title,
3653 QtxPreferenceItem* parent, const QString& sect,
3654 const QString& param )
3655 : QtxPageNamedPrefItem( title, parent, sect, param )
3657 setControl( myFont = new QtxFontEdit( feat ) );
3662 \param title preference item title
3663 \param parent parent preference item
3664 \param sect resource file section associated with the preference item
3665 \param param resource file parameter associated with the preference item
3667 QtxPagePrefFontItem::QtxPagePrefFontItem( const QString& title, QtxPreferenceItem* parent,
3668 const QString& sect, const QString& param )
3669 : QtxPageNamedPrefItem( title, parent, sect, param )
3671 setControl( myFont = new QtxFontEdit() );
3677 QtxPagePrefFontItem::~QtxPagePrefFontItem()
3682 \brief Get font widget features.
3683 \return font widget features (ORed QtxFontEdit::Features flags)
3686 int QtxPagePrefFontItem::features() const
3688 return myFont->features();
3692 \brief Set font widget features.
3693 \param f new font widget features (ORed QtxFontEdit::Features flags)
3696 void QtxPagePrefFontItem::setFeatures( const int f )
3698 myFont->setFeatures( f );
3702 \brief Specifies whether widget works in Native or Custom mode. Native mode
3703 is intended for working with system fonts. Custom mode is intended for
3704 working with manually defined set of fonts. Set of custom fonts can be
3705 specified with setFonts() method
3706 \param mode mode from QtxFontEdit::Mode enumeration
3709 void QtxPagePrefFontItem::setMode( const int mode )
3711 myFont->setMode( mode );
3715 \brief Verifies whether widget works in Native or Custom mode
3716 \return Native or Custom mode
3719 int QtxPagePrefFontItem::mode() const
3721 return myFont->mode();
3725 \brief Sets list of custom fonts.
3726 <b>This method is intended for working in Custom mode only.</b>
3727 \param fams list of families
3728 \sa fonts(), setMode()
3730 void QtxPagePrefFontItem::setFonts( const QStringList& fams )
3732 myFont->setFonts( fams );
3736 \brief Gets list of custom fonts
3737 \return list of families
3738 \sa setFonts(), setMode()
3740 QStringList QtxPagePrefFontItem::fonts() const
3742 return myFont->fonts();
3746 \brief Sets list of available font sizes.
3747 <b>This method is intended for working in Custom mode only.</b> The list of sizes can
3748 be empty. In this case system generate listof size automatically from 8 till 72.
3749 \param sizes list of sizes
3750 \sa sizes(), setMode()
3752 void QtxPagePrefFontItem::setSizes( const QList<int>& sizes )
3754 myFont->setSizes( sizes );
3758 \brief Gets list of custom fonts
3759 \return list of families
3760 \sa setFonts(), setMode()
3762 QList<int> QtxPagePrefFontItem::sizes() const
3764 return myFont->sizes();
3768 \brief Store preference item to the resource manager.
3771 void QtxPagePrefFontItem::store()
3773 setFont( myFont->currentFont() );
3777 \brief Retrieve preference item from the resource manager.
3780 void QtxPagePrefFontItem::retrieve()
3782 myFont->setCurrentFont( getFont() );
3786 \brief Get preference item option value.
3787 \param name option name
3788 \return property value or null QVariant if option is not set
3789 \sa setOptionValue()
3791 QVariant QtxPagePrefFontItem::optionValue( const QString& name ) const
3793 if ( name == "features" )
3795 else if ( name == "mode" )
3797 else if ( name == "fonts" || name == "families" )
3799 else if ( name == "sizes" )
3801 QList<QVariant> lst;
3802 QList<int> nums = sizes();
3803 for ( QList<int>::const_iterator it = nums.begin(); it != nums.end(); ++it )
3808 return QtxPageNamedPrefItem::optionValue( name );
3812 \brief Set preference item option value.
3813 \param name option name
3814 \param val new property value
3817 void QtxPagePrefFontItem::setOptionValue( const QString& name, const QVariant& val )
3819 if ( name == "features" )
3821 if ( val.canConvert( QVariant::Int ) )
3822 setFeatures( val.toInt() );
3824 else if ( name == "mode" )
3826 if ( val.canConvert( QVariant::Int ) )
3827 setMode( val.toInt() );
3829 else if ( name == "fonts" || name == "families" )
3832 if ( toStringList( val, values ) )
3835 else if ( name == "sizes" )
3837 if ( val.type() == QVariant::List )
3840 QList<QVariant> varList = val.toList();
3841 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
3843 if ( (*it).canConvert( QVariant::Int ) )
3844 lst.append( (*it).toInt() );
3850 QtxPageNamedPrefItem::setOptionValue( name, val );
3854 \class QtxPagePrefPathItem
3855 \brief GUI implementation of the resources file/directory path item.
3860 \param type path widget mode (Qtx::PathType )
3861 \param title preference item title
3862 \param parent parent preference item
3863 \param sect resource file section associated with the preference item
3864 \param param resource file parameter associated with the preference item
3866 QtxPagePrefPathItem::QtxPagePrefPathItem( const Qtx::PathType type, const QString& title,
3867 QtxPreferenceItem* parent, const QString& sect, const QString& param )
3868 : QtxPageNamedPrefItem( title, parent, sect, param )
3870 setControl( myPath = new QtxPathEdit( type ) );
3875 \param title preference item title
3876 \param parent parent preference item
3877 \param sect resource file section associated with the preference item
3878 \param param resource file parameter associated with the preference item
3880 QtxPagePrefPathItem::QtxPagePrefPathItem( const QString& title, QtxPreferenceItem* parent,
3881 const QString& sect, const QString& param )
3882 : QtxPageNamedPrefItem( title, parent, sect, param )
3884 setControl( myPath = new QtxPathEdit() );
3890 QtxPagePrefPathItem::~QtxPagePrefPathItem()
3895 \brief Get path widget mode.
3896 \return current path widget mode (Qtx::PathType)
3899 Qtx::PathType QtxPagePrefPathItem::pathType() const
3901 return myPath->pathType();
3905 \brief Set path widget mode.
3906 \param type new path widget mode (Qtx::PathType)
3909 void QtxPagePrefPathItem::setPathType( const Qtx::PathType type )
3911 myPath->setPathType( type );
3915 \brief Get currently used path widget filters.
3916 \return file or directory path filters
3919 QString QtxPagePrefPathItem::pathFilter() const
3921 return myPath->pathFilter();
3925 \brief Set path widget filters.
3926 \param f new file or directory path filters
3929 void QtxPagePrefPathItem::setPathFilter( const QString& f )
3931 myPath->setPathFilter( f );
3935 \brief Get currently used path widget options.
3936 \return file or directory path options
3937 \sa setPathOptions()
3939 QFileDialog::Options QtxPagePrefPathItem::pathOptions() const
3941 return myPath->pathOptions();
3945 \brief Set path widget options.
3946 \param f new file or directory path options
3949 void QtxPagePrefPathItem::setPathOptions( const QFileDialog::Options options )
3951 myPath->setPathOptions( options );
3956 \brief Store preference item to the resource manager.
3959 void QtxPagePrefPathItem::store()
3961 setString( myPath->path() );
3965 \brief Retrieve preference item from the resource manager.
3968 void QtxPagePrefPathItem::retrieve()
3970 myPath->setPath( getString() );
3974 \brief Get preference item option value.
3975 \param name option name
3976 \return property value or null QVariant if option is not set
3977 \sa setOptionValue()
3979 QVariant QtxPagePrefPathItem::optionValue( const QString& name ) const
3981 if ( name == "path_type" )
3983 else if ( name == "path_filter" )
3984 return pathFilter();
3985 else if ( name == "path_options" )
3986 return QVariant::fromValue(pathOptions());
3988 return QtxPageNamedPrefItem::optionValue( name );
3992 \brief Set preference item option value.
3993 \param name option name
3994 \param val new property value
3997 void QtxPagePrefPathItem::setOptionValue( const QString& name, const QVariant& val )
3999 if ( name == "path_type" )
4001 if ( val.canConvert( QVariant::Int ) )
4002 setPathType( (Qtx::PathType)val.toInt() );
4004 else if ( name == "path_filter" )
4006 if ( val.canConvert( QVariant::String ) )
4007 setPathFilter( val.toString() );
4009 else if ( name == "path_options" )
4011 if ( val.canConvert( QVariant::Int ) )
4012 setPathOptions( (QFileDialog::Options)val.toInt() );
4015 QtxPageNamedPrefItem::setOptionValue( name, val );
4019 \class QtxPagePrefPathListItem
4020 \brief GUI implementation of the resources files/directories list item.
4025 \param parent parent preference item
4026 \param sect resource file section associated with the preference item
4027 \param param resource file parameter associated with the preference item
4029 QtxPagePrefPathListItem::QtxPagePrefPathListItem( QtxPreferenceItem* parent,
4030 const QString& sect, const QString& param )
4031 : QtxPageNamedPrefItem( QString(), parent, sect, param )
4033 setControl( myPaths = new QtxPathListEdit() );
4038 \param type path list widget mode (Qtx::PathType)
4039 \param title preference item title
4040 \param parent parent preference item
4041 \param sect resource file section associated with the preference item
4042 \param param resource file parameter associated with the preference item
4044 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const Qtx::PathType type, const QString& title,
4045 QtxPreferenceItem* parent, const QString& sect, const QString& param )
4046 : QtxPageNamedPrefItem( title, parent, sect, param )
4048 setControl( myPaths = new QtxPathListEdit( type ) );
4053 \param title preference item title
4054 \param parent parent preference item
4055 \param sect resource file section associated with the preference item
4056 \param param resource file parameter associated with the preference item
4058 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const QString& title, QtxPreferenceItem* parent,
4059 const QString& sect, const QString& param )
4060 : QtxPageNamedPrefItem( title, parent, sect, param )
4062 setControl( myPaths = new QtxPathListEdit() );
4068 QtxPagePrefPathListItem::~QtxPagePrefPathListItem()
4073 \brief Get path list widget mode.
4074 \return currently used path list widget mode (Qtx::PathType)
4077 Qtx::PathType QtxPagePrefPathListItem::pathType() const
4079 return myPaths->pathType();
4083 \brief Set path list widget mode.
4084 \param type new path list widget mode (Qtx::PathType)
4087 void QtxPagePrefPathListItem::setPathType( const Qtx::PathType type )
4089 myPaths->setPathType( type );
4093 \brief Store preference item to the resource manager.
4096 void QtxPagePrefPathListItem::store()
4098 setString( myPaths->pathList().join( ";" ) );
4102 \brief Retrieve preference item from the resource manager.
4105 void QtxPagePrefPathListItem::retrieve()
4107 myPaths->setPathList( getString().split( ";" ) );
4111 \brief Get preference item option value.
4112 \param name option name
4113 \return property value or null QVariant if option is not set
4114 \sa setOptionValue()
4116 QVariant QtxPagePrefPathListItem::optionValue( const QString& name ) const
4118 if ( name == "path_type" )
4121 return QtxPageNamedPrefItem::optionValue( name );
4125 \brief Set preference item option value.
4126 \param name option name
4127 \param val new property value
4130 void QtxPagePrefPathListItem::setOptionValue( const QString& name, const QVariant& val )
4132 if ( name == "path_type" )
4134 if ( val.canConvert( QVariant::Int ) )
4135 setPathType( (Qtx::PathType)val.toInt() );
4138 QtxPageNamedPrefItem::setOptionValue( name, val );
4142 \class QtxPagePrefDateTimeItem
4143 \brief GUI implementation of resources date/time item.
4149 Creates an item to enter date and time.
4151 \param title preference item title
4152 \param parent parent preference item
4153 \param sect resource file section associated with the preference item
4154 \param param resource file parameter associated with the preference item
4156 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const QString& title, QtxPreferenceItem* parent,
4157 const QString& sect, const QString& param )
4158 : QtxPageNamedPrefItem( title, parent, sect, param ),
4161 setControl( myDateTime = new QDateTimeEdit() );
4162 myDateTime->setCalendarPopup( true );
4163 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4170 Creates preference item for editing of the date and/or time value:
4171 the type is specified by parameter \a type.
4173 \param type preference item input type (QtxPagePrefDateTimeItem::InputType)
4174 \param title preference item title
4175 \param parent parent preference item
4176 \param sect resource file section associated with the preference item
4177 \param param resource file parameter associated with the preference item
4179 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const int type, const QString& title, QtxPreferenceItem* parent,
4180 const QString& sect, const QString& param )
4181 : QtxPageNamedPrefItem( title, parent, sect, param ),
4184 setControl( myDateTime = new QDateTimeEdit() );
4185 myDateTime->setCalendarPopup( true );
4186 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4193 QtxPagePrefDateTimeItem::~QtxPagePrefDateTimeItem()
4198 \brief Get date/time box preference item input type.
4199 \return preference item input type (QtxPagePrefDateTimeItem::InputType)
4202 int QtxPagePrefDateTimeItem::inputType() const
4208 \brief Set date/time box preference item input type.
4209 \param type new preference item input type (QtxPagePrefDateTimeItem::InputType)
4212 void QtxPagePrefDateTimeItem::setInputType( const int type )
4214 if ( myType == type )
4222 \brief Check if the popup calendar menu is enabled.
4223 \return \c true if calendar popup menu is enabled
4225 bool QtxPagePrefDateTimeItem::calendar() const
4227 return myDateTime->calendarPopup();
4231 \brief Enable/disable popup calendar menu.
4232 \param on new flag state
4234 void QtxPagePrefDateTimeItem::setCalendar( const bool on )
4236 myDateTime->setCalendarPopup( on );
4240 \brief Get maximum date value.
4241 \return maximum date value
4242 \sa setMaximumDate(), minimumDate(), maximumTime(), minimumTime()
4244 QDate QtxPagePrefDateTimeItem::maximumDate() const
4246 return myDateTime->maximumDate();
4250 \brief Get maximum time value.
4251 \return maximum time value
4252 \sa setMaximumTime(), minimumTime(), maximumDate(), minimumDate()
4254 QTime QtxPagePrefDateTimeItem::maximumTime() const
4256 return myDateTime->maximumTime();
4260 \brief Get minimum date value.
4261 \return minimum date value
4262 \sa setMinimumDate(), maximumDate(), maximumTime(), minimumTime()
4264 QDate QtxPagePrefDateTimeItem::minimumDate() const
4266 return myDateTime->minimumDate();
4270 \brief Get minimum time value.
4271 \return maximum time value
4272 \sa setMinimumTime(), maximumTime(), maximumDate(), minimumDate()
4274 QTime QtxPagePrefDateTimeItem::minimumTime() const
4276 return myDateTime->minimumTime();
4280 \brief Set maximum date value.
4281 \param d new maximum date value
4282 \sa maximumDate(), minimumDate(), maximumTime(), minimumTime()
4284 void QtxPagePrefDateTimeItem::setMaximumDate( const QDate& d )
4287 myDateTime->setMaximumDate( d );
4289 myDateTime->clearMaximumDate();
4293 \brief Set maximum time value.
4294 \param t new maximum time value
4295 \sa maximumTime(), minimumTime(), maximumDate(), minimumDate()
4297 void QtxPagePrefDateTimeItem::setMaximumTime( const QTime& t )
4300 myDateTime->setMaximumTime( t );
4302 myDateTime->clearMaximumTime();
4306 \brief Set minimum date value.
4307 \param d new minimum date value
4308 \sa minimumDate(), maximumDate(), maximumTime(), minimumTime()
4310 void QtxPagePrefDateTimeItem::setMinimumDate( const QDate& d )
4313 myDateTime->setMinimumDate( d );
4315 myDateTime->clearMinimumDate();
4319 \brief Set minimum time value.
4320 \param t new minimum time value
4321 \sa minimumTime(), maximumTime(), maximumDate(), minimumDate()
4323 void QtxPagePrefDateTimeItem::setMinimumTime( const QTime& t )
4326 myDateTime->setMinimumTime( t );
4328 myDateTime->clearMinimumTime();
4332 \brief Store preference item to the resource manager.
4335 void QtxPagePrefDateTimeItem::store()
4338 switch ( inputType() )
4341 str = myDateTime->date().toString( Qt::ISODate );
4344 str = myDateTime->time().toString( Qt::ISODate );
4347 str = myDateTime->dateTime().toString( Qt::ISODate );
4355 \brief Retrieve preference item from the resource manager.
4358 void QtxPagePrefDateTimeItem::retrieve()
4360 QString str = getString();
4361 switch ( inputType() )
4364 myDateTime->setDate( QDate::fromString( str, Qt::ISODate ) );
4367 myDateTime->setTime( QTime::fromString( str, Qt::ISODate ) );
4370 myDateTime->setDateTime( QDateTime::fromString( str, Qt::ISODate ) );
4376 \brief Get preference item option value.
4377 \param name option name
4378 \return property value or null QVariant if option is not set
4379 \sa setOptionValue()
4381 QVariant QtxPagePrefDateTimeItem::optionValue( const QString& name ) const
4383 if ( name == "input_type" || name == "type" )
4385 else if ( name == "minimum_date" || name == "min_date" )
4386 return minimumDate();
4387 else if ( name == "maximum_date" || name == "max_date" )
4388 return maximumDate();
4389 else if ( name == "minimum_time" || name == "min_time" )
4390 return minimumTime();
4391 else if ( name == "maximum_time" || name == "max_time" )
4392 return maximumTime();
4394 return QtxPageNamedPrefItem::optionValue( name );
4398 \brief Set preference item option value.
4399 \param name option name
4400 \param val new property value
4403 void QtxPagePrefDateTimeItem::setOptionValue( const QString& name, const QVariant& val )
4405 if ( name == "input_type" || name == "type" )
4407 if ( val.canConvert( QVariant::Int ) )
4408 setInputType( val.toInt() );
4410 else if ( name == "minimum_date" || name == "min_date" )
4412 if ( val.canConvert( QVariant::Date ) )
4413 setMinimumDate( val.toDate() );
4415 else if ( name == "maximum_date" || name == "max_date" )
4417 if ( val.canConvert( QVariant::Date ) )
4418 setMaximumDate( val.toDate() );
4420 else if ( name == "minimum_time" || name == "min_time" )
4422 if ( val.canConvert( QVariant::Time ) )
4423 setMinimumTime( val.toTime() );
4425 else if ( name == "maximum_time" || name == "max_time" )
4427 if ( val.canConvert( QVariant::Time ) )
4428 setMaximumTime( val.toTime() );
4431 QtxPageNamedPrefItem::setOptionValue( name, val );
4435 \brief Update date/time widget.
4437 void QtxPagePrefDateTimeItem::updateDateTime()
4440 switch ( inputType() )
4443 dispFmt = QDateEdit().displayFormat();
4446 dispFmt = QTimeEdit().displayFormat();
4449 dispFmt = QDateTimeEdit().displayFormat();
4453 myDateTime->setDisplayFormat( dispFmt );
4458 \class QtxPagePrefBackgroundItem
4459 \brief GUI implementation of the resources item to store background data.
4461 Preference item allows specifying background data in different ways:
4463 - texture image file
4464 - simple two-color gradient
4465 - complex custom gradient (NOT IMPLEMENTED YET)
4467 Allowed background modes can be specified using setModeAllowed() method.
4468 Texture modes can be enabled/disabled using setTextureModeAllowed() method.
4469 Also, showing texture controls can be enabled/disabled by means of
4470 setTextureAllowed() method.
4471 Verical or horizontal orientation of the widget can be chosen via setOrientation()
4472 method (default orientation is horizontal).
4474 Simple gradient types can be specified using setGradients() method.
4476 \sa Qtx::BackgroundData, QtxBackgroundTool
4481 \param title preference item title
4482 \param parent parent preference item
4483 \param sect resource file section associated with the preference item
4484 \param param resource file parameter associated with the preference item
4486 QtxPagePrefBackgroundItem::QtxPagePrefBackgroundItem( const QString& title, QtxPreferenceItem* parent,
4487 const QString& sect, const QString& param )
4488 : QtxPageNamedPrefItem( title, parent, sect, param )
4490 setControl( myBgTool = new QtxBackgroundTool( 0 ) );
4496 QtxPagePrefBackgroundItem::~QtxPagePrefBackgroundItem()
4501 \brief Get allowed two-color gradients to the widget
4502 \param gradients gradients names are returned via this parameter
4503 \param ids gradients identifiers are returned via this parameter (empty list can be returned)
4505 void QtxPagePrefBackgroundItem::gradients( QStringList& gradList, QIntList& idList ) const
4507 myBgTool->gradients( gradList, idList );
4511 \brief Set allowed two-color gradients to the widget
4512 \param gradients gradients names
4513 \param ids optional gradients identifiers; if not specified, gradients are automatically numbered starting from 0
4515 void QtxPagePrefBackgroundItem::setGradients( const QStringList& gradients, const QIntList& ids )
4517 myBgTool->setGradients( gradients, ids );
4521 \brief Check if specific background mode is allowed
4522 \param mode background mode
4523 \return \c true if specified background mode is enabled or \c false otherwise
4524 \sa setModeAllowed()
4526 bool QtxPagePrefBackgroundItem::isModeAllowed( Qtx::BackgroundMode mode ) const
4528 return myBgTool->isModeAllowed( mode );
4532 \brief Enable / disable specific background mode
4533 \param mode background mode
4534 \param on enable / disable flag
4537 void QtxPagePrefBackgroundItem::setModeAllowed( Qtx::BackgroundMode mode, bool on )
4539 myBgTool->setModeAllowed( mode, on );
4543 \brief Check if specific texture mode is allowed
4544 \param mode texture mode
4545 \return \c true if specified texture mode is enabled or \c false otherwise
4546 \sa setTextureModeAllowed(), setTextureAllowed()
4548 bool QtxPagePrefBackgroundItem::isTextureModeAllowed( Qtx::TextureMode mode ) const
4550 return myBgTool->isTextureModeAllowed( mode );
4554 \brief Enable / disable specific texture mode
4555 \param mode texture mode
4556 \param on enable / disable flag (\c true by default)
4557 \sa isTextureModeAllowed(), setTextureAllowed()
4559 void QtxPagePrefBackgroundItem::setTextureModeAllowed( Qtx::TextureMode mode, bool on )
4561 myBgTool->setTextureModeAllowed( mode, on );
4565 \brief Check if texture controls are allowed (shown)
4566 \return \c true if texture controls are enabled or \c false otherwise
4567 \sa setTextureAllowed(), setTextureModeAllowed()
4569 bool QtxPagePrefBackgroundItem::isTextureAllowed() const
4571 return myBgTool->isTextureAllowed();
4575 \brief Enable / disable texture controls
4576 \param on enable / disable flag (\c true by default)
4577 \sa isTextureAllowed(), setTextureModeAllowed()
4579 void QtxPagePrefBackgroundItem::setTextureAllowed( bool on )
4581 myBgTool->setTextureAllowed( on );
4585 \brief Get allowed image formats
4586 \return image formats
4588 QString QtxPagePrefBackgroundItem::imageFormats() const
4590 return myBgTool->imageFormats();
4594 \brief Set allowed image formats
4595 \param formats image formats
4597 void QtxPagePrefBackgroundItem::setImageFormats( const QString& formats )
4599 myBgTool->setImageFormats( formats );
4603 \brief Get widget editor orientation
4606 Qt::Orientation QtxPagePrefBackgroundItem::orientation() const
4608 return myBgTool->orientation();
4612 \brief Set widget editor orientation
4613 \param o orientation
4615 void QtxPagePrefBackgroundItem::setOrientation( Qt::Orientation o )
4617 myBgTool->setOrientation( o );
4621 \brief Store preference item to the resource manager.
4624 void QtxPagePrefBackgroundItem::store()
4626 setString( Qtx::backgroundToString( myBgTool->data() ) );
4630 \brief Retrieve preference item from the resource manager.
4633 void QtxPagePrefBackgroundItem::retrieve()
4635 myBgTool->setData( Qtx::stringToBackground( getString() ) );
4639 \brief Get preference item option value.
4640 \param name option name
4641 \return property value or null QVariant if option is not set
4642 \sa setOptionValue()
4644 QVariant QtxPagePrefBackgroundItem::optionValue( const QString& name ) const
4646 if ( name == "texture_enabled" )
4647 return isTextureAllowed();
4648 else if ( name == "color_enabled" )
4649 return isModeAllowed( Qtx::ColorBackground );
4650 else if ( name == "gradient_enabled" )
4651 return isModeAllowed( Qtx::SimpleGradientBackground );
4652 else if ( name == "custom_enabled" )
4653 return isModeAllowed( Qtx::CustomGradientBackground );
4654 else if ( name == "texture_center_enabled" )
4655 return isTextureModeAllowed( Qtx::CenterTexture );
4656 else if ( name == "texture_tile_enabled" )
4657 return isTextureModeAllowed( Qtx::TileTexture );
4658 else if ( name == "texture_stretch_enabled" )
4659 return isTextureModeAllowed( Qtx::StretchTexture );
4660 else if ( name == "orientation" )
4661 return orientation();
4662 else if ( name == "image_formats" )
4663 return imageFormats();
4664 else if ( name == "gradient_names" ) {
4667 gradients( grList, idList );
4670 else if ( name == "gradient_ids" ) {
4673 gradients( grList, idList );
4674 QList<QVariant> lst;
4675 for ( QIntList::const_iterator it = idList.begin(); it != idList.end(); ++it )
4680 return QtxPageNamedPrefItem::optionValue( name );
4684 \brief Set preference item option value.
4685 \param name option name
4686 \param val new property value
4689 void QtxPagePrefBackgroundItem::setOptionValue( const QString& name, const QVariant& val )
4691 if ( name == "texture_enabled" ) {
4692 if ( val.canConvert( QVariant::Bool ) )
4693 setTextureAllowed( val.toBool() );
4695 else if ( name == "color_enabled" ) {
4696 if ( val.canConvert( QVariant::Bool ) )
4697 setModeAllowed( Qtx::ColorBackground, val.toBool() );
4699 else if ( name == "gradient_enabled" ) {
4700 if ( val.canConvert( QVariant::Bool ) )
4701 setModeAllowed( Qtx::SimpleGradientBackground, val.toBool() );
4703 else if ( name == "custom_enabled" ) {
4704 if ( val.canConvert( QVariant::Bool ) )
4705 setModeAllowed( Qtx::CustomGradientBackground, val.toBool() );
4707 else if ( name == "texture_center_enabled" ) {
4708 if ( val.canConvert( QVariant::Bool ) )
4709 setTextureModeAllowed( Qtx::CenterTexture, val.toBool() );
4711 else if ( name == "texture_tile_enabled" ) {
4712 if ( val.canConvert( QVariant::Bool ) )
4713 setTextureModeAllowed( Qtx::TileTexture, val.toBool() );
4715 else if ( name == "texture_stretch_enabled" ) {
4716 if ( val.canConvert( QVariant::Bool ) )
4717 setTextureModeAllowed( Qtx::StretchTexture, val.toBool() );
4719 else if ( name == "orientation" ) {
4720 if ( val.canConvert( QVariant::Int ) )
4721 setOrientation( (Qt::Orientation)val.toInt() );
4723 else if ( name == "image_formats" ) {
4724 if ( val.canConvert( QVariant::String ) )
4725 setImageFormats( val.toString() );
4727 else if ( name == "gradient_names" ) {
4729 if ( toStringList( val, values ) )
4730 setGradients( values );
4732 else if ( name == "gradient_ids" ) {
4733 if ( val.canConvert( QVariant::List ) ) {
4736 gradients( grList, idList );
4738 QList<QVariant> varList = val.toList();
4739 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it ) {
4740 if ( (*it).canConvert( QVariant::Int ) )
4741 idList.append( (*it).toInt() );
4743 setGradients( grList, idList );
4747 QtxPageNamedPrefItem::setOptionValue( name, val );
4753 Creates preference item of user defined widget. The item widget has to be inherited from
4754 QtxUserDefinedContent class. An instance of this class has to be installed into the item
4755 with help of setContent method. Methods optionValue and setOptionValue use pointer on the
4756 content widget an qint64 value.
4758 \param parent parent preference item
4760 QtxUserDefinedItem::QtxUserDefinedItem( QtxPreferenceItem* parent )
4761 : QtxPageNamedPrefItem(QString(), parent), myContent(0)
4766 \brief Lets to Store preferences for content instance
4769 void QtxUserDefinedItem::store()
4772 myContent->store( resourceMgr(), preferenceMgr());
4777 \brief Lets to Retrieve preferences for content instance
4780 void QtxUserDefinedItem::retrieve()
4783 myContent->retrieve( resourceMgr(), preferenceMgr());
4788 * \brief Returns option value
4789 * \param theName is a string "content"
4790 * \return pointer on QtxUserDefinedContent class instance as a qint64 value
4792 QVariant QtxUserDefinedItem::optionValue( const QString& theName ) const
4794 if ( theName == "content" )
4795 return (qint64) myContent;
4797 return QtxPreferenceItem::optionValue( theName );
4801 * \brief Sets option value
4802 * \param theName is a string "content"
4803 * \param theVal is a pointer on QtxUserDefinedContent class instance represented as qint64 value
4805 void QtxUserDefinedItem::setOptionValue( const QString& theName, const QVariant& theVal)
4807 if ( theName == "content" ) {
4808 if ( theVal.canConvert( QVariant::ULongLong ) ) {
4809 setContent( (QtxUserDefinedContent*)theVal.toULongLong() );
4812 QtxPreferenceItem::setOptionValue( theName, theVal );
4816 * \brief Defines content of the property item as a Widget which has to be inherited from
4817 * QtxUserDefinedContent class.
4818 * \param theContent is an QtxUserDefinedContent class instance.
4820 void QtxUserDefinedItem::setContent( QtxUserDefinedContent* theContent )
4822 myContent = theContent;
4823 setControl(myContent);