1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, 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 \brief GUI implementation of the QtxPreferenceMgr class: preferences manager.
61 \param resMgr resource manager
62 \param parent parent widget
64 QtxPagePrefMgr::QtxPagePrefMgr( QtxResourceMgr* resMgr, QWidget* parent )
66 QtxPreferenceMgr( resMgr ),
69 myBox = new QtxGridBox( 1, Qt::Horizontal, this, 0 );
70 QVBoxLayout* base = new QVBoxLayout( this );
72 base->setSpacing( 0 );
73 base->addWidget( myBox );
79 QtxPagePrefMgr::~QtxPagePrefMgr()
84 \brief Get recommended size for the widget.
85 \return recommended widget size
87 QSize QtxPagePrefMgr::sizeHint() const
89 return QFrame::sizeHint();
93 \brief Get recommended minimum size for the widget.
94 \return recommended minimum widget size
96 QSize QtxPagePrefMgr::minimumSizeHint() const
98 return QFrame::minimumSizeHint();
102 \brief Customize show/hide widget operation.
103 \param on if \c true the widget is being shown, otherswise
106 void QtxPagePrefMgr::setVisible( bool on )
111 QApplication::instance()->processEvents();
113 QFrame::setVisible( on );
117 \brief Update widget contents.
119 void QtxPagePrefMgr::updateContents()
121 QtxPreferenceMgr::updateContents();
123 QList<QtxPreferenceItem*> lst = childItems();
124 for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
126 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
127 if ( item && item->widget() && item->widget()->parent() != myBox )
128 item->widget()->setParent( myBox );
131 setWindowIcon( icon() );
135 \brief Callback function which is called when the child
136 preference item is added.
137 \param item child item being added
138 \sa itemRemoved(), itemChanged()
140 void QtxPagePrefMgr::itemAdded( QtxPreferenceItem* /*item*/ )
146 \brief Callback function which is called when the child
147 preference item is removed.
148 \param item child item being removed
149 \sa itemAdded(), itemChanged()
151 void QtxPagePrefMgr::itemRemoved( QtxPreferenceItem* /*item*/ )
157 \brief Callback function which is called when the child
158 preference item is modified.
159 \param item child item being modified
160 \sa itemAdded(), itemRemoved()
162 void QtxPagePrefMgr::itemChanged( QtxPreferenceItem* /*item*/ )
168 \brief Get preference item option value.
169 \param name option name
170 \return property value or null QVariant if option is not set
173 QVariant QtxPagePrefMgr::optionValue( const QString& name ) const
175 if ( name == "orientation" )
176 return myBox->orientation() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
178 return QtxPreferenceMgr::optionValue( name );
182 \brief Set preference item option value.
183 \param name option name
184 \param val new property value
187 void QtxPagePrefMgr::setOptionValue( const QString& name, const QVariant& val )
189 if ( name == "orientation" )
191 if ( val.canConvert( QVariant::Int ) )
192 myBox->setOrientation( val.toInt() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal );
195 QtxPreferenceMgr::setOptionValue( name, val );
199 \brief Perform internal initialization.
201 void QtxPagePrefMgr::initialize() const
206 QtxPagePrefMgr* that = (QtxPagePrefMgr*)this;
207 that->initialize( that );
209 // that->myInit = true;
212 void QtxPagePrefMgr::initialize( QtxPreferenceItem* item )
217 QList<QtxPreferenceItem*> lst = item->childItems( false );
218 for ( QList<QtxPreferenceItem*>::iterator it = lst.begin(); it != lst.end(); ++it )
225 \class QtxPagePrefItem
226 \brief Base class for implementation of all the widget-based
230 class QtxPagePrefItem::Listener : public QObject
233 Listener( QtxPagePrefItem* );
236 virtual bool eventFilter( QObject*, QEvent* );
239 QtxPagePrefItem* myItem;
242 QtxPagePrefItem::Listener::Listener( QtxPagePrefItem* item )
248 QtxPagePrefItem::Listener::~Listener()
252 bool QtxPagePrefItem::Listener::eventFilter( QObject* o, QEvent* e )
254 if ( !myItem || myItem->widget() != o )
257 if ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent )
258 myItem->widgetShown();
259 if ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent )
260 myItem->widgetHided();
267 \param title preference item title
268 \param parent parent preference item
269 \param sect resource file section associated with the preference item
270 \param param resource file parameter associated with the preference item
272 QtxPagePrefItem::QtxPagePrefItem( const QString& title, QtxPreferenceItem* parent,
273 const QString& sect, const QString& param )
274 : QtxPreferenceItem( title, sect, param, parent ),
283 QtxPagePrefItem::~QtxPagePrefItem()
289 void QtxPagePrefItem::activate()
291 QtxPreferenceItem::activate();
294 widget()->setFocus();
298 \brief Get preference item editor widget.
299 \return editor widget
302 QWidget* QtxPagePrefItem::widget() const
308 \brief Set preference item editor widget.
309 \param wid editor widget
312 void QtxPagePrefItem::setWidget( QWidget* wid )
314 if ( myWidget && myListener )
315 myWidget->removeEventFilter( myListener );
322 myListener = new Listener( this );
323 myWidget->installEventFilter( myListener );
330 \brief Callback function which is called when the child
331 preference item is added.
332 \param item child item being added
333 \sa itemRemoved(), itemChanged()
335 void QtxPagePrefItem::itemAdded( QtxPreferenceItem* /*item*/ )
341 \brief Callback function which is called when the child
342 preference item is removed.
343 \param item child item being removed
344 \sa itemAdded(), itemChanged()
346 void QtxPagePrefItem::itemRemoved( QtxPreferenceItem* /*item*/ )
352 \brief Callback function which is called when the child
353 preference item is modified.
354 \param item child item being modified
355 \sa itemAdded(), itemRemoved()
357 void QtxPagePrefItem::itemChanged( QtxPreferenceItem* /*item*/ )
363 \brief Store preference item to the resource manager.
365 This method should be reimplemented in the subclasses.
366 Base implementation does nothing.
370 void QtxPagePrefItem::store()
375 \brief Retrieve preference item from the resource manager.
377 This method should be reimplemented in the subclasses.
378 Base implementation does nothing.
382 void QtxPagePrefItem::retrieve()
387 \brief Invoked when preference item widget is shown.
389 void QtxPagePrefItem::widgetShown()
394 \brief Invoked when preference item widget is hided.
396 void QtxPagePrefItem::widgetHided()
400 void QtxPagePrefItem::ensureVisible( QtxPreferenceItem* i )
402 QtxPreferenceItem::ensureVisible();
404 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
405 if ( item && item->widget() )
406 item->widget()->setVisible( true );
410 \brief Find all child items of the QtxPagePrefItem type.
411 \param list used to return list of child items
412 \param rec if \c true, perform recursive search
414 void QtxPagePrefItem::pageChildItems( QList<QtxPagePrefItem*>& list, const bool rec ) const
416 QList<QtxPreferenceItem*> lst = childItems( rec );
417 for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
419 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
426 \brief Called when contents is changed (item is added, removed or modified).
428 Triggers the item update.
430 void QtxPagePrefItem::contentChanged()
436 \class QtxPageNamedPrefItem
437 \brief Base class for implementation of the named preference items
438 (items with text labels).
443 \param title preference item title
444 \param parent parent preference item
445 \param sect resource file section associated with the preference item
446 \param param resource file parameter associated with the preference item
448 QtxPageNamedPrefItem::QtxPageNamedPrefItem( const QString& title, QtxPreferenceItem* parent,
449 const QString& sect, const QString& param )
450 : QtxPagePrefItem( title, parent, sect, param ),
453 QWidget* main = new QWidget();
455 // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parent);
458 QHBoxLayout* base = new QHBoxLayout( main );
459 base->setMargin( 0 );
460 base->setSpacing( 5 );
462 myLabel = new QLabel( title, main );
463 base->addWidget( myLabel );
466 // myLabel = new QLabel( title, aGroup->gridBox() );
470 myLabel->setVisible( !title.isEmpty() );
476 QtxPageNamedPrefItem::~QtxPageNamedPrefItem()
481 \brief Set preference title.
482 \param txt new preference title.
484 void QtxPageNamedPrefItem::setTitle( const QString& txt )
486 QtxPagePrefItem::setTitle( txt );
488 label()->setText( title() );
489 if ( !title().isEmpty() )
490 label()->setVisible( true );
494 \brief Get label widget corresponding to the preference item.
497 QLabel* QtxPageNamedPrefItem::label() const
503 \brief Get control widget corresponding to the preference item.
504 \return control widget
507 QWidget* QtxPageNamedPrefItem::control() const
513 \brief Set control widget corresponding to the preference item.
514 \param wid control widget
517 void QtxPageNamedPrefItem::setControl( QWidget* wid )
519 if ( myControl == wid )
527 // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parentItem());
529 widget()->layout()->addWidget( myControl );
530 widget()->setFocusProxy( myControl );
531 // else myControl->setParent( aGroup->gridBox() );
535 void QtxPageNamedPrefItem::adjustLabels( QtxPagePrefItem* parent )
540 QList<QtxPreferenceItem*> childList = parent->childItems();
542 QList<QtxPageNamedPrefItem*> namedItems;
543 for ( QList<QtxPreferenceItem*>::iterator it = childList.begin(); it != childList.end(); ++it )
545 QtxPageNamedPrefItem* item = dynamic_cast<QtxPageNamedPrefItem*>( *it );
547 namedItems.append( item );
551 for ( QList<QtxPageNamedPrefItem*>::iterator it1 = namedItems.begin(); it1 != namedItems.end(); ++it1 )
553 QtxPageNamedPrefItem* item = *it1;
555 sz = qMax( sz, item->label()->sizeHint().width() );
558 for ( QList<QtxPageNamedPrefItem*>::iterator it2 = namedItems.begin(); it2 != namedItems.end(); ++it2 )
560 QtxPageNamedPrefItem* item = *it2;
562 item->label()->setMinimumWidth( sz );
567 \class QtxPagePrefListItem
568 \brief GUI implementation of the list container preference item.
573 \param title preference item title
574 \param parent parent preference item
575 \param sect resource file section associated with the preference item
576 \param param resource file parameter associated with the preference item
578 QtxPagePrefListItem::QtxPagePrefListItem( const QString& title, QtxPreferenceItem* parent,
579 const QString& sect, const QString& param )
580 : QtxPagePrefItem( title, parent, sect, param ),
583 QSplitter* main = new QSplitter( Qt::Horizontal );
584 main->setChildrenCollapsible( false );
586 main->addWidget( myList = new QListWidget( main ) );
587 main->addWidget( myStack = new QStackedWidget( main ) );
589 myList->setSelectionMode( QListWidget::SingleSelection );
591 myStack->addWidget( myInfLabel = new QLabel( myStack ) );
592 myInfLabel->setAlignment( Qt::AlignCenter );
594 connect( myList, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) );
602 QtxPagePrefListItem::~QtxPagePrefListItem()
607 \brief Get message text which is shown if the container is empty.
611 QString QtxPagePrefListItem::emptyInfo() const
617 \brief Set message text which is shown if the container is empty.
618 \param new message text
621 void QtxPagePrefListItem::setEmptyInfo( const QString& inf )
623 if ( myInfText == inf )
632 \brief Check if the preference item widget is of fixed size.
633 \return \c true if the widget has the fixed size
636 bool QtxPagePrefListItem::isFixedSize() const
642 \brief Set the preference item widget to be of fixed size.
643 \param on if \c true, the widget will have the fixed size
646 void QtxPagePrefListItem::setFixedSize( const bool on )
657 \brief Update widget contents.
659 void QtxPagePrefListItem::updateContents()
661 QtxPagePrefItem::updateContents();
666 \brief Get preference item option value.
667 \param name option name
668 \return property value or null QVariant if option is not set
671 QVariant QtxPagePrefListItem::optionValue( const QString& name ) const
673 if ( name == "fixed_size" )
674 return isFixedSize();
675 else if ( name == "empty_info" || name == "info" )
678 return QtxPagePrefItem::optionValue( name );
682 \brief Set preference item option value.
683 \param name option name
684 \param val new property value
687 void QtxPagePrefListItem::setOptionValue( const QString& name, const QVariant& val )
689 if ( name == "fixed_size" )
691 if ( val.canConvert( QVariant::Bool ) )
692 setFixedSize( val.toBool() );
694 else if ( name == "empty_info" || name == "info" )
696 if ( val.canConvert( QVariant::String ) )
697 setEmptyInfo( val.toString() );
700 QtxPagePrefItem::setOptionValue( name, val );
703 void QtxPagePrefListItem::widgetShown()
708 void QtxPagePrefListItem::ensureVisible( QtxPreferenceItem* i )
713 QtxPreferenceItem::ensureVisible( i );
715 setSelected( i->id() );
720 \brief Called when the selection in the list box is changed.
722 void QtxPagePrefListItem::onItemSelectionChanged()
728 \brief Update information label widget.
730 void QtxPagePrefListItem::updateInfo()
733 QtxPagePrefItem* item = selectedItem();
736 infoText = emptyInfo();
737 QRegExp rx( "%([%|N])" );
740 while ( ( idx = rx.indexIn( infoText ) ) != -1 )
742 if ( rx.cap() == QString( "%%" ) )
743 infoText.replace( idx, rx.matchedLength(), "%" );
744 else if ( rx.cap() == QString( "%N" ) )
745 infoText.replace( idx, rx.matchedLength(), item->title() );
748 myInfLabel->setText( infoText );
752 \brief Update widget state.
754 void QtxPagePrefListItem::updateState()
756 QtxPagePrefItem* item = selectedItem();
757 QWidget* wid = item && !item->isEmpty() ? item->widget() : myInfLabel;
759 myStack->setCurrentWidget( wid );
765 \brief Update visibile child widgets.
767 void QtxPagePrefListItem::updateVisible()
769 QList<QtxPagePrefItem*> items;
770 pageChildItems( items );
772 QMap<QWidget*, int> map;
773 for ( int i = 0; i < (int)myStack->count(); i++ )
774 map.insert( myStack->widget( i ), 0 );
776 int selId = selected();
778 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
780 if ( (*it)->isEmpty() && myInfText.isEmpty() )
783 myList->addItem( (*it)->title() );
784 myList->item( myList->count() - 1 )->setIcon( (*it)->icon() );
785 myList->item( myList->count() - 1 )->setData( Qt::UserRole, (*it)->id() );
787 QWidget* wid = (*it)->widget();
788 if ( !map.contains( wid ) )
789 myStack->addWidget( wid );
794 map.remove( myInfLabel );
796 for ( QMap<QWidget*, int>::const_iterator it = map.begin(); it != map.end(); ++it )
797 myStack->removeWidget( it.key() );
799 setSelected( selId );
800 if ( selected() == -1 && myList->count() )
801 setSelected( myList->item( 0 )->data( Qt::UserRole ).toInt() );
803 //myList->setVisible( myList->count() > 1 );
810 \brief Update widget geometry.
812 void QtxPagePrefListItem::updateGeom()
815 myList->setFixedWidth( myList->minimumSizeHint().width() + 10 );
818 myList->setMinimumWidth( 0 );
819 myList->setMaximumWidth( 16777215 );
821 QSplitter* s = ::qobject_cast<QSplitter*>( widget() );
824 int w = myList->minimumSizeHint().width() + 30;
827 szList.append( s->width() - w );
828 s->setSizes( szList );
834 \brief Get identifier of the currently selected preference item.
835 \return identifier of the currently selected item or -1 if no item is selected
838 int QtxPagePrefListItem::selected() const
840 QList<QListWidgetItem*> selList = myList->selectedItems();
841 if ( selList.isEmpty() )
844 QVariant v = selList.first()->data( Qt::UserRole );
845 return v.canConvert( QVariant::Int ) ? v.toInt() : -1;
849 \brief Get currently selected preference item.
850 \return currently selected item or 0 if no item is selected
853 QtxPagePrefItem* QtxPagePrefListItem::selectedItem() const
855 int selId = selected();
857 QList<QtxPagePrefItem*> items;
858 pageChildItems( items );
860 QtxPagePrefItem* item = 0;
861 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end() && !item; ++it )
863 if ( (*it)->id() == selId )
870 \brief Set currently selected preference item.
871 \param id identifier of the preference item to make selected
873 void QtxPagePrefListItem::setSelected( const int id )
876 for ( int i = 0; i < (int)myList->count() && idx < 0; i++ )
878 QVariant v = myList->item( i )->data( Qt::UserRole );
879 if ( v.canConvert( QVariant::Int ) && v.toInt() == id )
884 QItemSelectionModel* selModel = myList->selectionModel();
887 sel.select( myList->model()->index( idx, 0 ), myList->model()->index( idx, 0 ) );
889 selModel->select( sel, QItemSelectionModel::ClearAndSelect );
893 \class QtxPagePrefToolBoxItem
894 \brief GUI implementation of the tool box container preference item.
899 \param title preference item title
900 \param parent parent preference item
901 \param sect resource file section associated with the preference item
902 \param param resource file parameter associated with the preference item
904 QtxPagePrefToolBoxItem::QtxPagePrefToolBoxItem( const QString& title, QtxPreferenceItem* parent,
905 const QString& sect, const QString& param )
906 : QtxPagePrefItem( title, parent, sect, param )
908 setWidget( myToolBox = new QToolBox( 0 ) );
914 QtxPagePrefToolBoxItem::~QtxPagePrefToolBoxItem()
919 \brief Update widget contents.
921 void QtxPagePrefToolBoxItem::updateContents()
923 QtxPagePrefItem::updateContents();
928 \brief Update tool box widget.
930 void QtxPagePrefToolBoxItem::updateToolBox()
932 QList<QtxPagePrefItem*> items;
933 pageChildItems( items );
935 QWidget* cur = myToolBox->currentWidget();
938 QMap<QWidget*, int> map;
939 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
941 QWidget* wid = (*it)->widget();
945 if ( myToolBox->widget( i ) != wid )
947 if ( myToolBox->indexOf( wid ) != -1 )
948 myToolBox->removeItem( myToolBox->indexOf( wid ) );
950 myToolBox->insertItem( i, wid, (*it)->title() );
953 myToolBox->setItemText( i, (*it)->title() );
955 myToolBox->setItemIcon( i, (*it)->icon() );
958 map.insert( wid, 0 );
962 for ( int idx = 0; idx < (int)myToolBox->count(); idx++ )
964 QWidget* w = myToolBox->widget( idx );
965 if ( !map.contains( w ) )
969 for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
970 myToolBox->removeItem( myToolBox->indexOf( *itr ) );
973 myToolBox->setCurrentWidget( cur );
976 void QtxPagePrefToolBoxItem::ensureVisible( QtxPreferenceItem* i )
981 QtxPreferenceItem::ensureVisible( i );
983 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
984 if ( item && item->widget() )
985 myToolBox->setCurrentWidget( item->widget() );
989 \class QtxPagePrefTabsItem
990 \brief GUI implementation of the tab widget container.
995 \param title preference item title
996 \param parent parent preference item
997 \param sect resource file section associated with the preference item
998 \param param resource file parameter associated with the preference item
1000 QtxPagePrefTabsItem::QtxPagePrefTabsItem( const QString& title, QtxPreferenceItem* parent,
1001 const QString& sect, const QString& param )
1002 : QtxPagePrefItem( title, parent, sect, param )
1004 setWidget( myTabs = new QTabWidget( 0 ) );
1010 QtxPagePrefTabsItem::~QtxPagePrefTabsItem()
1015 \brief Update widget contents.
1017 void QtxPagePrefTabsItem::updateContents()
1019 QtxPagePrefItem::updateContents();
1024 \brief Get tabs position.
1025 \return current tabs position (QTabWidget::TabPosition)
1026 \sa setTabPosition()
1028 int QtxPagePrefTabsItem::tabPosition() const
1030 return myTabs->tabPosition();
1034 \brief Set tabs position.
1035 \param tp new tabs position (QTabWidget::TabPosition)
1038 void QtxPagePrefTabsItem::setTabPosition( const int tp )
1040 myTabs->setTabPosition( (QTabWidget::TabPosition)tp );
1044 \brief Get tabs shape.
1045 \return current tabs shape (QTabWidget::TabShape)
1048 int QtxPagePrefTabsItem::tabShape() const
1050 return myTabs->tabShape();
1054 \brief Set tabs shape.
1055 \param ts new tabs shape (QTabWidget::TabShape)
1058 void QtxPagePrefTabsItem::setTabShape( const int ts )
1060 myTabs->setTabShape( (QTabWidget::TabShape)ts );
1064 \brief Get tabs icon size.
1065 \return current tabs icon size
1066 \sa setTabIconSize()
1068 QSize QtxPagePrefTabsItem::tabIconSize() const
1070 return myTabs->iconSize();
1074 \brief Set tabs icon size.
1075 \param sz new tabs icon size
1078 void QtxPagePrefTabsItem::setTabIconSize( const QSize& sz )
1080 myTabs->setIconSize( sz );
1084 \brief Get preference item option value.
1085 \param name option name
1086 \return property value or null QVariant if option is not set
1087 \sa setOptionValue()
1089 QVariant QtxPagePrefTabsItem::optionValue( const QString& name ) const
1091 if ( name == "position" )
1092 return tabPosition();
1093 else if ( name == "shape" )
1095 else if ( name == "icon_size" )
1096 return tabIconSize();
1098 return QtxPagePrefItem::optionValue( name );
1102 \brief Set preference item option value.
1103 \param name option name
1104 \param val new property value
1107 void QtxPagePrefTabsItem::setOptionValue( const QString& name, const QVariant& val )
1109 if ( name == "position" )
1111 if ( val.canConvert( QVariant::Int ) )
1112 setTabPosition( val.toInt() );
1114 else if ( name == "shape" )
1116 if ( val.canConvert( QVariant::Int ) )
1117 setTabShape( val.toInt() );
1119 else if ( name == "icon_size" )
1121 if ( val.canConvert( QVariant::Size ) )
1122 setTabIconSize( val.toSize() );
1125 QtxPagePrefItem::setOptionValue( name, val );
1128 void QtxPagePrefTabsItem::ensureVisible( QtxPreferenceItem* i )
1133 QtxPreferenceItem::ensureVisible( i );
1135 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
1136 if ( item && item->widget() )
1137 myTabs->setCurrentWidget( item->widget() );
1143 void QtxPagePrefTabsItem::updateTabs()
1145 QList<QtxPagePrefItem*> items;
1146 pageChildItems( items );
1148 QWidget* cur = myTabs->currentWidget();
1151 QMap<QWidget*, int> map;
1152 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1154 QWidget* wid = (*it)->widget();
1158 if ( myTabs->widget( i ) != wid )
1160 if ( myTabs->indexOf( wid ) != -1 )
1161 myTabs->removeTab( myTabs->indexOf( wid ) );
1163 myTabs->insertTab( i, wid, (*it)->title() );
1166 myTabs->setTabText( i, (*it)->title() );
1168 myTabs->setTabIcon( i, (*it)->icon() );
1171 map.insert( wid, 0 );
1174 QList<QWidget*> del;
1175 for ( int idx = 0; idx < (int)myTabs->count(); idx++ )
1177 QWidget* w = myTabs->widget( idx );
1178 if ( !map.contains( w ) )
1182 for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
1183 myTabs->removeTab( myTabs->indexOf( *itr ) );
1186 myTabs->setCurrentWidget( cur );
1190 \class QtxPagePrefFrameItem
1191 \brief GUI implementation of the frame widget container.
1196 \param title preference item title
1197 \param parent parent preference item
1198 \param sect resource file section associated with the preference item
1199 \param param resource file parameter associated with the preference item
1201 QtxPagePrefFrameItem::QtxPagePrefFrameItem( const QString& title, QtxPreferenceItem* parent,
1202 const QString& sect, const QString& param, const bool scrollable )
1203 : QtxPagePrefItem( title, parent, sect, param )
1205 QWidget* main = new QWidget();
1206 QVBoxLayout* base = new QVBoxLayout( main );
1207 base->setMargin( 0 );
1208 base->setSpacing( 0 );
1210 base->addWidget( myBox = new QtxGridBox( 1, Qt::Horizontal, main, 5, 5 ) );
1214 QScrollArea* scroll = new QScrollArea();
1215 scroll->setWidget( main );
1216 scroll->setWidgetResizable( true );
1217 base->layout()->setSizeConstraint(QLayout::SetMinAndMaxSize);
1227 QtxPagePrefFrameItem::~QtxPagePrefFrameItem()
1232 \brief Update widget contents.
1234 void QtxPagePrefFrameItem::updateContents()
1236 QtxPagePrefItem::updateContents();
1240 QtxPageNamedPrefItem::adjustLabels( this );
1244 \brief Get frame margin.
1245 \return current frame margin
1248 int QtxPagePrefFrameItem::margin() const
1250 return myBox->insideMargin();
1254 \brief Get frame margin.
1255 \param m new frame margin
1258 void QtxPagePrefFrameItem::setMargin( const int m )
1260 myBox->setInsideMargin( m );
1264 \brief Get frame spacing.
1265 \return current frame spacing
1268 int QtxPagePrefFrameItem::spacing() const
1270 return myBox->insideSpacing();
1274 \brief Set frame spacing.
1275 \param s new frame spacing
1278 void QtxPagePrefFrameItem::setSpacing( const int s )
1280 myBox->setInsideSpacing( s );
1284 \brief Get number of frame columns.
1285 \return current columns number
1288 int QtxPagePrefFrameItem::columns() const
1290 return myBox->columns();
1294 \brief Set number of frame columns.
1295 \param c new columns number
1298 void QtxPagePrefFrameItem::setColumns( const int c )
1300 myBox->setColumns( c );
1304 \brief Get frame box orientation.
1305 \return current frame orientation
1306 \sa setOrientation()
1308 Qt::Orientation QtxPagePrefFrameItem::orientation() const
1310 return myBox->orientation();
1314 \brief Set frame box orientation.
1315 \param o new frame orientation
1318 void QtxPagePrefFrameItem::setOrientation( const Qt::Orientation o )
1320 myBox->setOrientation( o );
1324 \brief Check if the frame widget stretching is enabled.
1325 \return \c true if the widget is stretchable
1328 bool QtxPagePrefFrameItem::stretch() const
1331 QLayout* l = widget() ? widget()->layout() : 0;
1332 for ( int i = 0; l && i < l->count() && !s; i++ )
1333 s = l->itemAt( i )->spacerItem();
1335 return s ? (bool)( s->expandingDirections() & Qt::Vertical ) : false;
1339 \brief Enable/disable frame widget stretching.
1340 \param on new stretchable state
1343 void QtxPagePrefFrameItem::setStretch( const bool on )
1346 QWidget* w = widget();
1347 if ( qobject_cast<QScrollArea*>( w ) )
1348 w = qobject_cast<QScrollArea*>( w )->widget();
1349 QLayout* l = w ? w->layout() : 0;
1350 for ( int i = 0; l && i < l->count() && !s; i++ )
1351 s = l->itemAt( i )->spacerItem();
1354 s->changeSize( 0, 0, QSizePolicy::Minimum, on ? QSizePolicy::Expanding : QSizePolicy::Minimum );
1358 \brief Get preference item option value.
1359 \param name option name
1360 \return property value or null QVariant if option is not set
1361 \sa setOptionValue()
1363 QVariant QtxPagePrefFrameItem::optionValue( const QString& name ) const
1365 if ( name == "margin" )
1367 else if ( name == "spacing" )
1369 else if ( name == "columns" )
1371 else if ( name == "orientation" )
1372 return orientation();
1373 else if ( name == "stretch" )
1376 return QtxPagePrefItem::optionValue( name );
1380 \brief Set preference item option value.
1381 \param name option name
1382 \param val new property value
1385 void QtxPagePrefFrameItem::setOptionValue( const QString& name, const QVariant& val )
1387 if ( name == "margin" )
1389 if ( val.canConvert( QVariant::Int ) )
1390 setMargin( val.toInt() );
1392 else if ( name == "spacing" )
1394 if ( val.canConvert( QVariant::Int ) )
1395 setSpacing( val.toInt() );
1397 else if ( name == "columns" )
1399 if ( val.canConvert( QVariant::Int ) )
1400 setColumns( val.toInt() );
1402 else if ( name == "orientation" )
1404 if ( val.canConvert( QVariant::Int ) )
1405 setOrientation( (Qt::Orientation)val.toInt() );
1407 else if ( name == "stretch" )
1409 if ( val.canConvert( QVariant::Bool ) )
1410 setStretch( val.toBool() );
1413 QtxPagePrefItem::setOptionValue( name, val );
1416 void QtxPagePrefFrameItem::widgetShown()
1418 QtxPagePrefItem::widgetShown();
1420 QtxPageNamedPrefItem::adjustLabels( this );
1424 \brief Update frame widget.
1426 void QtxPagePrefFrameItem::updateFrame()
1428 QList<QtxPagePrefItem*> items;
1429 pageChildItems( items );
1431 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1433 QWidget* wid = (*it)->widget();
1437 if ( wid->parent() != myBox )
1438 wid->setParent( myBox );
1443 \class QtxPagePrefGroupItem
1444 \brief GUI implementation of the group widget container.
1449 \param title preference item title
1450 \param parent parent preference item
1451 \param sect resource file section associated with the preference item
1452 \param param resource file parameter associated with the preference item
1454 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const QString& title, QtxPreferenceItem* parent,
1455 const QString& sect, const QString& param )
1456 : QtxPagePrefItem( title, parent, sect, param )
1458 myGroup = new QtxGroupBox( title, 0 );
1459 myBox = new QtxGridBox( 1, Qt::Horizontal, myGroup, 5, 5 );
1460 myGroup->setWidget( myBox );
1462 setWidget( myGroup );
1469 \param cols columns number
1470 \param title preference item title
1471 \param parent parent preference item
1472 \param sect resource file section associated with the preference item
1473 \param param resource file parameter associated with the preference item
1475 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const int cols, const QString& title, QtxPreferenceItem* parent,
1476 const QString& sect, const QString& param )
1477 : QtxPagePrefItem( title, parent, sect, param )
1479 myGroup = new QtxGroupBox( title, 0 );
1480 myBox = new QtxGridBox( cols, Qt::Horizontal, myGroup, 5, 5 );
1481 myGroup->setWidget( myBox );
1483 setWidget( myGroup );
1491 QtxPagePrefGroupItem::~QtxPagePrefGroupItem()
1496 \brief Assign resource file settings to the preference item.
1497 \param sect resource file section name
1498 \param param resource file parameter name
1501 void QtxPagePrefGroupItem::setResource( const QString& sect, const QString& param )
1503 QtxPagePrefItem::setResource( sect, param );
1508 \brief Update widget contents.
1510 void QtxPagePrefGroupItem::updateContents()
1512 QtxPagePrefItem::updateContents();
1514 myGroup->setTitle( title() );
1519 QtxPageNamedPrefItem::adjustLabels( this );
1523 \brief Get group box margin.
1524 \return current group box margin
1527 int QtxPagePrefGroupItem::margin() const
1529 return myBox->insideMargin();
1533 \brief Get group box margin.
1534 \param m new group box margin
1537 void QtxPagePrefGroupItem::setMargin( const int m )
1539 myBox->setInsideMargin( m );
1543 \brief Get group box spacing.
1544 \return current group box spacing
1547 int QtxPagePrefGroupItem::spacing() const
1549 return myBox->insideSpacing();
1553 \brief Set group box spacing.
1554 \param s new group box spacing
1557 void QtxPagePrefGroupItem::setSpacing( const int s )
1559 myBox->setInsideSpacing( s );
1563 \brief Get number of group box columns.
1564 \return current columns number
1567 int QtxPagePrefGroupItem::columns() const
1569 return myBox->columns();
1573 \brief Set number of group box columns.
1574 \param c new columns number
1577 void QtxPagePrefGroupItem::setColumns( const int c )
1579 myBox->setColumns( c );
1583 \brief Get group box orientation.
1584 \return current group box orientation
1585 \sa setOrientation()
1587 Qt::Orientation QtxPagePrefGroupItem::orientation() const
1589 return myBox->orientation();
1593 \brief Set group box orientation.
1594 \param o new group box orientation
1597 void QtxPagePrefGroupItem::setOrientation( const Qt::Orientation o )
1599 myBox->setOrientation( o );
1603 \brief Get 'flat' flag of the group box widget.
1604 \return \c true if the group box is flat
1606 bool QtxPagePrefGroupItem::isFlat() const
1608 return myGroup->isFlat();
1612 \brief Get 'flat' flag of the group box widget.
1613 \param on if \c true the group box will be made flat
1615 void QtxPagePrefGroupItem::setFlat( const bool on )
1617 myGroup->setFlat( on );
1621 \brief Store preference item to the resource manager.
1624 void QtxPagePrefGroupItem::store()
1626 if ( myGroup->isCheckable() )
1627 setBoolean( myGroup->isChecked() );
1631 \brief Return widget contained grid layout of this group.
1633 QtxGridBox* QtxPagePrefGroupItem::gridBox() const
1639 \brief Retrieve preference item from the resource manager.
1642 void QtxPagePrefGroupItem::retrieve()
1644 if ( myGroup->isCheckable() )
1645 myGroup->setChecked( getBoolean() );
1649 \brief Get preference item option value.
1650 \param name option name
1651 \return property value or null QVariant if option is not set
1652 \sa setOptionValue()
1654 QVariant QtxPagePrefGroupItem::optionValue( const QString& name ) const
1656 if ( name == "margin" )
1658 else if ( name == "spacing" )
1660 else if ( name == "columns" )
1662 else if ( name == "orientation" )
1663 return orientation();
1664 else if ( name == "flat" )
1667 return QtxPagePrefItem::optionValue( name );
1671 \brief Set preference item option value.
1672 \param name option name
1673 \param val new property value
1676 void QtxPagePrefGroupItem::setOptionValue( const QString& name, const QVariant& val )
1678 if ( name == "margin" )
1680 if ( val.canConvert( QVariant::Int ) )
1681 setMargin( val.toInt() );
1683 else if ( name == "spacing" )
1685 if ( val.canConvert( QVariant::Int ) )
1686 setSpacing( val.toInt() );
1688 else if ( name == "columns" )
1690 if ( val.canConvert( QVariant::Int ) )
1691 setColumns( val.toInt() );
1693 else if ( name == "orientation" )
1695 if ( val.canConvert( QVariant::Int ) )
1696 setOrientation( (Qt::Orientation)val.toInt() );
1698 else if ( name == "flat" )
1700 if ( val.canConvert( QVariant::Bool ) )
1701 setFlat( val.toBool() );
1704 QtxPagePrefItem::setOptionValue( name, val );
1707 void QtxPagePrefGroupItem::widgetShown()
1709 QtxPagePrefItem::widgetShown();
1711 QtxPageNamedPrefItem::adjustLabels( this );
1715 \brief Update widget state.
1717 void QtxPagePrefGroupItem::updateState()
1719 QString section, param;
1720 resource( section, param );
1721 myGroup->setCheckable( !title().isEmpty() && !section.isEmpty() && !param.isEmpty() );
1725 \brief Update group box widget.
1727 void QtxPagePrefGroupItem::updateGroup()
1729 QList<QtxPagePrefItem*> items;
1730 pageChildItems( items );
1732 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1734 QWidget* wid = (*it)->widget();
1738 if ( wid->parent() != myBox )
1739 wid->setParent( myBox );
1744 \class QtxPagePrefLabelItem
1745 \brief Label item which can be used in the preferences editor dialog box.
1751 Creates label item with specified title.
1753 \param text label text
1754 \param parent parent preference item
1756 QtxPagePrefLabelItem::QtxPagePrefLabelItem( const QString& text, QtxPreferenceItem* parent )
1757 : QtxPagePrefItem( text, parent )
1759 setWidget( myLabel = new QLabel( text ) );
1762 QtxPagePrefLabelItem::QtxPagePrefLabelItem( Qt::Alignment align, const QString& text, QtxPreferenceItem* parent )
1763 : QtxPagePrefItem( text, parent )
1765 setWidget( myLabel = new QLabel( text ) );
1766 myLabel->setAlignment( align );
1769 QtxPagePrefLabelItem::~QtxPagePrefLabelItem()
1773 void QtxPagePrefLabelItem::setTitle( const QString& text )
1775 QtxPagePrefItem::setTitle( text );
1778 myLabel->setText( text );
1781 Qt::Alignment QtxPagePrefLabelItem::alignment() const
1783 return myLabel->alignment();
1786 void QtxPagePrefLabelItem::setAlignment( Qt::Alignment align )
1788 myLabel->setAlignment( align );
1791 QVariant QtxPagePrefLabelItem::optionValue( const QString& name ) const
1794 if ( name == "alignment" )
1795 val = (int)alignment();
1799 void QtxPagePrefLabelItem::setOptionValue( const QString& name, const QVariant& val )
1801 if ( name == "alignment" )
1803 if ( val.canConvert( QVariant::Int ) )
1804 setAlignment( (Qt::Alignment)val.toInt() );
1809 \class QtxPagePrefSpaceItem
1810 \brief Simple spacer item which can be used in the preferences
1817 Creates spacer item with zero width and height and expanding
1818 on both directions (by height and width).
1820 \param parent parent preference item
1822 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( QtxPreferenceItem* parent )
1823 : QtxPagePrefItem( QString(), parent )
1825 initialize( 0, 0, 1, 1 );
1831 Creates spacer item with zero width and height and expanding
1832 according to the specified orientation.
1834 \param o spacer orientation
1835 \param parent parent preference item
1837 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( Qt::Orientation o, QtxPreferenceItem* parent )
1838 : QtxPagePrefItem( QString(), parent )
1840 if ( o == Qt::Horizontal )
1841 initialize( 0, 0, 1, 0 );
1843 initialize( 0, 0, 0, 1 );
1849 Creates spacer item with specified width and height. The spacing
1850 item is expanding horizontally if \a w <= 0 and vertically
1853 \param w spacer width
1854 \param h spacer height
1855 \param parent parent preference item
1857 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( const int w, const int h, QtxPreferenceItem* parent )
1858 : QtxPagePrefItem( QString(), parent )
1860 initialize( w, h, w > 0 ? 0 : 1, h > 0 ? 0 : 1 );
1866 QtxPagePrefSpaceItem::~QtxPagePrefSpaceItem()
1871 \brief Get spacer item size for the specified direction.
1873 \return size for the specified direction
1876 int QtxPagePrefSpaceItem::size( Qt::Orientation o ) const
1878 return o == Qt::Horizontal ? widget()->minimumWidth() : widget()->minimumHeight();
1882 \brief Set spacer item size for the specified direction.
1884 \param sz new size for the specified direction
1887 void QtxPagePrefSpaceItem::setSize( Qt::Orientation o, const int sz )
1889 if ( o == Qt::Horizontal )
1890 widget()->setMinimumWidth( sz );
1892 widget()->setMinimumHeight( sz );
1896 \brief Get spacer item stretch factor for the specified direction.
1898 \return stretch factor for the specified direction
1901 int QtxPagePrefSpaceItem::stretch( Qt::Orientation o ) const
1903 QSizePolicy sp = widget()->sizePolicy();
1904 return o == Qt::Horizontal ? sp.horizontalStretch() : sp.verticalStretch();
1908 \brief Set spacer item stretch factor for the specified direction.
1910 \param sf new stretch factor for the specified direction
1913 void QtxPagePrefSpaceItem::setStretch( Qt::Orientation o, const int sf )
1915 QSizePolicy sp = widget()->sizePolicy();
1916 if ( o == Qt::Horizontal )
1918 sp.setHorizontalStretch( sf );
1919 sp.setHorizontalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1923 sp.setVerticalStretch( sf );
1924 sp.setVerticalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1927 widget()->setSizePolicy( sp );
1931 \brief Get preference item option value.
1932 \param name option name
1933 \return property value or null QVariant if option is not set
1934 \sa setOptionValue()
1936 QVariant QtxPagePrefSpaceItem::optionValue( const QString& name ) const
1938 if ( name == "horizontal_size" || name == "hsize" )
1939 return size( Qt::Horizontal );
1940 else if ( name == "vertical_size" || name == "vsize" )
1941 return size( Qt::Vertical );
1942 else if ( name == "horizontal_stretch" || name == "hstretch" )
1943 return stretch( Qt::Horizontal );
1944 else if ( name == "vertical_stretch" || name == "vstretch" )
1945 return stretch( Qt::Vertical );
1947 return QtxPagePrefItem::optionValue( name );
1951 \brief Set preference item option value.
1952 \param name option name
1953 \param val new property value
1956 void QtxPagePrefSpaceItem::setOptionValue( const QString& name, const QVariant& val )
1958 if ( name == "horizontal_size" || name == "hsize" )
1960 if ( val.canConvert( QVariant::Int ) )
1961 setSize( Qt::Horizontal, val.toInt() );
1963 else if ( name == "vertical_size" || name == "vsize" )
1965 if ( val.canConvert( QVariant::Int ) )
1966 setSize( Qt::Vertical, val.toInt() );
1968 else if ( name == "horizontal_stretch" || name == "hstretch" )
1970 if ( val.canConvert( QVariant::Int ) )
1971 setStretch( Qt::Horizontal, val.toInt() );
1973 else if ( name == "vertical_stretch" || name == "vstretch" )
1975 if ( val.canConvert( QVariant::Int ) )
1976 setStretch( Qt::Vertical, val.toInt() );
1979 QtxPagePrefItem::setOptionValue( name, val );
1983 \brief Perform internal initialization.
1984 \param w spacer item width
1985 \param h spacer item height
1986 \param ws spacer item horizontal stretch factor
1987 \param hs spacer item vertical stretch factor
1989 void QtxPagePrefSpaceItem::initialize( const int w, const int h, const int hs, const int vs )
1992 sp.setHorizontalPolicy( hs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1993 sp.setVerticalPolicy( vs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1995 sp.setHorizontalStretch( hs );
1996 sp.setVerticalStretch( vs );
1998 QWidget* wid = new QWidget();
1999 wid->setSizePolicy( sp );
2001 wid->setMinimumSize( w, h );
2007 \class QtxPagePrefCheckItem
2008 \brief GUI implementation of the resources check box item (boolean).
2013 \param title preference item title
2014 \param parent parent preference item
2015 \param sect resource file section associated with the preference item
2016 \param param resource file parameter associated with the preference item
2018 QtxPagePrefCheckItem::QtxPagePrefCheckItem( const QString& title, QtxPreferenceItem* parent,
2019 const QString& sect, const QString& param )
2021 : QtxPagePrefItem( title, parent, sect, param )
2023 myCheck = new QCheckBox( title );
2024 myCheck->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
2025 setWidget( myCheck );
2031 QtxPagePrefCheckItem::~QtxPagePrefCheckItem()
2036 \brief Set preference item title.
2037 \param txt new preference title.
2039 void QtxPagePrefCheckItem::setTitle( const QString& txt )
2041 QtxPagePrefItem::setTitle( txt );
2043 myCheck->setText( title() );
2047 \brief Store preference item to the resource manager.
2050 void QtxPagePrefCheckItem::store()
2052 setBoolean( myCheck->isChecked() );
2056 \brief Retrieve preference item from the resource manager.
2059 void QtxPagePrefCheckItem::retrieve()
2061 myCheck->setChecked( getBoolean() );
2065 \class QtxPagePrefEditItem
2066 \brief GUI implementation of the resources line edit box item
2067 for string, integer and double values.
2070 static void fixupAndSet( QLineEdit* le, const QString& txt )
2074 if ( le->validator() ) {
2075 const QDoubleValidator* de = dynamic_cast<const QDoubleValidator*>( le->validator() );
2077 int dec = de->decimals();
2078 int idx = val.lastIndexOf( QRegExp( QString("[.|%1]").arg( le->locale().decimalPoint () ) ) );
2080 QString tmp = val.mid( idx+1 );
2082 val = val.left( idx+1 );
2083 idx = tmp.indexOf( QRegExp( QString("[e|E]") ) );
2085 exp = tmp.mid( idx );
2086 tmp = tmp.left( idx );
2088 tmp.truncate( dec );
2089 val = val + tmp + exp;
2093 if ( le->validator()->validate( val, pos ) == QValidator::Invalid )
2103 Creates preference item for string value editing.
2105 \param title preference item title
2106 \param parent parent preference item
2107 \param sect resource file section associated with the preference item
2108 \param param resource file parameter associated with the preference item
2110 QtxPagePrefEditItem::QtxPagePrefEditItem( const QString& title, QtxPreferenceItem* parent,
2111 const QString& sect, const QString& param )
2112 : QtxPageNamedPrefItem( title, parent, sect, param ),
2117 setControl( myEditor = new QLineEdit() );
2124 Creates preference item for editing of the value which type
2125 is specified by parameter \a type.
2127 \param type preference item input type (QtxPagePrefEditItem::InputType)
2128 \param title preference item title
2129 \param parent parent preference item
2130 \param sect resource file section associated with the preference item
2131 \param param resource file parameter associated with the preference item
2133 QtxPagePrefEditItem::QtxPagePrefEditItem( const int type, const QString& title,
2134 QtxPreferenceItem* parent, const QString& sect,
2135 const QString& param )
2136 : QtxPageNamedPrefItem( title, parent, sect, param ),
2141 setControl( myEditor = new QLineEdit() );
2148 QtxPagePrefEditItem::~QtxPagePrefEditItem()
2153 \brief Get edit box preference item input type.
2154 \return preference item input type (QtxPagePrefEditItem::InputType)
2157 int QtxPagePrefEditItem::inputType() const
2163 \brief Set edit box preference item input type.
2164 \param type new preference item input type (QtxPagePrefEditItem::InputType)
2167 void QtxPagePrefEditItem::setInputType( const int type )
2169 if ( myType == type )
2177 \brief Get number of digits after decimal point (for Double input type)
2178 \return preference item decimals value
2181 int QtxPagePrefEditItem::decimals() const
2187 \brief Set number of digits after decimal point (for Double input type)
2188 \param dec new preference item decimals value
2191 void QtxPagePrefEditItem::setDecimals( const int dec )
2193 if ( myDecimals == dec )
2201 \brief Get the line edit's echo mode
2202 \return preference item echo mode value
2205 int QtxPagePrefEditItem::echoMode() const
2211 \brief Set the line edit's echo mode
2212 \param echo new preference item echo mode value
2215 void QtxPagePrefEditItem::setEchoMode( const int echo )
2217 if ( myEchoMode == echo )
2225 \brief Store preference item to the resource manager.
2228 void QtxPagePrefEditItem::store()
2230 setString( myEditor->text() );
2234 \brief Retrieve preference item from the resource manager.
2237 void QtxPagePrefEditItem::retrieve()
2239 QString txt = getString();
2240 fixupAndSet( myEditor, txt );
2244 \brief Get preference item option value.
2245 \param name option name
2246 \return property value or null QVariant if option is not set
2247 \sa setOptionValue()
2249 QVariant QtxPagePrefEditItem::optionValue( const QString& name ) const
2251 if ( name == "input_type" || name == "type" )
2253 else if ( name == "precision" || name == "prec" || name == "decimals" )
2255 else if ( name == "echo" || name == "echo_mode" || name == "echomode")
2258 return QtxPageNamedPrefItem::optionValue( name );
2262 \brief Set preference item option value.
2263 \param name option name
2264 \param val new property value
2267 void QtxPagePrefEditItem::setOptionValue( const QString& name, const QVariant& val )
2269 if ( name == "input_type" || name == "type" )
2271 if ( val.canConvert( QVariant::Int ) )
2272 setInputType( val.toInt() );
2274 else if ( name == "precision" || name == "prec" || name == "decimals" ) {
2275 if ( val.canConvert( QVariant::Int ) )
2276 setDecimals( val.toInt() );
2278 else if ( name == "echo" || name == "echo_mode" || name == "echomode") {
2279 if ( val.canConvert( QVariant::Int ) )
2280 setEchoMode( val.toInt() );
2283 QtxPageNamedPrefItem::setOptionValue( name, val );
2287 \brief Update edit box widget.
2289 void QtxPagePrefEditItem::updateEditor()
2294 myEditor->setEchoMode(QLineEdit::Normal);
2297 myEditor->setEchoMode(QLineEdit::NoEcho);
2300 myEditor->setEchoMode(QLineEdit::Password);
2303 myEditor->setEchoMode(QLineEdit::PasswordEchoOnEdit);
2306 myEditor->setEchoMode(QLineEdit::Normal);
2309 QValidator* val = 0;
2310 switch ( inputType() )
2313 val = new QIntValidator( myEditor );
2316 val = new QDoubleValidator( myEditor );
2317 dynamic_cast<QDoubleValidator*>( val )->setDecimals( myDecimals < 0 ? 1000 : myDecimals );
2323 QString txt = myEditor->text();
2324 delete myEditor->validator();
2325 myEditor->setValidator( val );
2326 fixupAndSet( myEditor, txt );
2330 \class QtxPagePrefSliderItem
2336 Creates preference item with slider widget
2338 \param title preference item title
2339 \param parent parent preference item
2340 \param sect resource file section associated with the preference item
2341 \param param resource file parameter associated with the preference item
2343 QtxPagePrefSliderItem::QtxPagePrefSliderItem( const QString& title, QtxPreferenceItem* parent,
2344 const QString& sect, const QString& param )
2345 : QtxPageNamedPrefItem( title, parent, sect, param )
2347 setControl( mySlider = new QSlider( Qt::Horizontal ) );
2348 widget()->layout()->addWidget( myLabel = new QLabel( ) );
2355 mySlider->setTickPosition( QSlider::TicksBothSides );
2357 connect (mySlider, SIGNAL(valueChanged(int)), this, SLOT(setIcon(int)));
2364 QtxPagePrefSliderItem::~QtxPagePrefSliderItem()
2369 \brief Get slider preference item step value.
2370 \return slider single step value
2373 int QtxPagePrefSliderItem::singleStep() const
2375 return mySlider->singleStep();
2379 \brief Get slider preference item step value.
2380 \return slider page step value
2383 int QtxPagePrefSliderItem::pageStep() const
2385 return mySlider->pageStep();
2389 \brief Get slider preference item minimum value.
2390 \return slider minimum value
2393 int QtxPagePrefSliderItem::minimum() const
2395 return mySlider->minimum();
2399 \brief Get slider preference item maximum value.
2400 \return slider maximum value
2403 int QtxPagePrefSliderItem::maximum() const
2405 return mySlider->maximum();
2409 \brief Get the list of the icons associated with the selection widget items
2410 \return list of icons
2413 QList<QIcon> QtxPagePrefSliderItem::icons() const
2419 \brief Set slider preference item step value.
2420 \param step new slider single step value
2423 void QtxPagePrefSliderItem::setSingleStep( const int& step )
2425 mySlider->setSingleStep( step );
2429 \brief Set slider preference item step value.
2430 \param step new slider single step value
2433 void QtxPagePrefSliderItem::setPageStep( const int& step )
2435 mySlider->setPageStep( step );
2439 \brief Set slider preference item minimum value.
2440 \param min new slider minimum value
2443 void QtxPagePrefSliderItem::setMinimum( const int& min )
2445 mySlider->setMinimum( min );
2446 setIcon( mySlider->value() );
2450 \brief Set slider preference item maximum value.
2451 \param max new slider maximum value
2454 void QtxPagePrefSliderItem::setMaximum( const int& max )
2456 mySlider->setMaximum( max );
2457 setIcon( mySlider->value() );
2461 \brief Set the list of the icons to the selection widget items
2462 \param icns new list of icons
2465 void QtxPagePrefSliderItem::setIcons( const QList<QIcon>& icns )
2467 if ( icns.isEmpty() )
2471 QSize maxsize(0, 0);
2472 for ( QList<QIcon>::const_iterator it = myIcons.begin(); it != myIcons.end(); ++it ) {
2473 if ( (*it).isNull() ) continue;
2474 maxsize = maxsize.expandedTo( (*it).availableSizes().first() );
2476 myLabel->setFixedSize( maxsize );
2482 \brief Store preference item to the resource manager.
2485 void QtxPagePrefSliderItem::store()
2487 setInteger( mySlider->value() );
2491 \brief Retrieve preference item from the resource manager.
2494 void QtxPagePrefSliderItem::retrieve()
2496 mySlider->setValue( getInteger( mySlider->value() ) );
2500 \brief Get preference item option value.
2501 \param name option name
2502 \return property value or null integer if option is not set
2503 \sa setOptionValue()
2505 QVariant QtxPagePrefSliderItem::optionValue( const QString& name ) const
2507 if ( name == "minimum" || name == "min" )
2509 else if ( name == "maximum" || name == "max" )
2511 else if ( name == "single_step" )
2512 return singleStep();
2513 else if ( name == "page_step" )
2515 else if ( name == "icons" || name == "pixmaps" )
2517 QList<QVariant> lst;
2518 QList<QIcon> ics = icons();
2519 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2524 return QtxPageNamedPrefItem::optionValue( name );
2528 \brief Set preference item option value.
2529 \param name option name
2530 \param val new property value
2533 void QtxPagePrefSliderItem::setOptionValue( const QString& name, const QVariant& val )
2535 if ( val.canConvert( QVariant::Int ) )
2537 if ( name == "minimum" || name == "min" )
2538 setMinimum( val.toInt() );
2539 else if ( name == "maximum" || name == "max" )
2540 setMaximum( val.toInt() );
2541 else if ( name == "single_step" )
2542 setSingleStep( val.toInt() );
2543 else if ( name == "page_step" )
2544 setPageStep( val.toInt() );
2546 QtxPageNamedPrefItem::setOptionValue( name, val );
2548 else if ( name == "icons" || name == "pixmaps" )
2551 QtxPageNamedPrefItem::setOptionValue( name, val );
2554 void QtxPagePrefSliderItem::setIcon( int pos )
2556 int index = pos - mySlider->minimum();
2557 if ( !myIcons.isEmpty() && index >= 0 && index < myIcons.size() && !myIcons[index].isNull() )
2558 myLabel->setPixmap( myIcons[index].pixmap( myIcons[index].availableSizes().first() ) );
2564 \brief Update slider widget.
2566 void QtxPagePrefSliderItem::updateSlider()
2568 int val = mySlider->value();
2569 int stp = singleStep();
2570 int ptp = pageStep();
2571 int min = minimum();
2572 int max = maximum();
2574 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2575 mySlider->setFocusPolicy(Qt::StrongFocus);
2577 mySlider->setValue( val );
2578 setSingleStep( stp );
2583 myLabel->setVisible( !myIcons.empty() );
2584 widget()->layout()->setSpacing( !myIcons.empty() ? 6 : 0 );
2588 \brief Set the list of the icons from the resource manager.
2589 \param var new icons list
2592 void QtxPagePrefSliderItem::setIcons( const QVariant& var )
2594 if ( var.type() != QVariant::List )
2598 QList<QVariant> varList = var.toList();
2599 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2601 if ( (*it).canConvert<QIcon>() )
2602 lst.append( (*it).value<QIcon>() );
2603 else if ( (*it).canConvert<QPixmap>() )
2604 lst.append( (*it).value<QPixmap>() );
2606 lst.append( QIcon() );
2612 \class QtxPagePrefSelectItem
2613 \brief GUI implementation of the resources selector item
2614 (string, integer or double values list).
2616 All items in the list (represented as combo box) should be specified
2617 by the unique identifier which is stored to the resource file instead
2618 of the value itself.
2624 Creates preference item with combo box widget which is not editable
2625 (direct value entering is disabled).
2627 \param title preference item title
2628 \param parent parent preference item
2629 \param sect resource file section associated with the preference item
2630 \param param resource file parameter associated with the preference item
2632 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const QString& title, QtxPreferenceItem* parent,
2633 const QString& sect, const QString& param )
2634 : QtxPageNamedPrefItem( title, parent, sect, param ),
2637 setControl( mySelector = new QtxComboBox() );
2638 mySelector->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2639 mySelector->setDuplicatesEnabled( false );
2646 Creates preference item with combo box widget which is editable
2647 according to the specified input type (integer, double or string values).
2649 \param type input type (QtxPagePrefSelectItem::InputType)
2650 \param title preference item title
2651 \param parent parent preference item
2652 \param sect resource file section associated with the preference item
2653 \param param resource file parameter associated with the preference item
2655 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const int type, const QString& title, QtxPreferenceItem* parent,
2656 const QString& sect, const QString& param )
2657 : QtxPageNamedPrefItem( title, parent, sect, param ),
2660 setControl( mySelector = new QtxComboBox() );
2661 mySelector->setDuplicatesEnabled( false );
2668 QtxPagePrefSelectItem::~QtxPagePrefSelectItem()
2673 \brief Get edit box preference item input type.
2674 \return preference item input type (QtxPagePrefSelectItem::InputType)
2677 int QtxPagePrefSelectItem::inputType() const
2683 \brief Set edit box preference item input type.
2684 \param type new preference item input type (QtxPagePrefSelectItem::InputType)
2687 void QtxPagePrefSelectItem::setInputType( const int type )
2689 if ( myType == type )
2697 \brief Get the list of the values from the selection widget.
2698 \return list of values
2699 \sa numbers(), icons(), setStrings()
2701 QStringList QtxPagePrefSelectItem::strings() const
2704 for ( uint i = 0; i < mySelector->count(); i++ )
2705 res.append( mySelector->itemText( i ) );
2710 \brief Get the list of the values identifiers from the selection widget.
2711 \return list of values IDs
2712 \sa strings(), icons(), setNumbers()
2714 QList<int> QtxPagePrefSelectItem::numbers() const
2717 for ( uint i = 0; i < mySelector->count(); i++ )
2719 if ( mySelector->hasId( i ) )
2720 res.append( mySelector->id( i ) );
2726 \brief Get the list of the icons associated with the selection widget.items
2727 \return list of icons
2728 \sa strings(), numbers(), setIcons()
2730 QList<QIcon> QtxPagePrefSelectItem::icons() const
2733 for ( uint i = 0; i < mySelector->count(); i++ )
2734 res.append( mySelector->itemIcon( i ) );
2739 \brief Set the list of the values to the selection widget.
2740 \param lst new list of values
2741 \sa strings(), setNumbers(), setIcons()
2743 void QtxPagePrefSelectItem::setStrings( const QStringList& lst )
2745 mySelector->clear();
2746 mySelector->addItems( lst );
2750 \brief Set the list of the values identifiers to the selection widget
2751 \param ids new list of values IDs
2752 \sa numbers(), setStrings(), setIcons()
2754 void QtxPagePrefSelectItem::setNumbers( const QList<int>& ids )
2757 for ( QList<int>::const_iterator it = ids.begin(); it != ids.end(); ++it, i++ ) {
2758 if ( i >= mySelector->count() )
2759 mySelector->addItem(QString("") );
2761 mySelector->setId( i, *it );
2766 \brief Set the list of the icons to the selection widget items
2768 Important: call this method after setStrings() or setNumbers()
2770 \param icns new list of icons
2771 \sa icons(), setStrings(), setNumbers()
2773 void QtxPagePrefSelectItem::setIcons( const QList<QIcon>& icns )
2776 for ( QList<QIcon>::const_iterator it = icns.begin(); it != icns.end() && i < mySelector->count(); ++it, i++ )
2777 mySelector->setItemIcon( i, *it );
2781 \brief Store preference item to the resource manager.
2784 void QtxPagePrefSelectItem::store()
2786 if ( mySelector->isCleared() )
2789 int idx = mySelector->currentIndex();
2791 if ( mySelector->hasId( idx ) )
2792 setInteger( mySelector->id( idx ) );
2793 else if ( idx >= 0 )
2794 setString( mySelector->itemText( idx ) );
2798 \brief Retrieve preference item from the resource manager.
2801 void QtxPagePrefSelectItem::retrieve()
2803 QString txt = getString();
2808 int num = txt.toInt( &ok );
2810 idx = mySelector->index( num );
2813 for ( uint i = 0; i < mySelector->count() && idx == -1; i++ )
2815 if ( mySelector->itemText( i ) == txt )
2821 mySelector->setCurrentIndex( idx );
2822 else if ( mySelector->isEditable() )
2825 if ( mySelector->validator() &&
2826 mySelector->validator()->validate( txt, pos ) == QValidator::Invalid )
2827 mySelector->setCleared( true );
2830 mySelector->setCleared( false );
2831 mySelector->addItem( txt );
2832 mySelector->setCurrentIndex( mySelector->count() - 1 );
2838 \brief Get preference item option value.
2839 \param name option name
2840 \return property value or null QVariant if option is not set
2841 \sa setOptionValue()
2843 QVariant QtxPagePrefSelectItem::optionValue( const QString& name ) const
2845 if ( name == "input_type" || name == "type" )
2847 else if ( name == "strings" || name == "labels" )
2849 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2851 QList<QVariant> lst;
2852 QList<int> nums = numbers();
2853 for ( QList<int>::const_iterator it = nums.begin(); it != nums.end(); ++it )
2857 else if ( name == "icons" || name == "pixmaps" )
2859 QList<QVariant> lst;
2860 QList<QIcon> ics = icons();
2861 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2866 return QtxPageNamedPrefItem::optionValue( name );
2870 \brief Set preference item option value.
2871 \param name option name
2872 \param val new property value
2875 void QtxPagePrefSelectItem::setOptionValue( const QString& name, const QVariant& val )
2877 if ( name == "input_type" || name == "type" )
2879 if ( val.canConvert( QVariant::Int ) )
2880 setInputType( val.toInt() );
2882 else if ( name == "strings" || name == "labels" )
2884 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2886 else if ( name == "icons" || name == "pixmaps" )
2889 QtxPageNamedPrefItem::setOptionValue( name, val );
2893 \brief Set the list of the values from the resource manager.
2894 \param var new values list
2897 void QtxPagePrefSelectItem::setStrings( const QVariant& var )
2899 if ( var.type() != QVariant::StringList )
2902 setStrings( var.toStringList() );
2906 \brief Set the list of the values identifiers from the resource manager.
2907 \param var new values IDs list
2910 void QtxPagePrefSelectItem::setNumbers( const QVariant& var )
2912 if ( var.type() != QVariant::List )
2916 QList<QVariant> varList = var.toList();
2917 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2919 if ( (*it).canConvert( QVariant::Int ) )
2920 lst.append( (*it).toInt() );
2926 \brief Set the list of the icons from the resource manager.
2927 \param var new icons list
2930 void QtxPagePrefSelectItem::setIcons( const QVariant& var )
2932 if ( var.type() != QVariant::List )
2936 QList<QVariant> varList = var.toList();
2937 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2939 if ( (*it).canConvert<QIcon>() )
2940 lst.append( (*it).value<QIcon>() );
2941 else if ( (*it).canConvert<QPixmap>() )
2942 lst.append( (*it).value<QPixmap>() );
2944 lst.append( QIcon() );
2950 \brief Update selector widget.
2952 void QtxPagePrefSelectItem::updateSelector()
2954 QValidator* val = 0;
2955 switch ( inputType() )
2958 val = new QIntValidator( mySelector );
2961 val = new QDoubleValidator( mySelector );
2967 mySelector->setEditable( inputType() != NoInput );
2969 if ( mySelector->isEditable() && !mySelector->currentText().isEmpty() && val )
2972 QString str = mySelector->currentText();
2973 if ( val->validate( str, pos ) == QValidator::Invalid )
2974 mySelector->clearEditText();
2977 delete mySelector->validator();
2978 mySelector->setValidator( val );
2982 \class QtxPagePrefSpinItem
2983 \brief GUI implementation of the resources spin box item
2984 (for integer or double value).
2990 Creates spin box preference item for the entering integer values.
2992 \param title preference item title
2993 \param parent parent preference item
2994 \param sect resource file section associated with the preference item
2995 \param param resource file parameter associated with the preference item
2997 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const QString& title, QtxPreferenceItem* parent,
2998 const QString& sect, const QString& param )
2999 : QtxPageNamedPrefItem( title, parent, sect, param ),
3008 Creates spin box preference item for the entering values which type
3009 is specified by the parameter \a type.
3011 \param type input type (QtxPagePrefSpinItem::InputType).
3012 \param title preference item title
3013 \param parent parent preference item
3014 \param sect resource file section associated with the preference item
3015 \param param resource file parameter associated with the preference item
3017 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const int type, const QString& title,
3018 QtxPreferenceItem* parent, const QString& sect,
3019 const QString& param )
3020 : QtxPageNamedPrefItem( title, parent, sect, param ),
3029 QtxPagePrefSpinItem::~QtxPagePrefSpinItem()
3034 \brief Get spin box preference item input type.
3035 \return preference item input type (QtxPagePrefSpinItem::InputType)
3038 int QtxPagePrefSpinItem::inputType() const
3044 \brief Set spin box preference item input type.
3045 \param type new preference item input type (QtxPagePrefSpinItem::InputType)
3048 void QtxPagePrefSpinItem::setInputType( const int type )
3050 if ( myType == type )
3058 \brief Get spin box preference item step value.
3059 \return spin box single step value
3062 QVariant QtxPagePrefSpinItem::step() const
3064 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3065 return isb->singleStep();
3066 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3067 return dsb->singleStep();
3073 \brief Get double spin box preference item precision value.
3074 \return double spin box precision
3077 QVariant QtxPagePrefSpinItem::precision() const
3079 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3080 return dsb->decimals();
3086 \brief Get spin box preference item minimum value.
3087 \return spin box minimum value
3090 QVariant QtxPagePrefSpinItem::minimum() const
3092 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3093 return isb->minimum();
3094 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3095 return dsb->minimum();
3101 \brief Get spin box preference item maximum value.
3102 \return spin box maximum value
3105 QVariant QtxPagePrefSpinItem::maximum() const
3107 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3108 return isb->maximum();
3109 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3110 return dsb->maximum();
3116 \brief Get spin box preference item prefix string.
3117 \return spin box prefix string
3120 QString QtxPagePrefSpinItem::prefix() const
3122 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3123 return isb->prefix();
3124 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3125 return dsb->prefix();
3131 \brief Get spin box preference item suffix string.
3132 \return spin box suffix string
3135 QString QtxPagePrefSpinItem::suffix() const
3137 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3138 return isb->suffix();
3139 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3140 return dsb->suffix();
3146 \brief Get spin box preference item special value text (which is shown
3147 when the spin box reaches minimum value).
3148 \return spin box special value text
3149 \sa setSpecialValueText()
3151 QString QtxPagePrefSpinItem::specialValueText() const
3153 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3155 return sb->specialValueText();
3161 \brief Set spin box preference item step value.
3162 \param step new spin box single step value
3165 void QtxPagePrefSpinItem::setStep( const QVariant& step )
3167 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3169 if ( step.canConvert( QVariant::Int ) )
3170 isb->setSingleStep( step.toInt() );
3172 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3174 if ( step.canConvert( QVariant::Double ) )
3175 dsb->setSingleStep( step.toDouble() );
3180 \brief Set double spin box preference item precision value.
3181 \param step new double spin box precision value
3184 void QtxPagePrefSpinItem::setPrecision( const QVariant& prec )
3186 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3188 if ( prec.canConvert( QVariant::Int ) ) {
3189 dsb->setDecimals( qAbs( prec.toInt() ) );
3190 dsb->setPrecision( prec.toInt() );
3196 \brief Set spin box preference item minimum value.
3197 \param min new spin box minimum value
3200 void QtxPagePrefSpinItem::setMinimum( const QVariant& min )
3202 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3204 if ( min.canConvert( QVariant::Int ) )
3205 isb->setMinimum( min.toInt() );
3207 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3209 if ( min.canConvert( QVariant::Double ) )
3210 dsb->setMinimum( min.toDouble() );
3215 \brief Set spin box preference item maximum value.
3216 \param min new spin box maximum value
3219 void QtxPagePrefSpinItem::setMaximum( const QVariant& max )
3221 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3223 if ( max.canConvert( QVariant::Int ) )
3224 isb->setMaximum( max.toInt() );
3226 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3228 if ( max.canConvert( QVariant::Double ) )
3229 dsb->setMaximum( max.toDouble() );
3234 \brief Set spin box preference item prefix string.
3235 \param txt new spin box prefix string
3238 void QtxPagePrefSpinItem::setPrefix( const QString& txt )
3240 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3241 isb->setPrefix( txt );
3242 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3243 dsb->setPrefix( txt );
3247 \brief Set spin box preference item suffix string.
3248 \param txt new spin box suffix string
3251 void QtxPagePrefSpinItem::setSuffix( const QString& txt )
3253 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3254 isb->setSuffix( txt );
3255 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3256 dsb->setSuffix( txt );
3260 \brief Set spin box preference item special value text (which is shown
3261 when the spin box reaches minimum value).
3262 \param txt new spin box special value text
3263 \sa specialValueText()
3265 void QtxPagePrefSpinItem::setSpecialValueText( const QString& txt )
3267 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3269 sb->setSpecialValueText( txt );
3273 \brief Store preference item to the resource manager.
3276 void QtxPagePrefSpinItem::store()
3278 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3279 setInteger( isb->value() );
3280 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3281 setDouble( dsb->value() );
3285 \brief Retrieve preference item from the resource manager.
3288 void QtxPagePrefSpinItem::retrieve()
3290 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3291 isb->setValue( getInteger( isb->value() ) );
3292 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3293 dsb->setValue( getDouble( dsb->value() ) );
3297 \brief Get preference item option value.
3298 \param name option name
3299 \return property value or null QVariant if option is not set
3300 \sa setOptionValue()
3302 QVariant QtxPagePrefSpinItem::optionValue( const QString& name ) const
3304 if ( name == "input_type" || name == "type" )
3306 else if ( name == "minimum" || name == "min" )
3308 else if ( name == "maximum" || name == "max" )
3310 else if ( name == "step" )
3312 else if ( name == "precision" )
3314 else if ( name == "prefix" )
3316 else if ( name == "suffix" )
3318 else if ( name == "special" )
3319 return specialValueText();
3321 return QtxPageNamedPrefItem::optionValue( name );
3325 \brief Set preference item option value.
3326 \param name option name
3327 \param val new property value
3330 void QtxPagePrefSpinItem::setOptionValue( const QString& name, const QVariant& val )
3332 if ( name == "input_type" || name == "type" )
3334 if ( val.canConvert( QVariant::Int ) )
3335 setInputType( val.toInt() );
3337 else if ( name == "minimum" || name == "min" )
3339 else if ( name == "maximum" || name == "max" )
3341 else if ( name == "step" )
3343 else if ( name == "precision" )
3344 setPrecision( val );
3345 else if ( name == "prefix" )
3347 if ( val.canConvert( QVariant::String ) )
3348 setPrefix( val.toString() );
3350 else if ( name == "suffix" )
3352 if ( val.canConvert( QVariant::String ) )
3353 setSuffix( val.toString() );
3355 else if ( name == "special" )
3357 if ( val.canConvert( QVariant::String ) )
3358 setSpecialValueText( val.toString() );
3361 QtxPageNamedPrefItem::setOptionValue( name, val );
3365 \brief Update spin box widget.
3367 void QtxPagePrefSpinItem::updateSpinBox()
3370 QVariant stp = step();
3371 QVariant prec = precision();
3372 QVariant min = minimum();
3373 QVariant max = maximum();
3375 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3377 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3380 switch ( inputType() )
3383 setControl( new QtxIntSpinBox() );
3386 setControl( new QtxDoubleSpinBox() );
3392 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3395 setPrecision( prec );
3399 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3401 if ( val.canConvert( QVariant::Int ) )
3402 isb->setValue( val.toInt() );
3404 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3406 if ( val.canConvert( QVariant::Double ) )
3407 dsb->setValue( val.toDouble() );
3412 \class QtxPagePrefTextItem
3413 \brief GUI implementation of the resources text box edit item
3414 (for large text data).
3419 \param parent parent preference item
3420 \param sect resource file section associated with the preference item
3421 \param param resource file parameter associated with the preference item
3423 QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect,
3424 const QString& param )
3425 : QtxPageNamedPrefItem( QString(), parent, sect, param )
3427 myEditor = new QTextEdit();
3428 myEditor->setAcceptRichText( false );
3430 setControl( myEditor );
3435 \param title preference item title
3436 \param parent parent preference item
3437 \param sect resource file section associated with the preference item
3438 \param param resource file parameter associated with the preference item
3440 QtxPagePrefTextItem::QtxPagePrefTextItem( const QString& title, QtxPreferenceItem* parent,
3441 const QString& sect, const QString& param )
3442 : QtxPageNamedPrefItem( title, parent, sect, param )
3444 myEditor = new QTextEdit();
3445 myEditor->setAcceptRichText( false );
3447 setControl( myEditor );
3453 QtxPagePrefTextItem::~QtxPagePrefTextItem()
3458 \brief Store preference item to the resource manager.
3461 void QtxPagePrefTextItem::store()
3463 setString( myEditor->toPlainText() );
3467 \brief Retrieve preference item from the resource manager.
3470 void QtxPagePrefTextItem::retrieve()
3472 myEditor->setPlainText( getString() );
3476 \class QtxPagePrefColorItem
3477 \brief GUI implementation of the resources color item.
3482 \param title preference item title
3483 \param parent parent preference item
3484 \param sect resource file section associated with the preference item
3485 \param param resource file parameter associated with the preference item
3487 QtxPagePrefColorItem::QtxPagePrefColorItem( const QString& title, QtxPreferenceItem* parent,
3488 const QString& sect, const QString& param )
3489 : QtxPageNamedPrefItem( title, parent, sect, param )
3491 // QtxPagePrefGroupItem* aGroup 0; //= dynamic_cast<QtxPagePrefGroupItem*>( parent );
3493 // setControl( myColor = new QtxColorButton( aGroup ? aGroup->gridBox() : 0 ) );
3494 setControl( myColor = new QtxColorButton( 0 ) );
3495 myColor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3501 QtxPagePrefColorItem::~QtxPagePrefColorItem()
3506 \brief Store preference item to the resource manager.
3509 void QtxPagePrefColorItem::store()
3511 setColor( myColor->color() );
3515 \brief Retrieve preference item from the resource manager.
3518 void QtxPagePrefColorItem::retrieve()
3520 myColor->setColor( getColor() );
3524 \class QtxPagePrefBiColorItem
3525 \brief GUI implementation of the resources item to store a bi-color value.
3527 The main color is specified explicitly. The secondary color is calculated
3528 by changing "value" and "saturation" parameters of the main color in the
3529 HSV notation using specified delta.
3534 \param title preference item title
3535 \param parent parent preference item
3536 \param sect resource file section associated with the preference item
3537 \param param resource file parameter associated with the preference item
3539 QtxPagePrefBiColorItem::QtxPagePrefBiColorItem( const QString& title, QtxPreferenceItem* parent,
3540 const QString& sect, const QString& param )
3541 : QtxPageNamedPrefItem( title, parent, sect, param )
3543 setControl( myColors = new QtxBiColorTool( 0 ) );
3549 QtxPagePrefBiColorItem::~QtxPagePrefBiColorItem()
3554 \bried Get auxiliary text
3555 \return text assigned to the item
3558 QString QtxPagePrefBiColorItem::text() const
3560 return myColors->text();
3564 \bried Set auxiliary text
3565 \param t text being assigned to the item
3568 void QtxPagePrefBiColorItem::setText( const QString& t )
3570 myColors->setText( t );
3574 \brief Store preference item to the resource manager.
3577 void QtxPagePrefBiColorItem::store()
3579 setString( Qtx::biColorToString( myColors->mainColor(), myColors->delta() ) );
3583 \brief Retrieve preference item from the resource manager.
3586 void QtxPagePrefBiColorItem::retrieve()
3590 Qtx::stringToBiColor( getString(), c, d );
3591 myColors->setMainColor( c );
3592 myColors->setDelta( d );
3596 \brief Get preference item option value.
3597 \param name option name
3598 \return property value or null QVariant if option is not set
3599 \sa setOptionValue()
3601 QVariant QtxPagePrefBiColorItem::optionValue( const QString& name ) const
3603 if ( name == "text" )
3606 return QtxPageNamedPrefItem::optionValue( name );
3610 \brief Set preference item option value.
3611 \param name option name
3612 \param val new property value
3615 void QtxPagePrefBiColorItem::setOptionValue( const QString& name, const QVariant& val )
3617 if ( name == "text" )
3619 if ( val.canConvert( QVariant::String ) )
3620 setText( val.toString() );
3623 QtxPageNamedPrefItem::setOptionValue( name, val );
3627 \class QtxPagePrefFontItem
3628 \brief GUI implementation of the resources font item.
3633 \param feat font editor widget features (QtxFontEdit::Features)
3634 \param title preference item title
3635 \param parent parent preference item
3636 \param sect resource file section associated with the preference item
3637 \param param resource file parameter associated with the preference item
3639 QtxPagePrefFontItem::QtxPagePrefFontItem( const int feat, const QString& title,
3640 QtxPreferenceItem* parent, const QString& sect,
3641 const QString& param )
3642 : QtxPageNamedPrefItem( title, parent, sect, param )
3644 setControl( myFont = new QtxFontEdit( feat ) );
3649 \param title preference item title
3650 \param parent parent preference item
3651 \param sect resource file section associated with the preference item
3652 \param param resource file parameter associated with the preference item
3654 QtxPagePrefFontItem::QtxPagePrefFontItem( const QString& title, QtxPreferenceItem* parent,
3655 const QString& sect, const QString& param )
3656 : QtxPageNamedPrefItem( title, parent, sect, param )
3658 setControl( myFont = new QtxFontEdit() );
3664 QtxPagePrefFontItem::~QtxPagePrefFontItem()
3669 \brief Get font widget features.
3670 \return font widget features (ORed QtxFontEdit::Features flags)
3673 int QtxPagePrefFontItem::features() const
3675 return myFont->features();
3679 \brief Set font widget features.
3680 \param f new font widget features (ORed QtxFontEdit::Features flags)
3683 void QtxPagePrefFontItem::setFeatures( const int f )
3685 myFont->setFeatures( f );
3689 \brief Specifies whether widget works in Native or Custom mode. Native mode
3690 is intended for working with system fonts. Custom mode is intended for
3691 working with manually defined set of fonts. Set of custom fonts can be
3692 specified with setFonts() method
3693 \param mode mode from QtxFontEdit::Mode enumeration
3696 void QtxPagePrefFontItem::setMode( const int mode )
3698 myFont->setMode( mode );
3702 \brief Verifies whether widget works in Native or Custom mode
3703 \return Native or Custom mode
3706 int QtxPagePrefFontItem::mode() const
3708 return myFont->mode();
3712 \brief Sets list of custom fonts.
3713 <b>This method is intended for working in Custom mode only.</b>
3714 \param fams list of families
3715 \sa fonts(), setMode()
3717 void QtxPagePrefFontItem::setFonts( const QStringList& fams )
3719 myFont->setFonts( fams );
3723 \brief Gets list of custom fonts
3724 \return list of families
3725 \sa setFonts(), setMode()
3727 QStringList QtxPagePrefFontItem::fonts() const
3729 return myFont->fonts();
3733 \brief Sets list of available font sizes.
3734 <b>This method is intended for working in Custom mode only.</b> The list of sizes can
3735 be empty. In this case system generate listof size automatically from 8 till 72.
3736 \param sizes list of sizes
3737 \sa sizes(), setMode()
3739 void QtxPagePrefFontItem::setSizes( const QList<int>& sizes )
3741 myFont->setSizes( sizes );
3745 \brief Gets list of custom fonts
3746 \return list of families
3747 \sa setFonts(), setMode()
3749 QList<int> QtxPagePrefFontItem::sizes() const
3751 return myFont->sizes();
3755 \brief Store preference item to the resource manager.
3758 void QtxPagePrefFontItem::store()
3760 setFont( myFont->currentFont() );
3764 \brief Retrieve preference item from the resource manager.
3767 void QtxPagePrefFontItem::retrieve()
3769 myFont->setCurrentFont( getFont() );
3773 \brief Get preference item option value.
3774 \param name option name
3775 \return property value or null QVariant if option is not set
3776 \sa setOptionValue()
3778 QVariant QtxPagePrefFontItem::optionValue( const QString& name ) const
3780 if ( name == "features" )
3782 else if ( name == "mode" )
3784 else if ( name == "fonts" || name == "families" )
3786 else if ( name == "sizes" )
3788 QList<QVariant> lst;
3789 QList<int> nums = sizes();
3790 for ( QList<int>::const_iterator it = nums.begin(); it != nums.end(); ++it )
3795 return QtxPageNamedPrefItem::optionValue( name );
3799 \brief Set preference item option value.
3800 \param name option name
3801 \param val new property value
3804 void QtxPagePrefFontItem::setOptionValue( const QString& name, const QVariant& val )
3806 if ( name == "features" )
3808 if ( val.canConvert( QVariant::Int ) )
3809 setFeatures( val.toInt() );
3811 else if ( name == "mode" )
3813 if ( val.canConvert( QVariant::Int ) )
3814 setMode( val.toInt() );
3816 else if ( name == "fonts" || name == "families" )
3818 if ( val.canConvert( QVariant::StringList ) )
3819 setFonts( val.toStringList() );
3821 else if ( name == "sizes" )
3823 if ( val.type() == QVariant::List )
3826 QList<QVariant> varList = val.toList();
3827 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
3829 if ( (*it).canConvert( QVariant::Int ) )
3830 lst.append( (*it).toInt() );
3836 QtxPageNamedPrefItem::setOptionValue( name, val );
3840 \class QtxPagePrefPathItem
3841 \brief GUI implementation of the resources file/directory path item.
3846 \param type path widget mode (Qtx::PathType )
3847 \param title preference item title
3848 \param parent parent preference item
3849 \param sect resource file section associated with the preference item
3850 \param param resource file parameter associated with the preference item
3852 QtxPagePrefPathItem::QtxPagePrefPathItem( const Qtx::PathType type, const QString& title,
3853 QtxPreferenceItem* parent, const QString& sect, const QString& param )
3854 : QtxPageNamedPrefItem( title, parent, sect, param )
3856 setControl( myPath = new QtxPathEdit( type ) );
3861 \param title preference item title
3862 \param parent parent preference item
3863 \param sect resource file section associated with the preference item
3864 \param param resource file parameter associated with the preference item
3866 QtxPagePrefPathItem::QtxPagePrefPathItem( const QString& title, QtxPreferenceItem* parent,
3867 const QString& sect, const QString& param )
3868 : QtxPageNamedPrefItem( title, parent, sect, param )
3870 setControl( myPath = new QtxPathEdit() );
3876 QtxPagePrefPathItem::~QtxPagePrefPathItem()
3881 \brief Get path widget mode.
3882 \return current path widget mode (Qtx::PathType)
3885 Qtx::PathType QtxPagePrefPathItem::pathType() const
3887 return myPath->pathType();
3891 \brief Set path widget mode.
3892 \param type new path widget mode (Qtx::PathType)
3895 void QtxPagePrefPathItem::setPathType( const Qtx::PathType type )
3897 myPath->setPathType( type );
3901 \brief Get currently used path widget filters.
3902 \return file or directory path filters
3905 QString QtxPagePrefPathItem::pathFilter() const
3907 return myPath->pathFilter();
3911 \brief Set path widget filters.
3912 \param f new file or directory path filters
3915 void QtxPagePrefPathItem::setPathFilter( const QString& f )
3917 myPath->setPathFilter( f );
3921 \brief Store preference item to the resource manager.
3924 void QtxPagePrefPathItem::store()
3926 setString( myPath->path() );
3930 \brief Retrieve preference item from the resource manager.
3933 void QtxPagePrefPathItem::retrieve()
3935 myPath->setPath( getString() );
3939 \brief Get preference item option value.
3940 \param name option name
3941 \return property value or null QVariant if option is not set
3942 \sa setOptionValue()
3944 QVariant QtxPagePrefPathItem::optionValue( const QString& name ) const
3946 if ( name == "path_type" )
3948 else if ( name == "path_filter" )
3949 return pathFilter();
3951 return QtxPageNamedPrefItem::optionValue( name );
3955 \brief Set preference item option value.
3956 \param name option name
3957 \param val new property value
3960 void QtxPagePrefPathItem::setOptionValue( const QString& name, const QVariant& val )
3962 if ( name == "path_type" )
3964 if ( val.canConvert( QVariant::Int ) )
3965 setPathType( (Qtx::PathType)val.toInt() );
3967 else if ( name == "path_filter" )
3969 if ( val.canConvert( QVariant::String ) )
3970 setPathFilter( val.toString() );
3973 QtxPageNamedPrefItem::setOptionValue( name, val );
3977 \class QtxPagePrefPathListItem
3978 \brief GUI implementation of the resources files/directories list item.
3983 \param parent parent preference item
3984 \param sect resource file section associated with the preference item
3985 \param param resource file parameter associated with the preference item
3987 QtxPagePrefPathListItem::QtxPagePrefPathListItem( QtxPreferenceItem* parent,
3988 const QString& sect, const QString& param )
3989 : QtxPageNamedPrefItem( QString(), parent, sect, param )
3991 setControl( myPaths = new QtxPathListEdit() );
3996 \param type path list widget mode (Qtx::PathType)
3997 \param title preference item title
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( const Qtx::PathType type, const QString& title,
4003 QtxPreferenceItem* parent, const QString& sect, const QString& param )
4004 : QtxPageNamedPrefItem( title, parent, sect, param )
4006 setControl( myPaths = new QtxPathListEdit( type ) );
4011 \param title preference item title
4012 \param parent parent preference item
4013 \param sect resource file section associated with the preference item
4014 \param param resource file parameter associated with the preference item
4016 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const QString& title, QtxPreferenceItem* parent,
4017 const QString& sect, const QString& param )
4018 : QtxPageNamedPrefItem( title, parent, sect, param )
4020 setControl( myPaths = new QtxPathListEdit() );
4026 QtxPagePrefPathListItem::~QtxPagePrefPathListItem()
4031 \brief Get path list widget mode.
4032 \return currently used path list widget mode (Qtx::PathType)
4035 Qtx::PathType QtxPagePrefPathListItem::pathType() const
4037 return myPaths->pathType();
4041 \brief Set path list widget mode.
4042 \param type new path list widget mode (Qtx::PathType)
4045 void QtxPagePrefPathListItem::setPathType( const Qtx::PathType type )
4047 myPaths->setPathType( type );
4051 \brief Store preference item to the resource manager.
4054 void QtxPagePrefPathListItem::store()
4056 setString( myPaths->pathList().join( ";" ) );
4060 \brief Retrieve preference item from the resource manager.
4063 void QtxPagePrefPathListItem::retrieve()
4065 myPaths->setPathList( getString().split( ";" ) );
4069 \brief Get preference item option value.
4070 \param name option name
4071 \return property value or null QVariant if option is not set
4072 \sa setOptionValue()
4074 QVariant QtxPagePrefPathListItem::optionValue( const QString& name ) const
4076 if ( name == "path_type" )
4079 return QtxPageNamedPrefItem::optionValue( name );
4083 \brief Set preference item option value.
4084 \param name option name
4085 \param val new property value
4088 void QtxPagePrefPathListItem::setOptionValue( const QString& name, const QVariant& val )
4090 if ( name == "path_type" )
4092 if ( val.canConvert( QVariant::Int ) )
4093 setPathType( (Qtx::PathType)val.toInt() );
4096 QtxPageNamedPrefItem::setOptionValue( name, val );
4100 \class QtxPagePrefDateTimeItem
4101 \brief GUI implementation of resources date/time item.
4107 Creates an item to enter date and time.
4109 \param title preference item title
4110 \param parent parent preference item
4111 \param sect resource file section associated with the preference item
4112 \param param resource file parameter associated with the preference item
4114 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const QString& title, QtxPreferenceItem* parent,
4115 const QString& sect, const QString& param )
4116 : QtxPageNamedPrefItem( title, parent, sect, param ),
4119 setControl( myDateTime = new QDateTimeEdit() );
4120 myDateTime->setCalendarPopup( true );
4121 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4128 Creates preference item for editing of the date and/or time value:
4129 the type is specified by parameter \a type.
4131 \param type preference item input type (QtxPagePrefDateTimeItem::InputType)
4132 \param title preference item title
4133 \param parent parent preference item
4134 \param sect resource file section associated with the preference item
4135 \param param resource file parameter associated with the preference item
4137 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const int type, const QString& title, QtxPreferenceItem* parent,
4138 const QString& sect, const QString& param )
4139 : QtxPageNamedPrefItem( title, parent, sect, param ),
4142 setControl( myDateTime = new QDateTimeEdit() );
4143 myDateTime->setCalendarPopup( true );
4144 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4151 QtxPagePrefDateTimeItem::~QtxPagePrefDateTimeItem()
4156 \brief Get date/time box preference item input type.
4157 \return preference item input type (QtxPagePrefDateTimeItem::InputType)
4160 int QtxPagePrefDateTimeItem::inputType() const
4166 \brief Set date/time box preference item input type.
4167 \param type new preference item input type (QtxPagePrefDateTimeItem::InputType)
4170 void QtxPagePrefDateTimeItem::setInputType( const int type )
4172 if ( myType == type )
4180 \brief Check if the popup calendar menu is enabled.
4181 \return \c true if calendar popup menu is enabled
4183 bool QtxPagePrefDateTimeItem::calendar() const
4185 return myDateTime->calendarPopup();
4189 \brief Enable/disable popup calendar menu.
4190 \param on new flag state
4192 void QtxPagePrefDateTimeItem::setCalendar( const bool on )
4194 myDateTime->setCalendarPopup( on );
4198 \brief Get maximum date value.
4199 \return maximum date value
4200 \sa setMaximumDate(), minimumDate(), maximumTime(), minimumTime()
4202 QDate QtxPagePrefDateTimeItem::maximumDate() const
4204 return myDateTime->maximumDate();
4208 \brief Get maximum time value.
4209 \return maximum time value
4210 \sa setMaximumTime(), minimumTime(), maximumDate(), minimumDate()
4212 QTime QtxPagePrefDateTimeItem::maximumTime() const
4214 return myDateTime->maximumTime();
4218 \brief Get minimum date value.
4219 \return minimum date value
4220 \sa setMinimumDate(), maximumDate(), maximumTime(), minimumTime()
4222 QDate QtxPagePrefDateTimeItem::minimumDate() const
4224 return myDateTime->minimumDate();
4228 \brief Get minimum time value.
4229 \return maximum time value
4230 \sa setMinimumTime(), maximumTime(), maximumDate(), minimumDate()
4232 QTime QtxPagePrefDateTimeItem::minimumTime() const
4234 return myDateTime->minimumTime();
4238 \brief Set maximum date value.
4239 \param d new maximum date value
4240 \sa maximumDate(), minimumDate(), maximumTime(), minimumTime()
4242 void QtxPagePrefDateTimeItem::setMaximumDate( const QDate& d )
4245 myDateTime->setMaximumDate( d );
4247 myDateTime->clearMaximumDate();
4251 \brief Set maximum time value.
4252 \param t new maximum time value
4253 \sa maximumTime(), minimumTime(), maximumDate(), minimumDate()
4255 void QtxPagePrefDateTimeItem::setMaximumTime( const QTime& t )
4258 myDateTime->setMaximumTime( t );
4260 myDateTime->clearMaximumTime();
4264 \brief Set minimum date value.
4265 \param d new minimum date value
4266 \sa minimumDate(), maximumDate(), maximumTime(), minimumTime()
4268 void QtxPagePrefDateTimeItem::setMinimumDate( const QDate& d )
4271 myDateTime->setMinimumDate( d );
4273 myDateTime->clearMinimumDate();
4277 \brief Set minimum time value.
4278 \param t new minimum time value
4279 \sa minimumTime(), maximumTime(), maximumDate(), minimumDate()
4281 void QtxPagePrefDateTimeItem::setMinimumTime( const QTime& t )
4284 myDateTime->setMinimumTime( t );
4286 myDateTime->clearMinimumTime();
4290 \brief Store preference item to the resource manager.
4293 void QtxPagePrefDateTimeItem::store()
4296 switch ( inputType() )
4299 str = myDateTime->date().toString( Qt::ISODate );
4302 str = myDateTime->time().toString( Qt::ISODate );
4305 str = myDateTime->dateTime().toString( Qt::ISODate );
4313 \brief Retrieve preference item from the resource manager.
4316 void QtxPagePrefDateTimeItem::retrieve()
4318 QString str = getString();
4319 switch ( inputType() )
4322 myDateTime->setDate( QDate::fromString( str, Qt::ISODate ) );
4325 myDateTime->setTime( QTime::fromString( str, Qt::ISODate ) );
4328 myDateTime->setDateTime( QDateTime::fromString( str, Qt::ISODate ) );
4334 \brief Get preference item option value.
4335 \param name option name
4336 \return property value or null QVariant if option is not set
4337 \sa setOptionValue()
4339 QVariant QtxPagePrefDateTimeItem::optionValue( const QString& name ) const
4341 if ( name == "input_type" || name == "type" )
4343 else if ( name == "minimum_date" || name == "min_date" )
4344 return minimumDate();
4345 else if ( name == "maximum_date" || name == "max_date" )
4346 return maximumDate();
4347 else if ( name == "minimum_time" || name == "min_time" )
4348 return minimumTime();
4349 else if ( name == "maximum_time" || name == "max_time" )
4350 return maximumTime();
4352 return QtxPageNamedPrefItem::optionValue( name );
4356 \brief Set preference item option value.
4357 \param name option name
4358 \param val new property value
4361 void QtxPagePrefDateTimeItem::setOptionValue( const QString& name, const QVariant& val )
4363 if ( name == "input_type" || name == "type" )
4365 if ( val.canConvert( QVariant::Int ) )
4366 setInputType( val.toInt() );
4368 else if ( name == "minimum_date" || name == "min_date" )
4370 if ( val.canConvert( QVariant::Date ) )
4371 setMinimumDate( val.toDate() );
4373 else if ( name == "maximum_date" || name == "max_date" )
4375 if ( val.canConvert( QVariant::Date ) )
4376 setMaximumDate( val.toDate() );
4378 else if ( name == "minimum_time" || name == "min_time" )
4380 if ( val.canConvert( QVariant::Time ) )
4381 setMinimumTime( val.toTime() );
4383 else if ( name == "maximum_time" || name == "max_time" )
4385 if ( val.canConvert( QVariant::Time ) )
4386 setMaximumTime( val.toTime() );
4389 QtxPageNamedPrefItem::setOptionValue( name, val );
4393 \brief Update date/time widget.
4395 void QtxPagePrefDateTimeItem::updateDateTime()
4398 switch ( inputType() )
4401 dispFmt = QDateEdit().displayFormat();
4404 dispFmt = QTimeEdit().displayFormat();
4407 dispFmt = QDateTimeEdit().displayFormat();
4411 myDateTime->setDisplayFormat( dispFmt );
4416 \param title preference item title
4417 \param parent parent preference item
4418 \param sect resource file section associated with the preference item
4419 \param param resource file parameter associated with the preference item
4421 QtxPagePrefShortcutBtnsItem::QtxPagePrefShortcutBtnsItem( const QString& title, QtxPreferenceItem* parent, const QString& sect,
4422 const QString& param ): QtxPageNamedPrefItem( title, parent, sect, param )
4424 setControl( myShortcut = new QtxShortcutEdit() );
4430 QtxPagePrefShortcutBtnsItem::~QtxPagePrefShortcutBtnsItem()
4435 \brief Store preference item to the resource manager.
4438 void QtxPagePrefShortcutBtnsItem::store()
4440 setString( myShortcut->shortcut().toString() );
4444 \brief Retrieve preference item from the resource manager.
4447 void QtxPagePrefShortcutBtnsItem::retrieve()
4449 myShortcut->setShortcut( QKeySequence::fromString( getString() ) );
4455 Creates preference item for editing of key bindings
4457 \param title preference item title
4458 \param parent parent preference item
4459 \param sect resource file section associated with the preference item
4460 \param param resource file parameter associated with the preference item
4462 QtxPagePrefShortcutTreeItem::QtxPagePrefShortcutTreeItem( const QString& title, QtxPreferenceItem* parent, const QString& sect,
4463 const QString& param ): QtxPageNamedPrefItem( title, parent, sect, "" )
4467 myShortcutTree = new QtxShortcutTree();
4469 // Retrieve shortcuts common sections from resources
4470 QtxResourceMgr* resMgr = resourceMgr();
4472 QString generalSections = resourceMgr()->stringValue( "shortcuts_settings", "general_sections", QString() );
4473 QStringList sectionsList = generalSections.split( ";", QString::SkipEmptyParts );
4474 myShortcutTree->setGeneralSections( sectionsList );
4477 setControl( myShortcutTree );
4483 QtxPagePrefShortcutTreeItem::~QtxPagePrefShortcutTreeItem()
4488 \brief Retrieve preference item from the resource manager.
4491 void QtxPagePrefShortcutTreeItem::retrieve()
4493 QtxResourceMgr* resMgr = resourceMgr();
4495 QStringList secLst = resMgr->subSections( mySection, false );
4496 ShortcutMap aMap; QStringList paramLst;
4497 for( int i = 0; i < secLst.size(); i++ ) {
4498 paramLst = resMgr->parameters( QStringList() << mySection << secLst.at( i ) );
4499 for( int j = 0; j < paramLst.size(); j++ )
4500 resMgr->value( mySection + resMgr->sectionsToken() + secLst.at( i ), paramLst.at( j ),aMap[ paramLst.at( j ) ], false );
4501 myShortcutTree->setBindings( secLst.at( i ), aMap );
4508 \brief Store preference item to the resource manager.
4511 void QtxPagePrefShortcutTreeItem::store()
4513 QStringList lst = myShortcutTree->sections();
4515 QtxResourceMgr* resMgr = resourceMgr();
4518 for( int i = 0; i < lst.size(); i++ ) {
4519 ShortcutMap* aMap( myShortcutTree->bindings( lst.at( i ) ) );
4520 aSection = mySection + resMgr->sectionsToken() + lst.at( i );
4521 for( ShortcutMap::const_iterator it = aMap->constBegin(); it != aMap->constEnd(); ++it )
4522 resMgr->setValue( aSection, it.key(), it.value() );
4528 \class QtxPagePrefBackgroundItem
4529 \brief GUI implementation of the resources item to store background data.
4531 Preference item allows specifying background data in different ways:
4533 - texture image file
4534 - simple two-color gradient
4535 - complex custom gradient (NOT IMPLEMENTED YET)
4537 Allowed background modes can be specified using setModeAllowed() method.
4538 Texture modes can be enabled/disabled using setTextureModeAllowed() method.
4539 Also, showing texture controls can be enabled/disabled by means of
4540 setTextureAllowed() method.
4541 Verical or horizontal orientation of the widget can be chosen via setOrientation()
4542 method (default orientation is horizontal).
4544 Simple gradient types can be specified using setGradients() method.
4546 \sa Qtx::BackgroundData, QtxBackgroundTool
4551 \param title preference item title
4552 \param parent parent preference item
4553 \param sect resource file section associated with the preference item
4554 \param param resource file parameter associated with the preference item
4556 QtxPagePrefBackgroundItem::QtxPagePrefBackgroundItem( const QString& title, QtxPreferenceItem* parent,
4557 const QString& sect, const QString& param )
4558 : QtxPageNamedPrefItem( title, parent, sect, param )
4560 setControl( myBgTool = new QtxBackgroundTool( 0 ) );
4566 QtxPagePrefBackgroundItem::~QtxPagePrefBackgroundItem()
4571 \brief Get allowed two-color gradients to the widget
4572 \param gradients gradients names are returned via this parameter
4573 \param ids gradients identifiers are returned via this parameter (empty list can be returned)
4575 void QtxPagePrefBackgroundItem::gradients( QStringList& gradList, QIntList& idList ) const
4577 myBgTool->gradients( gradList, idList );
4581 \brief Set allowed two-color gradients to the widget
4582 \param gradients gradients names
4583 \param ids optional gradients identifiers; if not specified, gradients are automatically numbered starting from 0
4585 void QtxPagePrefBackgroundItem::setGradients( const QStringList& gradients, const QIntList& ids )
4587 myBgTool->setGradients( gradients, ids );
4591 \brief Check if specific background mode is allowed
4592 \param mode background mode
4593 \return \c true if specified background mode is enabled or \c false otherwise
4594 \sa setModeAllowed()
4596 bool QtxPagePrefBackgroundItem::isModeAllowed( Qtx::BackgroundMode mode ) const
4598 return myBgTool->isModeAllowed( mode );
4602 \brief Enable / disable specific background mode
4603 \param mode background mode
4604 \param on enable / disable flag
4607 void QtxPagePrefBackgroundItem::setModeAllowed( Qtx::BackgroundMode mode, bool on )
4609 myBgTool->setModeAllowed( mode, on );
4613 \brief Check if specific texture mode is allowed
4614 \param mode texture mode
4615 \return \c true if specified texture mode is enabled or \c false otherwise
4616 \sa setTextureModeAllowed(), setTextureAllowed()
4618 bool QtxPagePrefBackgroundItem::isTextureModeAllowed( Qtx::TextureMode mode ) const
4620 return myBgTool->isTextureModeAllowed( mode );
4624 \brief Enable / disable specific texture mode
4625 \param mode texture mode
4626 \param on enable / disable flag (\c true by default)
4627 \sa isTextureModeAllowed(), setTextureAllowed()
4629 void QtxPagePrefBackgroundItem::setTextureModeAllowed( Qtx::TextureMode mode, bool on )
4631 myBgTool->setTextureModeAllowed( mode, on );
4635 \brief Check if texture controls are allowed (shown)
4636 \return \c true if texture controls are enabled or \c false otherwise
4637 \sa setTextureAllowed(), setTextureModeAllowed()
4639 bool QtxPagePrefBackgroundItem::isTextureAllowed() const
4641 return myBgTool->isTextureAllowed();
4645 \brief Enable / disable texture controls
4646 \param on enable / disable flag (\c true by default)
4647 \sa isTextureAllowed(), setTextureModeAllowed()
4649 void QtxPagePrefBackgroundItem::setTextureAllowed( bool on )
4651 myBgTool->setTextureAllowed( on );
4655 \brief Get allowed image formats
4656 \return image formats
4658 QString QtxPagePrefBackgroundItem::imageFormats() const
4660 return myBgTool->imageFormats();
4664 \brief Set allowed image formats
4665 \param formats image formats
4667 void QtxPagePrefBackgroundItem::setImageFormats( const QString& formats )
4669 myBgTool->setImageFormats( formats );
4673 \brief Get widget editor orientation
4676 Qt::Orientation QtxPagePrefBackgroundItem::orientation() const
4678 return myBgTool->orientation();
4682 \brief Set widget editor orientation
4683 \param o orientation
4685 void QtxPagePrefBackgroundItem::setOrientation( Qt::Orientation o )
4687 myBgTool->setOrientation( o );
4691 \brief Store preference item to the resource manager.
4694 void QtxPagePrefBackgroundItem::store()
4696 setString( Qtx::backgroundToString( myBgTool->data() ) );
4700 \brief Retrieve preference item from the resource manager.
4703 void QtxPagePrefBackgroundItem::retrieve()
4705 myBgTool->setData( Qtx::stringToBackground( getString() ) );
4709 \brief Get preference item option value.
4710 \param name option name
4711 \return property value or null QVariant if option is not set
4712 \sa setOptionValue()
4714 QVariant QtxPagePrefBackgroundItem::optionValue( const QString& name ) const
4716 if ( name == "texture_enabled" )
4717 return isTextureAllowed();
4718 else if ( name == "color_enabled" )
4719 return isModeAllowed( Qtx::ColorBackground );
4720 else if ( name == "gradient_enabled" )
4721 return isModeAllowed( Qtx::SimpleGradientBackground );
4722 else if ( name == "custom_enabled" )
4723 return isModeAllowed( Qtx::CustomGradientBackground );
4724 else if ( name == "texture_center_enabled" )
4725 return isTextureModeAllowed( Qtx::CenterTexture );
4726 else if ( name == "texture_tile_enabled" )
4727 return isTextureModeAllowed( Qtx::TileTexture );
4728 else if ( name == "texture_stretch_enabled" )
4729 return isTextureModeAllowed( Qtx::StretchTexture );
4730 else if ( name == "orientation" )
4731 return orientation();
4732 else if ( name == "image_formats" )
4733 return imageFormats();
4734 else if ( name == "gradient_names" ) {
4737 gradients( grList, idList );
4740 else if ( name == "gradient_ids" ) {
4743 gradients( grList, idList );
4744 QList<QVariant> lst;
4745 for ( QIntList::const_iterator it = idList.begin(); it != idList.end(); ++it )
4750 return QtxPageNamedPrefItem::optionValue( name );
4754 \brief Set preference item option value.
4755 \param name option name
4756 \param val new property value
4759 void QtxPagePrefBackgroundItem::setOptionValue( const QString& name, const QVariant& val )
4761 if ( name == "texture_enabled" ) {
4762 if ( val.canConvert( QVariant::Bool ) )
4763 setTextureAllowed( val.toBool() );
4765 else if ( name == "color_enabled" ) {
4766 if ( val.canConvert( QVariant::Bool ) )
4767 setModeAllowed( Qtx::ColorBackground, val.toBool() );
4769 else if ( name == "gradient_enabled" ) {
4770 if ( val.canConvert( QVariant::Bool ) )
4771 setModeAllowed( Qtx::SimpleGradientBackground, val.toBool() );
4773 else if ( name == "custom_enabled" ) {
4774 if ( val.canConvert( QVariant::Bool ) )
4775 setModeAllowed( Qtx::CustomGradientBackground, val.toBool() );
4777 else if ( name == "texture_center_enabled" ) {
4778 if ( val.canConvert( QVariant::Bool ) )
4779 setTextureModeAllowed( Qtx::CenterTexture, val.toBool() );
4781 else if ( name == "texture_tile_enabled" ) {
4782 if ( val.canConvert( QVariant::Bool ) )
4783 setTextureModeAllowed( Qtx::TileTexture, val.toBool() );
4785 else if ( name == "texture_stretch_enabled" ) {
4786 if ( val.canConvert( QVariant::Bool ) )
4787 setTextureModeAllowed( Qtx::StretchTexture, val.toBool() );
4789 else if ( name == "orientation" ) {
4790 if ( val.canConvert( QVariant::Int ) )
4791 setOrientation( (Qt::Orientation)val.toInt() );
4793 else if ( name == "image_formats" ) {
4794 if ( val.canConvert( QVariant::String ) )
4795 setImageFormats( val.toString() );
4797 else if ( name == "gradient_names" ) {
4798 if ( val.canConvert( QVariant::StringList ) )
4799 setGradients( val.toStringList() );
4801 else if ( name == "gradient_ids" ) {
4802 if ( val.canConvert( QVariant::List ) ) {
4805 gradients( grList, idList );
4807 QList<QVariant> varList = val.toList();
4808 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it ) {
4809 if ( (*it).canConvert( QVariant::Int ) )
4810 idList.append( (*it).toInt() );
4812 setGradients( grList, idList );
4816 QtxPageNamedPrefItem::setOptionValue( name, val );
4822 Creates preference item of user defined widget. The item widget has to be inherited from
4823 QtxUserDefinedContent class. An instance of this class has to be installed into the item
4824 with help of setContent method. Methods optionValue and setOptionValue use pointer on the
4825 content widget an qint64 value.
4827 \param parent parent preference item
4829 QtxUserDefinedItem::QtxUserDefinedItem( QtxPreferenceItem* parent )
4830 : QtxPageNamedPrefItem(QString(), parent), myContent(0)
4835 \brief Lets to Store preferences for content instance
4838 void QtxUserDefinedItem::store()
4841 myContent->store( resourceMgr(), preferenceMgr());
4846 \brief Lets to Retrieve preferences for content instance
4849 void QtxUserDefinedItem::retrieve()
4852 myContent->retrieve( resourceMgr(), preferenceMgr());
4857 * \brief Returns option value
4858 * \param theName is a string "content"
4859 * \return pointer on QtxUserDefinedContent class instance as a qint64 value
4861 QVariant QtxUserDefinedItem::optionValue( const QString& theName ) const
4863 if ( theName == "content" )
4864 return (qint64) myContent;
4866 return QtxPreferenceItem::optionValue( theName );
4870 * \brief Sets option value
4871 * \param theName is a string "content"
4872 * \param theVal is a pointer on QtxUserDefinedContent class instance represented as qint64 value
4874 void QtxUserDefinedItem::setOptionValue( const QString& theName, const QVariant& theVal)
4876 if ( theName == "content" ) {
4877 if ( theVal.canConvert( QVariant::ULongLong ) ) {
4878 setContent( (QtxUserDefinedContent*)theVal.toULongLong() );
4881 QtxPreferenceItem::setOptionValue( theName, theVal );
4885 * \brief Defines content of the property item as a Widget which has to be inherited from
4886 * QtxUserDefinedContent class.
4887 * \param theContent is an QtxUserDefinedContent class instance.
4889 void QtxUserDefinedItem::setContent( QtxUserDefinedContent* theContent )
4891 myContent = theContent;
4892 setControl(myContent);