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 "QtxShortcutEdit.h"
34 #include "QtxBackgroundTool.h"
35 #include "QtxResourceMgr.h"
45 #include <QListWidget>
46 #include <QApplication>
47 #include <QDateTimeEdit>
48 #include <QStackedWidget>
50 #include <QScrollArea>
56 bool toStringList(const QVariant& value, QStringList& result)
59 if ( value.type() == QVariant::StringList )
61 result = value.toStringList();
64 else if ( value.type() == QVariant::List )
66 QList<QVariant> valueList = value.toList();
67 for ( QList<QVariant>::const_iterator it = valueList.begin(); it != valueList.end(); ++it )
69 if ( (*it).canConvert( QVariant::String ) )
70 result.append( (*it).toString() );
80 \brief GUI implementation of the QtxPreferenceMgr class: preferences manager.
85 \param resMgr resource manager
86 \param parent parent widget
88 QtxPagePrefMgr::QtxPagePrefMgr( QtxResourceMgr* resMgr, QWidget* parent )
90 QtxPreferenceMgr( resMgr ),
93 myBox = new QtxGridBox( 1, Qt::Horizontal, this, 0 );
94 QVBoxLayout* base = new QVBoxLayout( this );
96 base->setSpacing( 0 );
97 base->addWidget( myBox );
103 QtxPagePrefMgr::~QtxPagePrefMgr()
108 \brief Get recommended size for the widget.
109 \return recommended widget size
111 QSize QtxPagePrefMgr::sizeHint() const
113 return QFrame::sizeHint();
117 \brief Get recommended minimum size for the widget.
118 \return recommended minimum widget size
120 QSize QtxPagePrefMgr::minimumSizeHint() const
122 return QFrame::minimumSizeHint();
126 \brief Customize show/hide widget operation.
127 \param on if \c true the widget is being shown, otherswise
130 void QtxPagePrefMgr::setVisible( bool on )
135 QApplication::instance()->processEvents();
137 QFrame::setVisible( on );
141 \brief Update widget contents.
143 void QtxPagePrefMgr::updateContents()
145 QtxPreferenceMgr::updateContents();
147 QList<QtxPreferenceItem*> lst = childItems();
148 for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
150 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
151 if ( item && item->widget() && item->widget()->parent() != myBox )
152 item->widget()->setParent( myBox );
155 setWindowIcon( icon() );
159 \brief Callback function which is called when the child
160 preference item is added.
161 \param item child item being added
162 \sa itemRemoved(), itemChanged()
164 void QtxPagePrefMgr::itemAdded( QtxPreferenceItem* /*item*/ )
170 \brief Callback function which is called when the child
171 preference item is removed.
172 \param item child item being removed
173 \sa itemAdded(), itemChanged()
175 void QtxPagePrefMgr::itemRemoved( QtxPreferenceItem* /*item*/ )
181 \brief Callback function which is called when the child
182 preference item is modified.
183 \param item child item being modified
184 \sa itemAdded(), itemRemoved()
186 void QtxPagePrefMgr::itemChanged( QtxPreferenceItem* /*item*/ )
192 \brief Get preference item option value.
193 \param name option name
194 \return property value or null QVariant if option is not set
197 QVariant QtxPagePrefMgr::optionValue( const QString& name ) const
199 if ( name == "orientation" )
200 return myBox->orientation() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
202 return QtxPreferenceMgr::optionValue( name );
206 \brief Set preference item option value.
207 \param name option name
208 \param val new property value
211 void QtxPagePrefMgr::setOptionValue( const QString& name, const QVariant& val )
213 if ( name == "orientation" )
215 if ( val.canConvert( QVariant::Int ) )
216 myBox->setOrientation( val.toInt() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal );
219 QtxPreferenceMgr::setOptionValue( name, val );
223 \brief Perform internal initialization.
225 void QtxPagePrefMgr::initialize() const
230 QtxPagePrefMgr* that = (QtxPagePrefMgr*)this;
231 that->initialize( that );
233 // that->myInit = true;
236 void QtxPagePrefMgr::initialize( QtxPreferenceItem* item )
241 QList<QtxPreferenceItem*> lst = item->childItems( false );
242 for ( QList<QtxPreferenceItem*>::iterator it = lst.begin(); it != lst.end(); ++it )
249 \class QtxPagePrefItem
250 \brief Base class for implementation of all the widget-based
254 class QtxPagePrefItem::Listener : public QObject
257 Listener( QtxPagePrefItem* );
260 virtual bool eventFilter( QObject*, QEvent* );
263 QtxPagePrefItem* myItem;
266 QtxPagePrefItem::Listener::Listener( QtxPagePrefItem* item )
272 QtxPagePrefItem::Listener::~Listener()
276 bool QtxPagePrefItem::Listener::eventFilter( QObject* o, QEvent* e )
278 if ( !myItem || myItem->widget() != o )
281 if ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent )
282 myItem->widgetShown();
283 if ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent )
284 myItem->widgetHided();
291 \param title preference item title
292 \param parent parent preference item
293 \param sect resource file section associated with the preference item
294 \param param resource file parameter associated with the preference item
296 QtxPagePrefItem::QtxPagePrefItem( const QString& title, QtxPreferenceItem* parent,
297 const QString& sect, const QString& param )
298 : QtxPreferenceItem( title, sect, param, parent ),
307 QtxPagePrefItem::~QtxPagePrefItem()
313 void QtxPagePrefItem::activate()
315 QtxPreferenceItem::activate();
318 widget()->setFocus();
322 \brief Get preference item editor widget.
323 \return editor widget
326 QWidget* QtxPagePrefItem::widget() const
332 \brief Set preference item editor widget.
333 \param wid editor widget
336 void QtxPagePrefItem::setWidget( QWidget* wid )
338 if ( myWidget && myListener )
339 myWidget->removeEventFilter( myListener );
346 myListener = new Listener( this );
347 myWidget->installEventFilter( myListener );
354 \brief Callback function which is called when the child
355 preference item is added.
356 \param item child item being added
357 \sa itemRemoved(), itemChanged()
359 void QtxPagePrefItem::itemAdded( QtxPreferenceItem* /*item*/ )
365 \brief Callback function which is called when the child
366 preference item is removed.
367 \param item child item being removed
368 \sa itemAdded(), itemChanged()
370 void QtxPagePrefItem::itemRemoved( QtxPreferenceItem* /*item*/ )
376 \brief Callback function which is called when the child
377 preference item is modified.
378 \param item child item being modified
379 \sa itemAdded(), itemRemoved()
381 void QtxPagePrefItem::itemChanged( QtxPreferenceItem* /*item*/ )
387 \brief Store preference item to the resource manager.
389 This method should be reimplemented in the subclasses.
390 Base implementation does nothing.
394 void QtxPagePrefItem::store()
399 \brief Retrieve preference item from the resource manager.
401 This method should be reimplemented in the subclasses.
402 Base implementation does nothing.
406 void QtxPagePrefItem::retrieve()
411 \brief Invoked when preference item widget is shown.
413 void QtxPagePrefItem::widgetShown()
418 \brief Invoked when preference item widget is hided.
420 void QtxPagePrefItem::widgetHided()
424 void QtxPagePrefItem::ensureVisible( QtxPreferenceItem* i )
426 QtxPreferenceItem::ensureVisible();
428 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
429 if ( item && item->widget() )
430 item->widget()->setVisible( true );
434 \brief Find all child items of the QtxPagePrefItem type.
435 \param list used to return list of child items
436 \param rec if \c true, perform recursive search
438 void QtxPagePrefItem::pageChildItems( QList<QtxPagePrefItem*>& list, const bool rec ) const
440 QList<QtxPreferenceItem*> lst = childItems( rec );
441 for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
443 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
450 \brief Called when contents is changed (item is added, removed or modified).
452 Triggers the item update.
454 void QtxPagePrefItem::contentChanged()
460 \class QtxPageNamedPrefItem
461 \brief Base class for implementation of the named preference items
462 (items with text labels).
467 \param title preference item title
468 \param parent parent preference item
469 \param sect resource file section associated with the preference item
470 \param param resource file parameter associated with the preference item
472 QtxPageNamedPrefItem::QtxPageNamedPrefItem( const QString& title, QtxPreferenceItem* parent,
473 const QString& sect, const QString& param )
474 : QtxPagePrefItem( title, parent, sect, param ),
477 QWidget* main = new QWidget();
479 // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parent);
482 QHBoxLayout* base = new QHBoxLayout( main );
483 base->setMargin( 0 );
484 base->setSpacing( 5 );
486 myLabel = new QLabel( title, main );
487 base->addWidget( myLabel );
490 // myLabel = new QLabel( title, aGroup->gridBox() );
494 myLabel->setVisible( !title.isEmpty() );
500 QtxPageNamedPrefItem::~QtxPageNamedPrefItem()
505 \brief Set preference title.
506 \param txt new preference title.
508 void QtxPageNamedPrefItem::setTitle( const QString& txt )
510 QtxPagePrefItem::setTitle( txt );
512 label()->setText( title() );
513 if ( !title().isEmpty() )
514 label()->setVisible( true );
518 \brief Get label widget corresponding to the preference item.
521 QLabel* QtxPageNamedPrefItem::label() const
527 \brief Get control widget corresponding to the preference item.
528 \return control widget
531 QWidget* QtxPageNamedPrefItem::control() const
537 \brief Set control widget corresponding to the preference item.
538 \param wid control widget
541 void QtxPageNamedPrefItem::setControl( QWidget* wid )
543 if ( myControl == wid )
551 // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parentItem());
553 widget()->layout()->addWidget( myControl );
554 widget()->setFocusProxy( myControl );
555 // else myControl->setParent( aGroup->gridBox() );
559 void QtxPageNamedPrefItem::adjustLabels( QtxPagePrefItem* parent )
564 QList<QtxPreferenceItem*> childList = parent->childItems();
566 QList<QtxPageNamedPrefItem*> namedItems;
567 for ( QList<QtxPreferenceItem*>::iterator it = childList.begin(); it != childList.end(); ++it )
569 QtxPageNamedPrefItem* item = dynamic_cast<QtxPageNamedPrefItem*>( *it );
571 namedItems.append( item );
575 for ( QList<QtxPageNamedPrefItem*>::iterator it1 = namedItems.begin(); it1 != namedItems.end(); ++it1 )
577 QtxPageNamedPrefItem* item = *it1;
579 sz = qMax( sz, item->label()->sizeHint().width() );
582 for ( QList<QtxPageNamedPrefItem*>::iterator it2 = namedItems.begin(); it2 != namedItems.end(); ++it2 )
584 QtxPageNamedPrefItem* item = *it2;
586 item->label()->setMinimumWidth( sz );
591 \class QtxPagePrefListItem
592 \brief GUI implementation of the list container preference item.
597 \param title preference item title
598 \param parent parent preference item
599 \param sect resource file section associated with the preference item
600 \param param resource file parameter associated with the preference item
602 QtxPagePrefListItem::QtxPagePrefListItem( const QString& title, QtxPreferenceItem* parent,
603 const QString& sect, const QString& param )
604 : QtxPagePrefItem( title, parent, sect, param ),
607 QSplitter* main = new QSplitter( Qt::Horizontal );
608 main->setChildrenCollapsible( false );
610 main->addWidget( myList = new QListWidget( main ) );
611 main->addWidget( myStack = new QStackedWidget( main ) );
613 myList->setSelectionMode( QListWidget::SingleSelection );
615 myStack->addWidget( myInfLabel = new QLabel( myStack ) );
616 myInfLabel->setAlignment( Qt::AlignCenter );
618 connect( myList, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) );
626 QtxPagePrefListItem::~QtxPagePrefListItem()
631 \brief Get message text which is shown if the container is empty.
635 QString QtxPagePrefListItem::emptyInfo() const
641 \brief Set message text which is shown if the container is empty.
642 \param new message text
645 void QtxPagePrefListItem::setEmptyInfo( const QString& inf )
647 if ( myInfText == inf )
656 \brief Check if the preference item widget is of fixed size.
657 \return \c true if the widget has the fixed size
660 bool QtxPagePrefListItem::isFixedSize() const
666 \brief Set the preference item widget to be of fixed size.
667 \param on if \c true, the widget will have the fixed size
670 void QtxPagePrefListItem::setFixedSize( const bool on )
681 \brief Update widget contents.
683 void QtxPagePrefListItem::updateContents()
685 QtxPagePrefItem::updateContents();
690 \brief Get preference item option value.
691 \param name option name
692 \return property value or null QVariant if option is not set
695 QVariant QtxPagePrefListItem::optionValue( const QString& name ) const
697 if ( name == "fixed_size" )
698 return isFixedSize();
699 else if ( name == "empty_info" || name == "info" )
702 return QtxPagePrefItem::optionValue( name );
706 \brief Set preference item option value.
707 \param name option name
708 \param val new property value
711 void QtxPagePrefListItem::setOptionValue( const QString& name, const QVariant& val )
713 if ( name == "fixed_size" )
715 if ( val.canConvert( QVariant::Bool ) )
716 setFixedSize( val.toBool() );
718 else if ( name == "empty_info" || name == "info" )
720 if ( val.canConvert( QVariant::String ) )
721 setEmptyInfo( val.toString() );
724 QtxPagePrefItem::setOptionValue( name, val );
727 void QtxPagePrefListItem::widgetShown()
732 void QtxPagePrefListItem::ensureVisible( QtxPreferenceItem* i )
737 QtxPreferenceItem::ensureVisible( i );
739 setSelected( i->id() );
744 \brief Called when the selection in the list box is changed.
746 void QtxPagePrefListItem::onItemSelectionChanged()
752 \brief Update information label widget.
754 void QtxPagePrefListItem::updateInfo()
757 QtxPagePrefItem* item = selectedItem();
760 infoText = emptyInfo();
761 QRegExp rx( "%([%|N])" );
764 while ( ( idx = rx.indexIn( infoText ) ) != -1 )
766 if ( rx.cap() == QString( "%%" ) )
767 infoText.replace( idx, rx.matchedLength(), "%" );
768 else if ( rx.cap() == QString( "%N" ) )
769 infoText.replace( idx, rx.matchedLength(), item->title() );
772 myInfLabel->setText( infoText );
776 \brief Update widget state.
778 void QtxPagePrefListItem::updateState()
780 QtxPagePrefItem* item = selectedItem();
781 QWidget* wid = item && !item->isEmpty() ? item->widget() : myInfLabel;
783 myStack->setCurrentWidget( wid );
789 \brief Update visibile child widgets.
791 void QtxPagePrefListItem::updateVisible()
793 QList<QtxPagePrefItem*> items;
794 pageChildItems( items );
796 QMap<QWidget*, int> map;
797 for ( int i = 0; i < (int)myStack->count(); i++ )
798 map.insert( myStack->widget( i ), 0 );
800 int selId = selected();
802 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
804 if ( (*it)->isEmpty() && myInfText.isEmpty() )
807 myList->addItem( (*it)->title() );
808 myList->item( myList->count() - 1 )->setIcon( (*it)->icon() );
809 myList->item( myList->count() - 1 )->setData( Qt::UserRole, (*it)->id() );
811 QWidget* wid = (*it)->widget();
812 if ( !map.contains( wid ) )
813 myStack->addWidget( wid );
818 map.remove( myInfLabel );
820 for ( QMap<QWidget*, int>::const_iterator it = map.begin(); it != map.end(); ++it )
821 myStack->removeWidget( it.key() );
823 setSelected( selId );
824 if ( selected() == -1 && myList->count() )
825 setSelected( myList->item( 0 )->data( Qt::UserRole ).toInt() );
827 //myList->setVisible( myList->count() > 1 );
834 \brief Update widget geometry.
836 void QtxPagePrefListItem::updateGeom()
839 myList->setFixedWidth( myList->minimumSizeHint().width() + 10 );
842 myList->setMinimumWidth( 0 );
843 myList->setMaximumWidth( 16777215 );
845 QSplitter* s = ::qobject_cast<QSplitter*>( widget() );
848 int w = myList->minimumSizeHint().width() + 30;
851 szList.append( s->width() - w );
852 s->setSizes( szList );
858 \brief Get identifier of the currently selected preference item.
859 \return identifier of the currently selected item or -1 if no item is selected
862 int QtxPagePrefListItem::selected() const
864 QList<QListWidgetItem*> selList = myList->selectedItems();
865 if ( selList.isEmpty() )
868 QVariant v = selList.first()->data( Qt::UserRole );
869 return v.canConvert( QVariant::Int ) ? v.toInt() : -1;
873 \brief Get currently selected preference item.
874 \return currently selected item or 0 if no item is selected
877 QtxPagePrefItem* QtxPagePrefListItem::selectedItem() const
879 int selId = selected();
881 QList<QtxPagePrefItem*> items;
882 pageChildItems( items );
884 QtxPagePrefItem* item = 0;
885 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end() && !item; ++it )
887 if ( (*it)->id() == selId )
894 \brief Set currently selected preference item.
895 \param id identifier of the preference item to make selected
897 void QtxPagePrefListItem::setSelected( const int id )
900 for ( int i = 0; i < (int)myList->count() && idx < 0; i++ )
902 QVariant v = myList->item( i )->data( Qt::UserRole );
903 if ( v.canConvert( QVariant::Int ) && v.toInt() == id )
908 QItemSelectionModel* selModel = myList->selectionModel();
911 sel.select( myList->model()->index( idx, 0 ), myList->model()->index( idx, 0 ) );
913 selModel->select( sel, QItemSelectionModel::ClearAndSelect );
917 \class QtxPagePrefToolBoxItem
918 \brief GUI implementation of the tool box container preference item.
923 \param title preference item title
924 \param parent parent preference item
925 \param sect resource file section associated with the preference item
926 \param param resource file parameter associated with the preference item
928 QtxPagePrefToolBoxItem::QtxPagePrefToolBoxItem( const QString& title, QtxPreferenceItem* parent,
929 const QString& sect, const QString& param )
930 : QtxPagePrefItem( title, parent, sect, param )
932 setWidget( myToolBox = new QToolBox( 0 ) );
938 QtxPagePrefToolBoxItem::~QtxPagePrefToolBoxItem()
943 \brief Update widget contents.
945 void QtxPagePrefToolBoxItem::updateContents()
947 QtxPagePrefItem::updateContents();
952 \brief Update tool box widget.
954 void QtxPagePrefToolBoxItem::updateToolBox()
956 QList<QtxPagePrefItem*> items;
957 pageChildItems( items );
959 QWidget* cur = myToolBox->currentWidget();
962 QMap<QWidget*, int> map;
963 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
965 QWidget* wid = (*it)->widget();
969 if ( myToolBox->widget( i ) != wid )
971 if ( myToolBox->indexOf( wid ) != -1 )
972 myToolBox->removeItem( myToolBox->indexOf( wid ) );
974 myToolBox->insertItem( i, wid, (*it)->title() );
977 myToolBox->setItemText( i, (*it)->title() );
979 myToolBox->setItemIcon( i, (*it)->icon() );
982 map.insert( wid, 0 );
986 for ( int idx = 0; idx < (int)myToolBox->count(); idx++ )
988 QWidget* w = myToolBox->widget( idx );
989 if ( !map.contains( w ) )
993 for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
994 myToolBox->removeItem( myToolBox->indexOf( *itr ) );
997 myToolBox->setCurrentWidget( cur );
1000 void QtxPagePrefToolBoxItem::ensureVisible( QtxPreferenceItem* i )
1005 QtxPreferenceItem::ensureVisible( i );
1007 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
1008 if ( item && item->widget() )
1009 myToolBox->setCurrentWidget( item->widget() );
1013 \class QtxPagePrefTabsItem
1014 \brief GUI implementation of the tab widget container.
1019 \param title preference item title
1020 \param parent parent preference item
1021 \param sect resource file section associated with the preference item
1022 \param param resource file parameter associated with the preference item
1024 QtxPagePrefTabsItem::QtxPagePrefTabsItem( const QString& title, QtxPreferenceItem* parent,
1025 const QString& sect, const QString& param )
1026 : QtxPagePrefItem( title, parent, sect, param )
1028 setWidget( myTabs = new QTabWidget( 0 ) );
1034 QtxPagePrefTabsItem::~QtxPagePrefTabsItem()
1039 \brief Update widget contents.
1041 void QtxPagePrefTabsItem::updateContents()
1043 QtxPagePrefItem::updateContents();
1048 \brief Get tabs position.
1049 \return current tabs position (QTabWidget::TabPosition)
1050 \sa setTabPosition()
1052 int QtxPagePrefTabsItem::tabPosition() const
1054 return myTabs->tabPosition();
1058 \brief Set tabs position.
1059 \param tp new tabs position (QTabWidget::TabPosition)
1062 void QtxPagePrefTabsItem::setTabPosition( const int tp )
1064 myTabs->setTabPosition( (QTabWidget::TabPosition)tp );
1068 \brief Get tabs shape.
1069 \return current tabs shape (QTabWidget::TabShape)
1072 int QtxPagePrefTabsItem::tabShape() const
1074 return myTabs->tabShape();
1078 \brief Set tabs shape.
1079 \param ts new tabs shape (QTabWidget::TabShape)
1082 void QtxPagePrefTabsItem::setTabShape( const int ts )
1084 myTabs->setTabShape( (QTabWidget::TabShape)ts );
1088 \brief Get tabs icon size.
1089 \return current tabs icon size
1090 \sa setTabIconSize()
1092 QSize QtxPagePrefTabsItem::tabIconSize() const
1094 return myTabs->iconSize();
1098 \brief Set tabs icon size.
1099 \param sz new tabs icon size
1102 void QtxPagePrefTabsItem::setTabIconSize( const QSize& sz )
1104 myTabs->setIconSize( sz );
1108 \brief Get preference item option value.
1109 \param name option name
1110 \return property value or null QVariant if option is not set
1111 \sa setOptionValue()
1113 QVariant QtxPagePrefTabsItem::optionValue( const QString& name ) const
1115 if ( name == "position" )
1116 return tabPosition();
1117 else if ( name == "shape" )
1119 else if ( name == "icon_size" )
1120 return tabIconSize();
1122 return QtxPagePrefItem::optionValue( name );
1126 \brief Set preference item option value.
1127 \param name option name
1128 \param val new property value
1131 void QtxPagePrefTabsItem::setOptionValue( const QString& name, const QVariant& val )
1133 if ( name == "position" )
1135 if ( val.canConvert( QVariant::Int ) )
1136 setTabPosition( val.toInt() );
1138 else if ( name == "shape" )
1140 if ( val.canConvert( QVariant::Int ) )
1141 setTabShape( val.toInt() );
1143 else if ( name == "icon_size" )
1145 if ( val.canConvert( QVariant::Size ) )
1146 setTabIconSize( val.toSize() );
1149 QtxPagePrefItem::setOptionValue( name, val );
1152 void QtxPagePrefTabsItem::ensureVisible( QtxPreferenceItem* i )
1157 QtxPreferenceItem::ensureVisible( i );
1159 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
1160 if ( item && item->widget() )
1161 myTabs->setCurrentWidget( item->widget() );
1167 void QtxPagePrefTabsItem::updateTabs()
1169 QList<QtxPagePrefItem*> items;
1170 pageChildItems( items );
1172 QWidget* cur = myTabs->currentWidget();
1175 QMap<QWidget*, int> map;
1176 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1178 QWidget* wid = (*it)->widget();
1182 if ( myTabs->widget( i ) != wid )
1184 if ( myTabs->indexOf( wid ) != -1 )
1185 myTabs->removeTab( myTabs->indexOf( wid ) );
1187 myTabs->insertTab( i, wid, (*it)->title() );
1190 myTabs->setTabText( i, (*it)->title() );
1192 myTabs->setTabIcon( i, (*it)->icon() );
1195 map.insert( wid, 0 );
1198 QList<QWidget*> del;
1199 for ( int idx = 0; idx < (int)myTabs->count(); idx++ )
1201 QWidget* w = myTabs->widget( idx );
1202 if ( !map.contains( w ) )
1206 for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
1207 myTabs->removeTab( myTabs->indexOf( *itr ) );
1210 myTabs->setCurrentWidget( cur );
1214 \class QtxPagePrefFrameItem
1215 \brief GUI implementation of the frame widget container.
1220 \param title preference item title
1221 \param parent parent preference item
1222 \param sect resource file section associated with the preference item
1223 \param param resource file parameter associated with the preference item
1225 QtxPagePrefFrameItem::QtxPagePrefFrameItem( const QString& title, QtxPreferenceItem* parent,
1226 const QString& sect, const QString& param, const bool scrollable )
1227 : QtxPagePrefItem( title, parent, sect, param )
1229 QWidget* main = new QWidget();
1230 QVBoxLayout* base = new QVBoxLayout( main );
1231 base->setMargin( 0 );
1232 base->setSpacing( 0 );
1234 base->addWidget( myBox = new QtxGridBox( 1, Qt::Horizontal, main, 5, 5 ) );
1238 QScrollArea* scroll = new QScrollArea();
1239 scroll->setWidget( main );
1240 scroll->setWidgetResizable( true );
1241 base->layout()->setSizeConstraint(QLayout::SetMinAndMaxSize);
1251 QtxPagePrefFrameItem::~QtxPagePrefFrameItem()
1256 \brief Update widget contents.
1258 void QtxPagePrefFrameItem::updateContents()
1260 QtxPagePrefItem::updateContents();
1264 QtxPageNamedPrefItem::adjustLabels( this );
1268 \brief Get frame margin.
1269 \return current frame margin
1272 int QtxPagePrefFrameItem::margin() const
1274 return myBox->insideMargin();
1278 \brief Get frame margin.
1279 \param m new frame margin
1282 void QtxPagePrefFrameItem::setMargin( const int m )
1284 myBox->setInsideMargin( m );
1288 \brief Get frame spacing.
1289 \return current frame spacing
1292 int QtxPagePrefFrameItem::spacing() const
1294 return myBox->insideSpacing();
1298 \brief Set frame spacing.
1299 \param s new frame spacing
1302 void QtxPagePrefFrameItem::setSpacing( const int s )
1304 myBox->setInsideSpacing( s );
1308 \brief Get number of frame columns.
1309 \return current columns number
1312 int QtxPagePrefFrameItem::columns() const
1314 return myBox->columns();
1318 \brief Set number of frame columns.
1319 \param c new columns number
1322 void QtxPagePrefFrameItem::setColumns( const int c )
1324 myBox->setColumns( c );
1328 \brief Get frame box orientation.
1329 \return current frame orientation
1330 \sa setOrientation()
1332 Qt::Orientation QtxPagePrefFrameItem::orientation() const
1334 return myBox->orientation();
1338 \brief Set frame box orientation.
1339 \param o new frame orientation
1342 void QtxPagePrefFrameItem::setOrientation( const Qt::Orientation o )
1344 myBox->setOrientation( o );
1348 \brief Check if the frame widget stretching is enabled.
1349 \return \c true if the widget is stretchable
1352 bool QtxPagePrefFrameItem::stretch() const
1355 QLayout* l = widget() ? widget()->layout() : 0;
1356 for ( int i = 0; l && i < l->count() && !s; i++ )
1357 s = l->itemAt( i )->spacerItem();
1359 return s ? (bool)( s->expandingDirections() & Qt::Vertical ) : false;
1363 \brief Enable/disable frame widget stretching.
1364 \param on new stretchable state
1367 void QtxPagePrefFrameItem::setStretch( const bool on )
1370 QWidget* w = widget();
1371 if ( qobject_cast<QScrollArea*>( w ) )
1372 w = qobject_cast<QScrollArea*>( w )->widget();
1373 QLayout* l = w ? w->layout() : 0;
1374 for ( int i = 0; l && i < l->count() && !s; i++ )
1375 s = l->itemAt( i )->spacerItem();
1378 s->changeSize( 0, 0, QSizePolicy::Minimum, on ? QSizePolicy::Expanding : QSizePolicy::Minimum );
1382 \brief Get preference item option value.
1383 \param name option name
1384 \return property value or null QVariant if option is not set
1385 \sa setOptionValue()
1387 QVariant QtxPagePrefFrameItem::optionValue( const QString& name ) const
1389 if ( name == "margin" )
1391 else if ( name == "spacing" )
1393 else if ( name == "columns" )
1395 else if ( name == "orientation" )
1396 return orientation();
1397 else if ( name == "stretch" )
1400 return QtxPagePrefItem::optionValue( name );
1404 \brief Set preference item option value.
1405 \param name option name
1406 \param val new property value
1409 void QtxPagePrefFrameItem::setOptionValue( const QString& name, const QVariant& val )
1411 if ( name == "margin" )
1413 if ( val.canConvert( QVariant::Int ) )
1414 setMargin( val.toInt() );
1416 else if ( name == "spacing" )
1418 if ( val.canConvert( QVariant::Int ) )
1419 setSpacing( val.toInt() );
1421 else if ( name == "columns" )
1423 if ( val.canConvert( QVariant::Int ) )
1424 setColumns( val.toInt() );
1426 else if ( name == "orientation" )
1428 if ( val.canConvert( QVariant::Int ) )
1429 setOrientation( (Qt::Orientation)val.toInt() );
1431 else if ( name == "stretch" )
1433 if ( val.canConvert( QVariant::Bool ) )
1434 setStretch( val.toBool() );
1437 QtxPagePrefItem::setOptionValue( name, val );
1440 void QtxPagePrefFrameItem::widgetShown()
1442 QtxPagePrefItem::widgetShown();
1444 QtxPageNamedPrefItem::adjustLabels( this );
1448 \brief Update frame widget.
1450 void QtxPagePrefFrameItem::updateFrame()
1452 QList<QtxPagePrefItem*> items;
1453 pageChildItems( items );
1455 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1457 QWidget* wid = (*it)->widget();
1461 if ( wid->parent() != myBox )
1462 wid->setParent( myBox );
1467 \class QtxPagePrefGroupItem
1468 \brief GUI implementation of the group widget container.
1473 \param title preference item title
1474 \param parent parent preference item
1475 \param sect resource file section associated with the preference item
1476 \param param resource file parameter associated with the preference item
1478 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const QString& title, QtxPreferenceItem* parent,
1479 const QString& sect, const QString& param )
1480 : QtxPagePrefItem( title, parent, sect, param )
1482 myGroup = new QtxGroupBox( title, 0 );
1483 myBox = new QtxGridBox( 1, Qt::Horizontal, myGroup, 5, 5 );
1484 myGroup->setWidget( myBox );
1486 setWidget( myGroup );
1493 \param cols columns number
1494 \param title preference item title
1495 \param parent parent preference item
1496 \param sect resource file section associated with the preference item
1497 \param param resource file parameter associated with the preference item
1499 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const int cols, const QString& title, QtxPreferenceItem* parent,
1500 const QString& sect, const QString& param )
1501 : QtxPagePrefItem( title, parent, sect, param )
1503 myGroup = new QtxGroupBox( title, 0 );
1504 myBox = new QtxGridBox( cols, Qt::Horizontal, myGroup, 5, 5 );
1505 myGroup->setWidget( myBox );
1507 setWidget( myGroup );
1515 QtxPagePrefGroupItem::~QtxPagePrefGroupItem()
1520 \brief Assign resource file settings to the preference item.
1521 \param sect resource file section name
1522 \param param resource file parameter name
1525 void QtxPagePrefGroupItem::setResource( const QString& sect, const QString& param )
1527 QtxPagePrefItem::setResource( sect, param );
1532 \brief Update widget contents.
1534 void QtxPagePrefGroupItem::updateContents()
1536 QtxPagePrefItem::updateContents();
1538 myGroup->setTitle( title() );
1543 QtxPageNamedPrefItem::adjustLabels( this );
1547 \brief Get group box margin.
1548 \return current group box margin
1551 int QtxPagePrefGroupItem::margin() const
1553 return myBox->insideMargin();
1557 \brief Get group box margin.
1558 \param m new group box margin
1561 void QtxPagePrefGroupItem::setMargin( const int m )
1563 myBox->setInsideMargin( m );
1567 \brief Get group box spacing.
1568 \return current group box spacing
1571 int QtxPagePrefGroupItem::spacing() const
1573 return myBox->insideSpacing();
1577 \brief Set group box spacing.
1578 \param s new group box spacing
1581 void QtxPagePrefGroupItem::setSpacing( const int s )
1583 myBox->setInsideSpacing( s );
1587 \brief Get number of group box columns.
1588 \return current columns number
1591 int QtxPagePrefGroupItem::columns() const
1593 return myBox->columns();
1597 \brief Set number of group box columns.
1598 \param c new columns number
1601 void QtxPagePrefGroupItem::setColumns( const int c )
1603 myBox->setColumns( c );
1607 \brief Get group box orientation.
1608 \return current group box orientation
1609 \sa setOrientation()
1611 Qt::Orientation QtxPagePrefGroupItem::orientation() const
1613 return myBox->orientation();
1617 \brief Set group box orientation.
1618 \param o new group box orientation
1621 void QtxPagePrefGroupItem::setOrientation( const Qt::Orientation o )
1623 myBox->setOrientation( o );
1627 \brief Get 'flat' flag of the group box widget.
1628 \return \c true if the group box is flat
1630 bool QtxPagePrefGroupItem::isFlat() const
1632 return myGroup->isFlat();
1636 \brief Get 'flat' flag of the group box widget.
1637 \param on if \c true the group box will be made flat
1639 void QtxPagePrefGroupItem::setFlat( const bool on )
1641 myGroup->setFlat( on );
1645 \brief Store preference item to the resource manager.
1648 void QtxPagePrefGroupItem::store()
1650 if ( myGroup->isCheckable() )
1651 setBoolean( myGroup->isChecked() );
1655 \brief Return widget contained grid layout of this group.
1657 QtxGridBox* QtxPagePrefGroupItem::gridBox() const
1663 \brief Retrieve preference item from the resource manager.
1666 void QtxPagePrefGroupItem::retrieve()
1668 if ( myGroup->isCheckable() )
1669 myGroup->setChecked( getBoolean() );
1673 \brief Get preference item option value.
1674 \param name option name
1675 \return property value or null QVariant if option is not set
1676 \sa setOptionValue()
1678 QVariant QtxPagePrefGroupItem::optionValue( const QString& name ) const
1680 if ( name == "margin" )
1682 else if ( name == "spacing" )
1684 else if ( name == "columns" )
1686 else if ( name == "orientation" )
1687 return orientation();
1688 else if ( name == "flat" )
1691 return QtxPagePrefItem::optionValue( name );
1695 \brief Set preference item option value.
1696 \param name option name
1697 \param val new property value
1700 void QtxPagePrefGroupItem::setOptionValue( const QString& name, const QVariant& val )
1702 if ( name == "margin" )
1704 if ( val.canConvert( QVariant::Int ) )
1705 setMargin( val.toInt() );
1707 else if ( name == "spacing" )
1709 if ( val.canConvert( QVariant::Int ) )
1710 setSpacing( val.toInt() );
1712 else if ( name == "columns" )
1714 if ( val.canConvert( QVariant::Int ) )
1715 setColumns( val.toInt() );
1717 else if ( name == "orientation" )
1719 if ( val.canConvert( QVariant::Int ) )
1720 setOrientation( (Qt::Orientation)val.toInt() );
1722 else if ( name == "flat" )
1724 if ( val.canConvert( QVariant::Bool ) )
1725 setFlat( val.toBool() );
1728 QtxPagePrefItem::setOptionValue( name, val );
1731 void QtxPagePrefGroupItem::widgetShown()
1733 QtxPagePrefItem::widgetShown();
1735 QtxPageNamedPrefItem::adjustLabels( this );
1739 \brief Update widget state.
1741 void QtxPagePrefGroupItem::updateState()
1743 QString section, param;
1744 resource( section, param );
1745 myGroup->setCheckable( !title().isEmpty() && !section.isEmpty() && !param.isEmpty() );
1749 \brief Update group box widget.
1751 void QtxPagePrefGroupItem::updateGroup()
1753 QList<QtxPagePrefItem*> items;
1754 pageChildItems( items );
1756 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1758 QWidget* wid = (*it)->widget();
1762 if ( wid->parent() != myBox )
1763 wid->setParent( myBox );
1768 \class QtxPagePrefLabelItem
1769 \brief Label item which can be used in the preferences editor dialog box.
1775 Creates label item with specified title.
1777 \param text label text
1778 \param parent parent preference item
1780 QtxPagePrefLabelItem::QtxPagePrefLabelItem( const QString& text, QtxPreferenceItem* parent )
1781 : QtxPagePrefItem( text, parent )
1783 setWidget( myLabel = new QLabel( text ) );
1786 QtxPagePrefLabelItem::QtxPagePrefLabelItem( Qt::Alignment align, const QString& text, QtxPreferenceItem* parent )
1787 : QtxPagePrefItem( text, parent )
1789 setWidget( myLabel = new QLabel( text ) );
1790 myLabel->setAlignment( align );
1793 QtxPagePrefLabelItem::~QtxPagePrefLabelItem()
1797 void QtxPagePrefLabelItem::setTitle( const QString& text )
1799 QtxPagePrefItem::setTitle( text );
1802 myLabel->setText( text );
1805 Qt::Alignment QtxPagePrefLabelItem::alignment() const
1807 return myLabel->alignment();
1810 void QtxPagePrefLabelItem::setAlignment( Qt::Alignment align )
1812 myLabel->setAlignment( align );
1815 QVariant QtxPagePrefLabelItem::optionValue( const QString& name ) const
1818 if ( name == "alignment" )
1819 val = (int)alignment();
1823 void QtxPagePrefLabelItem::setOptionValue( const QString& name, const QVariant& val )
1825 if ( name == "alignment" )
1827 if ( val.canConvert( QVariant::Int ) )
1828 setAlignment( (Qt::Alignment)val.toInt() );
1833 \class QtxPagePrefSpaceItem
1834 \brief Simple spacer item which can be used in the preferences
1841 Creates spacer item with zero width and height and expanding
1842 on both directions (by height and width).
1844 \param parent parent preference item
1846 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( QtxPreferenceItem* parent )
1847 : QtxPagePrefItem( QString(), parent )
1849 initialize( 0, 0, 1, 1 );
1855 Creates spacer item with zero width and height and expanding
1856 according to the specified orientation.
1858 \param o spacer orientation
1859 \param parent parent preference item
1861 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( Qt::Orientation o, QtxPreferenceItem* parent )
1862 : QtxPagePrefItem( QString(), parent )
1864 if ( o == Qt::Horizontal )
1865 initialize( 0, 0, 1, 0 );
1867 initialize( 0, 0, 0, 1 );
1873 Creates spacer item with specified width and height. The spacing
1874 item is expanding horizontally if \a w <= 0 and vertically
1877 \param w spacer width
1878 \param h spacer height
1879 \param parent parent preference item
1881 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( const int w, const int h, QtxPreferenceItem* parent )
1882 : QtxPagePrefItem( QString(), parent )
1884 initialize( w, h, w > 0 ? 0 : 1, h > 0 ? 0 : 1 );
1890 QtxPagePrefSpaceItem::~QtxPagePrefSpaceItem()
1895 \brief Get spacer item size for the specified direction.
1897 \return size for the specified direction
1900 int QtxPagePrefSpaceItem::size( Qt::Orientation o ) const
1902 return o == Qt::Horizontal ? widget()->minimumWidth() : widget()->minimumHeight();
1906 \brief Set spacer item size for the specified direction.
1908 \param sz new size for the specified direction
1911 void QtxPagePrefSpaceItem::setSize( Qt::Orientation o, const int sz )
1913 if ( o == Qt::Horizontal )
1914 widget()->setMinimumWidth( sz );
1916 widget()->setMinimumHeight( sz );
1920 \brief Get spacer item stretch factor for the specified direction.
1922 \return stretch factor for the specified direction
1925 int QtxPagePrefSpaceItem::stretch( Qt::Orientation o ) const
1927 QSizePolicy sp = widget()->sizePolicy();
1928 return o == Qt::Horizontal ? sp.horizontalStretch() : sp.verticalStretch();
1932 \brief Set spacer item stretch factor for the specified direction.
1934 \param sf new stretch factor for the specified direction
1937 void QtxPagePrefSpaceItem::setStretch( Qt::Orientation o, const int sf )
1939 QSizePolicy sp = widget()->sizePolicy();
1940 if ( o == Qt::Horizontal )
1942 sp.setHorizontalStretch( sf );
1943 sp.setHorizontalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1947 sp.setVerticalStretch( sf );
1948 sp.setVerticalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1951 widget()->setSizePolicy( sp );
1955 \brief Get preference item option value.
1956 \param name option name
1957 \return property value or null QVariant if option is not set
1958 \sa setOptionValue()
1960 QVariant QtxPagePrefSpaceItem::optionValue( const QString& name ) const
1962 if ( name == "horizontal_size" || name == "hsize" )
1963 return size( Qt::Horizontal );
1964 else if ( name == "vertical_size" || name == "vsize" )
1965 return size( Qt::Vertical );
1966 else if ( name == "horizontal_stretch" || name == "hstretch" )
1967 return stretch( Qt::Horizontal );
1968 else if ( name == "vertical_stretch" || name == "vstretch" )
1969 return stretch( Qt::Vertical );
1971 return QtxPagePrefItem::optionValue( name );
1975 \brief Set preference item option value.
1976 \param name option name
1977 \param val new property value
1980 void QtxPagePrefSpaceItem::setOptionValue( const QString& name, const QVariant& val )
1982 if ( name == "horizontal_size" || name == "hsize" )
1984 if ( val.canConvert( QVariant::Int ) )
1985 setSize( Qt::Horizontal, val.toInt() );
1987 else if ( name == "vertical_size" || name == "vsize" )
1989 if ( val.canConvert( QVariant::Int ) )
1990 setSize( Qt::Vertical, val.toInt() );
1992 else if ( name == "horizontal_stretch" || name == "hstretch" )
1994 if ( val.canConvert( QVariant::Int ) )
1995 setStretch( Qt::Horizontal, val.toInt() );
1997 else if ( name == "vertical_stretch" || name == "vstretch" )
1999 if ( val.canConvert( QVariant::Int ) )
2000 setStretch( Qt::Vertical, val.toInt() );
2003 QtxPagePrefItem::setOptionValue( name, val );
2007 \brief Perform internal initialization.
2008 \param w spacer item width
2009 \param h spacer item height
2010 \param ws spacer item horizontal stretch factor
2011 \param hs spacer item vertical stretch factor
2013 void QtxPagePrefSpaceItem::initialize( const int w, const int h, const int hs, const int vs )
2016 sp.setHorizontalPolicy( hs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
2017 sp.setVerticalPolicy( vs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
2019 sp.setHorizontalStretch( hs );
2020 sp.setVerticalStretch( vs );
2022 QWidget* wid = new QWidget();
2023 wid->setSizePolicy( sp );
2025 wid->setMinimumSize( w, h );
2031 \class QtxPagePrefCheckItem
2032 \brief GUI implementation of the resources check box item (boolean).
2037 \param title preference item title
2038 \param parent parent preference item
2039 \param sect resource file section associated with the preference item
2040 \param param resource file parameter associated with the preference item
2042 QtxPagePrefCheckItem::QtxPagePrefCheckItem( const QString& title, QtxPreferenceItem* parent,
2043 const QString& sect, const QString& param )
2045 : QtxPagePrefItem( title, parent, sect, param )
2047 myCheck = new QCheckBox( title );
2048 myCheck->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
2049 setWidget( myCheck );
2055 QtxPagePrefCheckItem::~QtxPagePrefCheckItem()
2060 \brief Set preference item title.
2061 \param txt new preference title.
2063 void QtxPagePrefCheckItem::setTitle( const QString& txt )
2065 QtxPagePrefItem::setTitle( txt );
2067 myCheck->setText( title() );
2071 \brief Store preference item to the resource manager.
2074 void QtxPagePrefCheckItem::store()
2076 setBoolean( myCheck->isChecked() );
2080 \brief Retrieve preference item from the resource manager.
2083 void QtxPagePrefCheckItem::retrieve()
2085 myCheck->setChecked( getBoolean() );
2089 \class QtxPagePrefEditItem
2090 \brief GUI implementation of the resources line edit box item
2091 for string, integer and double values.
2094 static void fixupAndSet( QLineEdit* le, const QString& txt )
2098 if ( le->validator() ) {
2099 const QDoubleValidator* de = dynamic_cast<const QDoubleValidator*>( le->validator() );
2101 int dec = de->decimals();
2102 int idx = val.lastIndexOf( QRegExp( QString("[.|%1]").arg( le->locale().decimalPoint () ) ) );
2104 QString tmp = val.mid( idx+1 );
2106 val = val.left( idx+1 );
2107 idx = tmp.indexOf( QRegExp( QString("[e|E]") ) );
2109 exp = tmp.mid( idx );
2110 tmp = tmp.left( idx );
2112 tmp.truncate( dec );
2113 val = val + tmp + exp;
2117 if ( le->validator()->validate( val, pos ) == QValidator::Invalid )
2127 Creates preference item for string value editing.
2129 \param title preference item title
2130 \param parent parent preference item
2131 \param sect resource file section associated with the preference item
2132 \param param resource file parameter associated with the preference item
2134 QtxPagePrefEditItem::QtxPagePrefEditItem( const QString& title, QtxPreferenceItem* parent,
2135 const QString& sect, const QString& param )
2136 : QtxPageNamedPrefItem( title, parent, sect, param ),
2141 setControl( myEditor = new QLineEdit() );
2148 Creates preference item for editing of the value which type
2149 is specified by parameter \a type.
2151 \param type preference item input type (QtxPagePrefEditItem::InputType)
2152 \param title preference item title
2153 \param parent parent preference item
2154 \param sect resource file section associated with the preference item
2155 \param param resource file parameter associated with the preference item
2157 QtxPagePrefEditItem::QtxPagePrefEditItem( const int type, const QString& title,
2158 QtxPreferenceItem* parent, const QString& sect,
2159 const QString& param )
2160 : QtxPageNamedPrefItem( title, parent, sect, param ),
2165 setControl( myEditor = new QLineEdit() );
2172 QtxPagePrefEditItem::~QtxPagePrefEditItem()
2177 \brief Get edit box preference item input type.
2178 \return preference item input type (QtxPagePrefEditItem::InputType)
2181 int QtxPagePrefEditItem::inputType() const
2187 \brief Set edit box preference item input type.
2188 \param type new preference item input type (QtxPagePrefEditItem::InputType)
2191 void QtxPagePrefEditItem::setInputType( const int type )
2193 if ( myType == type )
2201 \brief Get number of digits after decimal point (for Double input type)
2202 \return preference item decimals value
2205 int QtxPagePrefEditItem::decimals() const
2211 \brief Set number of digits after decimal point (for Double input type)
2212 \param dec new preference item decimals value
2215 void QtxPagePrefEditItem::setDecimals( const int dec )
2217 if ( myDecimals == dec )
2225 \brief Get the line edit's echo mode
2226 \return preference item echo mode value
2229 int QtxPagePrefEditItem::echoMode() const
2235 \brief Set the line edit's echo mode
2236 \param echo new preference item echo mode value
2239 void QtxPagePrefEditItem::setEchoMode( const int echo )
2241 if ( myEchoMode == echo )
2249 \brief Store preference item to the resource manager.
2252 void QtxPagePrefEditItem::store()
2254 setString( myEditor->text() );
2258 \brief Retrieve preference item from the resource manager.
2261 void QtxPagePrefEditItem::retrieve()
2263 QString txt = getString();
2264 fixupAndSet( myEditor, txt );
2268 \brief Get preference item option value.
2269 \param name option name
2270 \return property value or null QVariant if option is not set
2271 \sa setOptionValue()
2273 QVariant QtxPagePrefEditItem::optionValue( const QString& name ) const
2275 if ( name == "input_type" || name == "type" )
2277 else if ( name == "precision" || name == "prec" || name == "decimals" )
2279 else if ( name == "echo" || name == "echo_mode" || name == "echomode")
2282 return QtxPageNamedPrefItem::optionValue( name );
2286 \brief Set preference item option value.
2287 \param name option name
2288 \param val new property value
2291 void QtxPagePrefEditItem::setOptionValue( const QString& name, const QVariant& val )
2293 if ( name == "input_type" || name == "type" )
2295 if ( val.canConvert( QVariant::Int ) )
2296 setInputType( val.toInt() );
2298 else if ( name == "precision" || name == "prec" || name == "decimals" ) {
2299 if ( val.canConvert( QVariant::Int ) )
2300 setDecimals( val.toInt() );
2302 else if ( name == "echo" || name == "echo_mode" || name == "echomode") {
2303 if ( val.canConvert( QVariant::Int ) )
2304 setEchoMode( val.toInt() );
2307 QtxPageNamedPrefItem::setOptionValue( name, val );
2311 \brief Update edit box widget.
2313 void QtxPagePrefEditItem::updateEditor()
2318 myEditor->setEchoMode(QLineEdit::Normal);
2321 myEditor->setEchoMode(QLineEdit::NoEcho);
2324 myEditor->setEchoMode(QLineEdit::Password);
2327 myEditor->setEchoMode(QLineEdit::PasswordEchoOnEdit);
2330 myEditor->setEchoMode(QLineEdit::Normal);
2333 QValidator* val = 0;
2334 switch ( inputType() )
2337 val = new QIntValidator( myEditor );
2340 val = new QDoubleValidator( myEditor );
2341 dynamic_cast<QDoubleValidator*>( val )->setDecimals( myDecimals < 0 ? 1000 : myDecimals );
2347 QString txt = myEditor->text();
2348 delete myEditor->validator();
2349 myEditor->setValidator( val );
2350 fixupAndSet( myEditor, txt );
2354 \class QtxPagePrefSliderItem
2360 Creates preference item with slider widget
2362 \param title preference item title
2363 \param parent parent preference item
2364 \param sect resource file section associated with the preference item
2365 \param param resource file parameter associated with the preference item
2367 QtxPagePrefSliderItem::QtxPagePrefSliderItem( const QString& title, QtxPreferenceItem* parent,
2368 const QString& sect, const QString& param )
2369 : QtxPageNamedPrefItem( title, parent, sect, param )
2371 setControl( mySlider = new QSlider( Qt::Horizontal ) );
2372 widget()->layout()->addWidget( myLabel = new QLabel( ) );
2379 mySlider->setTickPosition( QSlider::TicksBothSides );
2381 connect (mySlider, SIGNAL(valueChanged(int)), this, SLOT(setIcon(int)));
2388 QtxPagePrefSliderItem::~QtxPagePrefSliderItem()
2393 \brief Get slider preference item step value.
2394 \return slider single step value
2397 int QtxPagePrefSliderItem::singleStep() const
2399 return mySlider->singleStep();
2403 \brief Get slider preference item step value.
2404 \return slider page step value
2407 int QtxPagePrefSliderItem::pageStep() const
2409 return mySlider->pageStep();
2413 \brief Get slider preference item minimum value.
2414 \return slider minimum value
2417 int QtxPagePrefSliderItem::minimum() const
2419 return mySlider->minimum();
2423 \brief Get slider preference item maximum value.
2424 \return slider maximum value
2427 int QtxPagePrefSliderItem::maximum() const
2429 return mySlider->maximum();
2433 \brief Get the list of the icons associated with the selection widget items
2434 \return list of icons
2437 QList<QIcon> QtxPagePrefSliderItem::icons() const
2443 \brief Set slider preference item step value.
2444 \param step new slider single step value
2447 void QtxPagePrefSliderItem::setSingleStep( const int& step )
2449 mySlider->setSingleStep( step );
2453 \brief Set slider preference item step value.
2454 \param step new slider single step value
2457 void QtxPagePrefSliderItem::setPageStep( const int& step )
2459 mySlider->setPageStep( step );
2463 \brief Set slider preference item minimum value.
2464 \param min new slider minimum value
2467 void QtxPagePrefSliderItem::setMinimum( const int& min )
2469 mySlider->setMinimum( min );
2470 setIcon( mySlider->value() );
2474 \brief Set slider preference item maximum value.
2475 \param max new slider maximum value
2478 void QtxPagePrefSliderItem::setMaximum( const int& max )
2480 mySlider->setMaximum( max );
2481 setIcon( mySlider->value() );
2485 \brief Set the list of the icons to the selection widget items
2486 \param icns new list of icons
2489 void QtxPagePrefSliderItem::setIcons( const QList<QIcon>& icns )
2491 if ( icns.isEmpty() )
2495 QSize maxsize(0, 0);
2496 for ( QList<QIcon>::const_iterator it = myIcons.begin(); it != myIcons.end(); ++it ) {
2497 if ( (*it).isNull() ) continue;
2498 maxsize = maxsize.expandedTo( (*it).availableSizes().first() );
2500 myLabel->setFixedSize( maxsize );
2506 \brief Store preference item to the resource manager.
2509 void QtxPagePrefSliderItem::store()
2511 setInteger( mySlider->value() );
2515 \brief Retrieve preference item from the resource manager.
2518 void QtxPagePrefSliderItem::retrieve()
2520 mySlider->setValue( getInteger( mySlider->value() ) );
2524 \brief Get preference item option value.
2525 \param name option name
2526 \return property value or null integer if option is not set
2527 \sa setOptionValue()
2529 QVariant QtxPagePrefSliderItem::optionValue( const QString& name ) const
2531 if ( name == "minimum" || name == "min" )
2533 else if ( name == "maximum" || name == "max" )
2535 else if ( name == "single_step" )
2536 return singleStep();
2537 else if ( name == "page_step" )
2539 else if ( name == "icons" || name == "pixmaps" )
2541 QList<QVariant> lst;
2542 QList<QIcon> ics = icons();
2543 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2548 return QtxPageNamedPrefItem::optionValue( name );
2552 \brief Set preference item option value.
2553 \param name option name
2554 \param val new property value
2557 void QtxPagePrefSliderItem::setOptionValue( const QString& name, const QVariant& val )
2559 if ( val.canConvert( QVariant::Int ) )
2561 if ( name == "minimum" || name == "min" )
2562 setMinimum( val.toInt() );
2563 else if ( name == "maximum" || name == "max" )
2564 setMaximum( val.toInt() );
2565 else if ( name == "single_step" )
2566 setSingleStep( val.toInt() );
2567 else if ( name == "page_step" )
2568 setPageStep( val.toInt() );
2570 QtxPageNamedPrefItem::setOptionValue( name, val );
2572 else if ( name == "icons" || name == "pixmaps" )
2575 QtxPageNamedPrefItem::setOptionValue( name, val );
2578 void QtxPagePrefSliderItem::setIcon( int pos )
2580 int index = pos - mySlider->minimum();
2581 if ( !myIcons.isEmpty() && index >= 0 && index < myIcons.size() && !myIcons[index].isNull() )
2582 myLabel->setPixmap( myIcons[index].pixmap( myIcons[index].availableSizes().first() ) );
2588 \brief Update slider widget.
2590 void QtxPagePrefSliderItem::updateSlider()
2592 int val = mySlider->value();
2593 int stp = singleStep();
2594 int ptp = pageStep();
2595 int min = minimum();
2596 int max = maximum();
2598 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2599 mySlider->setFocusPolicy(Qt::StrongFocus);
2601 mySlider->setValue( val );
2602 setSingleStep( stp );
2607 myLabel->setVisible( !myIcons.empty() );
2608 widget()->layout()->setSpacing( !myIcons.empty() ? 6 : 0 );
2612 \brief Set the list of the icons from the resource manager.
2613 \param var new icons list
2616 void QtxPagePrefSliderItem::setIcons( const QVariant& var )
2618 if ( var.type() != QVariant::List )
2622 QList<QVariant> varList = var.toList();
2623 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2625 if ( (*it).canConvert<QIcon>() )
2626 lst.append( (*it).value<QIcon>() );
2627 else if ( (*it).canConvert<QPixmap>() )
2628 lst.append( (*it).value<QPixmap>() );
2630 lst.append( QIcon() );
2636 \class QtxPagePrefSelectItem
2637 \brief GUI implementation of the resources selector item
2638 (string, integer or double values list).
2640 All items in the list (represented as combo box) should be specified
2641 by the unique identifier which is stored to the resource file instead
2642 of the value itself.
2648 Creates preference item with combo box widget which is not editable
2649 (direct value entering is disabled).
2651 \param title preference item title
2652 \param parent parent preference item
2653 \param sect resource file section associated with the preference item
2654 \param param resource file parameter associated with the preference item
2656 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const QString& title, QtxPreferenceItem* parent,
2657 const QString& sect, const QString& param )
2658 : QtxPageNamedPrefItem( title, parent, sect, param ),
2661 setControl( mySelector = new QtxComboBox() );
2662 mySelector->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2663 mySelector->setDuplicatesEnabled( false );
2670 Creates preference item with combo box widget which is editable
2671 according to the specified input type (integer, double or string values).
2673 \param type input type (QtxPagePrefSelectItem::InputType)
2674 \param title preference item title
2675 \param parent parent preference item
2676 \param sect resource file section associated with the preference item
2677 \param param resource file parameter associated with the preference item
2679 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const int type, const QString& title, QtxPreferenceItem* parent,
2680 const QString& sect, const QString& param )
2681 : QtxPageNamedPrefItem( title, parent, sect, param ),
2684 setControl( mySelector = new QtxComboBox() );
2685 mySelector->setDuplicatesEnabled( false );
2692 QtxPagePrefSelectItem::~QtxPagePrefSelectItem()
2697 \brief Get edit box preference item input type.
2698 \return preference item input type (QtxPagePrefSelectItem::InputType)
2701 int QtxPagePrefSelectItem::inputType() const
2707 \brief Set edit box preference item input type.
2708 \param type new preference item input type (QtxPagePrefSelectItem::InputType)
2711 void QtxPagePrefSelectItem::setInputType( const int type )
2713 if ( myType == type )
2721 \brief Get the list of the values from the selection widget.
2722 \return list of values
2723 \sa numbers(), icons(), setStrings()
2725 QStringList QtxPagePrefSelectItem::strings() const
2728 for ( int i = 0; i < mySelector->count(); i++ )
2729 res.append( mySelector->itemText( i ) );
2734 \brief Get the list of the values identifiers from the selection widget.
2735 \return list of values IDs
2736 \sa strings(), icons(), setNumbers()
2738 QList<QVariant> QtxPagePrefSelectItem::numbers() const
2740 QList<QVariant> res;
2741 for ( int i = 0; i < mySelector->count(); i++ )
2743 if ( mySelector->hasId( i ) )
2744 res.append( mySelector->id( i ) );
2750 \brief Get the list of the icons associated with the selection widget.items
2751 \return list of icons
2752 \sa strings(), numbers(), setIcons()
2754 QList<QIcon> QtxPagePrefSelectItem::icons() const
2757 for ( int i = 0; i < mySelector->count(); i++ )
2758 res.append( mySelector->itemIcon( i ) );
2763 \brief Set the list of the values to the selection widget.
2764 \param lst new list of values
2765 \sa strings(), setNumbers(), setIcons()
2767 void QtxPagePrefSelectItem::setStrings( const QStringList& lst )
2769 mySelector->clear();
2770 mySelector->addItems( lst );
2774 \brief Set the list of the values identifiers to the selection widget
2775 \param ids new list of values IDs
2776 \sa numbers(), setStrings(), setIcons()
2778 void QtxPagePrefSelectItem::setNumbers( const QList<QVariant>& ids )
2781 for ( QList<QVariant>::const_iterator it = ids.begin(); it != ids.end(); ++it, i++ ) {
2782 if ( i >= mySelector->count() )
2783 mySelector->addItem(QString("") );
2785 mySelector->setId( i, *it );
2790 \brief Set the list of the icons to the selection widget items
2792 Important: call this method after setStrings() or setNumbers()
2794 \param icns new list of icons
2795 \sa icons(), setStrings(), setNumbers()
2797 void QtxPagePrefSelectItem::setIcons( const QList<QIcon>& icns )
2800 for ( QList<QIcon>::const_iterator it = icns.begin(); it != icns.end() && i < mySelector->count(); ++it, i++ )
2801 mySelector->setItemIcon( i, *it );
2805 \brief Store preference item to the resource manager.
2808 void QtxPagePrefSelectItem::store()
2810 if ( mySelector->isCleared() )
2813 int idx = mySelector->currentIndex();
2815 if ( mySelector->hasId( idx ) ) {
2816 QVariant id = mySelector->id( idx );
2817 if ( id.type() == QVariant::Int )
2818 setInteger( id.toInt() );
2819 else if ( id.type() == QVariant::String )
2820 setString( id.toString() );
2822 else if ( idx >= 0 ) {
2823 setString( mySelector->itemText( idx ) );
2828 \brief Retrieve preference item from the resource manager.
2831 void QtxPagePrefSelectItem::retrieve()
2833 QString txt = getString();
2835 // try to find via the id
2836 int idx = mySelector->index( txt );
2839 for ( int i = 0; i < mySelector->count() && idx == -1; i++ )
2841 if ( mySelector->itemText( i ) == txt )
2847 mySelector->setCurrentIndex( idx );
2848 else if ( mySelector->isEditable() )
2851 if ( mySelector->validator() &&
2852 mySelector->validator()->validate( txt, pos ) == QValidator::Invalid )
2853 mySelector->setCleared( true );
2856 mySelector->setCleared( false );
2857 mySelector->addItem( txt );
2858 mySelector->setCurrentIndex( mySelector->count() - 1 );
2864 \brief Get preference item option value.
2865 \param name option name
2866 \return property value or null QVariant if option is not set
2867 \sa setOptionValue()
2869 QVariant QtxPagePrefSelectItem::optionValue( const QString& name ) const
2871 if ( name == "input_type" || name == "type" )
2873 else if ( name == "strings" || name == "labels" )
2875 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2879 else if ( name == "icons" || name == "pixmaps" )
2881 QList<QVariant> lst;
2882 QList<QIcon> ics = icons();
2883 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2888 return QtxPageNamedPrefItem::optionValue( name );
2892 \brief Set preference item option value.
2893 \param name option name
2894 \param val new property value
2897 void QtxPagePrefSelectItem::setOptionValue( const QString& name, const QVariant& val )
2899 if ( name == "input_type" || name == "type" )
2901 if ( val.canConvert( QVariant::Int ) )
2902 setInputType( val.toInt() );
2904 else if ( name == "strings" || name == "labels" )
2906 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2908 else if ( name == "icons" || name == "pixmaps" )
2911 QtxPageNamedPrefItem::setOptionValue( name, val );
2915 \brief Set the list of the values from the resource manager.
2916 \param var new values list
2919 void QtxPagePrefSelectItem::setStrings( const QVariant& var )
2922 if ( toStringList( var, values ) )
2923 setStrings( values );
2927 \brief Set the list of the values identifiers from the resource manager.
2928 \param var new values IDs list
2931 void QtxPagePrefSelectItem::setNumbers( const QVariant& var )
2933 if ( var.type() != QVariant::List )
2936 setNumbers( var.toList() );
2940 \brief Set the list of the icons from the resource manager.
2941 \param var new icons list
2944 void QtxPagePrefSelectItem::setIcons( const QVariant& var )
2946 if ( var.type() != QVariant::List )
2950 QList<QVariant> varList = var.toList();
2951 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2953 if ( (*it).canConvert<QIcon>() )
2954 lst.append( (*it).value<QIcon>() );
2955 else if ( (*it).canConvert<QPixmap>() )
2956 lst.append( (*it).value<QPixmap>() );
2958 lst.append( QIcon() );
2964 \brief Update selector widget.
2966 void QtxPagePrefSelectItem::updateSelector()
2968 QValidator* val = 0;
2969 switch ( inputType() )
2972 val = new QIntValidator( mySelector );
2975 val = new QDoubleValidator( mySelector );
2981 mySelector->setEditable( inputType() != NoInput );
2983 if ( mySelector->isEditable() && !mySelector->currentText().isEmpty() && val )
2986 QString str = mySelector->currentText();
2987 if ( val->validate( str, pos ) == QValidator::Invalid )
2988 mySelector->clearEditText();
2991 delete mySelector->validator();
2992 mySelector->setValidator( val );
2996 \class QtxPagePrefSpinItem
2997 \brief GUI implementation of the resources spin box item
2998 (for integer or double value).
3004 Creates spin box preference item for the entering integer values.
3006 \param title preference item title
3007 \param parent parent preference item
3008 \param sect resource file section associated with the preference item
3009 \param param resource file parameter associated with the preference item
3011 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const QString& title, QtxPreferenceItem* parent,
3012 const QString& sect, const QString& param )
3013 : QtxPageNamedPrefItem( title, parent, sect, param ),
3022 Creates spin box preference item for the entering values which type
3023 is specified by the parameter \a type.
3025 \param type input type (QtxPagePrefSpinItem::InputType).
3026 \param title preference item title
3027 \param parent parent preference item
3028 \param sect resource file section associated with the preference item
3029 \param param resource file parameter associated with the preference item
3031 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const int type, const QString& title,
3032 QtxPreferenceItem* parent, const QString& sect,
3033 const QString& param )
3034 : QtxPageNamedPrefItem( title, parent, sect, param ),
3043 QtxPagePrefSpinItem::~QtxPagePrefSpinItem()
3048 \brief Get spin box preference item input type.
3049 \return preference item input type (QtxPagePrefSpinItem::InputType)
3052 int QtxPagePrefSpinItem::inputType() const
3058 \brief Set spin box preference item input type.
3059 \param type new preference item input type (QtxPagePrefSpinItem::InputType)
3062 void QtxPagePrefSpinItem::setInputType( const int type )
3064 if ( myType == type )
3072 \brief Get spin box preference item step value.
3073 \return spin box single step value
3076 QVariant QtxPagePrefSpinItem::step() const
3078 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3079 return isb->singleStep();
3080 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3081 return dsb->singleStep();
3087 \brief Get double spin box preference item precision value.
3088 \return double spin box precision
3091 QVariant QtxPagePrefSpinItem::precision() const
3093 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3094 return dsb->decimals();
3100 \brief Get spin box preference item minimum value.
3101 \return spin box minimum value
3104 QVariant QtxPagePrefSpinItem::minimum() const
3106 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3107 return isb->minimum();
3108 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3109 return dsb->minimum();
3115 \brief Get spin box preference item maximum value.
3116 \return spin box maximum value
3119 QVariant QtxPagePrefSpinItem::maximum() const
3121 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3122 return isb->maximum();
3123 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3124 return dsb->maximum();
3130 \brief Get spin box preference item prefix string.
3131 \return spin box prefix string
3134 QString QtxPagePrefSpinItem::prefix() const
3136 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3137 return isb->prefix();
3138 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3139 return dsb->prefix();
3145 \brief Get spin box preference item suffix string.
3146 \return spin box suffix string
3149 QString QtxPagePrefSpinItem::suffix() const
3151 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3152 return isb->suffix();
3153 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3154 return dsb->suffix();
3160 \brief Get spin box preference item special value text (which is shown
3161 when the spin box reaches minimum value).
3162 \return spin box special value text
3163 \sa setSpecialValueText()
3165 QString QtxPagePrefSpinItem::specialValueText() const
3167 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3169 return sb->specialValueText();
3175 \brief Set spin box preference item step value.
3176 \param step new spin box single step value
3179 void QtxPagePrefSpinItem::setStep( const QVariant& step )
3181 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3183 if ( step.canConvert( QVariant::Int ) )
3184 isb->setSingleStep( step.toInt() );
3186 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3188 if ( step.canConvert( QVariant::Double ) )
3189 dsb->setSingleStep( step.toDouble() );
3194 \brief Set double spin box preference item precision value.
3195 \param step new double spin box precision value
3198 void QtxPagePrefSpinItem::setPrecision( const QVariant& prec )
3200 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3202 if ( prec.canConvert( QVariant::Int ) ) {
3203 dsb->setDecimals( qAbs( prec.toInt() ) );
3204 dsb->setPrecision( prec.toInt() );
3210 \brief Set spin box preference item minimum value.
3211 \param min new spin box minimum value
3214 void QtxPagePrefSpinItem::setMinimum( const QVariant& min )
3216 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3218 if ( min.canConvert( QVariant::Int ) )
3219 isb->setMinimum( min.toInt() );
3221 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3223 if ( min.canConvert( QVariant::Double ) )
3224 dsb->setMinimum( min.toDouble() );
3229 \brief Set spin box preference item maximum value.
3230 \param min new spin box maximum value
3233 void QtxPagePrefSpinItem::setMaximum( const QVariant& max )
3235 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3237 if ( max.canConvert( QVariant::Int ) )
3238 isb->setMaximum( max.toInt() );
3240 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3242 if ( max.canConvert( QVariant::Double ) )
3243 dsb->setMaximum( max.toDouble() );
3248 \brief Set spin box preference item prefix string.
3249 \param txt new spin box prefix string
3252 void QtxPagePrefSpinItem::setPrefix( const QString& txt )
3254 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3255 isb->setPrefix( txt );
3256 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3257 dsb->setPrefix( txt );
3261 \brief Set spin box preference item suffix string.
3262 \param txt new spin box suffix string
3265 void QtxPagePrefSpinItem::setSuffix( const QString& txt )
3267 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3268 isb->setSuffix( txt );
3269 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3270 dsb->setSuffix( txt );
3274 \brief Set spin box preference item special value text (which is shown
3275 when the spin box reaches minimum value).
3276 \param txt new spin box special value text
3277 \sa specialValueText()
3279 void QtxPagePrefSpinItem::setSpecialValueText( const QString& txt )
3281 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3283 sb->setSpecialValueText( txt );
3287 \brief Store preference item to the resource manager.
3290 void QtxPagePrefSpinItem::store()
3292 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3293 setInteger( isb->value() );
3294 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3295 setDouble( dsb->value() );
3299 \brief Retrieve preference item from the resource manager.
3302 void QtxPagePrefSpinItem::retrieve()
3304 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3305 isb->setValue( getInteger( isb->value() ) );
3306 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3307 dsb->setValue( getDouble( dsb->value() ) );
3311 \brief Get preference item option value.
3312 \param name option name
3313 \return property value or null QVariant if option is not set
3314 \sa setOptionValue()
3316 QVariant QtxPagePrefSpinItem::optionValue( const QString& name ) const
3318 if ( name == "input_type" || name == "type" )
3320 else if ( name == "minimum" || name == "min" )
3322 else if ( name == "maximum" || name == "max" )
3324 else if ( name == "step" )
3326 else if ( name == "precision" )
3328 else if ( name == "prefix" )
3330 else if ( name == "suffix" )
3332 else if ( name == "special" )
3333 return specialValueText();
3335 return QtxPageNamedPrefItem::optionValue( name );
3339 \brief Set preference item option value.
3340 \param name option name
3341 \param val new property value
3344 void QtxPagePrefSpinItem::setOptionValue( const QString& name, const QVariant& val )
3346 if ( name == "input_type" || name == "type" )
3348 if ( val.canConvert( QVariant::Int ) )
3349 setInputType( val.toInt() );
3351 else if ( name == "minimum" || name == "min" )
3353 else if ( name == "maximum" || name == "max" )
3355 else if ( name == "step" )
3357 else if ( name == "precision" )
3358 setPrecision( val );
3359 else if ( name == "prefix" )
3361 if ( val.canConvert( QVariant::String ) )
3362 setPrefix( val.toString() );
3364 else if ( name == "suffix" )
3366 if ( val.canConvert( QVariant::String ) )
3367 setSuffix( val.toString() );
3369 else if ( name == "special" )
3371 if ( val.canConvert( QVariant::String ) )
3372 setSpecialValueText( val.toString() );
3375 QtxPageNamedPrefItem::setOptionValue( name, val );
3379 \brief Update spin box widget.
3381 void QtxPagePrefSpinItem::updateSpinBox()
3384 QVariant stp = step();
3385 QVariant prec = precision();
3386 QVariant min = minimum();
3387 QVariant max = maximum();
3389 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3391 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3394 switch ( inputType() )
3397 setControl( new QtxIntSpinBox() );
3400 setControl( new QtxDoubleSpinBox() );
3406 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3409 setPrecision( prec );
3413 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3415 if ( val.canConvert( QVariant::Int ) )
3416 isb->setValue( val.toInt() );
3418 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3420 if ( val.canConvert( QVariant::Double ) )
3421 dsb->setValue( val.toDouble() );
3426 \class QtxPagePrefTextItem
3427 \brief GUI implementation of the resources text box edit item
3428 (for large text data).
3433 \param parent parent preference item
3434 \param sect resource file section associated with the preference item
3435 \param param resource file parameter associated with the preference item
3437 QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect,
3438 const QString& param )
3439 : QtxPageNamedPrefItem( QString(), parent, sect, param )
3441 myEditor = new QTextEdit();
3442 myEditor->setAcceptRichText( false );
3444 setControl( myEditor );
3449 \param title preference item title
3450 \param parent parent preference item
3451 \param sect resource file section associated with the preference item
3452 \param param resource file parameter associated with the preference item
3454 QtxPagePrefTextItem::QtxPagePrefTextItem( const QString& title, QtxPreferenceItem* parent,
3455 const QString& sect, const QString& param )
3456 : QtxPageNamedPrefItem( title, parent, sect, param )
3458 myEditor = new QTextEdit();
3459 myEditor->setAcceptRichText( false );
3461 setControl( myEditor );
3467 QtxPagePrefTextItem::~QtxPagePrefTextItem()
3472 \brief Store preference item to the resource manager.
3475 void QtxPagePrefTextItem::store()
3477 setString( myEditor->toPlainText() );
3481 \brief Retrieve preference item from the resource manager.
3484 void QtxPagePrefTextItem::retrieve()
3486 myEditor->setPlainText( getString() );
3490 \class QtxPagePrefColorItem
3491 \brief GUI implementation of the resources color item.
3496 \param title preference item title
3497 \param parent parent preference item
3498 \param sect resource file section associated with the preference item
3499 \param param resource file parameter associated with the preference item
3501 QtxPagePrefColorItem::QtxPagePrefColorItem( const QString& title, QtxPreferenceItem* parent,
3502 const QString& sect, const QString& param )
3503 : QtxPageNamedPrefItem( title, parent, sect, param )
3505 // QtxPagePrefGroupItem* aGroup 0; //= dynamic_cast<QtxPagePrefGroupItem*>( parent );
3507 // setControl( myColor = new QtxColorButton( aGroup ? aGroup->gridBox() : 0 ) );
3508 setControl( myColor = new QtxColorButton( 0 ) );
3509 myColor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3515 QtxPagePrefColorItem::~QtxPagePrefColorItem()
3520 \brief Store preference item to the resource manager.
3523 void QtxPagePrefColorItem::store()
3525 setColor( myColor->color() );
3529 \brief Retrieve preference item from the resource manager.
3532 void QtxPagePrefColorItem::retrieve()
3534 myColor->setColor( getColor() );
3538 \class QtxPagePrefBiColorItem
3539 \brief GUI implementation of the resources item to store a bi-color value.
3541 The main color is specified explicitly. The secondary color is calculated
3542 by changing "value" and "saturation" parameters of the main color in the
3543 HSV notation using specified delta.
3548 \param title preference item title
3549 \param parent parent preference item
3550 \param sect resource file section associated with the preference item
3551 \param param resource file parameter associated with the preference item
3553 QtxPagePrefBiColorItem::QtxPagePrefBiColorItem( const QString& title, QtxPreferenceItem* parent,
3554 const QString& sect, const QString& param )
3555 : QtxPageNamedPrefItem( title, parent, sect, param )
3557 setControl( myColors = new QtxBiColorTool( 0 ) );
3563 QtxPagePrefBiColorItem::~QtxPagePrefBiColorItem()
3568 \bried Get auxiliary text
3569 \return text assigned to the item
3572 QString QtxPagePrefBiColorItem::text() const
3574 return myColors->text();
3578 \bried Set auxiliary text
3579 \param t text being assigned to the item
3582 void QtxPagePrefBiColorItem::setText( const QString& t )
3584 myColors->setText( t );
3588 \brief Store preference item to the resource manager.
3591 void QtxPagePrefBiColorItem::store()
3593 setString( Qtx::biColorToString( myColors->mainColor(), myColors->delta() ) );
3597 \brief Retrieve preference item from the resource manager.
3600 void QtxPagePrefBiColorItem::retrieve()
3604 Qtx::stringToBiColor( getString(), c, d );
3605 myColors->setMainColor( c );
3606 myColors->setDelta( d );
3610 \brief Get preference item option value.
3611 \param name option name
3612 \return property value or null QVariant if option is not set
3613 \sa setOptionValue()
3615 QVariant QtxPagePrefBiColorItem::optionValue( const QString& name ) const
3617 if ( name == "text" )
3620 return QtxPageNamedPrefItem::optionValue( name );
3624 \brief Set preference item option value.
3625 \param name option name
3626 \param val new property value
3629 void QtxPagePrefBiColorItem::setOptionValue( const QString& name, const QVariant& val )
3631 if ( name == "text" )
3633 if ( val.canConvert( QVariant::String ) )
3634 setText( val.toString() );
3637 QtxPageNamedPrefItem::setOptionValue( name, val );
3641 \class QtxPagePrefFontItem
3642 \brief GUI implementation of the resources font item.
3647 \param feat font editor widget features (QtxFontEdit::Features)
3648 \param title preference item title
3649 \param parent parent preference item
3650 \param sect resource file section associated with the preference item
3651 \param param resource file parameter associated with the preference item
3653 QtxPagePrefFontItem::QtxPagePrefFontItem( const int feat, const QString& title,
3654 QtxPreferenceItem* parent, const QString& sect,
3655 const QString& param )
3656 : QtxPageNamedPrefItem( title, parent, sect, param )
3658 setControl( myFont = new QtxFontEdit( feat ) );
3663 \param title preference item title
3664 \param parent parent preference item
3665 \param sect resource file section associated with the preference item
3666 \param param resource file parameter associated with the preference item
3668 QtxPagePrefFontItem::QtxPagePrefFontItem( const QString& title, QtxPreferenceItem* parent,
3669 const QString& sect, const QString& param )
3670 : QtxPageNamedPrefItem( title, parent, sect, param )
3672 setControl( myFont = new QtxFontEdit() );
3678 QtxPagePrefFontItem::~QtxPagePrefFontItem()
3683 \brief Get font widget features.
3684 \return font widget features (ORed QtxFontEdit::Features flags)
3687 int QtxPagePrefFontItem::features() const
3689 return myFont->features();
3693 \brief Set font widget features.
3694 \param f new font widget features (ORed QtxFontEdit::Features flags)
3697 void QtxPagePrefFontItem::setFeatures( const int f )
3699 myFont->setFeatures( f );
3703 \brief Specifies whether widget works in Native or Custom mode. Native mode
3704 is intended for working with system fonts. Custom mode is intended for
3705 working with manually defined set of fonts. Set of custom fonts can be
3706 specified with setFonts() method
3707 \param mode mode from QtxFontEdit::Mode enumeration
3710 void QtxPagePrefFontItem::setMode( const int mode )
3712 myFont->setMode( mode );
3716 \brief Verifies whether widget works in Native or Custom mode
3717 \return Native or Custom mode
3720 int QtxPagePrefFontItem::mode() const
3722 return myFont->mode();
3726 \brief Sets list of custom fonts.
3727 <b>This method is intended for working in Custom mode only.</b>
3728 \param fams list of families
3729 \sa fonts(), setMode()
3731 void QtxPagePrefFontItem::setFonts( const QStringList& fams )
3733 myFont->setFonts( fams );
3737 \brief Gets list of custom fonts
3738 \return list of families
3739 \sa setFonts(), setMode()
3741 QStringList QtxPagePrefFontItem::fonts() const
3743 return myFont->fonts();
3747 \brief Sets list of available font sizes.
3748 <b>This method is intended for working in Custom mode only.</b> The list of sizes can
3749 be empty. In this case system generate listof size automatically from 8 till 72.
3750 \param sizes list of sizes
3751 \sa sizes(), setMode()
3753 void QtxPagePrefFontItem::setSizes( const QList<int>& sizes )
3755 myFont->setSizes( sizes );
3759 \brief Gets list of custom fonts
3760 \return list of families
3761 \sa setFonts(), setMode()
3763 QList<int> QtxPagePrefFontItem::sizes() const
3765 return myFont->sizes();
3769 \brief Store preference item to the resource manager.
3772 void QtxPagePrefFontItem::store()
3774 setFont( myFont->currentFont() );
3778 \brief Retrieve preference item from the resource manager.
3781 void QtxPagePrefFontItem::retrieve()
3783 myFont->setCurrentFont( getFont() );
3787 \brief Get preference item option value.
3788 \param name option name
3789 \return property value or null QVariant if option is not set
3790 \sa setOptionValue()
3792 QVariant QtxPagePrefFontItem::optionValue( const QString& name ) const
3794 if ( name == "features" )
3796 else if ( name == "mode" )
3798 else if ( name == "fonts" || name == "families" )
3800 else if ( name == "sizes" )
3802 QList<QVariant> lst;
3803 QList<int> nums = sizes();
3804 for ( QList<int>::const_iterator it = nums.begin(); it != nums.end(); ++it )
3809 return QtxPageNamedPrefItem::optionValue( name );
3813 \brief Set preference item option value.
3814 \param name option name
3815 \param val new property value
3818 void QtxPagePrefFontItem::setOptionValue( const QString& name, const QVariant& val )
3820 if ( name == "features" )
3822 if ( val.canConvert( QVariant::Int ) )
3823 setFeatures( val.toInt() );
3825 else if ( name == "mode" )
3827 if ( val.canConvert( QVariant::Int ) )
3828 setMode( val.toInt() );
3830 else if ( name == "fonts" || name == "families" )
3833 if ( toStringList( val, values ) )
3836 else if ( name == "sizes" )
3838 if ( val.type() == QVariant::List )
3841 QList<QVariant> varList = val.toList();
3842 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
3844 if ( (*it).canConvert( QVariant::Int ) )
3845 lst.append( (*it).toInt() );
3851 QtxPageNamedPrefItem::setOptionValue( name, val );
3855 \class QtxPagePrefPathItem
3856 \brief GUI implementation of the resources file/directory path item.
3861 \param type path widget mode (Qtx::PathType )
3862 \param title preference item title
3863 \param parent parent preference item
3864 \param sect resource file section associated with the preference item
3865 \param param resource file parameter associated with the preference item
3867 QtxPagePrefPathItem::QtxPagePrefPathItem( const Qtx::PathType type, const QString& title,
3868 QtxPreferenceItem* parent, const QString& sect, const QString& param )
3869 : QtxPageNamedPrefItem( title, parent, sect, param )
3871 setControl( myPath = new QtxPathEdit( type ) );
3876 \param title preference item title
3877 \param parent parent preference item
3878 \param sect resource file section associated with the preference item
3879 \param param resource file parameter associated with the preference item
3881 QtxPagePrefPathItem::QtxPagePrefPathItem( const QString& title, QtxPreferenceItem* parent,
3882 const QString& sect, const QString& param )
3883 : QtxPageNamedPrefItem( title, parent, sect, param )
3885 setControl( myPath = new QtxPathEdit() );
3891 QtxPagePrefPathItem::~QtxPagePrefPathItem()
3896 \brief Get path widget mode.
3897 \return current path widget mode (Qtx::PathType)
3900 Qtx::PathType QtxPagePrefPathItem::pathType() const
3902 return myPath->pathType();
3906 \brief Set path widget mode.
3907 \param type new path widget mode (Qtx::PathType)
3910 void QtxPagePrefPathItem::setPathType( const Qtx::PathType type )
3912 myPath->setPathType( type );
3916 \brief Get currently used path widget filters.
3917 \return file or directory path filters
3920 QString QtxPagePrefPathItem::pathFilter() const
3922 return myPath->pathFilter();
3926 \brief Set path widget filters.
3927 \param f new file or directory path filters
3930 void QtxPagePrefPathItem::setPathFilter( const QString& f )
3932 myPath->setPathFilter( f );
3936 \brief Store preference item to the resource manager.
3939 void QtxPagePrefPathItem::store()
3941 setString( myPath->path() );
3945 \brief Retrieve preference item from the resource manager.
3948 void QtxPagePrefPathItem::retrieve()
3950 myPath->setPath( getString() );
3954 \brief Get preference item option value.
3955 \param name option name
3956 \return property value or null QVariant if option is not set
3957 \sa setOptionValue()
3959 QVariant QtxPagePrefPathItem::optionValue( const QString& name ) const
3961 if ( name == "path_type" )
3963 else if ( name == "path_filter" )
3964 return pathFilter();
3966 return QtxPageNamedPrefItem::optionValue( name );
3970 \brief Set preference item option value.
3971 \param name option name
3972 \param val new property value
3975 void QtxPagePrefPathItem::setOptionValue( const QString& name, const QVariant& val )
3977 if ( name == "path_type" )
3979 if ( val.canConvert( QVariant::Int ) )
3980 setPathType( (Qtx::PathType)val.toInt() );
3982 else if ( name == "path_filter" )
3984 if ( val.canConvert( QVariant::String ) )
3985 setPathFilter( val.toString() );
3988 QtxPageNamedPrefItem::setOptionValue( name, val );
3992 \class QtxPagePrefPathListItem
3993 \brief GUI implementation of the resources files/directories list item.
3998 \param parent parent preference item
3999 \param sect resource file section associated with the preference item
4000 \param param resource file parameter associated with the preference item
4002 QtxPagePrefPathListItem::QtxPagePrefPathListItem( QtxPreferenceItem* parent,
4003 const QString& sect, const QString& param )
4004 : QtxPageNamedPrefItem( QString(), parent, sect, param )
4006 setControl( myPaths = new QtxPathListEdit() );
4011 \param type path list widget mode (Qtx::PathType)
4012 \param title preference item title
4013 \param parent parent preference item
4014 \param sect resource file section associated with the preference item
4015 \param param resource file parameter associated with the preference item
4017 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const Qtx::PathType type, const QString& title,
4018 QtxPreferenceItem* parent, const QString& sect, const QString& param )
4019 : QtxPageNamedPrefItem( title, parent, sect, param )
4021 setControl( myPaths = new QtxPathListEdit( type ) );
4026 \param title preference item title
4027 \param parent parent preference item
4028 \param sect resource file section associated with the preference item
4029 \param param resource file parameter associated with the preference item
4031 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const QString& title, QtxPreferenceItem* parent,
4032 const QString& sect, const QString& param )
4033 : QtxPageNamedPrefItem( title, parent, sect, param )
4035 setControl( myPaths = new QtxPathListEdit() );
4041 QtxPagePrefPathListItem::~QtxPagePrefPathListItem()
4046 \brief Get path list widget mode.
4047 \return currently used path list widget mode (Qtx::PathType)
4050 Qtx::PathType QtxPagePrefPathListItem::pathType() const
4052 return myPaths->pathType();
4056 \brief Set path list widget mode.
4057 \param type new path list widget mode (Qtx::PathType)
4060 void QtxPagePrefPathListItem::setPathType( const Qtx::PathType type )
4062 myPaths->setPathType( type );
4066 \brief Store preference item to the resource manager.
4069 void QtxPagePrefPathListItem::store()
4071 setString( myPaths->pathList().join( ";" ) );
4075 \brief Retrieve preference item from the resource manager.
4078 void QtxPagePrefPathListItem::retrieve()
4080 myPaths->setPathList( getString().split( ";" ) );
4084 \brief Get preference item option value.
4085 \param name option name
4086 \return property value or null QVariant if option is not set
4087 \sa setOptionValue()
4089 QVariant QtxPagePrefPathListItem::optionValue( const QString& name ) const
4091 if ( name == "path_type" )
4094 return QtxPageNamedPrefItem::optionValue( name );
4098 \brief Set preference item option value.
4099 \param name option name
4100 \param val new property value
4103 void QtxPagePrefPathListItem::setOptionValue( const QString& name, const QVariant& val )
4105 if ( name == "path_type" )
4107 if ( val.canConvert( QVariant::Int ) )
4108 setPathType( (Qtx::PathType)val.toInt() );
4111 QtxPageNamedPrefItem::setOptionValue( name, val );
4115 \class QtxPagePrefDateTimeItem
4116 \brief GUI implementation of resources date/time item.
4122 Creates an item to enter date and time.
4124 \param title preference item title
4125 \param parent parent preference item
4126 \param sect resource file section associated with the preference item
4127 \param param resource file parameter associated with the preference item
4129 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const QString& title, QtxPreferenceItem* parent,
4130 const QString& sect, const QString& param )
4131 : QtxPageNamedPrefItem( title, parent, sect, param ),
4134 setControl( myDateTime = new QDateTimeEdit() );
4135 myDateTime->setCalendarPopup( true );
4136 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4143 Creates preference item for editing of the date and/or time value:
4144 the type is specified by parameter \a type.
4146 \param type preference item input type (QtxPagePrefDateTimeItem::InputType)
4147 \param title preference item title
4148 \param parent parent preference item
4149 \param sect resource file section associated with the preference item
4150 \param param resource file parameter associated with the preference item
4152 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const int type, const QString& title, QtxPreferenceItem* parent,
4153 const QString& sect, const QString& param )
4154 : QtxPageNamedPrefItem( title, parent, sect, param ),
4157 setControl( myDateTime = new QDateTimeEdit() );
4158 myDateTime->setCalendarPopup( true );
4159 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4166 QtxPagePrefDateTimeItem::~QtxPagePrefDateTimeItem()
4171 \brief Get date/time box preference item input type.
4172 \return preference item input type (QtxPagePrefDateTimeItem::InputType)
4175 int QtxPagePrefDateTimeItem::inputType() const
4181 \brief Set date/time box preference item input type.
4182 \param type new preference item input type (QtxPagePrefDateTimeItem::InputType)
4185 void QtxPagePrefDateTimeItem::setInputType( const int type )
4187 if ( myType == type )
4195 \brief Check if the popup calendar menu is enabled.
4196 \return \c true if calendar popup menu is enabled
4198 bool QtxPagePrefDateTimeItem::calendar() const
4200 return myDateTime->calendarPopup();
4204 \brief Enable/disable popup calendar menu.
4205 \param on new flag state
4207 void QtxPagePrefDateTimeItem::setCalendar( const bool on )
4209 myDateTime->setCalendarPopup( on );
4213 \brief Get maximum date value.
4214 \return maximum date value
4215 \sa setMaximumDate(), minimumDate(), maximumTime(), minimumTime()
4217 QDate QtxPagePrefDateTimeItem::maximumDate() const
4219 return myDateTime->maximumDate();
4223 \brief Get maximum time value.
4224 \return maximum time value
4225 \sa setMaximumTime(), minimumTime(), maximumDate(), minimumDate()
4227 QTime QtxPagePrefDateTimeItem::maximumTime() const
4229 return myDateTime->maximumTime();
4233 \brief Get minimum date value.
4234 \return minimum date value
4235 \sa setMinimumDate(), maximumDate(), maximumTime(), minimumTime()
4237 QDate QtxPagePrefDateTimeItem::minimumDate() const
4239 return myDateTime->minimumDate();
4243 \brief Get minimum time value.
4244 \return maximum time value
4245 \sa setMinimumTime(), maximumTime(), maximumDate(), minimumDate()
4247 QTime QtxPagePrefDateTimeItem::minimumTime() const
4249 return myDateTime->minimumTime();
4253 \brief Set maximum date value.
4254 \param d new maximum date value
4255 \sa maximumDate(), minimumDate(), maximumTime(), minimumTime()
4257 void QtxPagePrefDateTimeItem::setMaximumDate( const QDate& d )
4260 myDateTime->setMaximumDate( d );
4262 myDateTime->clearMaximumDate();
4266 \brief Set maximum time value.
4267 \param t new maximum time value
4268 \sa maximumTime(), minimumTime(), maximumDate(), minimumDate()
4270 void QtxPagePrefDateTimeItem::setMaximumTime( const QTime& t )
4273 myDateTime->setMaximumTime( t );
4275 myDateTime->clearMaximumTime();
4279 \brief Set minimum date value.
4280 \param d new minimum date value
4281 \sa minimumDate(), maximumDate(), maximumTime(), minimumTime()
4283 void QtxPagePrefDateTimeItem::setMinimumDate( const QDate& d )
4286 myDateTime->setMinimumDate( d );
4288 myDateTime->clearMinimumDate();
4292 \brief Set minimum time value.
4293 \param t new minimum time value
4294 \sa minimumTime(), maximumTime(), maximumDate(), minimumDate()
4296 void QtxPagePrefDateTimeItem::setMinimumTime( const QTime& t )
4299 myDateTime->setMinimumTime( t );
4301 myDateTime->clearMinimumTime();
4305 \brief Store preference item to the resource manager.
4308 void QtxPagePrefDateTimeItem::store()
4311 switch ( inputType() )
4314 str = myDateTime->date().toString( Qt::ISODate );
4317 str = myDateTime->time().toString( Qt::ISODate );
4320 str = myDateTime->dateTime().toString( Qt::ISODate );
4328 \brief Retrieve preference item from the resource manager.
4331 void QtxPagePrefDateTimeItem::retrieve()
4333 QString str = getString();
4334 switch ( inputType() )
4337 myDateTime->setDate( QDate::fromString( str, Qt::ISODate ) );
4340 myDateTime->setTime( QTime::fromString( str, Qt::ISODate ) );
4343 myDateTime->setDateTime( QDateTime::fromString( str, Qt::ISODate ) );
4349 \brief Get preference item option value.
4350 \param name option name
4351 \return property value or null QVariant if option is not set
4352 \sa setOptionValue()
4354 QVariant QtxPagePrefDateTimeItem::optionValue( const QString& name ) const
4356 if ( name == "input_type" || name == "type" )
4358 else if ( name == "minimum_date" || name == "min_date" )
4359 return minimumDate();
4360 else if ( name == "maximum_date" || name == "max_date" )
4361 return maximumDate();
4362 else if ( name == "minimum_time" || name == "min_time" )
4363 return minimumTime();
4364 else if ( name == "maximum_time" || name == "max_time" )
4365 return maximumTime();
4367 return QtxPageNamedPrefItem::optionValue( name );
4371 \brief Set preference item option value.
4372 \param name option name
4373 \param val new property value
4376 void QtxPagePrefDateTimeItem::setOptionValue( const QString& name, const QVariant& val )
4378 if ( name == "input_type" || name == "type" )
4380 if ( val.canConvert( QVariant::Int ) )
4381 setInputType( val.toInt() );
4383 else if ( name == "minimum_date" || name == "min_date" )
4385 if ( val.canConvert( QVariant::Date ) )
4386 setMinimumDate( val.toDate() );
4388 else if ( name == "maximum_date" || name == "max_date" )
4390 if ( val.canConvert( QVariant::Date ) )
4391 setMaximumDate( val.toDate() );
4393 else if ( name == "minimum_time" || name == "min_time" )
4395 if ( val.canConvert( QVariant::Time ) )
4396 setMinimumTime( val.toTime() );
4398 else if ( name == "maximum_time" || name == "max_time" )
4400 if ( val.canConvert( QVariant::Time ) )
4401 setMaximumTime( val.toTime() );
4404 QtxPageNamedPrefItem::setOptionValue( name, val );
4408 \brief Update date/time widget.
4410 void QtxPagePrefDateTimeItem::updateDateTime()
4413 switch ( inputType() )
4416 dispFmt = QDateEdit().displayFormat();
4419 dispFmt = QTimeEdit().displayFormat();
4422 dispFmt = QDateTimeEdit().displayFormat();
4426 myDateTime->setDisplayFormat( dispFmt );
4431 \param title preference item title
4432 \param parent parent preference item
4433 \param sect resource file section associated with the preference item
4434 \param param resource file parameter associated with the preference item
4436 QtxPagePrefShortcutBtnsItem::QtxPagePrefShortcutBtnsItem( const QString& title, QtxPreferenceItem* parent, const QString& sect,
4437 const QString& param ): QtxPageNamedPrefItem( title, parent, sect, param )
4439 setControl( myShortcut = new QtxShortcutEdit() );
4445 QtxPagePrefShortcutBtnsItem::~QtxPagePrefShortcutBtnsItem()
4450 \brief Store preference item to the resource manager.
4453 void QtxPagePrefShortcutBtnsItem::store()
4455 setString( myShortcut->shortcut().toString() );
4459 \brief Retrieve preference item from the resource manager.
4462 void QtxPagePrefShortcutBtnsItem::retrieve()
4464 myShortcut->setShortcut( QKeySequence::fromString( getString() ) );
4470 Creates preference item for editing of key bindings
4472 \param title preference item title
4473 \param parent parent preference item
4474 \param sect resource file section associated with the preference item
4475 \param param resource file parameter associated with the preference item
4477 QtxPagePrefShortcutTreeItem::QtxPagePrefShortcutTreeItem( const QString& title, QtxPreferenceItem* parent, const QString& sect,
4478 const QString& /*param*/ ): QtxPageNamedPrefItem( title, parent, sect, "" )
4482 myShortcutTree = new QtxShortcutTree();
4484 // Retrieve shortcuts common sections from resources
4485 QtxResourceMgr* resMgr = resourceMgr();
4487 QString generalSections = resourceMgr()->stringValue( "shortcuts_settings", "general_sections", QString() );
4488 QStringList sectionsList = generalSections.split( ";", QString::SkipEmptyParts );
4489 myShortcutTree->setGeneralSections( sectionsList );
4492 setControl( myShortcutTree );
4498 QtxPagePrefShortcutTreeItem::~QtxPagePrefShortcutTreeItem()
4503 \brief Retrieve preference item from the resource manager.
4506 void QtxPagePrefShortcutTreeItem::retrieve()
4508 QtxResourceMgr* resMgr = resourceMgr();
4510 QStringList secLst = resMgr->subSections( mySection, false );
4511 ShortcutMap aMap; QStringList paramLst;
4512 for( int i = 0; i < secLst.size(); i++ ) {
4513 paramLst = resMgr->parameters( QStringList() << mySection << secLst.at( i ) );
4514 for( int j = 0; j < paramLst.size(); j++ )
4515 resMgr->value( mySection + resMgr->sectionsToken() + secLst.at( i ), paramLst.at( j ),aMap[ paramLst.at( j ) ], false );
4516 myShortcutTree->setBindings( secLst.at( i ), aMap );
4523 \brief Store preference item to the resource manager.
4526 void QtxPagePrefShortcutTreeItem::store()
4528 QStringList lst = myShortcutTree->sections();
4530 QtxResourceMgr* resMgr = resourceMgr();
4533 for( int i = 0; i < lst.size(); i++ ) {
4534 ShortcutMap* aMap( myShortcutTree->bindings( lst.at( i ) ) );
4535 aSection = mySection + resMgr->sectionsToken() + lst.at( i );
4536 for( ShortcutMap::const_iterator it = aMap->constBegin(); it != aMap->constEnd(); ++it )
4537 resMgr->setValue( aSection, it.key(), it.value() );
4543 \class QtxPagePrefBackgroundItem
4544 \brief GUI implementation of the resources item to store background data.
4546 Preference item allows specifying background data in different ways:
4548 - texture image file
4549 - simple two-color gradient
4550 - complex custom gradient (NOT IMPLEMENTED YET)
4552 Allowed background modes can be specified using setModeAllowed() method.
4553 Texture modes can be enabled/disabled using setTextureModeAllowed() method.
4554 Also, showing texture controls can be enabled/disabled by means of
4555 setTextureAllowed() method.
4556 Verical or horizontal orientation of the widget can be chosen via setOrientation()
4557 method (default orientation is horizontal).
4559 Simple gradient types can be specified using setGradients() method.
4561 \sa Qtx::BackgroundData, QtxBackgroundTool
4566 \param title preference item title
4567 \param parent parent preference item
4568 \param sect resource file section associated with the preference item
4569 \param param resource file parameter associated with the preference item
4571 QtxPagePrefBackgroundItem::QtxPagePrefBackgroundItem( const QString& title, QtxPreferenceItem* parent,
4572 const QString& sect, const QString& param )
4573 : QtxPageNamedPrefItem( title, parent, sect, param )
4575 setControl( myBgTool = new QtxBackgroundTool( 0 ) );
4581 QtxPagePrefBackgroundItem::~QtxPagePrefBackgroundItem()
4586 \brief Get allowed two-color gradients to the widget
4587 \param gradients gradients names are returned via this parameter
4588 \param ids gradients identifiers are returned via this parameter (empty list can be returned)
4590 void QtxPagePrefBackgroundItem::gradients( QStringList& gradList, QIntList& idList ) const
4592 myBgTool->gradients( gradList, idList );
4596 \brief Set allowed two-color gradients to the widget
4597 \param gradients gradients names
4598 \param ids optional gradients identifiers; if not specified, gradients are automatically numbered starting from 0
4600 void QtxPagePrefBackgroundItem::setGradients( const QStringList& gradients, const QIntList& ids )
4602 myBgTool->setGradients( gradients, ids );
4606 \brief Check if specific background mode is allowed
4607 \param mode background mode
4608 \return \c true if specified background mode is enabled or \c false otherwise
4609 \sa setModeAllowed()
4611 bool QtxPagePrefBackgroundItem::isModeAllowed( Qtx::BackgroundMode mode ) const
4613 return myBgTool->isModeAllowed( mode );
4617 \brief Enable / disable specific background mode
4618 \param mode background mode
4619 \param on enable / disable flag
4622 void QtxPagePrefBackgroundItem::setModeAllowed( Qtx::BackgroundMode mode, bool on )
4624 myBgTool->setModeAllowed( mode, on );
4628 \brief Check if specific texture mode is allowed
4629 \param mode texture mode
4630 \return \c true if specified texture mode is enabled or \c false otherwise
4631 \sa setTextureModeAllowed(), setTextureAllowed()
4633 bool QtxPagePrefBackgroundItem::isTextureModeAllowed( Qtx::TextureMode mode ) const
4635 return myBgTool->isTextureModeAllowed( mode );
4639 \brief Enable / disable specific texture mode
4640 \param mode texture mode
4641 \param on enable / disable flag (\c true by default)
4642 \sa isTextureModeAllowed(), setTextureAllowed()
4644 void QtxPagePrefBackgroundItem::setTextureModeAllowed( Qtx::TextureMode mode, bool on )
4646 myBgTool->setTextureModeAllowed( mode, on );
4650 \brief Check if texture controls are allowed (shown)
4651 \return \c true if texture controls are enabled or \c false otherwise
4652 \sa setTextureAllowed(), setTextureModeAllowed()
4654 bool QtxPagePrefBackgroundItem::isTextureAllowed() const
4656 return myBgTool->isTextureAllowed();
4660 \brief Enable / disable texture controls
4661 \param on enable / disable flag (\c true by default)
4662 \sa isTextureAllowed(), setTextureModeAllowed()
4664 void QtxPagePrefBackgroundItem::setTextureAllowed( bool on )
4666 myBgTool->setTextureAllowed( on );
4670 \brief Get allowed image formats
4671 \return image formats
4673 QString QtxPagePrefBackgroundItem::imageFormats() const
4675 return myBgTool->imageFormats();
4679 \brief Set allowed image formats
4680 \param formats image formats
4682 void QtxPagePrefBackgroundItem::setImageFormats( const QString& formats )
4684 myBgTool->setImageFormats( formats );
4688 \brief Get widget editor orientation
4691 Qt::Orientation QtxPagePrefBackgroundItem::orientation() const
4693 return myBgTool->orientation();
4697 \brief Set widget editor orientation
4698 \param o orientation
4700 void QtxPagePrefBackgroundItem::setOrientation( Qt::Orientation o )
4702 myBgTool->setOrientation( o );
4706 \brief Store preference item to the resource manager.
4709 void QtxPagePrefBackgroundItem::store()
4711 setString( Qtx::backgroundToString( myBgTool->data() ) );
4715 \brief Retrieve preference item from the resource manager.
4718 void QtxPagePrefBackgroundItem::retrieve()
4720 myBgTool->setData( Qtx::stringToBackground( getString() ) );
4724 \brief Get preference item option value.
4725 \param name option name
4726 \return property value or null QVariant if option is not set
4727 \sa setOptionValue()
4729 QVariant QtxPagePrefBackgroundItem::optionValue( const QString& name ) const
4731 if ( name == "texture_enabled" )
4732 return isTextureAllowed();
4733 else if ( name == "color_enabled" )
4734 return isModeAllowed( Qtx::ColorBackground );
4735 else if ( name == "gradient_enabled" )
4736 return isModeAllowed( Qtx::SimpleGradientBackground );
4737 else if ( name == "custom_enabled" )
4738 return isModeAllowed( Qtx::CustomGradientBackground );
4739 else if ( name == "texture_center_enabled" )
4740 return isTextureModeAllowed( Qtx::CenterTexture );
4741 else if ( name == "texture_tile_enabled" )
4742 return isTextureModeAllowed( Qtx::TileTexture );
4743 else if ( name == "texture_stretch_enabled" )
4744 return isTextureModeAllowed( Qtx::StretchTexture );
4745 else if ( name == "orientation" )
4746 return orientation();
4747 else if ( name == "image_formats" )
4748 return imageFormats();
4749 else if ( name == "gradient_names" ) {
4752 gradients( grList, idList );
4755 else if ( name == "gradient_ids" ) {
4758 gradients( grList, idList );
4759 QList<QVariant> lst;
4760 for ( QIntList::const_iterator it = idList.begin(); it != idList.end(); ++it )
4765 return QtxPageNamedPrefItem::optionValue( name );
4769 \brief Set preference item option value.
4770 \param name option name
4771 \param val new property value
4774 void QtxPagePrefBackgroundItem::setOptionValue( const QString& name, const QVariant& val )
4776 if ( name == "texture_enabled" ) {
4777 if ( val.canConvert( QVariant::Bool ) )
4778 setTextureAllowed( val.toBool() );
4780 else if ( name == "color_enabled" ) {
4781 if ( val.canConvert( QVariant::Bool ) )
4782 setModeAllowed( Qtx::ColorBackground, val.toBool() );
4784 else if ( name == "gradient_enabled" ) {
4785 if ( val.canConvert( QVariant::Bool ) )
4786 setModeAllowed( Qtx::SimpleGradientBackground, val.toBool() );
4788 else if ( name == "custom_enabled" ) {
4789 if ( val.canConvert( QVariant::Bool ) )
4790 setModeAllowed( Qtx::CustomGradientBackground, val.toBool() );
4792 else if ( name == "texture_center_enabled" ) {
4793 if ( val.canConvert( QVariant::Bool ) )
4794 setTextureModeAllowed( Qtx::CenterTexture, val.toBool() );
4796 else if ( name == "texture_tile_enabled" ) {
4797 if ( val.canConvert( QVariant::Bool ) )
4798 setTextureModeAllowed( Qtx::TileTexture, val.toBool() );
4800 else if ( name == "texture_stretch_enabled" ) {
4801 if ( val.canConvert( QVariant::Bool ) )
4802 setTextureModeAllowed( Qtx::StretchTexture, val.toBool() );
4804 else if ( name == "orientation" ) {
4805 if ( val.canConvert( QVariant::Int ) )
4806 setOrientation( (Qt::Orientation)val.toInt() );
4808 else if ( name == "image_formats" ) {
4809 if ( val.canConvert( QVariant::String ) )
4810 setImageFormats( val.toString() );
4812 else if ( name == "gradient_names" ) {
4814 if ( toStringList( val, values ) )
4815 setGradients( values );
4817 else if ( name == "gradient_ids" ) {
4818 if ( val.canConvert( QVariant::List ) ) {
4821 gradients( grList, idList );
4823 QList<QVariant> varList = val.toList();
4824 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it ) {
4825 if ( (*it).canConvert( QVariant::Int ) )
4826 idList.append( (*it).toInt() );
4828 setGradients( grList, idList );
4832 QtxPageNamedPrefItem::setOptionValue( name, val );
4838 Creates preference item of user defined widget. The item widget has to be inherited from
4839 QtxUserDefinedContent class. An instance of this class has to be installed into the item
4840 with help of setContent method. Methods optionValue and setOptionValue use pointer on the
4841 content widget an qint64 value.
4843 \param parent parent preference item
4845 QtxUserDefinedItem::QtxUserDefinedItem( QtxPreferenceItem* parent )
4846 : QtxPageNamedPrefItem(QString(), parent), myContent(0)
4851 \brief Lets to Store preferences for content instance
4854 void QtxUserDefinedItem::store()
4857 myContent->store( resourceMgr(), preferenceMgr());
4862 \brief Lets to Retrieve preferences for content instance
4865 void QtxUserDefinedItem::retrieve()
4868 myContent->retrieve( resourceMgr(), preferenceMgr());
4873 * \brief Returns option value
4874 * \param theName is a string "content"
4875 * \return pointer on QtxUserDefinedContent class instance as a qint64 value
4877 QVariant QtxUserDefinedItem::optionValue( const QString& theName ) const
4879 if ( theName == "content" )
4880 return (qint64) myContent;
4882 return QtxPreferenceItem::optionValue( theName );
4886 * \brief Sets option value
4887 * \param theName is a string "content"
4888 * \param theVal is a pointer on QtxUserDefinedContent class instance represented as qint64 value
4890 void QtxUserDefinedItem::setOptionValue( const QString& theName, const QVariant& theVal)
4892 if ( theName == "content" ) {
4893 if ( theVal.canConvert( QVariant::ULongLong ) ) {
4894 setContent( (QtxUserDefinedContent*)theVal.toULongLong() );
4897 QtxPreferenceItem::setOptionValue( theName, theVal );
4901 * \brief Defines content of the property item as a Widget which has to be inherited from
4902 * QtxUserDefinedContent class.
4903 * \param theContent is an QtxUserDefinedContent class instance.
4905 void QtxUserDefinedItem::setContent( QtxUserDefinedContent* theContent )
4907 myContent = theContent;
4908 setControl(myContent);