1 // Copyright (C) 2007-2014 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 QLayout* l = widget() ? widget()->layout() : 0;
1347 for ( int i = 0; l && i < l->count() && !s; i++ )
1348 s = l->itemAt( i )->spacerItem();
1351 s->changeSize( 0, 0, QSizePolicy::Minimum, on ? QSizePolicy::Expanding : QSizePolicy::Minimum );
1355 \brief Get preference item option value.
1356 \param name option name
1357 \return property value or null QVariant if option is not set
1358 \sa setOptionValue()
1360 QVariant QtxPagePrefFrameItem::optionValue( const QString& name ) const
1362 if ( name == "margin" )
1364 else if ( name == "spacing" )
1366 else if ( name == "columns" )
1368 else if ( name == "orientation" )
1369 return orientation();
1370 else if ( name == "stretch" )
1373 return QtxPagePrefItem::optionValue( name );
1377 \brief Set preference item option value.
1378 \param name option name
1379 \param val new property value
1382 void QtxPagePrefFrameItem::setOptionValue( const QString& name, const QVariant& val )
1384 if ( name == "margin" )
1386 if ( val.canConvert( QVariant::Int ) )
1387 setMargin( val.toInt() );
1389 else if ( name == "spacing" )
1391 if ( val.canConvert( QVariant::Int ) )
1392 setSpacing( val.toInt() );
1394 else if ( name == "columns" )
1396 if ( val.canConvert( QVariant::Int ) )
1397 setColumns( val.toInt() );
1399 else if ( name == "orientation" )
1401 if ( val.canConvert( QVariant::Int ) )
1402 setOrientation( (Qt::Orientation)val.toInt() );
1404 else if ( name == "stretch" )
1406 if ( val.canConvert( QVariant::Bool ) )
1407 setStretch( val.toBool() );
1410 QtxPagePrefItem::setOptionValue( name, val );
1413 void QtxPagePrefFrameItem::widgetShown()
1415 QtxPagePrefItem::widgetShown();
1417 QtxPageNamedPrefItem::adjustLabels( this );
1421 \brief Update frame widget.
1423 void QtxPagePrefFrameItem::updateFrame()
1425 QList<QtxPagePrefItem*> items;
1426 pageChildItems( items );
1428 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1430 QWidget* wid = (*it)->widget();
1434 if ( wid->parent() != myBox )
1435 wid->setParent( myBox );
1440 \class QtxPagePrefGroupItem
1441 \brief GUI implementation of the group widget container.
1446 \param title preference item title
1447 \param parent parent preference item
1448 \param sect resource file section associated with the preference item
1449 \param param resource file parameter associated with the preference item
1451 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const QString& title, QtxPreferenceItem* parent,
1452 const QString& sect, const QString& param )
1453 : QtxPagePrefItem( title, parent, sect, param )
1455 myGroup = new QtxGroupBox( title, 0 );
1456 myBox = new QtxGridBox( 1, Qt::Horizontal, myGroup, 5, 5 );
1457 myGroup->setWidget( myBox );
1459 setWidget( myGroup );
1466 \param cols columns number
1467 \param title preference item title
1468 \param parent parent preference item
1469 \param sect resource file section associated with the preference item
1470 \param param resource file parameter associated with the preference item
1472 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const int cols, const QString& title, QtxPreferenceItem* parent,
1473 const QString& sect, const QString& param )
1474 : QtxPagePrefItem( title, parent, sect, param )
1476 myGroup = new QtxGroupBox( title, 0 );
1477 myBox = new QtxGridBox( cols, Qt::Horizontal, myGroup, 5, 5 );
1478 myGroup->setWidget( myBox );
1480 setWidget( myGroup );
1488 QtxPagePrefGroupItem::~QtxPagePrefGroupItem()
1493 \brief Assign resource file settings to the preference item.
1494 \param sect resource file section name
1495 \param param resource file parameter name
1498 void QtxPagePrefGroupItem::setResource( const QString& sect, const QString& param )
1500 QtxPagePrefItem::setResource( sect, param );
1505 \brief Update widget contents.
1507 void QtxPagePrefGroupItem::updateContents()
1509 QtxPagePrefItem::updateContents();
1511 myGroup->setTitle( title() );
1516 QtxPageNamedPrefItem::adjustLabels( this );
1520 \brief Get group box margin.
1521 \return current group box margin
1524 int QtxPagePrefGroupItem::margin() const
1526 return myBox->insideMargin();
1530 \brief Get group box margin.
1531 \param m new group box margin
1534 void QtxPagePrefGroupItem::setMargin( const int m )
1536 myBox->setInsideMargin( m );
1540 \brief Get group box spacing.
1541 \return current group box spacing
1544 int QtxPagePrefGroupItem::spacing() const
1546 return myBox->insideSpacing();
1550 \brief Set group box spacing.
1551 \param s new group box spacing
1554 void QtxPagePrefGroupItem::setSpacing( const int s )
1556 myBox->setInsideSpacing( s );
1560 \brief Get number of group box columns.
1561 \return current columns number
1564 int QtxPagePrefGroupItem::columns() const
1566 return myBox->columns();
1570 \brief Set number of group box columns.
1571 \param c new columns number
1574 void QtxPagePrefGroupItem::setColumns( const int c )
1576 myBox->setColumns( c );
1580 \brief Get group box orientation.
1581 \return current group box orientation
1582 \sa setOrientation()
1584 Qt::Orientation QtxPagePrefGroupItem::orientation() const
1586 return myBox->orientation();
1590 \brief Set group box orientation.
1591 \param o new group box orientation
1594 void QtxPagePrefGroupItem::setOrientation( const Qt::Orientation o )
1596 myBox->setOrientation( o );
1600 \brief Get 'flat' flag of the group box widget.
1601 \return \c true if the group box is flat
1603 bool QtxPagePrefGroupItem::isFlat() const
1605 return myGroup->isFlat();
1609 \brief Get 'flat' flag of the group box widget.
1610 \param on if \c true the group box will be made flat
1612 void QtxPagePrefGroupItem::setFlat( const bool on )
1614 myGroup->setFlat( on );
1618 \brief Store preference item to the resource manager.
1621 void QtxPagePrefGroupItem::store()
1623 if ( myGroup->isCheckable() )
1624 setBoolean( myGroup->isChecked() );
1628 \brief Return widget contained grid layout of this group.
1630 QtxGridBox* QtxPagePrefGroupItem::gridBox() const
1636 \brief Retrieve preference item from the resource manager.
1639 void QtxPagePrefGroupItem::retrieve()
1641 if ( myGroup->isCheckable() )
1642 myGroup->setChecked( getBoolean() );
1646 \brief Get preference item option value.
1647 \param name option name
1648 \return property value or null QVariant if option is not set
1649 \sa setOptionValue()
1651 QVariant QtxPagePrefGroupItem::optionValue( const QString& name ) const
1653 if ( name == "margin" )
1655 else if ( name == "spacing" )
1657 else if ( name == "columns" )
1659 else if ( name == "orientation" )
1660 return orientation();
1661 else if ( name == "flat" )
1664 return QtxPagePrefItem::optionValue( name );
1668 \brief Set preference item option value.
1669 \param name option name
1670 \param val new property value
1673 void QtxPagePrefGroupItem::setOptionValue( const QString& name, const QVariant& val )
1675 if ( name == "margin" )
1677 if ( val.canConvert( QVariant::Int ) )
1678 setMargin( val.toInt() );
1680 else if ( name == "spacing" )
1682 if ( val.canConvert( QVariant::Int ) )
1683 setSpacing( val.toInt() );
1685 else if ( name == "columns" )
1687 if ( val.canConvert( QVariant::Int ) )
1688 setColumns( val.toInt() );
1690 else if ( name == "orientation" )
1692 if ( val.canConvert( QVariant::Int ) )
1693 setOrientation( (Qt::Orientation)val.toInt() );
1695 else if ( name == "flat" )
1697 if ( val.canConvert( QVariant::Bool ) )
1698 setFlat( val.toBool() );
1701 QtxPagePrefItem::setOptionValue( name, val );
1704 void QtxPagePrefGroupItem::widgetShown()
1706 QtxPagePrefItem::widgetShown();
1708 QtxPageNamedPrefItem::adjustLabels( this );
1712 \brief Update widget state.
1714 void QtxPagePrefGroupItem::updateState()
1716 QString section, param;
1717 resource( section, param );
1718 myGroup->setCheckable( !title().isEmpty() && !section.isEmpty() && !param.isEmpty() );
1722 \brief Update group box widget.
1724 void QtxPagePrefGroupItem::updateGroup()
1726 QList<QtxPagePrefItem*> items;
1727 pageChildItems( items );
1729 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1731 QWidget* wid = (*it)->widget();
1735 if ( wid->parent() != myBox )
1736 wid->setParent( myBox );
1741 \class QtxPagePrefLabelItem
1742 \brief Label item which can be used in the preferences editor dialog box.
1748 Creates label item with specified title.
1750 \param text label text
1751 \param parent parent preference item
1753 QtxPagePrefLabelItem::QtxPagePrefLabelItem( const QString& text, QtxPreferenceItem* parent )
1754 : QtxPagePrefItem( text, parent )
1756 setWidget( myLabel = new QLabel( text ) );
1759 QtxPagePrefLabelItem::QtxPagePrefLabelItem( Qt::Alignment align, const QString& text, QtxPreferenceItem* parent )
1760 : QtxPagePrefItem( text, parent )
1762 setWidget( myLabel = new QLabel( text ) );
1763 myLabel->setAlignment( align );
1766 QtxPagePrefLabelItem::~QtxPagePrefLabelItem()
1770 void QtxPagePrefLabelItem::setTitle( const QString& text )
1772 QtxPagePrefItem::setTitle( text );
1775 myLabel->setText( text );
1778 Qt::Alignment QtxPagePrefLabelItem::alignment() const
1780 return myLabel->alignment();
1783 void QtxPagePrefLabelItem::setAlignment( Qt::Alignment align )
1785 myLabel->setAlignment( align );
1788 QVariant QtxPagePrefLabelItem::optionValue( const QString& name ) const
1791 if ( name == "alignment" )
1792 val = (int)alignment();
1796 void QtxPagePrefLabelItem::setOptionValue( const QString& name, const QVariant& val )
1798 if ( name == "alignment" )
1800 if ( val.canConvert( QVariant::Int ) )
1801 setAlignment( (Qt::Alignment)val.toInt() );
1806 \class QtxPagePrefSpaceItem
1807 \brief Simple spacer item which can be used in the preferences
1814 Creates spacer item with zero width and height and expanding
1815 on both directions (by height and width).
1817 \param parent parent preference item
1819 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( QtxPreferenceItem* parent )
1820 : QtxPagePrefItem( QString(), parent )
1822 initialize( 0, 0, 1, 1 );
1828 Creates spacer item with zero width and height and expanding
1829 according to the specified orientation.
1831 \param o spacer orientation
1832 \param parent parent preference item
1834 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( Qt::Orientation o, QtxPreferenceItem* parent )
1835 : QtxPagePrefItem( QString(), parent )
1837 if ( o == Qt::Horizontal )
1838 initialize( 0, 0, 1, 0 );
1840 initialize( 0, 0, 0, 1 );
1846 Creates spacer item with specified width and height. The spacing
1847 item is expanding horizontally if \a w <= 0 and vertically
1850 \param w spacer width
1851 \param h spacer height
1852 \param parent parent preference item
1854 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( const int w, const int h, QtxPreferenceItem* parent )
1855 : QtxPagePrefItem( QString(), parent )
1857 initialize( w, h, w > 0 ? 0 : 1, h > 0 ? 0 : 1 );
1863 QtxPagePrefSpaceItem::~QtxPagePrefSpaceItem()
1868 \brief Get spacer item size for the specified direction.
1870 \return size for the specified direction
1873 int QtxPagePrefSpaceItem::size( Qt::Orientation o ) const
1875 return o == Qt::Horizontal ? widget()->minimumWidth() : widget()->minimumHeight();
1879 \brief Set spacer item size for the specified direction.
1881 \param sz new size for the specified direction
1884 void QtxPagePrefSpaceItem::setSize( Qt::Orientation o, const int sz )
1886 if ( o == Qt::Horizontal )
1887 widget()->setMinimumWidth( sz );
1889 widget()->setMinimumHeight( sz );
1893 \brief Get spacer item stretch factor for the specified direction.
1895 \return stretch factor for the specified direction
1898 int QtxPagePrefSpaceItem::stretch( Qt::Orientation o ) const
1900 QSizePolicy sp = widget()->sizePolicy();
1901 return o == Qt::Horizontal ? sp.horizontalStretch() : sp.verticalStretch();
1905 \brief Set spacer item stretch factor for the specified direction.
1907 \param sf new stretch factor for the specified direction
1910 void QtxPagePrefSpaceItem::setStretch( Qt::Orientation o, const int sf )
1912 QSizePolicy sp = widget()->sizePolicy();
1913 if ( o == Qt::Horizontal )
1915 sp.setHorizontalStretch( sf );
1916 sp.setHorizontalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1920 sp.setVerticalStretch( sf );
1921 sp.setVerticalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1924 widget()->setSizePolicy( sp );
1928 \brief Get preference item option value.
1929 \param name option name
1930 \return property value or null QVariant if option is not set
1931 \sa setOptionValue()
1933 QVariant QtxPagePrefSpaceItem::optionValue( const QString& name ) const
1935 if ( name == "horizontal_size" || name == "hsize" )
1936 return size( Qt::Horizontal );
1937 else if ( name == "vertical_size" || name == "vsize" )
1938 return size( Qt::Vertical );
1939 else if ( name == "horizontal_stretch" || name == "hstretch" )
1940 return stretch( Qt::Horizontal );
1941 else if ( name == "vertical_stretch" || name == "vstretch" )
1942 return stretch( Qt::Vertical );
1944 return QtxPagePrefItem::optionValue( name );
1948 \brief Set preference item option value.
1949 \param name option name
1950 \param val new property value
1953 void QtxPagePrefSpaceItem::setOptionValue( const QString& name, const QVariant& val )
1955 if ( name == "horizontal_size" || name == "hsize" )
1957 if ( val.canConvert( QVariant::Int ) )
1958 setSize( Qt::Horizontal, val.toInt() );
1960 else if ( name == "vertical_size" || name == "vsize" )
1962 if ( val.canConvert( QVariant::Int ) )
1963 setSize( Qt::Vertical, val.toInt() );
1965 else if ( name == "horizontal_stretch" || name == "hstretch" )
1967 if ( val.canConvert( QVariant::Int ) )
1968 setStretch( Qt::Horizontal, val.toInt() );
1970 else if ( name == "vertical_stretch" || name == "vstretch" )
1972 if ( val.canConvert( QVariant::Int ) )
1973 setStretch( Qt::Vertical, val.toInt() );
1976 QtxPagePrefItem::setOptionValue( name, val );
1980 \brief Perform internal initialization.
1981 \param w spacer item width
1982 \param h spacer item height
1983 \param ws spacer item horizontal stretch factor
1984 \param hs spacer item vertical stretch factor
1986 void QtxPagePrefSpaceItem::initialize( const int w, const int h, const int hs, const int vs )
1989 sp.setHorizontalPolicy( hs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1990 sp.setVerticalPolicy( vs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1992 sp.setHorizontalStretch( hs );
1993 sp.setVerticalStretch( vs );
1995 QWidget* wid = new QWidget();
1996 wid->setSizePolicy( sp );
1998 wid->setMinimumSize( w, h );
2004 \class QtxPagePrefCheckItem
2005 \brief GUI implementation of the resources check box item (boolean).
2010 \param title preference item title
2011 \param parent parent preference item
2012 \param sect resource file section associated with the preference item
2013 \param param resource file parameter associated with the preference item
2015 QtxPagePrefCheckItem::QtxPagePrefCheckItem( const QString& title, QtxPreferenceItem* parent,
2016 const QString& sect, const QString& param )
2018 : QtxPagePrefItem( title, parent, sect, param )
2020 myCheck = new QCheckBox( title );
2021 myCheck->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
2022 setWidget( myCheck );
2028 QtxPagePrefCheckItem::~QtxPagePrefCheckItem()
2033 \brief Set preference item title.
2034 \param txt new preference title.
2036 void QtxPagePrefCheckItem::setTitle( const QString& txt )
2038 QtxPagePrefItem::setTitle( txt );
2040 myCheck->setText( title() );
2044 \brief Store preference item to the resource manager.
2047 void QtxPagePrefCheckItem::store()
2049 setBoolean( myCheck->isChecked() );
2053 \brief Retrieve preference item from the resource manager.
2056 void QtxPagePrefCheckItem::retrieve()
2058 myCheck->setChecked( getBoolean() );
2062 \class QtxPagePrefEditItem
2063 \brief GUI implementation of the resources line edit box item
2064 for string, integer and double values.
2067 static void fixupAndSet( QLineEdit* le, const QString& txt )
2071 if ( le->validator() ) {
2072 const QDoubleValidator* de = dynamic_cast<const QDoubleValidator*>( le->validator() );
2074 int dec = de->decimals();
2075 int idx = val.lastIndexOf( QRegExp( QString("[.|%1]").arg( le->locale().decimalPoint () ) ) );
2077 QString tmp = val.mid( idx+1 );
2079 val = val.left( idx+1 );
2080 idx = tmp.indexOf( QRegExp( QString("[e|E]") ) );
2082 exp = tmp.mid( idx );
2083 tmp = tmp.left( idx );
2085 tmp.truncate( dec );
2086 val = val + tmp + exp;
2090 if ( le->validator()->validate( val, pos ) == QValidator::Invalid )
2100 Creates preference item for string value editing.
2102 \param title preference item title
2103 \param parent parent preference item
2104 \param sect resource file section associated with the preference item
2105 \param param resource file parameter associated with the preference item
2107 QtxPagePrefEditItem::QtxPagePrefEditItem( const QString& title, QtxPreferenceItem* parent,
2108 const QString& sect, const QString& param )
2109 : QtxPageNamedPrefItem( title, parent, sect, param ),
2114 setControl( myEditor = new QLineEdit() );
2121 Creates preference item for editing of the value which type
2122 is specified by parameter \a type.
2124 \param type preference item input type (QtxPagePrefEditItem::InputType)
2125 \param title preference item title
2126 \param parent parent preference item
2127 \param sect resource file section associated with the preference item
2128 \param param resource file parameter associated with the preference item
2130 QtxPagePrefEditItem::QtxPagePrefEditItem( const int type, const QString& title,
2131 QtxPreferenceItem* parent, const QString& sect,
2132 const QString& param )
2133 : QtxPageNamedPrefItem( title, parent, sect, param ),
2138 setControl( myEditor = new QLineEdit() );
2145 QtxPagePrefEditItem::~QtxPagePrefEditItem()
2150 \brief Get edit box preference item input type.
2151 \return preference item input type (QtxPagePrefEditItem::InputType)
2154 int QtxPagePrefEditItem::inputType() const
2160 \brief Set edit box preference item input type.
2161 \param type new preference item input type (QtxPagePrefEditItem::InputType)
2164 void QtxPagePrefEditItem::setInputType( const int type )
2166 if ( myType == type )
2174 \brief Get number of digits after decimal point (for Double input type)
2175 \return preference item decimals value
2178 int QtxPagePrefEditItem::decimals() const
2184 \brief Set number of digits after decimal point (for Double input type)
2185 \param dec new preference item decimals value
2188 void QtxPagePrefEditItem::setDecimals( const int dec )
2190 if ( myDecimals == dec )
2198 \brief Get the line edit's echo mode
2199 \return preference item echo mode value
2202 int QtxPagePrefEditItem::echoMode() const
2208 \brief Set the line edit's echo mode
2209 \param echo new preference item echo mode value
2212 void QtxPagePrefEditItem::setEchoMode( const int echo )
2214 if ( myEchoMode == echo )
2222 \brief Store preference item to the resource manager.
2225 void QtxPagePrefEditItem::store()
2227 setString( myEditor->text() );
2231 \brief Retrieve preference item from the resource manager.
2234 void QtxPagePrefEditItem::retrieve()
2236 QString txt = getString();
2237 fixupAndSet( myEditor, txt );
2241 \brief Get preference item option value.
2242 \param name option name
2243 \return property value or null QVariant if option is not set
2244 \sa setOptionValue()
2246 QVariant QtxPagePrefEditItem::optionValue( const QString& name ) const
2248 if ( name == "input_type" || name == "type" )
2250 else if ( name == "precision" || name == "prec" || name == "decimals" )
2252 else if ( name == "echo" || name == "echo_mode" || name == "echomode")
2255 return QtxPageNamedPrefItem::optionValue( name );
2259 \brief Set preference item option value.
2260 \param name option name
2261 \param val new property value
2264 void QtxPagePrefEditItem::setOptionValue( const QString& name, const QVariant& val )
2266 if ( name == "input_type" || name == "type" )
2268 if ( val.canConvert( QVariant::Int ) )
2269 setInputType( val.toInt() );
2271 else if ( name == "precision" || name == "prec" || name == "decimals" ) {
2272 if ( val.canConvert( QVariant::Int ) )
2273 setDecimals( val.toInt() );
2275 else if ( name == "echo" || name == "echo_mode" || name == "echomode") {
2276 if ( val.canConvert( QVariant::Int ) )
2277 setEchoMode( val.toInt() );
2280 QtxPageNamedPrefItem::setOptionValue( name, val );
2284 \brief Update edit box widget.
2286 void QtxPagePrefEditItem::updateEditor()
2291 myEditor->setEchoMode(QLineEdit::Normal);
2294 myEditor->setEchoMode(QLineEdit::NoEcho);
2297 myEditor->setEchoMode(QLineEdit::Password);
2300 myEditor->setEchoMode(QLineEdit::PasswordEchoOnEdit);
2303 myEditor->setEchoMode(QLineEdit::Normal);
2306 QValidator* val = 0;
2307 switch ( inputType() )
2310 val = new QIntValidator( myEditor );
2313 val = new QDoubleValidator( myEditor );
2314 dynamic_cast<QDoubleValidator*>( val )->setDecimals( myDecimals < 0 ? 1000 : myDecimals );
2320 QString txt = myEditor->text();
2321 delete myEditor->validator();
2322 myEditor->setValidator( val );
2323 fixupAndSet( myEditor, txt );
2327 \class QtxPagePrefSliderItem
2333 Creates preference item with slider widget
2335 \param title preference item title
2336 \param parent parent preference item
2337 \param sect resource file section associated with the preference item
2338 \param param resource file parameter associated with the preference item
2340 QtxPagePrefSliderItem::QtxPagePrefSliderItem( const QString& title, QtxPreferenceItem* parent,
2341 const QString& sect, const QString& param )
2342 : QtxPageNamedPrefItem( title, parent, sect, param )
2344 setControl( mySlider = new QSlider( Qt::Horizontal ) );
2345 widget()->layout()->addWidget( myLabel = new QLabel( ) );
2352 mySlider->setTickPosition( QSlider::TicksBothSides );
2354 connect (mySlider, SIGNAL(valueChanged(int)), this, SLOT(setIcon(int)));
2361 QtxPagePrefSliderItem::~QtxPagePrefSliderItem()
2366 \brief Get slider preference item step value.
2367 \return slider single step value
2370 int QtxPagePrefSliderItem::singleStep() const
2372 return mySlider->singleStep();
2376 \brief Get slider preference item step value.
2377 \return slider page step value
2380 int QtxPagePrefSliderItem::pageStep() const
2382 return mySlider->pageStep();
2386 \brief Get slider preference item minimum value.
2387 \return slider minimum value
2390 int QtxPagePrefSliderItem::minimum() const
2392 return mySlider->minimum();
2396 \brief Get slider preference item maximum value.
2397 \return slider maximum value
2400 int QtxPagePrefSliderItem::maximum() const
2402 return mySlider->maximum();
2406 \brief Get the list of the icons associated with the selection widget items
2407 \return list of icons
2410 QList<QIcon> QtxPagePrefSliderItem::icons() const
2416 \brief Set slider preference item step value.
2417 \param step new slider single step value
2420 void QtxPagePrefSliderItem::setSingleStep( const int& step )
2422 mySlider->setSingleStep( step );
2426 \brief Set slider preference item step value.
2427 \param step new slider single step value
2430 void QtxPagePrefSliderItem::setPageStep( const int& step )
2432 mySlider->setPageStep( step );
2436 \brief Set slider preference item minimum value.
2437 \param min new slider minimum value
2440 void QtxPagePrefSliderItem::setMinimum( const int& min )
2442 mySlider->setMinimum( min );
2443 setIcon( mySlider->value() );
2447 \brief Set slider preference item maximum value.
2448 \param max new slider maximum value
2451 void QtxPagePrefSliderItem::setMaximum( const int& max )
2453 mySlider->setMaximum( max );
2454 setIcon( mySlider->value() );
2458 \brief Set the list of the icons to the selection widget items
2459 \param icns new list of icons
2462 void QtxPagePrefSliderItem::setIcons( const QList<QIcon>& icns )
2464 if ( icns.isEmpty() )
2468 QSize maxsize(0, 0);
2469 for ( QList<QIcon>::const_iterator it = myIcons.begin(); it != myIcons.end(); ++it ) {
2470 if ( (*it).isNull() ) continue;
2471 maxsize = maxsize.expandedTo( (*it).availableSizes().first() );
2473 myLabel->setFixedSize( maxsize );
2479 \brief Store preference item to the resource manager.
2482 void QtxPagePrefSliderItem::store()
2484 setInteger( mySlider->value() );
2488 \brief Retrieve preference item from the resource manager.
2491 void QtxPagePrefSliderItem::retrieve()
2493 mySlider->setValue( getInteger( mySlider->value() ) );
2497 \brief Get preference item option value.
2498 \param name option name
2499 \return property value or null integer if option is not set
2500 \sa setOptionValue()
2502 QVariant QtxPagePrefSliderItem::optionValue( const QString& name ) const
2504 if ( name == "minimum" || name == "min" )
2506 else if ( name == "maximum" || name == "max" )
2508 else if ( name == "single_step" )
2509 return singleStep();
2510 else if ( name == "page_step" )
2512 else if ( name == "icons" || name == "pixmaps" )
2514 QList<QVariant> lst;
2515 QList<QIcon> ics = icons();
2516 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2521 return QtxPageNamedPrefItem::optionValue( name );
2525 \brief Set preference item option value.
2526 \param name option name
2527 \param val new property value
2530 void QtxPagePrefSliderItem::setOptionValue( const QString& name, const QVariant& val )
2532 if ( val.canConvert( QVariant::Int ) )
2534 if ( name == "minimum" || name == "min" )
2535 setMinimum( val.toInt() );
2536 else if ( name == "maximum" || name == "max" )
2537 setMaximum( val.toInt() );
2538 else if ( name == "single_step" )
2539 setSingleStep( val.toInt() );
2540 else if ( name == "page_step" )
2541 setPageStep( val.toInt() );
2543 QtxPageNamedPrefItem::setOptionValue( name, val );
2545 else if ( name == "icons" || name == "pixmaps" )
2548 QtxPageNamedPrefItem::setOptionValue( name, val );
2551 void QtxPagePrefSliderItem::setIcon( int pos )
2553 int index = pos - mySlider->minimum();
2554 if ( !myIcons.isEmpty() && index >= 0 && index < myIcons.size() && !myIcons[index].isNull() )
2555 myLabel->setPixmap( myIcons[index].pixmap( myIcons[index].availableSizes().first() ) );
2561 \brief Update slider widget.
2563 void QtxPagePrefSliderItem::updateSlider()
2565 int val = mySlider->value();
2566 int stp = singleStep();
2567 int ptp = pageStep();
2568 int min = minimum();
2569 int max = maximum();
2571 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2572 mySlider->setFocusPolicy(Qt::StrongFocus);
2574 mySlider->setValue( val );
2575 setSingleStep( stp );
2580 myLabel->setVisible( !myIcons.empty() );
2581 widget()->layout()->setSpacing( !myIcons.empty() ? 6 : 0 );
2585 \brief Set the list of the icons from the resource manager.
2586 \param var new icons list
2589 void QtxPagePrefSliderItem::setIcons( const QVariant& var )
2591 if ( var.type() != QVariant::List )
2595 QList<QVariant> varList = var.toList();
2596 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2598 if ( (*it).canConvert<QIcon>() )
2599 lst.append( (*it).value<QIcon>() );
2600 else if ( (*it).canConvert<QPixmap>() )
2601 lst.append( (*it).value<QPixmap>() );
2603 lst.append( QIcon() );
2609 \class QtxPagePrefSelectItem
2610 \brief GUI implementation of the resources selector item
2611 (string, integer or double values list).
2613 All items in the list (represented as combo box) should be specified
2614 by the unique identifier which is stored to the resource file instead
2615 of the value itself.
2621 Creates preference item with combo box widget which is not editable
2622 (direct value entering is disabled).
2624 \param title preference item title
2625 \param parent parent preference item
2626 \param sect resource file section associated with the preference item
2627 \param param resource file parameter associated with the preference item
2629 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const QString& title, QtxPreferenceItem* parent,
2630 const QString& sect, const QString& param )
2631 : QtxPageNamedPrefItem( title, parent, sect, param ),
2634 setControl( mySelector = new QtxComboBox() );
2635 mySelector->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2636 mySelector->setDuplicatesEnabled( false );
2643 Creates preference item with combo box widget which is editable
2644 according to the specified input type (integer, double or string values).
2646 \param type input type (QtxPagePrefSelectItem::InputType)
2647 \param title preference item title
2648 \param parent parent preference item
2649 \param sect resource file section associated with the preference item
2650 \param param resource file parameter associated with the preference item
2652 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const int type, const QString& title, QtxPreferenceItem* parent,
2653 const QString& sect, const QString& param )
2654 : QtxPageNamedPrefItem( title, parent, sect, param ),
2657 setControl( mySelector = new QtxComboBox() );
2658 mySelector->setDuplicatesEnabled( false );
2665 QtxPagePrefSelectItem::~QtxPagePrefSelectItem()
2670 \brief Get edit box preference item input type.
2671 \return preference item input type (QtxPagePrefSelectItem::InputType)
2674 int QtxPagePrefSelectItem::inputType() const
2680 \brief Set edit box preference item input type.
2681 \param type new preference item input type (QtxPagePrefSelectItem::InputType)
2684 void QtxPagePrefSelectItem::setInputType( const int type )
2686 if ( myType == type )
2694 \brief Get the list of the values from the selection widget.
2695 \return list of values
2696 \sa numbers(), icons(), setStrings()
2698 QStringList QtxPagePrefSelectItem::strings() const
2701 for ( uint i = 0; i < mySelector->count(); i++ )
2702 res.append( mySelector->itemText( i ) );
2707 \brief Get the list of the values identifiers from the selection widget.
2708 \return list of values IDs
2709 \sa strings(), icons(), setNumbers()
2711 QList<int> QtxPagePrefSelectItem::numbers() const
2714 for ( uint i = 0; i < mySelector->count(); i++ )
2716 if ( mySelector->hasId( i ) )
2717 res.append( mySelector->id( i ) );
2723 \brief Get the list of the icons associated with the selection widget.items
2724 \return list of icons
2725 \sa strings(), numbers(), setIcons()
2727 QList<QIcon> QtxPagePrefSelectItem::icons() const
2730 for ( uint i = 0; i < mySelector->count(); i++ )
2731 res.append( mySelector->itemIcon( i ) );
2736 \brief Set the list of the values to the selection widget.
2737 \param lst new list of values
2738 \sa strings(), setNumbers(), setIcons()
2740 void QtxPagePrefSelectItem::setStrings( const QStringList& lst )
2742 mySelector->clear();
2743 mySelector->addItems( lst );
2747 \brief Set the list of the values identifiers to the selection widget
2748 \param ids new list of values IDs
2749 \sa numbers(), setStrings(), setIcons()
2751 void QtxPagePrefSelectItem::setNumbers( const QList<int>& ids )
2754 for ( QList<int>::const_iterator it = ids.begin(); it != ids.end(); ++it, i++ ) {
2755 if ( i >= mySelector->count() )
2756 mySelector->addItem(QString("") );
2758 mySelector->setId( i, *it );
2763 \brief Set the list of the icons to the selection widget items
2765 Important: call this method after setStrings() or setNumbers()
2767 \param icns new list of icons
2768 \sa icons(), setStrings(), setNumbers()
2770 void QtxPagePrefSelectItem::setIcons( const QList<QIcon>& icns )
2773 for ( QList<QIcon>::const_iterator it = icns.begin(); it != icns.end() && i < mySelector->count(); ++it, i++ )
2774 mySelector->setItemIcon( i, *it );
2778 \brief Store preference item to the resource manager.
2781 void QtxPagePrefSelectItem::store()
2783 if ( mySelector->isCleared() )
2786 int idx = mySelector->currentIndex();
2788 if ( mySelector->hasId( idx ) )
2789 setInteger( mySelector->id( idx ) );
2790 else if ( idx >= 0 )
2791 setString( mySelector->itemText( idx ) );
2795 \brief Retrieve preference item from the resource manager.
2798 void QtxPagePrefSelectItem::retrieve()
2800 QString txt = getString();
2805 int num = txt.toInt( &ok );
2807 idx = mySelector->index( num );
2810 for ( uint i = 0; i < mySelector->count() && idx == -1; i++ )
2812 if ( mySelector->itemText( i ) == txt )
2818 mySelector->setCurrentIndex( idx );
2819 else if ( mySelector->isEditable() )
2822 if ( mySelector->validator() &&
2823 mySelector->validator()->validate( txt, pos ) == QValidator::Invalid )
2824 mySelector->setCleared( true );
2827 mySelector->setCleared( false );
2828 mySelector->addItem( txt );
2829 mySelector->setCurrentIndex( mySelector->count() - 1 );
2835 \brief Get preference item option value.
2836 \param name option name
2837 \return property value or null QVariant if option is not set
2838 \sa setOptionValue()
2840 QVariant QtxPagePrefSelectItem::optionValue( const QString& name ) const
2842 if ( name == "input_type" || name == "type" )
2844 else if ( name == "strings" || name == "labels" )
2846 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2848 QList<QVariant> lst;
2849 QList<int> nums = numbers();
2850 for ( QList<int>::const_iterator it = nums.begin(); it != nums.end(); ++it )
2854 else if ( name == "icons" || name == "pixmaps" )
2856 QList<QVariant> lst;
2857 QList<QIcon> ics = icons();
2858 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2863 return QtxPageNamedPrefItem::optionValue( name );
2867 \brief Set preference item option value.
2868 \param name option name
2869 \param val new property value
2872 void QtxPagePrefSelectItem::setOptionValue( const QString& name, const QVariant& val )
2874 if ( name == "input_type" || name == "type" )
2876 if ( val.canConvert( QVariant::Int ) )
2877 setInputType( val.toInt() );
2879 else if ( name == "strings" || name == "labels" )
2881 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2883 else if ( name == "icons" || name == "pixmaps" )
2886 QtxPageNamedPrefItem::setOptionValue( name, val );
2890 \brief Set the list of the values from the resource manager.
2891 \param var new values list
2894 void QtxPagePrefSelectItem::setStrings( const QVariant& var )
2896 if ( var.type() != QVariant::StringList )
2899 setStrings( var.toStringList() );
2903 \brief Set the list of the values identifiers from the resource manager.
2904 \param var new values IDs list
2907 void QtxPagePrefSelectItem::setNumbers( const QVariant& var )
2909 if ( var.type() != QVariant::List )
2913 QList<QVariant> varList = var.toList();
2914 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2916 if ( (*it).canConvert( QVariant::Int ) )
2917 lst.append( (*it).toInt() );
2923 \brief Set the list of the icons from the resource manager.
2924 \param var new icons list
2927 void QtxPagePrefSelectItem::setIcons( const QVariant& var )
2929 if ( var.type() != QVariant::List )
2933 QList<QVariant> varList = var.toList();
2934 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2936 if ( (*it).canConvert<QIcon>() )
2937 lst.append( (*it).value<QIcon>() );
2938 else if ( (*it).canConvert<QPixmap>() )
2939 lst.append( (*it).value<QPixmap>() );
2941 lst.append( QIcon() );
2947 \brief Update selector widget.
2949 void QtxPagePrefSelectItem::updateSelector()
2951 QValidator* val = 0;
2952 switch ( inputType() )
2955 val = new QIntValidator( mySelector );
2958 val = new QDoubleValidator( mySelector );
2964 mySelector->setEditable( inputType() != NoInput );
2966 if ( mySelector->isEditable() && !mySelector->currentText().isEmpty() && val )
2969 QString str = mySelector->currentText();
2970 if ( val->validate( str, pos ) == QValidator::Invalid )
2971 mySelector->clearEditText();
2974 delete mySelector->validator();
2975 mySelector->setValidator( val );
2979 \class QtxPagePrefSpinItem
2980 \brief GUI implementation of the resources spin box item
2981 (for integer or double value).
2987 Creates spin box preference item for the entering integer values.
2989 \param title preference item title
2990 \param parent parent preference item
2991 \param sect resource file section associated with the preference item
2992 \param param resource file parameter associated with the preference item
2994 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const QString& title, QtxPreferenceItem* parent,
2995 const QString& sect, const QString& param )
2996 : QtxPageNamedPrefItem( title, parent, sect, param ),
3005 Creates spin box preference item for the entering values which type
3006 is specified by the parameter \a type.
3008 \param type input type (QtxPagePrefSpinItem::InputType).
3009 \param title preference item title
3010 \param parent parent preference item
3011 \param sect resource file section associated with the preference item
3012 \param param resource file parameter associated with the preference item
3014 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const int type, const QString& title,
3015 QtxPreferenceItem* parent, const QString& sect,
3016 const QString& param )
3017 : QtxPageNamedPrefItem( title, parent, sect, param ),
3026 QtxPagePrefSpinItem::~QtxPagePrefSpinItem()
3031 \brief Get spin box preference item input type.
3032 \return preference item input type (QtxPagePrefSpinItem::InputType)
3035 int QtxPagePrefSpinItem::inputType() const
3041 \brief Set spin box preference item input type.
3042 \param type new preference item input type (QtxPagePrefSpinItem::InputType)
3045 void QtxPagePrefSpinItem::setInputType( const int type )
3047 if ( myType == type )
3055 \brief Get spin box preference item step value.
3056 \return spin box single step value
3059 QVariant QtxPagePrefSpinItem::step() const
3061 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3062 return isb->singleStep();
3063 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3064 return dsb->singleStep();
3070 \brief Get double spin box preference item precision value.
3071 \return double spin box precision
3074 QVariant QtxPagePrefSpinItem::precision() const
3076 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3077 return dsb->decimals();
3083 \brief Get spin box preference item minimum value.
3084 \return spin box minimum value
3087 QVariant QtxPagePrefSpinItem::minimum() const
3089 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3090 return isb->minimum();
3091 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3092 return dsb->minimum();
3098 \brief Get spin box preference item maximum value.
3099 \return spin box maximum value
3102 QVariant QtxPagePrefSpinItem::maximum() const
3104 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3105 return isb->maximum();
3106 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3107 return dsb->maximum();
3113 \brief Get spin box preference item prefix string.
3114 \return spin box prefix string
3117 QString QtxPagePrefSpinItem::prefix() const
3119 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3120 return isb->prefix();
3121 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3122 return dsb->prefix();
3128 \brief Get spin box preference item suffix string.
3129 \return spin box suffix string
3132 QString QtxPagePrefSpinItem::suffix() const
3134 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3135 return isb->suffix();
3136 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3137 return dsb->suffix();
3143 \brief Get spin box preference item special value text (which is shown
3144 when the spin box reaches minimum value).
3145 \return spin box special value text
3146 \sa setSpecialValueText()
3148 QString QtxPagePrefSpinItem::specialValueText() const
3150 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3152 return sb->specialValueText();
3158 \brief Set spin box preference item step value.
3159 \param step new spin box single step value
3162 void QtxPagePrefSpinItem::setStep( const QVariant& step )
3164 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3166 if ( step.canConvert( QVariant::Int ) )
3167 isb->setSingleStep( step.toInt() );
3169 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3171 if ( step.canConvert( QVariant::Double ) )
3172 dsb->setSingleStep( step.toDouble() );
3177 \brief Set double spin box preference item precision value.
3178 \param step new double spin box precision value
3181 void QtxPagePrefSpinItem::setPrecision( const QVariant& prec )
3183 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3185 if ( prec.canConvert( QVariant::Int ) ) {
3186 dsb->setDecimals( qAbs( prec.toInt() ) );
3187 dsb->setPrecision( prec.toInt() );
3193 \brief Set spin box preference item minimum value.
3194 \param min new spin box minimum value
3197 void QtxPagePrefSpinItem::setMinimum( const QVariant& min )
3199 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3201 if ( min.canConvert( QVariant::Int ) )
3202 isb->setMinimum( min.toInt() );
3204 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3206 if ( min.canConvert( QVariant::Double ) )
3207 dsb->setMinimum( min.toDouble() );
3212 \brief Set spin box preference item maximum value.
3213 \param min new spin box maximum value
3216 void QtxPagePrefSpinItem::setMaximum( const QVariant& max )
3218 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3220 if ( max.canConvert( QVariant::Int ) )
3221 isb->setMaximum( max.toInt() );
3223 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3225 if ( max.canConvert( QVariant::Double ) )
3226 dsb->setMaximum( max.toDouble() );
3231 \brief Set spin box preference item prefix string.
3232 \param txt new spin box prefix string
3235 void QtxPagePrefSpinItem::setPrefix( const QString& txt )
3237 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3238 isb->setPrefix( txt );
3239 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3240 dsb->setPrefix( txt );
3244 \brief Set spin box preference item suffix string.
3245 \param txt new spin box suffix string
3248 void QtxPagePrefSpinItem::setSuffix( const QString& txt )
3250 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3251 isb->setSuffix( txt );
3252 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3253 dsb->setSuffix( txt );
3257 \brief Set spin box preference item special value text (which is shown
3258 when the spin box reaches minimum value).
3259 \param txt new spin box special value text
3260 \sa specialValueText()
3262 void QtxPagePrefSpinItem::setSpecialValueText( const QString& txt )
3264 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3266 sb->setSpecialValueText( txt );
3270 \brief Store preference item to the resource manager.
3273 void QtxPagePrefSpinItem::store()
3275 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3276 setInteger( isb->value() );
3277 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3278 setDouble( dsb->value() );
3282 \brief Retrieve preference item from the resource manager.
3285 void QtxPagePrefSpinItem::retrieve()
3287 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3288 isb->setValue( getInteger( isb->value() ) );
3289 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3290 dsb->setValue( getDouble( dsb->value() ) );
3294 \brief Get preference item option value.
3295 \param name option name
3296 \return property value or null QVariant if option is not set
3297 \sa setOptionValue()
3299 QVariant QtxPagePrefSpinItem::optionValue( const QString& name ) const
3301 if ( name == "input_type" || name == "type" )
3303 else if ( name == "minimum" || name == "min" )
3305 else if ( name == "maximum" || name == "max" )
3307 else if ( name == "step" )
3309 else if ( name == "precision" )
3311 else if ( name == "prefix" )
3313 else if ( name == "suffix" )
3315 else if ( name == "special" )
3316 return specialValueText();
3318 return QtxPageNamedPrefItem::optionValue( name );
3322 \brief Set preference item option value.
3323 \param name option name
3324 \param val new property value
3327 void QtxPagePrefSpinItem::setOptionValue( const QString& name, const QVariant& val )
3329 if ( name == "input_type" || name == "type" )
3331 if ( val.canConvert( QVariant::Int ) )
3332 setInputType( val.toInt() );
3334 else if ( name == "minimum" || name == "min" )
3336 else if ( name == "maximum" || name == "max" )
3338 else if ( name == "step" )
3340 else if ( name == "precision" )
3341 setPrecision( val );
3342 else if ( name == "prefix" )
3344 if ( val.canConvert( QVariant::String ) )
3345 setPrefix( val.toString() );
3347 else if ( name == "suffix" )
3349 if ( val.canConvert( QVariant::String ) )
3350 setSuffix( val.toString() );
3352 else if ( name == "special" )
3354 if ( val.canConvert( QVariant::String ) )
3355 setSpecialValueText( val.toString() );
3358 QtxPageNamedPrefItem::setOptionValue( name, val );
3362 \brief Update spin box widget.
3364 void QtxPagePrefSpinItem::updateSpinBox()
3367 QVariant stp = step();
3368 QVariant prec = precision();
3369 QVariant min = minimum();
3370 QVariant max = maximum();
3372 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3374 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3377 switch ( inputType() )
3380 setControl( new QtxIntSpinBox() );
3383 setControl( new QtxDoubleSpinBox() );
3389 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3392 setPrecision( prec );
3396 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3398 if ( val.canConvert( QVariant::Int ) )
3399 isb->setValue( val.toInt() );
3401 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3403 if ( val.canConvert( QVariant::Double ) )
3404 dsb->setValue( val.toDouble() );
3409 \class QtxPagePrefTextItem
3410 \brief GUI implementation of the resources text box edit item
3411 (for large text data).
3416 \param parent parent preference item
3417 \param sect resource file section associated with the preference item
3418 \param param resource file parameter associated with the preference item
3420 QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect,
3421 const QString& param )
3422 : QtxPageNamedPrefItem( QString(), parent, sect, param )
3424 myEditor = new QTextEdit();
3425 myEditor->setAcceptRichText( false );
3427 setControl( myEditor );
3432 \param title preference item title
3433 \param parent parent preference item
3434 \param sect resource file section associated with the preference item
3435 \param param resource file parameter associated with the preference item
3437 QtxPagePrefTextItem::QtxPagePrefTextItem( const QString& title, QtxPreferenceItem* parent,
3438 const QString& sect, const QString& param )
3439 : QtxPageNamedPrefItem( title, parent, sect, param )
3441 myEditor = new QTextEdit();
3442 myEditor->setAcceptRichText( false );
3444 setControl( myEditor );
3450 QtxPagePrefTextItem::~QtxPagePrefTextItem()
3455 \brief Store preference item to the resource manager.
3458 void QtxPagePrefTextItem::store()
3460 setString( myEditor->toPlainText() );
3464 \brief Retrieve preference item from the resource manager.
3467 void QtxPagePrefTextItem::retrieve()
3469 myEditor->setPlainText( getString() );
3473 \class QtxPagePrefColorItem
3474 \brief GUI implementation of the resources color item.
3479 \param title preference item title
3480 \param parent parent preference item
3481 \param sect resource file section associated with the preference item
3482 \param param resource file parameter associated with the preference item
3484 QtxPagePrefColorItem::QtxPagePrefColorItem( const QString& title, QtxPreferenceItem* parent,
3485 const QString& sect, const QString& param )
3486 : QtxPageNamedPrefItem( title, parent, sect, param )
3488 // QtxPagePrefGroupItem* aGroup 0; //= dynamic_cast<QtxPagePrefGroupItem*>( parent );
3490 // setControl( myColor = new QtxColorButton( aGroup ? aGroup->gridBox() : 0 ) );
3491 setControl( myColor = new QtxColorButton( 0 ) );
3492 myColor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3498 QtxPagePrefColorItem::~QtxPagePrefColorItem()
3503 \brief Store preference item to the resource manager.
3506 void QtxPagePrefColorItem::store()
3508 setColor( myColor->color() );
3512 \brief Retrieve preference item from the resource manager.
3515 void QtxPagePrefColorItem::retrieve()
3517 myColor->setColor( getColor() );
3521 \class QtxPagePrefBiColorItem
3522 \brief GUI implementation of the resources item to store a bi-color value.
3524 The main color is specified explicitly. The secondary color is calculated
3525 by changing "value" and "saturation" parameters of the main color in the
3526 HSV notation using specified delta.
3531 \param title preference item title
3532 \param parent parent preference item
3533 \param sect resource file section associated with the preference item
3534 \param param resource file parameter associated with the preference item
3536 QtxPagePrefBiColorItem::QtxPagePrefBiColorItem( const QString& title, QtxPreferenceItem* parent,
3537 const QString& sect, const QString& param )
3538 : QtxPageNamedPrefItem( title, parent, sect, param )
3540 setControl( myColors = new QtxBiColorTool( 0 ) );
3546 QtxPagePrefBiColorItem::~QtxPagePrefBiColorItem()
3551 \bried Get auxiliary text
3552 \return text assigned to the item
3555 QString QtxPagePrefBiColorItem::text() const
3557 return myColors->text();
3561 \bried Set auxiliary text
3562 \param t text being assigned to the item
3565 void QtxPagePrefBiColorItem::setText( const QString& t )
3567 myColors->setText( t );
3571 \brief Store preference item to the resource manager.
3574 void QtxPagePrefBiColorItem::store()
3576 setString( Qtx::biColorToString( myColors->mainColor(), myColors->delta() ) );
3580 \brief Retrieve preference item from the resource manager.
3583 void QtxPagePrefBiColorItem::retrieve()
3587 Qtx::stringToBiColor( getString(), c, d );
3588 myColors->setMainColor( c );
3589 myColors->setDelta( d );
3593 \brief Get preference item option value.
3594 \param name option name
3595 \return property value or null QVariant if option is not set
3596 \sa setOptionValue()
3598 QVariant QtxPagePrefBiColorItem::optionValue( const QString& name ) const
3600 if ( name == "text" )
3603 return QtxPageNamedPrefItem::optionValue( name );
3607 \brief Set preference item option value.
3608 \param name option name
3609 \param val new property value
3612 void QtxPagePrefBiColorItem::setOptionValue( const QString& name, const QVariant& val )
3614 if ( name == "text" )
3616 if ( val.canConvert( QVariant::String ) )
3617 setText( val.toString() );
3620 QtxPageNamedPrefItem::setOptionValue( name, val );
3624 \class QtxPagePrefFontItem
3625 \brief GUI implementation of the resources font item.
3630 \param feat font editor widget features (QtxFontEdit::Features)
3631 \param title preference item title
3632 \param parent parent preference item
3633 \param sect resource file section associated with the preference item
3634 \param param resource file parameter associated with the preference item
3636 QtxPagePrefFontItem::QtxPagePrefFontItem( const int feat, const QString& title,
3637 QtxPreferenceItem* parent, const QString& sect,
3638 const QString& param )
3639 : QtxPageNamedPrefItem( title, parent, sect, param )
3641 setControl( myFont = new QtxFontEdit( feat ) );
3646 \param title preference item title
3647 \param parent parent preference item
3648 \param sect resource file section associated with the preference item
3649 \param param resource file parameter associated with the preference item
3651 QtxPagePrefFontItem::QtxPagePrefFontItem( const QString& title, QtxPreferenceItem* parent,
3652 const QString& sect, const QString& param )
3653 : QtxPageNamedPrefItem( title, parent, sect, param )
3655 setControl( myFont = new QtxFontEdit() );
3661 QtxPagePrefFontItem::~QtxPagePrefFontItem()
3666 \brief Get font widget features.
3667 \return font widget features (ORed QtxFontEdit::Features flags)
3670 int QtxPagePrefFontItem::features() const
3672 return myFont->features();
3676 \brief Set font widget features.
3677 \param f new font widget features (ORed QtxFontEdit::Features flags)
3680 void QtxPagePrefFontItem::setFeatures( const int f )
3682 myFont->setFeatures( f );
3686 \brief Specifies whether widget works in Native or Custom mode. Native mode
3687 is intended for working with system fonts. Custom mode is intended for
3688 working with manually defined set of fonts. Set of custom fonts can be
3689 specified with setFonts() method
3690 \param mode mode from QtxFontEdit::Mode enumeration
3693 void QtxPagePrefFontItem::setMode( const int mode )
3695 myFont->setMode( mode );
3699 \brief Verifies whether widget works in Native or Custom mode
3700 \return Native or Custom mode
3703 int QtxPagePrefFontItem::mode() const
3705 return myFont->mode();
3709 \brief Sets list of custom fonts.
3710 <b>This method is intended for working in Custom mode only.</b>
3711 \param fams list of families
3712 \sa fonts(), setMode()
3714 void QtxPagePrefFontItem::setFonts( const QStringList& fams )
3716 myFont->setFonts( fams );
3720 \brief Gets list of custom fonts
3721 \return list of families
3722 \sa setFonts(), setMode()
3724 QStringList QtxPagePrefFontItem::fonts() const
3726 return myFont->fonts();
3730 \brief Sets list of available font sizes.
3731 <b>This method is intended for working in Custom mode only.</b> The list of sizes can
3732 be empty. In this case system generate listof size automatically from 8 till 72.
3733 \param sizes list of sizes
3734 \sa sizes(), setMode()
3736 void QtxPagePrefFontItem::setSizes( const QList<int>& sizes )
3738 myFont->setSizes( sizes );
3742 \brief Gets list of custom fonts
3743 \return list of families
3744 \sa setFonts(), setMode()
3746 QList<int> QtxPagePrefFontItem::sizes() const
3748 return myFont->sizes();
3752 \brief Store preference item to the resource manager.
3755 void QtxPagePrefFontItem::store()
3757 setFont( myFont->currentFont() );
3761 \brief Retrieve preference item from the resource manager.
3764 void QtxPagePrefFontItem::retrieve()
3766 myFont->setCurrentFont( getFont() );
3770 \brief Get preference item option value.
3771 \param name option name
3772 \return property value or null QVariant if option is not set
3773 \sa setOptionValue()
3775 QVariant QtxPagePrefFontItem::optionValue( const QString& name ) const
3777 if ( name == "features" )
3779 else if ( name == "mode" )
3781 else if ( name == "fonts" || name == "families" )
3783 else if ( name == "sizes" )
3785 QList<QVariant> lst;
3786 QList<int> nums = sizes();
3787 for ( QList<int>::const_iterator it = nums.begin(); it != nums.end(); ++it )
3792 return QtxPageNamedPrefItem::optionValue( name );
3796 \brief Set preference item option value.
3797 \param name option name
3798 \param val new property value
3801 void QtxPagePrefFontItem::setOptionValue( const QString& name, const QVariant& val )
3803 if ( name == "features" )
3805 if ( val.canConvert( QVariant::Int ) )
3806 setFeatures( val.toInt() );
3808 else if ( name == "mode" )
3810 if ( val.canConvert( QVariant::Int ) )
3811 setMode( val.toInt() );
3813 else if ( name == "fonts" || name == "families" )
3815 if ( val.canConvert( QVariant::StringList ) )
3816 setFonts( val.toStringList() );
3818 else if ( name == "sizes" )
3820 if ( val.type() == QVariant::List )
3823 QList<QVariant> varList = val.toList();
3824 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
3826 if ( (*it).canConvert( QVariant::Int ) )
3827 lst.append( (*it).toInt() );
3833 QtxPageNamedPrefItem::setOptionValue( name, val );
3837 \class QtxPagePrefPathItem
3838 \brief GUI implementation of the resources file/directory path item.
3843 \param type path widget mode (Qtx::PathType )
3844 \param title preference item title
3845 \param parent parent preference item
3846 \param sect resource file section associated with the preference item
3847 \param param resource file parameter associated with the preference item
3849 QtxPagePrefPathItem::QtxPagePrefPathItem( const Qtx::PathType type, const QString& title,
3850 QtxPreferenceItem* parent, const QString& sect, const QString& param )
3851 : QtxPageNamedPrefItem( title, parent, sect, param )
3853 setControl( myPath = new QtxPathEdit( type ) );
3858 \param title preference item title
3859 \param parent parent preference item
3860 \param sect resource file section associated with the preference item
3861 \param param resource file parameter associated with the preference item
3863 QtxPagePrefPathItem::QtxPagePrefPathItem( const QString& title, QtxPreferenceItem* parent,
3864 const QString& sect, const QString& param )
3865 : QtxPageNamedPrefItem( title, parent, sect, param )
3867 setControl( myPath = new QtxPathEdit() );
3873 QtxPagePrefPathItem::~QtxPagePrefPathItem()
3878 \brief Get path widget mode.
3879 \return current path widget mode (Qtx::PathType)
3882 Qtx::PathType QtxPagePrefPathItem::pathType() const
3884 return myPath->pathType();
3888 \brief Set path widget mode.
3889 \param type new path widget mode (Qtx::PathType)
3892 void QtxPagePrefPathItem::setPathType( const Qtx::PathType type )
3894 myPath->setPathType( type );
3898 \brief Get currently used path widget filters.
3899 \return file or directory path filters
3902 QString QtxPagePrefPathItem::pathFilter() const
3904 return myPath->pathFilter();
3908 \brief Set path widget filters.
3909 \param f new file or directory path filters
3912 void QtxPagePrefPathItem::setPathFilter( const QString& f )
3914 myPath->setPathFilter( f );
3918 \brief Store preference item to the resource manager.
3921 void QtxPagePrefPathItem::store()
3923 setString( myPath->path() );
3927 \brief Retrieve preference item from the resource manager.
3930 void QtxPagePrefPathItem::retrieve()
3932 myPath->setPath( getString() );
3936 \brief Get preference item option value.
3937 \param name option name
3938 \return property value or null QVariant if option is not set
3939 \sa setOptionValue()
3941 QVariant QtxPagePrefPathItem::optionValue( const QString& name ) const
3943 if ( name == "path_type" )
3945 else if ( name == "path_filter" )
3946 return pathFilter();
3948 return QtxPageNamedPrefItem::optionValue( name );
3952 \brief Set preference item option value.
3953 \param name option name
3954 \param val new property value
3957 void QtxPagePrefPathItem::setOptionValue( const QString& name, const QVariant& val )
3959 if ( name == "path_type" )
3961 if ( val.canConvert( QVariant::Int ) )
3962 setPathType( (Qtx::PathType)val.toInt() );
3964 else if ( name == "path_filter" )
3966 if ( val.canConvert( QVariant::String ) )
3967 setPathFilter( val.toString() );
3970 QtxPageNamedPrefItem::setOptionValue( name, val );
3974 \class QtxPagePrefPathListItem
3975 \brief GUI implementation of the resources files/directories list item.
3980 \param parent parent preference item
3981 \param sect resource file section associated with the preference item
3982 \param param resource file parameter associated with the preference item
3984 QtxPagePrefPathListItem::QtxPagePrefPathListItem( QtxPreferenceItem* parent,
3985 const QString& sect, const QString& param )
3986 : QtxPageNamedPrefItem( QString(), parent, sect, param )
3988 setControl( myPaths = new QtxPathListEdit() );
3993 \param type path list widget mode (Qtx::PathType)
3994 \param title preference item title
3995 \param parent parent preference item
3996 \param sect resource file section associated with the preference item
3997 \param param resource file parameter associated with the preference item
3999 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const Qtx::PathType type, const QString& title,
4000 QtxPreferenceItem* parent, const QString& sect, const QString& param )
4001 : QtxPageNamedPrefItem( title, parent, sect, param )
4003 setControl( myPaths = new QtxPathListEdit( type ) );
4008 \param title preference item title
4009 \param parent parent preference item
4010 \param sect resource file section associated with the preference item
4011 \param param resource file parameter associated with the preference item
4013 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const QString& title, QtxPreferenceItem* parent,
4014 const QString& sect, const QString& param )
4015 : QtxPageNamedPrefItem( title, parent, sect, param )
4017 setControl( myPaths = new QtxPathListEdit() );
4023 QtxPagePrefPathListItem::~QtxPagePrefPathListItem()
4028 \brief Get path list widget mode.
4029 \return currently used path list widget mode (Qtx::PathType)
4032 Qtx::PathType QtxPagePrefPathListItem::pathType() const
4034 return myPaths->pathType();
4038 \brief Set path list widget mode.
4039 \param type new path list widget mode (Qtx::PathType)
4042 void QtxPagePrefPathListItem::setPathType( const Qtx::PathType type )
4044 myPaths->setPathType( type );
4048 \brief Store preference item to the resource manager.
4051 void QtxPagePrefPathListItem::store()
4053 setString( myPaths->pathList().join( ";" ) );
4057 \brief Retrieve preference item from the resource manager.
4060 void QtxPagePrefPathListItem::retrieve()
4062 myPaths->setPathList( getString().split( ";" ) );
4066 \brief Get preference item option value.
4067 \param name option name
4068 \return property value or null QVariant if option is not set
4069 \sa setOptionValue()
4071 QVariant QtxPagePrefPathListItem::optionValue( const QString& name ) const
4073 if ( name == "path_type" )
4076 return QtxPageNamedPrefItem::optionValue( name );
4080 \brief Set preference item option value.
4081 \param name option name
4082 \param val new property value
4085 void QtxPagePrefPathListItem::setOptionValue( const QString& name, const QVariant& val )
4087 if ( name == "path_type" )
4089 if ( val.canConvert( QVariant::Int ) )
4090 setPathType( (Qtx::PathType)val.toInt() );
4093 QtxPageNamedPrefItem::setOptionValue( name, val );
4097 \class QtxPagePrefDateTimeItem
4098 \brief GUI implementation of resources date/time item.
4104 Creates an item to enter date and time.
4106 \param title preference item title
4107 \param parent parent preference item
4108 \param sect resource file section associated with the preference item
4109 \param param resource file parameter associated with the preference item
4111 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const QString& title, QtxPreferenceItem* parent,
4112 const QString& sect, const QString& param )
4113 : QtxPageNamedPrefItem( title, parent, sect, param ),
4116 setControl( myDateTime = new QDateTimeEdit() );
4117 myDateTime->setCalendarPopup( true );
4118 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4125 Creates preference item for editing of the date and/or time value:
4126 the type is specified by parameter \a type.
4128 \param type preference item input type (QtxPagePrefDateTimeItem::InputType)
4129 \param title preference item title
4130 \param parent parent preference item
4131 \param sect resource file section associated with the preference item
4132 \param param resource file parameter associated with the preference item
4134 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const int type, const QString& title, QtxPreferenceItem* parent,
4135 const QString& sect, const QString& param )
4136 : QtxPageNamedPrefItem( title, parent, sect, param ),
4139 setControl( myDateTime = new QDateTimeEdit() );
4140 myDateTime->setCalendarPopup( true );
4141 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4148 QtxPagePrefDateTimeItem::~QtxPagePrefDateTimeItem()
4153 \brief Get date/time box preference item input type.
4154 \return preference item input type (QtxPagePrefDateTimeItem::InputType)
4157 int QtxPagePrefDateTimeItem::inputType() const
4163 \brief Set date/time box preference item input type.
4164 \param type new preference item input type (QtxPagePrefDateTimeItem::InputType)
4167 void QtxPagePrefDateTimeItem::setInputType( const int type )
4169 if ( myType == type )
4177 \brief Check if the popup calendar menu is enabled.
4178 \return \c true if calendar popup menu is enabled
4180 bool QtxPagePrefDateTimeItem::calendar() const
4182 return myDateTime->calendarPopup();
4186 \brief Enable/disable popup calendar menu.
4187 \param on new flag state
4189 void QtxPagePrefDateTimeItem::setCalendar( const bool on )
4191 myDateTime->setCalendarPopup( on );
4195 \brief Get maximum date value.
4196 \return maximum date value
4197 \sa setMaximumDate(), minimumDate(), maximumTime(), minimumTime()
4199 QDate QtxPagePrefDateTimeItem::maximumDate() const
4201 return myDateTime->maximumDate();
4205 \brief Get maximum time value.
4206 \return maximum time value
4207 \sa setMaximumTime(), minimumTime(), maximumDate(), minimumDate()
4209 QTime QtxPagePrefDateTimeItem::maximumTime() const
4211 return myDateTime->maximumTime();
4215 \brief Get minimum date value.
4216 \return minimum date value
4217 \sa setMinimumDate(), maximumDate(), maximumTime(), minimumTime()
4219 QDate QtxPagePrefDateTimeItem::minimumDate() const
4221 return myDateTime->minimumDate();
4225 \brief Get minimum time value.
4226 \return maximum time value
4227 \sa setMinimumTime(), maximumTime(), maximumDate(), minimumDate()
4229 QTime QtxPagePrefDateTimeItem::minimumTime() const
4231 return myDateTime->minimumTime();
4235 \brief Set maximum date value.
4236 \param d new maximum date value
4237 \sa maximumDate(), minimumDate(), maximumTime(), minimumTime()
4239 void QtxPagePrefDateTimeItem::setMaximumDate( const QDate& d )
4242 myDateTime->setMaximumDate( d );
4244 myDateTime->clearMaximumDate();
4248 \brief Set maximum time value.
4249 \param t new maximum time value
4250 \sa maximumTime(), minimumTime(), maximumDate(), minimumDate()
4252 void QtxPagePrefDateTimeItem::setMaximumTime( const QTime& t )
4255 myDateTime->setMaximumTime( t );
4257 myDateTime->clearMaximumTime();
4261 \brief Set minimum date value.
4262 \param d new minimum date value
4263 \sa minimumDate(), maximumDate(), maximumTime(), minimumTime()
4265 void QtxPagePrefDateTimeItem::setMinimumDate( const QDate& d )
4268 myDateTime->setMinimumDate( d );
4270 myDateTime->clearMinimumDate();
4274 \brief Set minimum time value.
4275 \param t new minimum time value
4276 \sa minimumTime(), maximumTime(), maximumDate(), minimumDate()
4278 void QtxPagePrefDateTimeItem::setMinimumTime( const QTime& t )
4281 myDateTime->setMinimumTime( t );
4283 myDateTime->clearMinimumTime();
4287 \brief Store preference item to the resource manager.
4290 void QtxPagePrefDateTimeItem::store()
4293 switch ( inputType() )
4296 str = myDateTime->date().toString( Qt::ISODate );
4299 str = myDateTime->time().toString( Qt::ISODate );
4302 str = myDateTime->dateTime().toString( Qt::ISODate );
4310 \brief Retrieve preference item from the resource manager.
4313 void QtxPagePrefDateTimeItem::retrieve()
4315 QString str = getString();
4316 switch ( inputType() )
4319 myDateTime->setDate( QDate::fromString( str, Qt::ISODate ) );
4322 myDateTime->setTime( QTime::fromString( str, Qt::ISODate ) );
4325 myDateTime->setDateTime( QDateTime::fromString( str, Qt::ISODate ) );
4331 \brief Get preference item option value.
4332 \param name option name
4333 \return property value or null QVariant if option is not set
4334 \sa setOptionValue()
4336 QVariant QtxPagePrefDateTimeItem::optionValue( const QString& name ) const
4338 if ( name == "input_type" || name == "type" )
4340 else if ( name == "minimum_date" || name == "min_date" )
4341 return minimumDate();
4342 else if ( name == "maximum_date" || name == "max_date" )
4343 return maximumDate();
4344 else if ( name == "minimum_time" || name == "min_time" )
4345 return minimumTime();
4346 else if ( name == "maximum_time" || name == "max_time" )
4347 return maximumTime();
4349 return QtxPageNamedPrefItem::optionValue( name );
4353 \brief Set preference item option value.
4354 \param name option name
4355 \param val new property value
4358 void QtxPagePrefDateTimeItem::setOptionValue( const QString& name, const QVariant& val )
4360 if ( name == "input_type" || name == "type" )
4362 if ( val.canConvert( QVariant::Int ) )
4363 setInputType( val.toInt() );
4365 else if ( name == "minimum_date" || name == "min_date" )
4367 if ( val.canConvert( QVariant::Date ) )
4368 setMinimumDate( val.toDate() );
4370 else if ( name == "maximum_date" || name == "max_date" )
4372 if ( val.canConvert( QVariant::Date ) )
4373 setMaximumDate( val.toDate() );
4375 else if ( name == "minimum_time" || name == "min_time" )
4377 if ( val.canConvert( QVariant::Time ) )
4378 setMinimumTime( val.toTime() );
4380 else if ( name == "maximum_time" || name == "max_time" )
4382 if ( val.canConvert( QVariant::Time ) )
4383 setMaximumTime( val.toTime() );
4386 QtxPageNamedPrefItem::setOptionValue( name, val );
4390 \brief Update date/time widget.
4392 void QtxPagePrefDateTimeItem::updateDateTime()
4395 switch ( inputType() )
4398 dispFmt = QDateEdit().displayFormat();
4401 dispFmt = QTimeEdit().displayFormat();
4404 dispFmt = QDateTimeEdit().displayFormat();
4408 myDateTime->setDisplayFormat( dispFmt );
4413 \param title preference item title
4414 \param parent parent preference item
4415 \param sect resource file section associated with the preference item
4416 \param param resource file parameter associated with the preference item
4418 QtxPagePrefShortcutBtnsItem::QtxPagePrefShortcutBtnsItem( const QString& title, QtxPreferenceItem* parent, const QString& sect,
4419 const QString& param ): QtxPageNamedPrefItem( title, parent, sect, param )
4421 setControl( myShortcut = new QtxShortcutEdit() );
4427 QtxPagePrefShortcutBtnsItem::~QtxPagePrefShortcutBtnsItem()
4432 \brief Store preference item to the resource manager.
4435 void QtxPagePrefShortcutBtnsItem::store()
4437 setString( myShortcut->shortcut().toString() );
4441 \brief Retrieve preference item from the resource manager.
4444 void QtxPagePrefShortcutBtnsItem::retrieve()
4446 myShortcut->setShortcut( QKeySequence::fromString( getString() ) );
4452 Creates preference item for editing of key bindings
4454 \param title preference item title
4455 \param parent parent preference item
4456 \param sect resource file section associated with the preference item
4457 \param param resource file parameter associated with the preference item
4459 QtxPagePrefShortcutTreeItem::QtxPagePrefShortcutTreeItem( const QString& title, QtxPreferenceItem* parent, const QString& sect,
4460 const QString& param ): QtxPageNamedPrefItem( title, parent, sect, "" )
4464 myShortcutTree = new QtxShortcutTree();
4466 // Retrieve shortcuts common sections from resources
4467 QtxResourceMgr* resMgr = resourceMgr();
4469 QString generalSections = resourceMgr()->stringValue( "shortcuts_settings", "general_sections", QString() );
4470 QStringList sectionsList = generalSections.split( ";", QString::SkipEmptyParts );
4471 myShortcutTree->setGeneralSections( sectionsList );
4474 setControl( myShortcutTree );
4480 QtxPagePrefShortcutTreeItem::~QtxPagePrefShortcutTreeItem()
4485 \brief Retrieve preference item from the resource manager.
4488 void QtxPagePrefShortcutTreeItem::retrieve()
4490 QtxResourceMgr* resMgr = resourceMgr();
4492 QStringList secLst = resMgr->subSections( mySection, false );
4493 ShortcutMap aMap; QStringList paramLst;
4494 for( int i = 0; i < secLst.size(); i++ ) {
4495 paramLst = resMgr->parameters( QStringList() << mySection << secLst.at( i ) );
4496 for( int j = 0; j < paramLst.size(); j++ )
4497 resMgr->value( mySection + resMgr->sectionsToken() + secLst.at( i ), paramLst.at( j ),aMap[ paramLst.at( j ) ], false );
4498 myShortcutTree->setBindings( secLst.at( i ), aMap );
4505 \brief Store preference item to the resource manager.
4508 void QtxPagePrefShortcutTreeItem::store()
4510 QStringList lst = myShortcutTree->sections();
4512 QtxResourceMgr* resMgr = resourceMgr();
4515 for( int i = 0; i < lst.size(); i++ ) {
4516 ShortcutMap* aMap( myShortcutTree->bindings( lst.at( i ) ) );
4517 aSection = mySection + resMgr->sectionsToken() + lst.at( i );
4518 for( ShortcutMap::const_iterator it = aMap->constBegin(); it != aMap->constEnd(); ++it )
4519 resMgr->setValue( aSection, it.key(), it.value() );
4525 \class QtxPagePrefBackgroundItem
4526 \brief GUI implementation of the resources item to store background data.
4528 Preference item allows specifying background data in different ways:
4530 - texture image file
4531 - simple two-color gradient
4532 - complex custom gradient (NOT IMPLEMENTED YET)
4534 Allowed background modes can be specified using setModeAllowed() method.
4535 Texture modes can be enabled/disabled using setTextureModeAllowed() method.
4536 Also, showing texture controls can be enabled/disabled by means of
4537 setTextureAllowed() method.
4538 Verical or horizontal orientation of the widget can be chosen via setOrientation()
4539 method (default orientation is horizontal).
4541 Simple gradient types can be specified using setGradients() method.
4543 \sa Qtx::BackgroundData, QtxBackgroundTool
4548 \param title preference item title
4549 \param parent parent preference item
4550 \param sect resource file section associated with the preference item
4551 \param param resource file parameter associated with the preference item
4553 QtxPagePrefBackgroundItem::QtxPagePrefBackgroundItem( const QString& title, QtxPreferenceItem* parent,
4554 const QString& sect, const QString& param )
4555 : QtxPageNamedPrefItem( title, parent, sect, param )
4557 setControl( myBgTool = new QtxBackgroundTool( 0 ) );
4563 QtxPagePrefBackgroundItem::~QtxPagePrefBackgroundItem()
4568 \brief Get allowed two-color gradients to the widget
4569 \param gradients gradients names are returned via this parameter
4570 \param ids gradients identifiers are returned via this parameter (empty list can be returned)
4572 void QtxPagePrefBackgroundItem::gradients( QStringList& gradList, QIntList& idList ) const
4574 myBgTool->gradients( gradList, idList );
4578 \brief Set allowed two-color gradients to the widget
4579 \param gradients gradients names
4580 \param ids optional gradients identifiers; if not specified, gradients are automatically numbered starting from 0
4582 void QtxPagePrefBackgroundItem::setGradients( const QStringList& gradients, const QIntList& ids )
4584 myBgTool->setGradients( gradients, ids );
4588 \brief Check if specific background mode is allowed
4589 \param mode background mode
4590 \return \c true if specified background mode is enabled or \c false otherwise
4591 \sa setModeAllowed()
4593 bool QtxPagePrefBackgroundItem::isModeAllowed( Qtx::BackgroundMode mode ) const
4595 return myBgTool->isModeAllowed( mode );
4599 \brief Enable / disable specific background mode
4600 \param mode background mode
4601 \param on enable / disable flag
4604 void QtxPagePrefBackgroundItem::setModeAllowed( Qtx::BackgroundMode mode, bool on )
4606 myBgTool->setModeAllowed( mode, on );
4610 \brief Check if specific texture mode is allowed
4611 \param mode texture mode
4612 \return \c true if specified texture mode is enabled or \c false otherwise
4613 \sa setTextureModeAllowed(), setTextureAllowed()
4615 bool QtxPagePrefBackgroundItem::isTextureModeAllowed( Qtx::TextureMode mode ) const
4617 return myBgTool->isTextureModeAllowed( mode );
4621 \brief Enable / disable specific texture mode
4622 \param mode texture mode
4623 \param on enable / disable flag (\c true by default)
4624 \sa isTextureModeAllowed(), setTextureAllowed()
4626 void QtxPagePrefBackgroundItem::setTextureModeAllowed( Qtx::TextureMode mode, bool on )
4628 myBgTool->setTextureModeAllowed( mode, on );
4632 \brief Check if texture controls are allowed (shown)
4633 \return \c true if texture controls are enabled or \c false otherwise
4634 \sa setTextureAllowed(), setTextureModeAllowed()
4636 bool QtxPagePrefBackgroundItem::isTextureAllowed() const
4638 return myBgTool->isTextureAllowed();
4642 \brief Enable / disable texture controls
4643 \param on enable / disable flag (\c true by default)
4644 \sa isTextureAllowed(), setTextureModeAllowed()
4646 void QtxPagePrefBackgroundItem::setTextureAllowed( bool on )
4648 myBgTool->setTextureAllowed( on );
4652 \brief Get allowed image formats
4653 \return image formats
4655 QString QtxPagePrefBackgroundItem::imageFormats() const
4657 return myBgTool->imageFormats();
4661 \brief Set allowed image formats
4662 \param formats image formats
4664 void QtxPagePrefBackgroundItem::setImageFormats( const QString& formats )
4666 myBgTool->setImageFormats( formats );
4670 \brief Get widget editor orientation
4673 Qt::Orientation QtxPagePrefBackgroundItem::orientation() const
4675 return myBgTool->orientation();
4679 \brief Set widget editor orientation
4680 \param o orientation
4682 void QtxPagePrefBackgroundItem::setOrientation( Qt::Orientation o )
4684 myBgTool->setOrientation( o );
4688 \brief Store preference item to the resource manager.
4691 void QtxPagePrefBackgroundItem::store()
4693 setString( Qtx::backgroundToString( myBgTool->data() ) );
4697 \brief Retrieve preference item from the resource manager.
4700 void QtxPagePrefBackgroundItem::retrieve()
4702 myBgTool->setData( Qtx::stringToBackground( getString() ) );
4706 \brief Get preference item option value.
4707 \param name option name
4708 \return property value or null QVariant if option is not set
4709 \sa setOptionValue()
4711 QVariant QtxPagePrefBackgroundItem::optionValue( const QString& name ) const
4713 if ( name == "texture_enabled" )
4714 return isTextureAllowed();
4715 else if ( name == "color_enabled" )
4716 return isModeAllowed( Qtx::ColorBackground );
4717 else if ( name == "gradient_enabled" )
4718 return isModeAllowed( Qtx::SimpleGradientBackground );
4719 else if ( name == "custom_enabled" )
4720 return isModeAllowed( Qtx::CustomGradientBackground );
4721 else if ( name == "texture_center_enabled" )
4722 return isTextureModeAllowed( Qtx::CenterTexture );
4723 else if ( name == "texture_tile_enabled" )
4724 return isTextureModeAllowed( Qtx::TileTexture );
4725 else if ( name == "texture_stretch_enabled" )
4726 return isTextureModeAllowed( Qtx::StretchTexture );
4727 else if ( name == "orientation" )
4728 return orientation();
4729 else if ( name == "image_formats" )
4730 return imageFormats();
4731 else if ( name == "gradient_names" ) {
4734 gradients( grList, idList );
4737 else if ( name == "gradient_ids" ) {
4740 gradients( grList, idList );
4741 QList<QVariant> lst;
4742 for ( QIntList::const_iterator it = idList.begin(); it != idList.end(); ++it )
4747 return QtxPageNamedPrefItem::optionValue( name );
4751 \brief Set preference item option value.
4752 \param name option name
4753 \param val new property value
4756 void QtxPagePrefBackgroundItem::setOptionValue( const QString& name, const QVariant& val )
4758 if ( name == "texture_enabled" ) {
4759 if ( val.canConvert( QVariant::Bool ) )
4760 setTextureAllowed( val.toBool() );
4762 else if ( name == "color_enabled" ) {
4763 if ( val.canConvert( QVariant::Bool ) )
4764 setModeAllowed( Qtx::ColorBackground, val.toBool() );
4766 else if ( name == "gradient_enabled" ) {
4767 if ( val.canConvert( QVariant::Bool ) )
4768 setModeAllowed( Qtx::SimpleGradientBackground, val.toBool() );
4770 else if ( name == "custom_enabled" ) {
4771 if ( val.canConvert( QVariant::Bool ) )
4772 setModeAllowed( Qtx::CustomGradientBackground, val.toBool() );
4774 else if ( name == "texture_center_enabled" ) {
4775 if ( val.canConvert( QVariant::Bool ) )
4776 setTextureModeAllowed( Qtx::CenterTexture, val.toBool() );
4778 else if ( name == "texture_tile_enabled" ) {
4779 if ( val.canConvert( QVariant::Bool ) )
4780 setTextureModeAllowed( Qtx::TileTexture, val.toBool() );
4782 else if ( name == "texture_stretch_enabled" ) {
4783 if ( val.canConvert( QVariant::Bool ) )
4784 setTextureModeAllowed( Qtx::StretchTexture, val.toBool() );
4786 else if ( name == "orientation" ) {
4787 if ( val.canConvert( QVariant::Int ) )
4788 setOrientation( (Qt::Orientation)val.toInt() );
4790 else if ( name == "image_formats" ) {
4791 if ( val.canConvert( QVariant::String ) )
4792 setImageFormats( val.toString() );
4794 else if ( name == "gradient_names" ) {
4795 if ( val.canConvert( QVariant::StringList ) )
4796 setGradients( val.toStringList() );
4798 else if ( name == "gradient_ids" ) {
4799 if ( val.canConvert( QVariant::List ) ) {
4802 gradients( grList, idList );
4804 QList<QVariant> varList = val.toList();
4805 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it ) {
4806 if ( (*it).canConvert( QVariant::Int ) )
4807 idList.append( (*it).toInt() );
4809 setGradients( grList, idList );
4813 QtxPageNamedPrefItem::setOptionValue( name, val );
4819 Creates preference item of user defined widget. The item widget has to be inherited from
4820 QtxUserDefinedContent class. An instance of this class has to be installed into the item
4821 with help of setContent method. Methods optionValue and setOptionValue use pointer on the
4822 content widget an qint64 value.
4824 \param parent parent preference item
4826 QtxUserDefinedItem::QtxUserDefinedItem( QtxPreferenceItem* parent )
4827 : QtxPageNamedPrefItem(QString(), parent), myContent(0)
4832 \brief Lets to Store preferences for content instance
4835 void QtxUserDefinedItem::store()
4838 myContent->store( resourceMgr(), preferenceMgr());
4843 \brief Lets to Retrieve preferences for content instance
4846 void QtxUserDefinedItem::retrieve()
4849 myContent->retrieve( resourceMgr(), preferenceMgr());
4854 * \brief Returns option value
4855 * \param theName is a string "content"
4856 * \return pointer on QtxUserDefinedContent class instance as a qint64 value
4858 QVariant QtxUserDefinedItem::optionValue( const QString& theName ) const
4860 if ( theName == "content" )
4861 return (qint64) myContent;
4863 return QtxPreferenceItem::optionValue( theName );
4867 * \brief Sets option value
4868 * \param theName is a string "content"
4869 * \param theVal is a pointer on QtxUserDefinedContent class instance represented as qint64 value
4871 void QtxUserDefinedItem::setOptionValue( const QString& theName, const QVariant& theVal)
4873 if ( theName == "content" ) {
4874 if ( theVal.canConvert( QVariant::ULongLong ) ) {
4875 setContent( (QtxUserDefinedContent*)theVal.toULongLong() );
4878 QtxPreferenceItem::setOptionValue( theName, theVal );
4882 * \brief Defines content of the property item as a Widget which has to be inherited from
4883 * QtxUserDefinedContent class.
4884 * \param theContent is an QtxUserDefinedContent class instance.
4886 void QtxUserDefinedItem::setContent( QtxUserDefinedContent* theContent )
4888 myContent = theContent;
4889 setControl(myContent);