1 // Copyright (C) 2007-2012 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.
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>
55 \brief GUI implementation of the QtxPreferenceMgr class: preferences manager.
60 \param resMgr resource manager
61 \param parent parent widget
63 QtxPagePrefMgr::QtxPagePrefMgr( QtxResourceMgr* resMgr, QWidget* parent )
65 QtxPreferenceMgr( resMgr ),
68 myBox = new QtxGridBox( 1, Qt::Horizontal, this, 0 );
69 QVBoxLayout* base = new QVBoxLayout( this );
71 base->setSpacing( 0 );
72 base->addWidget( myBox );
78 QtxPagePrefMgr::~QtxPagePrefMgr()
83 \brief Get recommended size for the widget.
84 \return recommended widget size
86 QSize QtxPagePrefMgr::sizeHint() const
88 return QFrame::sizeHint();
92 \brief Get recommended minimum size for the widget.
93 \return recommended minimum widget size
95 QSize QtxPagePrefMgr::minimumSizeHint() const
97 return QFrame::minimumSizeHint();
101 \brief Customize show/hide widget operation.
102 \param on if \c true the widget is being shown, otherswise
105 void QtxPagePrefMgr::setVisible( bool on )
110 QApplication::instance()->processEvents();
112 QFrame::setVisible( on );
116 \brief Update widget contents.
118 void QtxPagePrefMgr::updateContents()
120 QtxPreferenceMgr::updateContents();
122 QList<QtxPreferenceItem*> lst = childItems();
123 for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
125 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
126 if ( item && item->widget() && item->widget()->parent() != myBox )
127 item->widget()->setParent( myBox );
130 setWindowIcon( icon() );
134 \brief Callback function which is called when the child
135 preference item is added.
136 \param item child item being added
137 \sa itemRemoved(), itemChanged()
139 void QtxPagePrefMgr::itemAdded( QtxPreferenceItem* /*item*/ )
145 \brief Callback function which is called when the child
146 preference item is removed.
147 \param item child item being removed
148 \sa itemAdded(), itemChanged()
150 void QtxPagePrefMgr::itemRemoved( QtxPreferenceItem* /*item*/ )
156 \brief Callback function which is called when the child
157 preference item is modified.
158 \param item child item being modified
159 \sa itemAdded(), itemRemoved()
161 void QtxPagePrefMgr::itemChanged( QtxPreferenceItem* /*item*/ )
167 \brief Get preference item option value.
168 \param name option name
169 \return property value or null QVariant if option is not set
172 QVariant QtxPagePrefMgr::optionValue( const QString& name ) const
174 if ( name == "orientation" )
175 return myBox->orientation() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
177 return QtxPreferenceMgr::optionValue( name );
181 \brief Set preference item option value.
182 \param name option name
183 \param val new property value
186 void QtxPagePrefMgr::setOptionValue( const QString& name, const QVariant& val )
188 if ( name == "orientation" )
190 if ( val.canConvert( QVariant::Int ) )
191 myBox->setOrientation( val.toInt() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal );
194 QtxPreferenceMgr::setOptionValue( name, val );
198 \brief Perform internal initialization.
200 void QtxPagePrefMgr::initialize() const
205 QtxPagePrefMgr* that = (QtxPagePrefMgr*)this;
206 that->initialize( that );
208 // that->myInit = true;
211 void QtxPagePrefMgr::initialize( QtxPreferenceItem* item )
216 QList<QtxPreferenceItem*> lst = item->childItems( false );
217 for ( QList<QtxPreferenceItem*>::iterator it = lst.begin(); it != lst.end(); ++it )
224 \class QtxPagePrefItem
225 \brief Base class for implementation of all the widget-based
229 class QtxPagePrefItem::Listener : public QObject
232 Listener( QtxPagePrefItem* );
235 virtual bool eventFilter( QObject*, QEvent* );
238 QtxPagePrefItem* myItem;
241 QtxPagePrefItem::Listener::Listener( QtxPagePrefItem* item )
247 QtxPagePrefItem::Listener::~Listener()
251 bool QtxPagePrefItem::Listener::eventFilter( QObject* o, QEvent* e )
253 if ( !myItem || myItem->widget() != o )
256 if ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent )
257 myItem->widgetShown();
258 if ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent )
259 myItem->widgetHided();
266 \param title preference item title
267 \param parent parent preference item
268 \param sect resource file section associated with the preference item
269 \param param resource file parameter associated with the preference item
271 QtxPagePrefItem::QtxPagePrefItem( const QString& title, QtxPreferenceItem* parent,
272 const QString& sect, const QString& param )
273 : QtxPreferenceItem( title, sect, param, parent ),
282 QtxPagePrefItem::~QtxPagePrefItem()
288 void QtxPagePrefItem::activate()
290 QtxPreferenceItem::activate();
293 widget()->setFocus();
297 \brief Get preference item editor widget.
298 \return editor widget
301 QWidget* QtxPagePrefItem::widget() const
307 \brief Set preference item editor widget.
308 \param wid editor widget
311 void QtxPagePrefItem::setWidget( QWidget* wid )
313 if ( myWidget && myListener )
314 myWidget->removeEventFilter( myListener );
321 myListener = new Listener( this );
322 myWidget->installEventFilter( myListener );
329 \brief Callback function which is called when the child
330 preference item is added.
331 \param item child item being added
332 \sa itemRemoved(), itemChanged()
334 void QtxPagePrefItem::itemAdded( QtxPreferenceItem* /*item*/ )
340 \brief Callback function which is called when the child
341 preference item is removed.
342 \param item child item being removed
343 \sa itemAdded(), itemChanged()
345 void QtxPagePrefItem::itemRemoved( QtxPreferenceItem* /*item*/ )
351 \brief Callback function which is called when the child
352 preference item is modified.
353 \param item child item being modified
354 \sa itemAdded(), itemRemoved()
356 void QtxPagePrefItem::itemChanged( QtxPreferenceItem* /*item*/ )
362 \brief Store preference item to the resource manager.
364 This method should be reimplemented in the subclasses.
365 Base implementation does nothing.
369 void QtxPagePrefItem::store()
374 \brief Retrieve preference item from the resource manager.
376 This method should be reimplemented in the subclasses.
377 Base implementation does nothing.
381 void QtxPagePrefItem::retrieve()
386 \brief Invoked when preference item widget is shown.
388 void QtxPagePrefItem::widgetShown()
393 \brief Invoked when preference item widget is hided.
395 void QtxPagePrefItem::widgetHided()
399 void QtxPagePrefItem::ensureVisible( QtxPreferenceItem* i )
401 QtxPreferenceItem::ensureVisible();
403 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
404 if ( item && item->widget() )
405 item->widget()->setVisible( true );
409 \brief Find all child items of the QtxPagePrefItem type.
410 \param list used to return list of child items
411 \param rec if \c true, perform recursive search
413 void QtxPagePrefItem::pageChildItems( QList<QtxPagePrefItem*>& list, const bool rec ) const
415 QList<QtxPreferenceItem*> lst = childItems( rec );
416 for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
418 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
425 \brief Called when contents is changed (item is added, removed or modified).
427 Triggers the item update.
429 void QtxPagePrefItem::contentChanged()
435 \class QtxPageNamedPrefItem
436 \brief Base class for implementation of the named preference items
437 (items with text labels).
442 \param title preference item title
443 \param parent parent preference item
444 \param sect resource file section associated with the preference item
445 \param param resource file parameter associated with the preference item
447 QtxPageNamedPrefItem::QtxPageNamedPrefItem( const QString& title, QtxPreferenceItem* parent,
448 const QString& sect, const QString& param )
449 : QtxPagePrefItem( title, parent, sect, param ),
452 QWidget* main = new QWidget();
454 // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parent);
457 QHBoxLayout* base = new QHBoxLayout( main );
458 base->setMargin( 0 );
459 base->setSpacing( 5 );
461 myLabel = new QLabel( title, main );
462 base->addWidget( myLabel );
465 // myLabel = new QLabel( title, aGroup->gridBox() );
469 myLabel->setVisible( !title.isEmpty() );
475 QtxPageNamedPrefItem::~QtxPageNamedPrefItem()
480 \brief Set preference title.
481 \param txt new preference title.
483 void QtxPageNamedPrefItem::setTitle( const QString& txt )
485 QtxPagePrefItem::setTitle( txt );
487 label()->setText( title() );
488 if ( !title().isEmpty() )
489 label()->setVisible( true );
493 \brief Get label widget corresponding to the preference item.
496 QLabel* QtxPageNamedPrefItem::label() const
502 \brief Get control widget corresponding to the preference item.
503 \return control widget
506 QWidget* QtxPageNamedPrefItem::control() const
512 \brief Set control widget corresponding to the preference item.
513 \param wid control widget
516 void QtxPageNamedPrefItem::setControl( QWidget* wid )
518 if ( myControl == wid )
526 // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parentItem());
528 widget()->layout()->addWidget( myControl );
529 widget()->setFocusProxy( myControl );
530 // else myControl->setParent( aGroup->gridBox() );
534 void QtxPageNamedPrefItem::adjustLabels( QtxPagePrefItem* parent )
539 QList<QtxPreferenceItem*> childList = parent->childItems();
541 QList<QtxPageNamedPrefItem*> namedItems;
542 for ( QList<QtxPreferenceItem*>::iterator it = childList.begin(); it != childList.end(); ++it )
544 QtxPageNamedPrefItem* item = dynamic_cast<QtxPageNamedPrefItem*>( *it );
546 namedItems.append( item );
550 for ( QList<QtxPageNamedPrefItem*>::iterator it1 = namedItems.begin(); it1 != namedItems.end(); ++it1 )
552 QtxPageNamedPrefItem* item = *it1;
554 sz = qMax( sz, item->label()->sizeHint().width() );
557 for ( QList<QtxPageNamedPrefItem*>::iterator it2 = namedItems.begin(); it2 != namedItems.end(); ++it2 )
559 QtxPageNamedPrefItem* item = *it2;
561 item->label()->setMinimumWidth( sz );
566 \class QtxPagePrefListItem
567 \brief GUI implementation of the list container preference item.
572 \param title preference item title
573 \param parent parent preference item
574 \param sect resource file section associated with the preference item
575 \param param resource file parameter associated with the preference item
577 QtxPagePrefListItem::QtxPagePrefListItem( const QString& title, QtxPreferenceItem* parent,
578 const QString& sect, const QString& param )
579 : QtxPagePrefItem( title, parent, sect, param ),
582 QSplitter* main = new QSplitter( Qt::Horizontal );
583 main->setChildrenCollapsible( false );
585 main->addWidget( myList = new QListWidget( main ) );
586 main->addWidget( myStack = new QStackedWidget( main ) );
588 myList->setSelectionMode( QListWidget::SingleSelection );
590 myStack->addWidget( myInfLabel = new QLabel( myStack ) );
591 myInfLabel->setAlignment( Qt::AlignCenter );
593 connect( myList, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) );
601 QtxPagePrefListItem::~QtxPagePrefListItem()
606 \brief Get message text which is shown if the container is empty.
610 QString QtxPagePrefListItem::emptyInfo() const
616 \brief Set message text which is shown if the container is empty.
617 \param new message text
620 void QtxPagePrefListItem::setEmptyInfo( const QString& inf )
622 if ( myInfText == inf )
631 \brief Check if the preference item widget is of fixed size.
632 \return \c true if the widget has the fixed size
635 bool QtxPagePrefListItem::isFixedSize() const
641 \brief Set the preference item widget to be of fixed size.
642 \param on if \c true, the widget will have the fixed size
645 void QtxPagePrefListItem::setFixedSize( const bool on )
656 \brief Update widget contents.
658 void QtxPagePrefListItem::updateContents()
660 QtxPagePrefItem::updateContents();
665 \brief Get preference item option value.
666 \param name option name
667 \return property value or null QVariant if option is not set
670 QVariant QtxPagePrefListItem::optionValue( const QString& name ) const
672 if ( name == "fixed_size" )
673 return isFixedSize();
674 else if ( name == "empty_info" || name == "info" )
677 return QtxPagePrefItem::optionValue( name );
681 \brief Set preference item option value.
682 \param name option name
683 \param val new property value
686 void QtxPagePrefListItem::setOptionValue( const QString& name, const QVariant& val )
688 if ( name == "fixed_size" )
690 if ( val.canConvert( QVariant::Bool ) )
691 setFixedSize( val.toBool() );
693 else if ( name == "empty_info" || name == "info" )
695 if ( val.canConvert( QVariant::String ) )
696 setEmptyInfo( val.toString() );
699 QtxPagePrefItem::setOptionValue( name, val );
702 void QtxPagePrefListItem::widgetShown()
707 void QtxPagePrefListItem::ensureVisible( QtxPreferenceItem* i )
712 QtxPreferenceItem::ensureVisible( i );
714 setSelected( i->id() );
719 \brief Called when the selection in the list box is changed.
721 void QtxPagePrefListItem::onItemSelectionChanged()
727 \brief Update information label widget.
729 void QtxPagePrefListItem::updateInfo()
732 QtxPagePrefItem* item = selectedItem();
735 infoText = emptyInfo();
736 QRegExp rx( "%([%|N])" );
739 while ( ( idx = rx.indexIn( infoText ) ) != -1 )
741 if ( rx.cap() == QString( "%%" ) )
742 infoText.replace( idx, rx.matchedLength(), "%" );
743 else if ( rx.cap() == QString( "%N" ) )
744 infoText.replace( idx, rx.matchedLength(), item->title() );
747 myInfLabel->setText( infoText );
751 \brief Update widget state.
753 void QtxPagePrefListItem::updateState()
755 QtxPagePrefItem* item = selectedItem();
756 QWidget* wid = item && !item->isEmpty() ? item->widget() : myInfLabel;
758 myStack->setCurrentWidget( wid );
764 \brief Update visibile child widgets.
766 void QtxPagePrefListItem::updateVisible()
768 QList<QtxPagePrefItem*> items;
769 pageChildItems( items );
771 QMap<QWidget*, int> map;
772 for ( int i = 0; i < (int)myStack->count(); i++ )
773 map.insert( myStack->widget( i ), 0 );
775 int selId = selected();
777 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
779 if ( (*it)->isEmpty() && myInfText.isEmpty() )
782 myList->addItem( (*it)->title() );
783 myList->item( myList->count() - 1 )->setIcon( (*it)->icon() );
784 myList->item( myList->count() - 1 )->setData( Qt::UserRole, (*it)->id() );
786 QWidget* wid = (*it)->widget();
787 if ( !map.contains( wid ) )
788 myStack->addWidget( wid );
793 map.remove( myInfLabel );
795 for ( QMap<QWidget*, int>::const_iterator it = map.begin(); it != map.end(); ++it )
796 myStack->removeWidget( it.key() );
798 setSelected( selId );
799 if ( selected() == -1 && myList->count() )
800 setSelected( myList->item( 0 )->data( Qt::UserRole ).toInt() );
802 //myList->setVisible( myList->count() > 1 );
809 \brief Update widget geometry.
811 void QtxPagePrefListItem::updateGeom()
814 myList->setFixedWidth( myList->minimumSizeHint().width() + 10 );
817 myList->setMinimumWidth( 0 );
818 myList->setMaximumWidth( 16777215 );
820 QSplitter* s = ::qobject_cast<QSplitter*>( widget() );
823 int w = myList->minimumSizeHint().width() + 30;
826 szList.append( s->width() - w );
827 s->setSizes( szList );
833 \brief Get identifier of the currently selected preference item.
834 \return identifier of the currently selected item or -1 if no item is selected
837 int QtxPagePrefListItem::selected() const
839 QList<QListWidgetItem*> selList = myList->selectedItems();
840 if ( selList.isEmpty() )
843 QVariant v = selList.first()->data( Qt::UserRole );
844 return v.canConvert( QVariant::Int ) ? v.toInt() : -1;
848 \brief Get currently selected preference item.
849 \return currently selected item or 0 if no item is selected
852 QtxPagePrefItem* QtxPagePrefListItem::selectedItem() const
854 int selId = selected();
856 QList<QtxPagePrefItem*> items;
857 pageChildItems( items );
859 QtxPagePrefItem* item = 0;
860 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end() && !item; ++it )
862 if ( (*it)->id() == selId )
869 \brief Set currently selected preference item.
870 \param id identifier of the preference item to make selected
872 void QtxPagePrefListItem::setSelected( const int id )
875 for ( int i = 0; i < (int)myList->count() && idx < 0; i++ )
877 QVariant v = myList->item( i )->data( Qt::UserRole );
878 if ( v.canConvert( QVariant::Int ) && v.toInt() == id )
883 QItemSelectionModel* selModel = myList->selectionModel();
886 sel.select( myList->model()->index( idx, 0 ), myList->model()->index( idx, 0 ) );
888 selModel->select( sel, QItemSelectionModel::ClearAndSelect );
892 \class QtxPagePrefToolBoxItem
893 \brief GUI implementation of the tool box container preference item.
898 \param title preference item title
899 \param parent parent preference item
900 \param sect resource file section associated with the preference item
901 \param param resource file parameter associated with the preference item
903 QtxPagePrefToolBoxItem::QtxPagePrefToolBoxItem( const QString& title, QtxPreferenceItem* parent,
904 const QString& sect, const QString& param )
905 : QtxPagePrefItem( title, parent, sect, param )
907 setWidget( myToolBox = new QToolBox( 0 ) );
913 QtxPagePrefToolBoxItem::~QtxPagePrefToolBoxItem()
918 \brief Update widget contents.
920 void QtxPagePrefToolBoxItem::updateContents()
922 QtxPagePrefItem::updateContents();
927 \brief Update tool box widget.
929 void QtxPagePrefToolBoxItem::updateToolBox()
931 QList<QtxPagePrefItem*> items;
932 pageChildItems( items );
934 QWidget* cur = myToolBox->currentWidget();
937 QMap<QWidget*, int> map;
938 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
940 QWidget* wid = (*it)->widget();
944 if ( myToolBox->widget( i ) != wid )
946 if ( myToolBox->indexOf( wid ) != -1 )
947 myToolBox->removeItem( myToolBox->indexOf( wid ) );
949 myToolBox->insertItem( i, wid, (*it)->title() );
952 myToolBox->setItemText( i, (*it)->title() );
954 myToolBox->setItemIcon( i, (*it)->icon() );
957 map.insert( wid, 0 );
961 for ( int idx = 0; idx < (int)myToolBox->count(); idx++ )
963 QWidget* w = myToolBox->widget( idx );
964 if ( !map.contains( w ) )
968 for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
969 myToolBox->removeItem( myToolBox->indexOf( *itr ) );
972 myToolBox->setCurrentWidget( cur );
975 void QtxPagePrefToolBoxItem::ensureVisible( QtxPreferenceItem* i )
980 QtxPreferenceItem::ensureVisible( i );
982 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
983 if ( item && item->widget() )
984 myToolBox->setCurrentWidget( item->widget() );
988 \class QtxPagePrefTabsItem
989 \brief GUI implementation of the tab widget container.
994 \param title preference item title
995 \param parent parent preference item
996 \param sect resource file section associated with the preference item
997 \param param resource file parameter associated with the preference item
999 QtxPagePrefTabsItem::QtxPagePrefTabsItem( const QString& title, QtxPreferenceItem* parent,
1000 const QString& sect, const QString& param )
1001 : QtxPagePrefItem( title, parent, sect, param )
1003 setWidget( myTabs = new QTabWidget( 0 ) );
1009 QtxPagePrefTabsItem::~QtxPagePrefTabsItem()
1014 \brief Update widget contents.
1016 void QtxPagePrefTabsItem::updateContents()
1018 QtxPagePrefItem::updateContents();
1023 \brief Get tabs position.
1024 \return current tabs position (QTabWidget::TabPosition)
1025 \sa setTabPosition()
1027 int QtxPagePrefTabsItem::tabPosition() const
1029 return myTabs->tabPosition();
1033 \brief Set tabs position.
1034 \param tp new tabs position (QTabWidget::TabPosition)
1037 void QtxPagePrefTabsItem::setTabPosition( const int tp )
1039 myTabs->setTabPosition( (QTabWidget::TabPosition)tp );
1043 \brief Get tabs shape.
1044 \return current tabs shape (QTabWidget::TabShape)
1047 int QtxPagePrefTabsItem::tabShape() const
1049 return myTabs->tabShape();
1053 \brief Set tabs shape.
1054 \param ts new tabs shape (QTabWidget::TabShape)
1057 void QtxPagePrefTabsItem::setTabShape( const int ts )
1059 myTabs->setTabShape( (QTabWidget::TabShape)ts );
1063 \brief Get tabs icon size.
1064 \return current tabs icon size
1065 \sa setTabIconSize()
1067 QSize QtxPagePrefTabsItem::tabIconSize() const
1069 return myTabs->iconSize();
1073 \brief Set tabs icon size.
1074 \param sz new tabs icon size
1077 void QtxPagePrefTabsItem::setTabIconSize( const QSize& sz )
1079 myTabs->setIconSize( sz );
1083 \brief Get preference item option value.
1084 \param name option name
1085 \return property value or null QVariant if option is not set
1086 \sa setOptionValue()
1088 QVariant QtxPagePrefTabsItem::optionValue( const QString& name ) const
1090 if ( name == "position" )
1091 return tabPosition();
1092 else if ( name == "shape" )
1094 else if ( name == "icon_size" )
1095 return tabIconSize();
1097 return QtxPagePrefItem::optionValue( name );
1101 \brief Set preference item option value.
1102 \param name option name
1103 \param val new property value
1106 void QtxPagePrefTabsItem::setOptionValue( const QString& name, const QVariant& val )
1108 if ( name == "position" )
1110 if ( val.canConvert( QVariant::Int ) )
1111 setTabPosition( val.toInt() );
1113 else if ( name == "shape" )
1115 if ( val.canConvert( QVariant::Int ) )
1116 setTabShape( val.toInt() );
1118 else if ( name == "icon_size" )
1120 if ( val.canConvert( QVariant::Size ) )
1121 setTabIconSize( val.toSize() );
1124 QtxPagePrefItem::setOptionValue( name, val );
1127 void QtxPagePrefTabsItem::ensureVisible( QtxPreferenceItem* i )
1132 QtxPreferenceItem::ensureVisible( i );
1134 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
1135 if ( item && item->widget() )
1136 myTabs->setCurrentWidget( item->widget() );
1142 void QtxPagePrefTabsItem::updateTabs()
1144 QList<QtxPagePrefItem*> items;
1145 pageChildItems( items );
1147 QWidget* cur = myTabs->currentWidget();
1150 QMap<QWidget*, int> map;
1151 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1153 QWidget* wid = (*it)->widget();
1157 if ( myTabs->widget( i ) != wid )
1159 if ( myTabs->indexOf( wid ) != -1 )
1160 myTabs->removeTab( myTabs->indexOf( wid ) );
1162 myTabs->insertTab( i, wid, (*it)->title() );
1165 myTabs->setTabText( i, (*it)->title() );
1167 myTabs->setTabIcon( i, (*it)->icon() );
1170 map.insert( wid, 0 );
1173 QList<QWidget*> del;
1174 for ( int idx = 0; idx < (int)myTabs->count(); idx++ )
1176 QWidget* w = myTabs->widget( idx );
1177 if ( !map.contains( w ) )
1181 for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
1182 myTabs->removeTab( myTabs->indexOf( *itr ) );
1185 myTabs->setCurrentWidget( cur );
1189 \class QtxPagePrefFrameItem
1190 \brief GUI implementation of the frame widget container.
1195 \param title preference item title
1196 \param parent parent preference item
1197 \param sect resource file section associated with the preference item
1198 \param param resource file parameter associated with the preference item
1200 QtxPagePrefFrameItem::QtxPagePrefFrameItem( const QString& title, QtxPreferenceItem* parent,
1201 const QString& sect, const QString& param )
1202 : QtxPagePrefItem( title, parent, sect, param )
1204 QWidget* main = new QWidget();
1205 QVBoxLayout* base = new QVBoxLayout( main );
1206 base->setMargin( 0 );
1207 base->setSpacing( 0 );
1209 base->addWidget( myBox = new QtxGridBox( 1, Qt::Horizontal, main, 5, 5 ) );
1210 base->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
1218 QtxPagePrefFrameItem::~QtxPagePrefFrameItem()
1223 \brief Update widget contents.
1225 void QtxPagePrefFrameItem::updateContents()
1227 QtxPagePrefItem::updateContents();
1231 QtxPageNamedPrefItem::adjustLabels( this );
1235 \brief Get frame margin.
1236 \return current frame margin
1239 int QtxPagePrefFrameItem::margin() const
1241 return myBox->insideMargin();
1245 \brief Get frame margin.
1246 \param m new frame margin
1249 void QtxPagePrefFrameItem::setMargin( const int m )
1251 myBox->setInsideMargin( m );
1255 \brief Get frame spacing.
1256 \return current frame spacing
1259 int QtxPagePrefFrameItem::spacing() const
1261 return myBox->insideSpacing();
1265 \brief Set frame spacing.
1266 \param s new frame spacing
1269 void QtxPagePrefFrameItem::setSpacing( const int s )
1271 myBox->setInsideSpacing( s );
1275 \brief Get number of frame columns.
1276 \return current columns number
1279 int QtxPagePrefFrameItem::columns() const
1281 return myBox->columns();
1285 \brief Set number of frame columns.
1286 \param c new columns number
1289 void QtxPagePrefFrameItem::setColumns( const int c )
1291 myBox->setColumns( c );
1295 \brief Get frame box orientation.
1296 \return current frame orientation
1297 \sa setOrientation()
1299 Qt::Orientation QtxPagePrefFrameItem::orientation() const
1301 return myBox->orientation();
1305 \brief Set frame box orientation.
1306 \param o new frame orientation
1309 void QtxPagePrefFrameItem::setOrientation( const Qt::Orientation o )
1311 myBox->setOrientation( o );
1315 \brief Check if the frame widget stretching is enabled.
1316 \return \c true if the widget is stretchable
1319 bool QtxPagePrefFrameItem::stretch() const
1322 QLayout* l = widget() ? widget()->layout() : 0;
1323 for ( int i = 0; l && i < l->count() && !s; i++ )
1324 s = l->itemAt( i )->spacerItem();
1326 return s ? (bool)( s->expandingDirections() & Qt::Vertical ) : false;
1330 \brief Enable/disable frame widget stretching.
1331 \param on new stretchable state
1334 void QtxPagePrefFrameItem::setStretch( const bool on )
1337 QLayout* l = widget() ? widget()->layout() : 0;
1338 for ( int i = 0; l && i < l->count() && !s; i++ )
1339 s = l->itemAt( i )->spacerItem();
1342 s->changeSize( 0, 0, QSizePolicy::Minimum, on ? QSizePolicy::Expanding : QSizePolicy::Minimum );
1346 \brief Get preference item option value.
1347 \param name option name
1348 \return property value or null QVariant if option is not set
1349 \sa setOptionValue()
1351 QVariant QtxPagePrefFrameItem::optionValue( const QString& name ) const
1353 if ( name == "margin" )
1355 else if ( name == "spacing" )
1357 else if ( name == "columns" )
1359 else if ( name == "orientation" )
1360 return orientation();
1361 else if ( name == "stretch" )
1364 return QtxPagePrefItem::optionValue( name );
1368 \brief Set preference item option value.
1369 \param name option name
1370 \param val new property value
1373 void QtxPagePrefFrameItem::setOptionValue( const QString& name, const QVariant& val )
1375 if ( name == "margin" )
1377 if ( val.canConvert( QVariant::Int ) )
1378 setMargin( val.toInt() );
1380 else if ( name == "spacing" )
1382 if ( val.canConvert( QVariant::Int ) )
1383 setSpacing( val.toInt() );
1385 else if ( name == "columns" )
1387 if ( val.canConvert( QVariant::Int ) )
1388 setColumns( val.toInt() );
1390 else if ( name == "orientation" )
1392 if ( val.canConvert( QVariant::Int ) )
1393 setOrientation( (Qt::Orientation)val.toInt() );
1395 else if ( name == "stretch" )
1397 if ( val.canConvert( QVariant::Bool ) )
1398 setStretch( val.toBool() );
1401 QtxPagePrefItem::setOptionValue( name, val );
1404 void QtxPagePrefFrameItem::widgetShown()
1406 QtxPagePrefItem::widgetShown();
1408 QtxPageNamedPrefItem::adjustLabels( this );
1412 \brief Update frame widget.
1414 void QtxPagePrefFrameItem::updateFrame()
1416 QList<QtxPagePrefItem*> items;
1417 pageChildItems( items );
1419 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1421 QWidget* wid = (*it)->widget();
1425 if ( wid->parent() != myBox )
1426 wid->setParent( myBox );
1431 \class QtxPagePrefGroupItem
1432 \brief GUI implementation of the group widget container.
1437 \param title preference item title
1438 \param parent parent preference item
1439 \param sect resource file section associated with the preference item
1440 \param param resource file parameter associated with the preference item
1442 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const QString& title, QtxPreferenceItem* parent,
1443 const QString& sect, const QString& param )
1444 : QtxPagePrefItem( title, parent, sect, param )
1446 myGroup = new QtxGroupBox( title, 0 );
1447 myBox = new QtxGridBox( 1, Qt::Horizontal, myGroup, 5, 5 );
1448 myGroup->setWidget( myBox );
1450 setWidget( myGroup );
1457 \param cols columns number
1458 \param title preference item title
1459 \param parent parent preference item
1460 \param sect resource file section associated with the preference item
1461 \param param resource file parameter associated with the preference item
1463 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const int cols, const QString& title, QtxPreferenceItem* parent,
1464 const QString& sect, const QString& param )
1465 : QtxPagePrefItem( title, parent, sect, param )
1467 myGroup = new QtxGroupBox( title, 0 );
1468 myBox = new QtxGridBox( cols, Qt::Horizontal, myGroup, 5, 5 );
1469 myGroup->setWidget( myBox );
1471 setWidget( myGroup );
1479 QtxPagePrefGroupItem::~QtxPagePrefGroupItem()
1484 \brief Assign resource file settings to the preference item.
1485 \param sect resource file section name
1486 \param param resource file parameter name
1489 void QtxPagePrefGroupItem::setResource( const QString& sect, const QString& param )
1491 QtxPagePrefItem::setResource( sect, param );
1496 \brief Update widget contents.
1498 void QtxPagePrefGroupItem::updateContents()
1500 QtxPagePrefItem::updateContents();
1502 myGroup->setTitle( title() );
1507 QtxPageNamedPrefItem::adjustLabels( this );
1511 \brief Get group box margin.
1512 \return current group box margin
1515 int QtxPagePrefGroupItem::margin() const
1517 return myBox->insideMargin();
1521 \brief Get group box margin.
1522 \param m new group box margin
1525 void QtxPagePrefGroupItem::setMargin( const int m )
1527 myBox->setInsideMargin( m );
1531 \brief Get group box spacing.
1532 \return current group box spacing
1535 int QtxPagePrefGroupItem::spacing() const
1537 return myBox->insideSpacing();
1541 \brief Set group box spacing.
1542 \param s new group box spacing
1545 void QtxPagePrefGroupItem::setSpacing( const int s )
1547 myBox->setInsideSpacing( s );
1551 \brief Get number of group box columns.
1552 \return current columns number
1555 int QtxPagePrefGroupItem::columns() const
1557 return myBox->columns();
1561 \brief Set number of group box columns.
1562 \param c new columns number
1565 void QtxPagePrefGroupItem::setColumns( const int c )
1567 myBox->setColumns( c );
1571 \brief Get group box orientation.
1572 \return current group box orientation
1573 \sa setOrientation()
1575 Qt::Orientation QtxPagePrefGroupItem::orientation() const
1577 return myBox->orientation();
1581 \brief Set group box orientation.
1582 \param o new group box orientation
1585 void QtxPagePrefGroupItem::setOrientation( const Qt::Orientation o )
1587 myBox->setOrientation( o );
1591 \brief Get 'flat' flag of the group box widget.
1592 \return \c true if the group box is flat
1594 bool QtxPagePrefGroupItem::isFlat() const
1596 return myGroup->isFlat();
1600 \brief Get 'flat' flag of the group box widget.
1601 \param on if \c true the group box will be made flat
1603 void QtxPagePrefGroupItem::setFlat( const bool on )
1605 myGroup->setFlat( on );
1609 \brief Store preference item to the resource manager.
1612 void QtxPagePrefGroupItem::store()
1614 if ( myGroup->isCheckable() )
1615 setBoolean( myGroup->isChecked() );
1619 \brief Return widget contained grid layout of this group.
1621 QtxGridBox* QtxPagePrefGroupItem::gridBox() const
1627 \brief Retrieve preference item from the resource manager.
1630 void QtxPagePrefGroupItem::retrieve()
1632 if ( myGroup->isCheckable() )
1633 myGroup->setChecked( getBoolean() );
1637 \brief Get preference item option value.
1638 \param name option name
1639 \return property value or null QVariant if option is not set
1640 \sa setOptionValue()
1642 QVariant QtxPagePrefGroupItem::optionValue( const QString& name ) const
1644 if ( name == "margin" )
1646 else if ( name == "spacing" )
1648 else if ( name == "columns" )
1650 else if ( name == "orientation" )
1651 return orientation();
1652 else if ( name == "flat" )
1655 return QtxPagePrefItem::optionValue( name );
1659 \brief Set preference item option value.
1660 \param name option name
1661 \param val new property value
1664 void QtxPagePrefGroupItem::setOptionValue( const QString& name, const QVariant& val )
1666 if ( name == "margin" )
1668 if ( val.canConvert( QVariant::Int ) )
1669 setMargin( val.toInt() );
1671 else if ( name == "spacing" )
1673 if ( val.canConvert( QVariant::Int ) )
1674 setSpacing( val.toInt() );
1676 else if ( name == "columns" )
1678 if ( val.canConvert( QVariant::Int ) )
1679 setColumns( val.toInt() );
1681 else if ( name == "orientation" )
1683 if ( val.canConvert( QVariant::Int ) )
1684 setOrientation( (Qt::Orientation)val.toInt() );
1686 else if ( name == "flat" )
1688 if ( val.canConvert( QVariant::Bool ) )
1689 setFlat( val.toBool() );
1692 QtxPagePrefItem::setOptionValue( name, val );
1695 void QtxPagePrefGroupItem::widgetShown()
1697 QtxPagePrefItem::widgetShown();
1699 QtxPageNamedPrefItem::adjustLabels( this );
1703 \brief Update widget state.
1705 void QtxPagePrefGroupItem::updateState()
1707 QString section, param;
1708 resource( section, param );
1709 myGroup->setCheckable( !title().isEmpty() && !section.isEmpty() && !param.isEmpty() );
1713 \brief Update group box widget.
1715 void QtxPagePrefGroupItem::updateGroup()
1717 QList<QtxPagePrefItem*> items;
1718 pageChildItems( items );
1720 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1722 QWidget* wid = (*it)->widget();
1726 if ( wid->parent() != myBox )
1727 wid->setParent( myBox );
1732 \class QtxPagePrefLabelItem
1733 \brief Label item which can be used in the preferences editor dialog box.
1739 Creates label item with specified title.
1741 \param text label text
1742 \param parent parent preference item
1744 QtxPagePrefLabelItem::QtxPagePrefLabelItem( const QString& text, QtxPreferenceItem* parent )
1745 : QtxPagePrefItem( text, parent )
1747 setWidget( myLabel = new QLabel( text ) );
1750 QtxPagePrefLabelItem::QtxPagePrefLabelItem( Qt::Alignment align, const QString& text, QtxPreferenceItem* parent )
1751 : QtxPagePrefItem( text, parent )
1753 setWidget( myLabel = new QLabel( text ) );
1754 myLabel->setAlignment( align );
1757 QtxPagePrefLabelItem::~QtxPagePrefLabelItem()
1761 void QtxPagePrefLabelItem::setTitle( const QString& text )
1763 QtxPagePrefItem::setTitle( text );
1766 myLabel->setText( text );
1769 Qt::Alignment QtxPagePrefLabelItem::alignment() const
1771 return myLabel->alignment();
1774 void QtxPagePrefLabelItem::setAlignment( Qt::Alignment align )
1776 myLabel->setAlignment( align );
1779 QVariant QtxPagePrefLabelItem::optionValue( const QString& name ) const
1782 if ( name == "alignment" )
1783 val = (int)alignment();
1787 void QtxPagePrefLabelItem::setOptionValue( const QString& name, const QVariant& val )
1789 if ( name == "alignment" )
1791 if ( val.canConvert( QVariant::Int ) )
1792 setAlignment( (Qt::Alignment)val.toInt() );
1797 \class QtxPagePrefSpaceItem
1798 \brief Simple spacer item which can be used in the preferences
1805 Creates spacer item with zero width and height and expanding
1806 on both directions (by height and width).
1808 \param parent parent preference item
1810 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( QtxPreferenceItem* parent )
1811 : QtxPagePrefItem( QString(), parent )
1813 initialize( 0, 0, 1, 1 );
1819 Creates spacer item with zero width and height and expanding
1820 according to the specified orientation.
1822 \param o spacer orientation
1823 \param parent parent preference item
1825 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( Qt::Orientation o, QtxPreferenceItem* parent )
1826 : QtxPagePrefItem( QString(), parent )
1828 if ( o == Qt::Horizontal )
1829 initialize( 0, 0, 1, 0 );
1831 initialize( 0, 0, 0, 1 );
1837 Creates spacer item with specified width and height. The spacing
1838 item is expanding horizontally if \a w <= 0 and vertically
1841 \param w spacer width
1842 \param h spacer height
1843 \param parent parent preference item
1845 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( const int w, const int h, QtxPreferenceItem* parent )
1846 : QtxPagePrefItem( QString(), parent )
1848 initialize( w, h, w > 0 ? 0 : 1, h > 0 ? 0 : 1 );
1854 QtxPagePrefSpaceItem::~QtxPagePrefSpaceItem()
1859 \brief Get spacer item size for the specified direction.
1861 \return size for the specified direction
1864 int QtxPagePrefSpaceItem::size( Qt::Orientation o ) const
1866 return o == Qt::Horizontal ? widget()->minimumWidth() : widget()->minimumHeight();
1870 \brief Set spacer item size for the specified direction.
1872 \param sz new size for the specified direction
1875 void QtxPagePrefSpaceItem::setSize( Qt::Orientation o, const int sz )
1877 if ( o == Qt::Horizontal )
1878 widget()->setMinimumWidth( sz );
1880 widget()->setMinimumHeight( sz );
1884 \brief Get spacer item stretch factor for the specified direction.
1886 \return stretch factor for the specified direction
1889 int QtxPagePrefSpaceItem::stretch( Qt::Orientation o ) const
1891 QSizePolicy sp = widget()->sizePolicy();
1892 return o == Qt::Horizontal ? sp.horizontalStretch() : sp.verticalStretch();
1896 \brief Set spacer item stretch factor for the specified direction.
1898 \param sf new stretch factor for the specified direction
1901 void QtxPagePrefSpaceItem::setStretch( Qt::Orientation o, const int sf )
1903 QSizePolicy sp = widget()->sizePolicy();
1904 if ( o == Qt::Horizontal )
1906 sp.setHorizontalStretch( sf );
1907 sp.setHorizontalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1911 sp.setVerticalStretch( sf );
1912 sp.setVerticalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1915 widget()->setSizePolicy( sp );
1919 \brief Get preference item option value.
1920 \param name option name
1921 \return property value or null QVariant if option is not set
1922 \sa setOptionValue()
1924 QVariant QtxPagePrefSpaceItem::optionValue( const QString& name ) const
1926 if ( name == "horizontal_size" || name == "hsize" )
1927 return size( Qt::Horizontal );
1928 else if ( name == "vertical_size" || name == "vsize" )
1929 return size( Qt::Vertical );
1930 else if ( name == "horizontal_stretch" || name == "hstretch" )
1931 return stretch( Qt::Horizontal );
1932 else if ( name == "vertical_stretch" || name == "vstretch" )
1933 return stretch( Qt::Vertical );
1935 return QtxPagePrefItem::optionValue( name );
1939 \brief Set preference item option value.
1940 \param name option name
1941 \param val new property value
1944 void QtxPagePrefSpaceItem::setOptionValue( const QString& name, const QVariant& val )
1946 if ( name == "horizontal_size" || name == "hsize" )
1948 if ( val.canConvert( QVariant::Int ) )
1949 setSize( Qt::Horizontal, val.toInt() );
1951 else if ( name == "vertical_size" || name == "vsize" )
1953 if ( val.canConvert( QVariant::Int ) )
1954 setSize( Qt::Vertical, val.toInt() );
1956 else if ( name == "horizontal_stretch" || name == "hstretch" )
1958 if ( val.canConvert( QVariant::Int ) )
1959 setStretch( Qt::Horizontal, val.toInt() );
1961 else if ( name == "vertical_stretch" || name == "vstretch" )
1963 if ( val.canConvert( QVariant::Int ) )
1964 setStretch( Qt::Vertical, val.toInt() );
1967 QtxPagePrefItem::setOptionValue( name, val );
1971 \brief Perform internal initialization.
1972 \param w spacer item width
1973 \param h spacer item height
1974 \param ws spacer item horizontal stretch factor
1975 \param hs spacer item vertical stretch factor
1977 void QtxPagePrefSpaceItem::initialize( const int w, const int h, const int hs, const int vs )
1980 sp.setHorizontalPolicy( hs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1981 sp.setVerticalPolicy( vs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1983 sp.setHorizontalStretch( hs );
1984 sp.setVerticalStretch( vs );
1986 QWidget* wid = new QWidget();
1987 wid->setSizePolicy( sp );
1989 wid->setMinimumSize( w, h );
1995 \class QtxPagePrefCheckItem
1996 \brief GUI implementation of the resources check box item (boolean).
2001 \param title preference item title
2002 \param parent parent preference item
2003 \param sect resource file section associated with the preference item
2004 \param param resource file parameter associated with the preference item
2006 QtxPagePrefCheckItem::QtxPagePrefCheckItem( const QString& title, QtxPreferenceItem* parent,
2007 const QString& sect, const QString& param )
2009 : QtxPagePrefItem( title, parent, sect, param )
2011 myCheck = new QCheckBox( title );
2012 myCheck->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2013 setWidget( myCheck );
2019 QtxPagePrefCheckItem::~QtxPagePrefCheckItem()
2024 \brief Set preference item title.
2025 \param txt new preference title.
2027 void QtxPagePrefCheckItem::setTitle( const QString& txt )
2029 QtxPagePrefItem::setTitle( txt );
2031 myCheck->setText( title() );
2035 \brief Store preference item to the resource manager.
2038 void QtxPagePrefCheckItem::store()
2040 setBoolean( myCheck->isChecked() );
2044 \brief Retrieve preference item from the resource manager.
2047 void QtxPagePrefCheckItem::retrieve()
2049 myCheck->setChecked( getBoolean() );
2053 \class QtxPagePrefEditItem
2054 \brief GUI implementation of the resources line edit box item
2055 for string, integer and double values.
2058 static void fixupAndSet( QLineEdit* le, const QString& txt )
2062 if ( le->validator() ) {
2063 const QDoubleValidator* de = dynamic_cast<const QDoubleValidator*>( le->validator() );
2065 int dec = de->decimals();
2066 int idx = val.lastIndexOf( QRegExp( QString("[.|%1]").arg( le->locale().decimalPoint () ) ) );
2068 QString tmp = val.mid( idx+1 );
2070 val = val.left( idx+1 );
2071 idx = tmp.indexOf( QRegExp( QString("[e|E]") ) );
2073 exp = tmp.mid( idx );
2074 tmp = tmp.left( idx );
2076 tmp.truncate( dec );
2077 val = val + tmp + exp;
2081 if ( le->validator()->validate( val, pos ) == QValidator::Invalid )
2091 Creates preference item for string value editing.
2093 \param title preference item title
2094 \param parent parent preference item
2095 \param sect resource file section associated with the preference item
2096 \param param resource file parameter associated with the preference item
2098 QtxPagePrefEditItem::QtxPagePrefEditItem( const QString& title, QtxPreferenceItem* parent,
2099 const QString& sect, const QString& param )
2100 : QtxPageNamedPrefItem( title, parent, sect, param ),
2105 setControl( myEditor = new QLineEdit() );
2112 Creates preference item for editing of the value which type
2113 is specified by parameter \a type.
2115 \param type preference item input type (QtxPagePrefEditItem::InputType)
2116 \param title preference item title
2117 \param parent parent preference item
2118 \param sect resource file section associated with the preference item
2119 \param param resource file parameter associated with the preference item
2121 QtxPagePrefEditItem::QtxPagePrefEditItem( const int type, const QString& title,
2122 QtxPreferenceItem* parent, const QString& sect,
2123 const QString& param )
2124 : QtxPageNamedPrefItem( title, parent, sect, param ),
2129 setControl( myEditor = new QLineEdit() );
2136 QtxPagePrefEditItem::~QtxPagePrefEditItem()
2141 \brief Get edit box preference item input type.
2142 \return preference item input type (QtxPagePrefEditItem::InputType)
2145 int QtxPagePrefEditItem::inputType() const
2151 \brief Set edit box preference item input type.
2152 \param type new preference item input type (QtxPagePrefEditItem::InputType)
2155 void QtxPagePrefEditItem::setInputType( const int type )
2157 if ( myType == type )
2165 \brief Get number of digits after decimal point (for Double input type)
2166 \return preference item decimals value
2169 int QtxPagePrefEditItem::decimals() const
2175 \brief Set number of digits after decimal point (for Double input type)
2176 \param dec new preference item decimals value
2179 void QtxPagePrefEditItem::setDecimals( const int dec )
2181 if ( myDecimals == dec )
2189 \brief Get the line edit's echo mode
2190 \return preference item echo mode value
2193 int QtxPagePrefEditItem::echoMode() const
2199 \brief Set the line edit's echo mode
2200 \param echo new preference item echo mode value
2203 void QtxPagePrefEditItem::setEchoMode( const int echo )
2205 if ( myEchoMode == echo )
2213 \brief Store preference item to the resource manager.
2216 void QtxPagePrefEditItem::store()
2218 setString( myEditor->text() );
2222 \brief Retrieve preference item from the resource manager.
2225 void QtxPagePrefEditItem::retrieve()
2227 QString txt = getString();
2228 fixupAndSet( myEditor, txt );
2232 \brief Get preference item option value.
2233 \param name option name
2234 \return property value or null QVariant if option is not set
2235 \sa setOptionValue()
2237 QVariant QtxPagePrefEditItem::optionValue( const QString& name ) const
2239 if ( name == "input_type" || name == "type" )
2241 else if ( name == "precision" || name == "prec" || name == "decimals" )
2243 else if ( name == "echo" || name == "echo_mode" || name == "echomode")
2246 return QtxPageNamedPrefItem::optionValue( name );
2250 \brief Set preference item option value.
2251 \param name option name
2252 \param val new property value
2255 void QtxPagePrefEditItem::setOptionValue( const QString& name, const QVariant& val )
2257 if ( name == "input_type" || name == "type" )
2259 if ( val.canConvert( QVariant::Int ) )
2260 setInputType( val.toInt() );
2262 else if ( name == "precision" || name == "prec" || name == "decimals" ) {
2263 if ( val.canConvert( QVariant::Int ) )
2264 setDecimals( val.toInt() );
2266 else if ( name == "echo" || name == "echo_mode" || name == "echomode") {
2267 if ( val.canConvert( QVariant::Int ) )
2268 setEchoMode( val.toInt() );
2271 QtxPageNamedPrefItem::setOptionValue( name, val );
2275 \brief Update edit box widget.
2277 void QtxPagePrefEditItem::updateEditor()
2282 myEditor->setEchoMode(QLineEdit::Normal);
2285 myEditor->setEchoMode(QLineEdit::NoEcho);
2288 myEditor->setEchoMode(QLineEdit::Password);
2291 myEditor->setEchoMode(QLineEdit::PasswordEchoOnEdit);
2294 myEditor->setEchoMode(QLineEdit::Normal);
2297 QValidator* val = 0;
2298 switch ( inputType() )
2301 val = new QIntValidator( myEditor );
2304 val = new QDoubleValidator( myEditor );
2305 dynamic_cast<QDoubleValidator*>( val )->setDecimals( myDecimals < 0 ? 1000 : myDecimals );
2311 QString txt = myEditor->text();
2312 delete myEditor->validator();
2313 myEditor->setValidator( val );
2314 fixupAndSet( myEditor, txt );
2318 \class QtxPagePrefSliderItem
2324 Creates preference item with slider widget
2326 \param title preference item title
2327 \param parent parent preference item
2328 \param sect resource file section associated with the preference item
2329 \param param resource file parameter associated with the preference item
2331 QtxPagePrefSliderItem::QtxPagePrefSliderItem( const QString& title, QtxPreferenceItem* parent,
2332 const QString& sect, const QString& param )
2333 : QtxPageNamedPrefItem( title, parent, sect, param )
2335 setControl( mySlider = new QSlider( Qt::Horizontal ) );
2336 widget()->layout()->addWidget( myLabel = new QLabel( ) );
2343 mySlider->setTickPosition( QSlider::TicksBothSides );
2345 connect (mySlider, SIGNAL(valueChanged(int)), this, SLOT(setIcon(int)));
2352 QtxPagePrefSliderItem::~QtxPagePrefSliderItem()
2357 \brief Get slider preference item step value.
2358 \return slider single step value
2361 int QtxPagePrefSliderItem::singleStep() const
2363 return mySlider->singleStep();
2367 \brief Get slider preference item step value.
2368 \return slider page step value
2371 int QtxPagePrefSliderItem::pageStep() const
2373 return mySlider->pageStep();
2377 \brief Get slider preference item minimum value.
2378 \return slider minimum value
2381 int QtxPagePrefSliderItem::minimum() const
2383 return mySlider->minimum();
2387 \brief Get slider preference item maximum value.
2388 \return slider maximum value
2391 int QtxPagePrefSliderItem::maximum() const
2393 return mySlider->maximum();
2397 \brief Get the list of the icons associated with the selection widget items
2398 \return list of icons
2401 QList<QIcon> QtxPagePrefSliderItem::icons() const
2407 \brief Set slider preference item step value.
2408 \param step new slider single step value
2411 void QtxPagePrefSliderItem::setSingleStep( const int& step )
2413 mySlider->setSingleStep( step );
2417 \brief Set slider preference item step value.
2418 \param step new slider single step value
2421 void QtxPagePrefSliderItem::setPageStep( const int& step )
2423 mySlider->setPageStep( step );
2427 \brief Set slider preference item minimum value.
2428 \param min new slider minimum value
2431 void QtxPagePrefSliderItem::setMinimum( const int& min )
2433 mySlider->setMinimum( min );
2434 setIcon( mySlider->value() );
2438 \brief Set slider preference item maximum value.
2439 \param max new slider maximum value
2442 void QtxPagePrefSliderItem::setMaximum( const int& max )
2444 mySlider->setMaximum( max );
2445 setIcon( mySlider->value() );
2449 \brief Set the list of the icons to the selection widget items
2450 \param icns new list of icons
2453 void QtxPagePrefSliderItem::setIcons( const QList<QIcon>& icns )
2455 if ( icns.isEmpty() )
2459 QSize maxsize(0, 0);
2460 for ( QList<QIcon>::const_iterator it = myIcons.begin(); it != myIcons.end(); ++it ) {
2461 if ( (*it).isNull() ) continue;
2462 maxsize = maxsize.expandedTo( (*it).availableSizes().first() );
2464 myLabel->setFixedSize( maxsize );
2470 \brief Store preference item to the resource manager.
2473 void QtxPagePrefSliderItem::store()
2475 setInteger( mySlider->value() );
2479 \brief Retrieve preference item from the resource manager.
2482 void QtxPagePrefSliderItem::retrieve()
2484 mySlider->setValue( getInteger( mySlider->value() ) );
2488 \brief Get preference item option value.
2489 \param name option name
2490 \return property value or null integer if option is not set
2491 \sa setOptionValue()
2493 QVariant QtxPagePrefSliderItem::optionValue( const QString& name ) const
2495 if ( name == "minimum" || name == "min" )
2497 else if ( name == "maximum" || name == "max" )
2499 else if ( name == "single_step" )
2500 return singleStep();
2501 else if ( name == "page_step" )
2503 else if ( name == "icons" || name == "pixmaps" )
2505 QList<QVariant> lst;
2506 QList<QIcon> ics = icons();
2507 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2512 return QtxPageNamedPrefItem::optionValue( name );
2516 \brief Set preference item option value.
2517 \param name option name
2518 \param val new property value
2521 void QtxPagePrefSliderItem::setOptionValue( const QString& name, const QVariant& val )
2523 if ( val.canConvert( QVariant::Int ) )
2525 if ( name == "minimum" || name == "min" )
2526 setMinimum( val.toInt() );
2527 else if ( name == "maximum" || name == "max" )
2528 setMaximum( val.toInt() );
2529 else if ( name == "single_step" )
2530 setSingleStep( val.toInt() );
2531 else if ( name == "page_step" )
2532 setPageStep( val.toInt() );
2534 QtxPageNamedPrefItem::setOptionValue( name, val );
2536 else if ( name == "icons" || name == "pixmaps" )
2539 QtxPageNamedPrefItem::setOptionValue( name, val );
2542 void QtxPagePrefSliderItem::setIcon( int pos )
2544 int index = pos - mySlider->minimum();
2545 if ( !myIcons.isEmpty() && index >= 0 && index < myIcons.size() && !myIcons[index].isNull() )
2546 myLabel->setPixmap( myIcons[index].pixmap( myIcons[index].availableSizes().first() ) );
2552 \brief Update slider widget.
2554 void QtxPagePrefSliderItem::updateSlider()
2556 int val = mySlider->value();
2557 int stp = singleStep();
2558 int ptp = pageStep();
2559 int min = minimum();
2560 int max = maximum();
2562 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2563 mySlider->setFocusPolicy(Qt::StrongFocus);
2565 mySlider->setValue( val );
2566 setSingleStep( stp );
2571 myLabel->setVisible( !myIcons.empty() );
2572 widget()->layout()->setSpacing( !myIcons.empty() ? 6 : 0 );
2576 \brief Set the list of the icons from the resource manager.
2577 \param var new icons list
2580 void QtxPagePrefSliderItem::setIcons( const QVariant& var )
2582 if ( var.type() != QVariant::List )
2586 QList<QVariant> varList = var.toList();
2587 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2589 if ( (*it).canConvert<QIcon>() )
2590 lst.append( (*it).value<QIcon>() );
2591 else if ( (*it).canConvert<QPixmap>() )
2592 lst.append( (*it).value<QPixmap>() );
2594 lst.append( QIcon() );
2600 \class QtxPagePrefSelectItem
2601 \brief GUI implementation of the resources selector item
2602 (string, integer or double values list).
2604 All items in the list (represented as combo box) should be specified
2605 by the unique identifier which is stored to the resource file instead
2606 of the value itself.
2612 Creates preference item with combo box widget which is not editable
2613 (direct value entering is disabled).
2615 \param title preference item title
2616 \param parent parent preference item
2617 \param sect resource file section associated with the preference item
2618 \param param resource file parameter associated with the preference item
2620 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const QString& title, QtxPreferenceItem* parent,
2621 const QString& sect, const QString& param )
2622 : QtxPageNamedPrefItem( title, parent, sect, param ),
2625 setControl( mySelector = new QtxComboBox() );
2626 mySelector->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2627 mySelector->setDuplicatesEnabled( false );
2634 Creates preference item with combo box widget which is editable
2635 according to the specified input type (integer, double or string values).
2637 \param type input type (QtxPagePrefSelectItem::InputType)
2638 \param title preference item title
2639 \param parent parent preference item
2640 \param sect resource file section associated with the preference item
2641 \param param resource file parameter associated with the preference item
2643 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const int type, const QString& title, QtxPreferenceItem* parent,
2644 const QString& sect, const QString& param )
2645 : QtxPageNamedPrefItem( title, parent, sect, param ),
2648 setControl( mySelector = new QtxComboBox() );
2649 mySelector->setDuplicatesEnabled( false );
2656 QtxPagePrefSelectItem::~QtxPagePrefSelectItem()
2661 \brief Get edit box preference item input type.
2662 \return preference item input type (QtxPagePrefSelectItem::InputType)
2665 int QtxPagePrefSelectItem::inputType() const
2671 \brief Set edit box preference item input type.
2672 \param type new preference item input type (QtxPagePrefSelectItem::InputType)
2675 void QtxPagePrefSelectItem::setInputType( const int type )
2677 if ( myType == type )
2685 \brief Get the list of the values from the selection widget.
2686 \return list of values
2687 \sa numbers(), icons(), setStrings()
2689 QStringList QtxPagePrefSelectItem::strings() const
2692 for ( uint i = 0; i < mySelector->count(); i++ )
2693 res.append( mySelector->itemText( i ) );
2698 \brief Get the list of the values identifiers from the selection widget.
2699 \return list of values IDs
2700 \sa strings(), icons(), setNumbers()
2702 QList<int> QtxPagePrefSelectItem::numbers() const
2705 for ( uint i = 0; i < mySelector->count(); i++ )
2707 if ( mySelector->hasId( i ) )
2708 res.append( mySelector->id( i ) );
2714 \brief Get the list of the icons associated with the selection widget.items
2715 \return list of icons
2716 \sa strings(), numbers(), setIcons()
2718 QList<QIcon> QtxPagePrefSelectItem::icons() const
2721 for ( uint i = 0; i < mySelector->count(); i++ )
2722 res.append( mySelector->itemIcon( i ) );
2727 \brief Set the list of the values to the selection widget.
2728 \param lst new list of values
2729 \sa strings(), setNumbers(), setIcons()
2731 void QtxPagePrefSelectItem::setStrings( const QStringList& lst )
2733 mySelector->clear();
2734 mySelector->addItems( lst );
2738 \brief Set the list of the values identifiers to the selection widget
2739 \param ids new list of values IDs
2740 \sa numbers(), setStrings(), setIcons()
2742 void QtxPagePrefSelectItem::setNumbers( const QList<int>& ids )
2745 for ( QList<int>::const_iterator it = ids.begin(); it != ids.end(); ++it, i++ ) {
2746 if ( i >= mySelector->count() )
2747 mySelector->addItem(QString("") );
2749 mySelector->setId( i, *it );
2754 \brief Set the list of the icons to the selection widget items
2756 Important: call this method after setStrings() or setNumbers()
2758 \param icns new list of icons
2759 \sa icons(), setStrings(), setNumbers()
2761 void QtxPagePrefSelectItem::setIcons( const QList<QIcon>& icns )
2764 for ( QList<QIcon>::const_iterator it = icns.begin(); it != icns.end() && i < mySelector->count(); ++it, i++ )
2765 mySelector->setItemIcon( i, *it );
2769 \brief Store preference item to the resource manager.
2772 void QtxPagePrefSelectItem::store()
2774 if ( mySelector->isCleared() )
2777 int idx = mySelector->currentIndex();
2779 if ( mySelector->hasId( idx ) )
2780 setInteger( mySelector->id( idx ) );
2781 else if ( idx >= 0 )
2782 setString( mySelector->itemText( idx ) );
2786 \brief Retrieve preference item from the resource manager.
2789 void QtxPagePrefSelectItem::retrieve()
2791 QString txt = getString();
2796 int num = txt.toInt( &ok );
2798 idx = mySelector->index( num );
2801 for ( uint i = 0; i < mySelector->count() && idx == -1; i++ )
2803 if ( mySelector->itemText( i ) == txt )
2809 mySelector->setCurrentIndex( idx );
2810 else if ( mySelector->isEditable() )
2813 if ( mySelector->validator() &&
2814 mySelector->validator()->validate( txt, pos ) == QValidator::Invalid )
2815 mySelector->setCleared( true );
2818 mySelector->setCleared( false );
2819 mySelector->addItem( txt );
2820 mySelector->setCurrentIndex( mySelector->count() - 1 );
2826 \brief Get preference item option value.
2827 \param name option name
2828 \return property value or null QVariant if option is not set
2829 \sa setOptionValue()
2831 QVariant QtxPagePrefSelectItem::optionValue( const QString& name ) const
2833 if ( name == "input_type" || name == "type" )
2835 else if ( name == "strings" || name == "labels" )
2837 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2839 QList<QVariant> lst;
2840 QList<int> nums = numbers();
2841 for ( QList<int>::const_iterator it = nums.begin(); it != nums.end(); ++it )
2845 else if ( name == "icons" || name == "pixmaps" )
2847 QList<QVariant> lst;
2848 QList<QIcon> ics = icons();
2849 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2854 return QtxPageNamedPrefItem::optionValue( name );
2858 \brief Set preference item option value.
2859 \param name option name
2860 \param val new property value
2863 void QtxPagePrefSelectItem::setOptionValue( const QString& name, const QVariant& val )
2865 if ( name == "input_type" || name == "type" )
2867 if ( val.canConvert( QVariant::Int ) )
2868 setInputType( val.toInt() );
2870 else if ( name == "strings" || name == "labels" )
2872 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2874 else if ( name == "icons" || name == "pixmaps" )
2877 QtxPageNamedPrefItem::setOptionValue( name, val );
2881 \brief Set the list of the values from the resource manager.
2882 \param var new values list
2885 void QtxPagePrefSelectItem::setStrings( const QVariant& var )
2887 if ( var.type() != QVariant::StringList )
2890 setStrings( var.toStringList() );
2894 \brief Set the list of the values identifiers from the resource manager.
2895 \param var new values IDs list
2898 void QtxPagePrefSelectItem::setNumbers( const QVariant& var )
2900 if ( var.type() != QVariant::List )
2904 QList<QVariant> varList = var.toList();
2905 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2907 if ( (*it).canConvert( QVariant::Int ) )
2908 lst.append( (*it).toInt() );
2914 \brief Set the list of the icons from the resource manager.
2915 \param var new icons list
2918 void QtxPagePrefSelectItem::setIcons( const QVariant& var )
2920 if ( var.type() != QVariant::List )
2924 QList<QVariant> varList = var.toList();
2925 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2927 if ( (*it).canConvert<QIcon>() )
2928 lst.append( (*it).value<QIcon>() );
2929 else if ( (*it).canConvert<QPixmap>() )
2930 lst.append( (*it).value<QPixmap>() );
2932 lst.append( QIcon() );
2938 \brief Update selector widget.
2940 void QtxPagePrefSelectItem::updateSelector()
2942 QValidator* val = 0;
2943 switch ( inputType() )
2946 val = new QIntValidator( mySelector );
2949 val = new QDoubleValidator( mySelector );
2955 mySelector->setEditable( inputType() != NoInput );
2957 if ( mySelector->isEditable() && !mySelector->currentText().isEmpty() && val )
2960 QString str = mySelector->currentText();
2961 if ( val->validate( str, pos ) == QValidator::Invalid )
2962 mySelector->clearEditText();
2965 delete mySelector->validator();
2966 mySelector->setValidator( val );
2970 \class QtxPagePrefSpinItem
2971 \brief GUI implementation of the resources spin box item
2972 (for integer or double value).
2978 Creates spin box preference item for the entering integer values.
2980 \param title preference item title
2981 \param parent parent preference item
2982 \param sect resource file section associated with the preference item
2983 \param param resource file parameter associated with the preference item
2985 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const QString& title, QtxPreferenceItem* parent,
2986 const QString& sect, const QString& param )
2987 : QtxPageNamedPrefItem( title, parent, sect, param ),
2996 Creates spin box preference item for the entering values which type
2997 is specified by the parameter \a type.
2999 \param type input type (QtxPagePrefSpinItem::InputType).
3000 \param title preference item title
3001 \param parent parent preference item
3002 \param sect resource file section associated with the preference item
3003 \param param resource file parameter associated with the preference item
3005 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const int type, const QString& title,
3006 QtxPreferenceItem* parent, const QString& sect,
3007 const QString& param )
3008 : QtxPageNamedPrefItem( title, parent, sect, param ),
3017 QtxPagePrefSpinItem::~QtxPagePrefSpinItem()
3022 \brief Get spin box preference item input type.
3023 \return preference item input type (QtxPagePrefSpinItem::InputType)
3026 int QtxPagePrefSpinItem::inputType() const
3032 \brief Set spin box preference item input type.
3033 \param type new preference item input type (QtxPagePrefSpinItem::InputType)
3036 void QtxPagePrefSpinItem::setInputType( const int type )
3038 if ( myType == type )
3046 \brief Get spin box preference item step value.
3047 \return spin box single step value
3050 QVariant QtxPagePrefSpinItem::step() const
3052 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3053 return isb->singleStep();
3054 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3055 return dsb->singleStep();
3061 \brief Get double spin box preference item precision value.
3062 \return double spin box precision
3065 QVariant QtxPagePrefSpinItem::precision() const
3067 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3068 return dsb->decimals();
3074 \brief Get spin box preference item minimum value.
3075 \return spin box minimum value
3078 QVariant QtxPagePrefSpinItem::minimum() const
3080 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3081 return isb->minimum();
3082 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3083 return dsb->minimum();
3089 \brief Get spin box preference item maximum value.
3090 \return spin box maximum value
3093 QVariant QtxPagePrefSpinItem::maximum() const
3095 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3096 return isb->maximum();
3097 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3098 return dsb->maximum();
3104 \brief Get spin box preference item prefix string.
3105 \return spin box prefix string
3108 QString QtxPagePrefSpinItem::prefix() const
3110 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3111 return isb->prefix();
3112 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3113 return dsb->prefix();
3119 \brief Get spin box preference item suffix string.
3120 \return spin box suffix string
3123 QString QtxPagePrefSpinItem::suffix() const
3125 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3126 return isb->suffix();
3127 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3128 return dsb->suffix();
3134 \brief Get spin box preference item special value text (which is shown
3135 when the spin box reaches minimum value).
3136 \return spin box special value text
3137 \sa setSpecialValueText()
3139 QString QtxPagePrefSpinItem::specialValueText() const
3141 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3143 return sb->specialValueText();
3149 \brief Set spin box preference item step value.
3150 \param step new spin box single step value
3153 void QtxPagePrefSpinItem::setStep( const QVariant& step )
3155 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3157 if ( step.canConvert( QVariant::Int ) )
3158 isb->setSingleStep( step.toInt() );
3160 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3162 if ( step.canConvert( QVariant::Double ) )
3163 dsb->setSingleStep( step.toDouble() );
3168 \brief Set double spin box preference item precision value.
3169 \param step new double spin box precision value
3172 void QtxPagePrefSpinItem::setPrecision( const QVariant& prec )
3174 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3176 if ( prec.canConvert( QVariant::Int ) ) {
3177 dsb->setDecimals( qAbs( prec.toInt() ) );
3178 dsb->setPrecision( prec.toInt() );
3184 \brief Set spin box preference item minimum value.
3185 \param min new spin box minimum value
3188 void QtxPagePrefSpinItem::setMinimum( const QVariant& min )
3190 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3192 if ( min.canConvert( QVariant::Int ) )
3193 isb->setMinimum( min.toInt() );
3195 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3197 if ( min.canConvert( QVariant::Double ) )
3198 dsb->setMinimum( min.toDouble() );
3203 \brief Set spin box preference item maximum value.
3204 \param min new spin box maximum value
3207 void QtxPagePrefSpinItem::setMaximum( const QVariant& max )
3209 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3211 if ( max.canConvert( QVariant::Int ) )
3212 isb->setMaximum( max.toInt() );
3214 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3216 if ( max.canConvert( QVariant::Double ) )
3217 dsb->setMaximum( max.toDouble() );
3222 \brief Set spin box preference item prefix string.
3223 \param txt new spin box prefix string
3226 void QtxPagePrefSpinItem::setPrefix( const QString& txt )
3228 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3229 isb->setPrefix( txt );
3230 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3231 dsb->setPrefix( txt );
3235 \brief Set spin box preference item suffix string.
3236 \param txt new spin box suffix string
3239 void QtxPagePrefSpinItem::setSuffix( const QString& txt )
3241 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3242 isb->setSuffix( txt );
3243 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3244 dsb->setSuffix( txt );
3248 \brief Set spin box preference item special value text (which is shown
3249 when the spin box reaches minimum value).
3250 \param txt new spin box special value text
3251 \sa specialValueText()
3253 void QtxPagePrefSpinItem::setSpecialValueText( const QString& txt )
3255 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3257 sb->setSpecialValueText( txt );
3261 \brief Store preference item to the resource manager.
3264 void QtxPagePrefSpinItem::store()
3266 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3267 setInteger( isb->value() );
3268 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3269 setDouble( dsb->value() );
3273 \brief Retrieve preference item from the resource manager.
3276 void QtxPagePrefSpinItem::retrieve()
3278 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3279 isb->setValue( getInteger( isb->value() ) );
3280 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3281 dsb->setValue( getDouble( dsb->value() ) );
3285 \brief Get preference item option value.
3286 \param name option name
3287 \return property value or null QVariant if option is not set
3288 \sa setOptionValue()
3290 QVariant QtxPagePrefSpinItem::optionValue( const QString& name ) const
3292 if ( name == "input_type" || name == "type" )
3294 else if ( name == "minimum" || name == "min" )
3296 else if ( name == "maximum" || name == "max" )
3298 else if ( name == "step" )
3300 else if ( name == "precision" )
3302 else if ( name == "prefix" )
3304 else if ( name == "suffix" )
3306 else if ( name == "special" )
3307 return specialValueText();
3309 return QtxPageNamedPrefItem::optionValue( name );
3313 \brief Set preference item option value.
3314 \param name option name
3315 \param val new property value
3318 void QtxPagePrefSpinItem::setOptionValue( const QString& name, const QVariant& val )
3320 if ( name == "input_type" || name == "type" )
3322 if ( val.canConvert( QVariant::Int ) )
3323 setInputType( val.toInt() );
3325 else if ( name == "minimum" || name == "min" )
3327 else if ( name == "maximum" || name == "max" )
3329 else if ( name == "step" )
3331 else if ( name == "precision" )
3332 setPrecision( val );
3333 else if ( name == "prefix" )
3335 if ( val.canConvert( QVariant::String ) )
3336 setPrefix( val.toString() );
3338 else if ( name == "suffix" )
3340 if ( val.canConvert( QVariant::String ) )
3341 setSuffix( val.toString() );
3343 else if ( name == "special" )
3345 if ( val.canConvert( QVariant::String ) )
3346 setSpecialValueText( val.toString() );
3349 QtxPageNamedPrefItem::setOptionValue( name, val );
3353 \brief Update spin box widget.
3355 void QtxPagePrefSpinItem::updateSpinBox()
3358 QVariant stp = step();
3359 QVariant prec = precision();
3360 QVariant min = minimum();
3361 QVariant max = maximum();
3363 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3365 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3368 switch ( inputType() )
3371 setControl( new QtxIntSpinBox() );
3374 setControl( new QtxDoubleSpinBox() );
3380 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3383 setPrecision( prec );
3387 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3389 if ( val.canConvert( QVariant::Int ) )
3390 isb->setValue( val.toInt() );
3392 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3394 if ( val.canConvert( QVariant::Double ) )
3395 dsb->setValue( val.toDouble() );
3400 \class QtxPagePrefTextItem
3401 \brief GUI implementation of the resources text box edit item
3402 (for large text data).
3407 \param parent parent preference item
3408 \param sect resource file section associated with the preference item
3409 \param param resource file parameter associated with the preference item
3411 QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect,
3412 const QString& param )
3413 : QtxPageNamedPrefItem( QString(), parent, sect, param )
3415 myEditor = new QTextEdit();
3416 myEditor->setAcceptRichText( false );
3418 setControl( myEditor );
3423 \param title preference item title
3424 \param parent parent preference item
3425 \param sect resource file section associated with the preference item
3426 \param param resource file parameter associated with the preference item
3428 QtxPagePrefTextItem::QtxPagePrefTextItem( const QString& title, QtxPreferenceItem* parent,
3429 const QString& sect, const QString& param )
3430 : QtxPageNamedPrefItem( title, parent, sect, param )
3432 myEditor = new QTextEdit();
3433 myEditor->setAcceptRichText( false );
3435 setControl( myEditor );
3441 QtxPagePrefTextItem::~QtxPagePrefTextItem()
3446 \brief Store preference item to the resource manager.
3449 void QtxPagePrefTextItem::store()
3451 setString( myEditor->toPlainText() );
3455 \brief Retrieve preference item from the resource manager.
3458 void QtxPagePrefTextItem::retrieve()
3460 myEditor->setPlainText( getString() );
3464 \class QtxPagePrefColorItem
3465 \brief GUI implementation of the resources color item.
3470 \param title preference item title
3471 \param parent parent preference item
3472 \param sect resource file section associated with the preference item
3473 \param param resource file parameter associated with the preference item
3475 QtxPagePrefColorItem::QtxPagePrefColorItem( const QString& title, QtxPreferenceItem* parent,
3476 const QString& sect, const QString& param )
3477 : QtxPageNamedPrefItem( title, parent, sect, param )
3479 // QtxPagePrefGroupItem* aGroup 0; //= dynamic_cast<QtxPagePrefGroupItem*>( parent );
3481 // setControl( myColor = new QtxColorButton( aGroup ? aGroup->gridBox() : 0 ) );
3482 setControl( myColor = new QtxColorButton( 0 ) );
3483 myColor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3489 QtxPagePrefColorItem::~QtxPagePrefColorItem()
3494 \brief Store preference item to the resource manager.
3497 void QtxPagePrefColorItem::store()
3499 setColor( myColor->color() );
3503 \brief Retrieve preference item from the resource manager.
3506 void QtxPagePrefColorItem::retrieve()
3508 myColor->setColor( getColor() );
3512 \class QtxPagePrefBiColorItem
3513 \brief GUI implementation of the resources item to store a bi-color value.
3515 The main color is specified explicitly. The secondary color is calculated
3516 by changing "value" and "saturation" parameters of the main color in the
3517 HSV notation using specified delta.
3522 \param title preference item title
3523 \param parent parent preference item
3524 \param sect resource file section associated with the preference item
3525 \param param resource file parameter associated with the preference item
3527 QtxPagePrefBiColorItem::QtxPagePrefBiColorItem( const QString& title, QtxPreferenceItem* parent,
3528 const QString& sect, const QString& param )
3529 : QtxPageNamedPrefItem( title, parent, sect, param )
3531 setControl( myColors = new QtxBiColorTool( 0 ) );
3537 QtxPagePrefBiColorItem::~QtxPagePrefBiColorItem()
3542 \bried Get auxiliary text
3543 \return text assigned to the item
3546 QString QtxPagePrefBiColorItem::text() const
3548 return myColors->text();
3552 \bried Set auxiliary text
3553 \param t text being assigned to the item
3556 void QtxPagePrefBiColorItem::setText( const QString& t )
3558 myColors->setText( t );
3562 \brief Store preference item to the resource manager.
3565 void QtxPagePrefBiColorItem::store()
3567 setString( Qtx::biColorToString( myColors->mainColor(), myColors->delta() ) );
3571 \brief Retrieve preference item from the resource manager.
3574 void QtxPagePrefBiColorItem::retrieve()
3578 Qtx::stringToBiColor( getString(), c, d );
3579 myColors->setMainColor( c );
3580 myColors->setDelta( d );
3584 \brief Get preference item option value.
3585 \param name option name
3586 \return property value or null QVariant if option is not set
3587 \sa setOptionValue()
3589 QVariant QtxPagePrefBiColorItem::optionValue( const QString& name ) const
3591 if ( name == "text" )
3594 return QtxPageNamedPrefItem::optionValue( name );
3598 \brief Set preference item option value.
3599 \param name option name
3600 \param val new property value
3603 void QtxPagePrefBiColorItem::setOptionValue( const QString& name, const QVariant& val )
3605 if ( name == "text" )
3607 if ( val.canConvert( QVariant::String ) )
3608 setText( val.toString() );
3611 QtxPageNamedPrefItem::setOptionValue( name, val );
3615 \class QtxPagePrefFontItem
3616 \brief GUI implementation of the resources font item.
3621 \param feat font editor widget features (QtxFontEdit::Features)
3622 \param title preference item title
3623 \param parent parent preference item
3624 \param sect resource file section associated with the preference item
3625 \param param resource file parameter associated with the preference item
3627 QtxPagePrefFontItem::QtxPagePrefFontItem( const int feat, const QString& title,
3628 QtxPreferenceItem* parent, const QString& sect,
3629 const QString& param )
3630 : QtxPageNamedPrefItem( title, parent, sect, param )
3632 setControl( myFont = new QtxFontEdit( feat ) );
3637 \param title preference item title
3638 \param parent parent preference item
3639 \param sect resource file section associated with the preference item
3640 \param param resource file parameter associated with the preference item
3642 QtxPagePrefFontItem::QtxPagePrefFontItem( const QString& title, QtxPreferenceItem* parent,
3643 const QString& sect, const QString& param )
3644 : QtxPageNamedPrefItem( title, parent, sect, param )
3646 setControl( myFont = new QtxFontEdit() );
3652 QtxPagePrefFontItem::~QtxPagePrefFontItem()
3657 \brief Get font widget features.
3658 \return font widget features (ORed QtxFontEdit::Features flags)
3661 int QtxPagePrefFontItem::features() const
3663 return myFont->features();
3667 \brief Set font widget features.
3668 \param f new font widget features (ORed QtxFontEdit::Features flags)
3671 void QtxPagePrefFontItem::setFeatures( const int f )
3673 myFont->setFeatures( f );
3677 \brief Specifies whether widget works in Native or Custom mode. Native mode
3678 is intended for working with system fonts. Custom mode is intended for
3679 working with manually defined set of fonts. Set of custom fonts can be
3680 specified with setFonts() method
3681 \param mode mode from QtxFontEdit::Mode enumeration
3684 void QtxPagePrefFontItem::setMode( const int mode )
3686 myFont->setMode( mode );
3690 \brief Verifies whether widget works in Native or Custom mode
3691 \return Native or Custom mode
3694 int QtxPagePrefFontItem::mode() const
3696 return myFont->mode();
3700 \brief Sets list of custom fonts.
3701 <b>This method is intended for working in Custom mode only.</b>
3702 \param fams list of families
3703 \sa fonts(), setMode()
3705 void QtxPagePrefFontItem::setFonts( const QStringList& fams )
3707 myFont->setFonts( fams );
3711 \brief Gets list of custom fonts
3712 \return list of families
3713 \sa setFonts(), setMode()
3715 QStringList QtxPagePrefFontItem::fonts() const
3717 return myFont->fonts();
3721 \brief Sets list of available font sizes.
3722 <b>This method is intended for working in Custom mode only.</b> The list of sizes can
3723 be empty. In this case system generate listof size automatically from 8 till 72.
3724 \param sizes list of sizes
3725 \sa sizes(), setMode()
3727 void QtxPagePrefFontItem::setSizes( const QList<int>& sizes )
3729 myFont->setSizes( sizes );
3733 \brief Gets list of custom fonts
3734 \return list of families
3735 \sa setFonts(), setMode()
3737 QList<int> QtxPagePrefFontItem::sizes() const
3739 return myFont->sizes();
3743 \brief Store preference item to the resource manager.
3746 void QtxPagePrefFontItem::store()
3748 setFont( myFont->currentFont() );
3752 \brief Retrieve preference item from the resource manager.
3755 void QtxPagePrefFontItem::retrieve()
3757 myFont->setCurrentFont( getFont() );
3761 \brief Get preference item option value.
3762 \param name option name
3763 \return property value or null QVariant if option is not set
3764 \sa setOptionValue()
3766 QVariant QtxPagePrefFontItem::optionValue( const QString& name ) const
3768 if ( name == "features" )
3770 else if ( name == "mode" )
3772 else if ( name == "fonts" || name == "families" )
3774 else if ( name == "sizes" )
3776 QList<QVariant> lst;
3777 QList<int> nums = sizes();
3778 for ( QList<int>::const_iterator it = nums.begin(); it != nums.end(); ++it )
3783 return QtxPageNamedPrefItem::optionValue( name );
3787 \brief Set preference item option value.
3788 \param name option name
3789 \param val new property value
3792 void QtxPagePrefFontItem::setOptionValue( const QString& name, const QVariant& val )
3794 if ( name == "features" )
3796 if ( val.canConvert( QVariant::Int ) )
3797 setFeatures( val.toInt() );
3799 else if ( name == "mode" )
3801 if ( val.canConvert( QVariant::Int ) )
3802 setMode( val.toInt() );
3804 else if ( name == "fonts" || name == "families" )
3806 if ( val.canConvert( QVariant::StringList ) )
3807 setFonts( val.toStringList() );
3809 else if ( name == "sizes" )
3811 if ( val.type() == QVariant::List )
3814 QList<QVariant> varList = val.toList();
3815 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
3817 if ( (*it).canConvert( QVariant::Int ) )
3818 lst.append( (*it).toInt() );
3824 QtxPageNamedPrefItem::setOptionValue( name, val );
3828 \class QtxPagePrefPathItem
3829 \brief GUI implementation of the resources file/directory path item.
3834 \param type path widget mode (Qtx::PathType )
3835 \param title preference item title
3836 \param parent parent preference item
3837 \param sect resource file section associated with the preference item
3838 \param param resource file parameter associated with the preference item
3840 QtxPagePrefPathItem::QtxPagePrefPathItem( const Qtx::PathType type, const QString& title,
3841 QtxPreferenceItem* parent, const QString& sect, const QString& param )
3842 : QtxPageNamedPrefItem( title, parent, sect, param )
3844 setControl( myPath = new QtxPathEdit( type ) );
3849 \param title preference item title
3850 \param parent parent preference item
3851 \param sect resource file section associated with the preference item
3852 \param param resource file parameter associated with the preference item
3854 QtxPagePrefPathItem::QtxPagePrefPathItem( const QString& title, QtxPreferenceItem* parent,
3855 const QString& sect, const QString& param )
3856 : QtxPageNamedPrefItem( title, parent, sect, param )
3858 setControl( myPath = new QtxPathEdit() );
3864 QtxPagePrefPathItem::~QtxPagePrefPathItem()
3869 \brief Get path widget mode.
3870 \return current path widget mode (Qtx::PathType)
3873 Qtx::PathType QtxPagePrefPathItem::pathType() const
3875 return myPath->pathType();
3879 \brief Set path widget mode.
3880 \param type new path widget mode (Qtx::PathType)
3883 void QtxPagePrefPathItem::setPathType( const Qtx::PathType type )
3885 myPath->setPathType( type );
3889 \brief Get currently used path widget filters.
3890 \return file or directory path filters
3893 QString QtxPagePrefPathItem::pathFilter() const
3895 return myPath->pathFilter();
3899 \brief Set path widget filters.
3900 \param f new file or directory path filters
3903 void QtxPagePrefPathItem::setPathFilter( const QString& f )
3905 myPath->setPathFilter( f );
3909 \brief Store preference item to the resource manager.
3912 void QtxPagePrefPathItem::store()
3914 setString( myPath->path() );
3918 \brief Retrieve preference item from the resource manager.
3921 void QtxPagePrefPathItem::retrieve()
3923 myPath->setPath( getString() );
3927 \brief Get preference item option value.
3928 \param name option name
3929 \return property value or null QVariant if option is not set
3930 \sa setOptionValue()
3932 QVariant QtxPagePrefPathItem::optionValue( const QString& name ) const
3934 if ( name == "path_type" )
3936 else if ( name == "path_filter" )
3937 return pathFilter();
3939 return QtxPageNamedPrefItem::optionValue( name );
3943 \brief Set preference item option value.
3944 \param name option name
3945 \param val new property value
3948 void QtxPagePrefPathItem::setOptionValue( const QString& name, const QVariant& val )
3950 if ( name == "path_type" )
3952 if ( val.canConvert( QVariant::Int ) )
3953 setPathType( (Qtx::PathType)val.toInt() );
3955 else if ( name == "path_filter" )
3957 if ( val.canConvert( QVariant::String ) )
3958 setPathFilter( val.toString() );
3961 QtxPageNamedPrefItem::setOptionValue( name, val );
3965 \class QtxPagePrefPathListItem
3966 \brief GUI implementation of the resources files/directories list item.
3971 \param parent parent preference item
3972 \param sect resource file section associated with the preference item
3973 \param param resource file parameter associated with the preference item
3975 QtxPagePrefPathListItem::QtxPagePrefPathListItem( QtxPreferenceItem* parent,
3976 const QString& sect, const QString& param )
3977 : QtxPageNamedPrefItem( QString(), parent, sect, param )
3979 setControl( myPaths = new QtxPathListEdit() );
3984 \param type path list widget mode (Qtx::PathType)
3985 \param title preference item title
3986 \param parent parent preference item
3987 \param sect resource file section associated with the preference item
3988 \param param resource file parameter associated with the preference item
3990 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const Qtx::PathType type, const QString& title,
3991 QtxPreferenceItem* parent, const QString& sect, const QString& param )
3992 : QtxPageNamedPrefItem( title, parent, sect, param )
3994 setControl( myPaths = new QtxPathListEdit( type ) );
3999 \param title preference item title
4000 \param parent parent preference item
4001 \param sect resource file section associated with the preference item
4002 \param param resource file parameter associated with the preference item
4004 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const QString& title, QtxPreferenceItem* parent,
4005 const QString& sect, const QString& param )
4006 : QtxPageNamedPrefItem( title, parent, sect, param )
4008 setControl( myPaths = new QtxPathListEdit() );
4014 QtxPagePrefPathListItem::~QtxPagePrefPathListItem()
4019 \brief Get path list widget mode.
4020 \return currently used path list widget mode (Qtx::PathType)
4023 Qtx::PathType QtxPagePrefPathListItem::pathType() const
4025 return myPaths->pathType();
4029 \brief Set path list widget mode.
4030 \param type new path list widget mode (Qtx::PathType)
4033 void QtxPagePrefPathListItem::setPathType( const Qtx::PathType type )
4035 myPaths->setPathType( type );
4039 \brief Store preference item to the resource manager.
4042 void QtxPagePrefPathListItem::store()
4044 setString( myPaths->pathList().join( ";" ) );
4048 \brief Retrieve preference item from the resource manager.
4051 void QtxPagePrefPathListItem::retrieve()
4053 myPaths->setPathList( getString().split( ";" ) );
4057 \brief Get preference item option value.
4058 \param name option name
4059 \return property value or null QVariant if option is not set
4060 \sa setOptionValue()
4062 QVariant QtxPagePrefPathListItem::optionValue( const QString& name ) const
4064 if ( name == "path_type" )
4067 return QtxPageNamedPrefItem::optionValue( name );
4071 \brief Set preference item option value.
4072 \param name option name
4073 \param val new property value
4076 void QtxPagePrefPathListItem::setOptionValue( const QString& name, const QVariant& val )
4078 if ( name == "path_type" )
4080 if ( val.canConvert( QVariant::Int ) )
4081 setPathType( (Qtx::PathType)val.toInt() );
4084 QtxPageNamedPrefItem::setOptionValue( name, val );
4088 \class QtxPagePrefDateTimeItem
4089 \brief GUI implementation of resources date/time item.
4095 Creates an item to enter date and time.
4097 \param title preference item title
4098 \param parent parent preference item
4099 \param sect resource file section associated with the preference item
4100 \param param resource file parameter associated with the preference item
4102 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const QString& title, QtxPreferenceItem* parent,
4103 const QString& sect, const QString& param )
4104 : QtxPageNamedPrefItem( title, parent, sect, param ),
4107 setControl( myDateTime = new QDateTimeEdit() );
4108 myDateTime->setCalendarPopup( true );
4109 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4116 Creates preference item for editing of the date and/or time value:
4117 the type is specified by parameter \a type.
4119 \param type preference item input type (QtxPagePrefDateTimeItem::InputType)
4120 \param title preference item title
4121 \param parent parent preference item
4122 \param sect resource file section associated with the preference item
4123 \param param resource file parameter associated with the preference item
4125 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const int type, const QString& title, QtxPreferenceItem* parent,
4126 const QString& sect, const QString& param )
4127 : QtxPageNamedPrefItem( title, parent, sect, param ),
4130 setControl( myDateTime = new QDateTimeEdit() );
4131 myDateTime->setCalendarPopup( true );
4132 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4139 QtxPagePrefDateTimeItem::~QtxPagePrefDateTimeItem()
4144 \brief Get date/time box preference item input type.
4145 \return preference item input type (QtxPagePrefDateTimeItem::InputType)
4148 int QtxPagePrefDateTimeItem::inputType() const
4154 \brief Set date/time box preference item input type.
4155 \param type new preference item input type (QtxPagePrefDateTimeItem::InputType)
4158 void QtxPagePrefDateTimeItem::setInputType( const int type )
4160 if ( myType == type )
4168 \brief Check if the popup calendar menu is enabled.
4169 \return \c true if calendar popup menu is enabled
4171 bool QtxPagePrefDateTimeItem::calendar() const
4173 return myDateTime->calendarPopup();
4177 \brief Enable/disable popup calendar menu.
4178 \param on new flag state
4180 void QtxPagePrefDateTimeItem::setCalendar( const bool on )
4182 myDateTime->setCalendarPopup( on );
4186 \brief Get maximum date value.
4187 \return maximum date value
4188 \sa setMaximumDate(), minimumDate(), maximumTime(), minimumTime()
4190 QDate QtxPagePrefDateTimeItem::maximumDate() const
4192 return myDateTime->maximumDate();
4196 \brief Get maximum time value.
4197 \return maximum time value
4198 \sa setMaximumTime(), minimumTime(), maximumDate(), minimumDate()
4200 QTime QtxPagePrefDateTimeItem::maximumTime() const
4202 return myDateTime->maximumTime();
4206 \brief Get minimum date value.
4207 \return minimum date value
4208 \sa setMinimumDate(), maximumDate(), maximumTime(), minimumTime()
4210 QDate QtxPagePrefDateTimeItem::minimumDate() const
4212 return myDateTime->minimumDate();
4216 \brief Get minimum time value.
4217 \return maximum time value
4218 \sa setMinimumTime(), maximumTime(), maximumDate(), minimumDate()
4220 QTime QtxPagePrefDateTimeItem::minimumTime() const
4222 return myDateTime->minimumTime();
4226 \brief Set maximum date value.
4227 \param d new maximum date value
4228 \sa maximumDate(), minimumDate(), maximumTime(), minimumTime()
4230 void QtxPagePrefDateTimeItem::setMaximumDate( const QDate& d )
4233 myDateTime->setMaximumDate( d );
4235 myDateTime->clearMaximumDate();
4239 \brief Set maximum time value.
4240 \param t new maximum time value
4241 \sa maximumTime(), minimumTime(), maximumDate(), minimumDate()
4243 void QtxPagePrefDateTimeItem::setMaximumTime( const QTime& t )
4246 myDateTime->setMaximumTime( t );
4248 myDateTime->clearMaximumTime();
4252 \brief Set minimum date value.
4253 \param d new minimum date value
4254 \sa minimumDate(), maximumDate(), maximumTime(), minimumTime()
4256 void QtxPagePrefDateTimeItem::setMinimumDate( const QDate& d )
4259 myDateTime->setMinimumDate( d );
4261 myDateTime->clearMinimumDate();
4265 \brief Set minimum time value.
4266 \param t new minimum time value
4267 \sa minimumTime(), maximumTime(), maximumDate(), minimumDate()
4269 void QtxPagePrefDateTimeItem::setMinimumTime( const QTime& t )
4272 myDateTime->setMinimumTime( t );
4274 myDateTime->clearMinimumTime();
4278 \brief Store preference item to the resource manager.
4281 void QtxPagePrefDateTimeItem::store()
4284 switch ( inputType() )
4287 str = myDateTime->date().toString( Qt::ISODate );
4290 str = myDateTime->time().toString( Qt::ISODate );
4293 str = myDateTime->dateTime().toString( Qt::ISODate );
4301 \brief Retrieve preference item from the resource manager.
4304 void QtxPagePrefDateTimeItem::retrieve()
4306 QString str = getString();
4307 switch ( inputType() )
4310 myDateTime->setDate( QDate::fromString( str, Qt::ISODate ) );
4313 myDateTime->setTime( QTime::fromString( str, Qt::ISODate ) );
4316 myDateTime->setDateTime( QDateTime::fromString( str, Qt::ISODate ) );
4322 \brief Get preference item option value.
4323 \param name option name
4324 \return property value or null QVariant if option is not set
4325 \sa setOptionValue()
4327 QVariant QtxPagePrefDateTimeItem::optionValue( const QString& name ) const
4329 if ( name == "input_type" || name == "type" )
4331 else if ( name == "minimum_date" || name == "min_date" )
4332 return minimumDate();
4333 else if ( name == "maximum_date" || name == "max_date" )
4334 return maximumDate();
4335 else if ( name == "minimum_time" || name == "min_time" )
4336 return minimumTime();
4337 else if ( name == "maximum_time" || name == "max_time" )
4338 return maximumTime();
4340 return QtxPageNamedPrefItem::optionValue( name );
4344 \brief Set preference item option value.
4345 \param name option name
4346 \param val new property value
4349 void QtxPagePrefDateTimeItem::setOptionValue( const QString& name, const QVariant& val )
4351 if ( name == "input_type" || name == "type" )
4353 if ( val.canConvert( QVariant::Int ) )
4354 setInputType( val.toInt() );
4356 else if ( name == "minimum_date" || name == "min_date" )
4358 if ( val.canConvert( QVariant::Date ) )
4359 setMinimumDate( val.toDate() );
4361 else if ( name == "maximum_date" || name == "max_date" )
4363 if ( val.canConvert( QVariant::Date ) )
4364 setMaximumDate( val.toDate() );
4366 else if ( name == "minimum_time" || name == "min_time" )
4368 if ( val.canConvert( QVariant::Time ) )
4369 setMinimumTime( val.toTime() );
4371 else if ( name == "maximum_time" || name == "max_time" )
4373 if ( val.canConvert( QVariant::Time ) )
4374 setMaximumTime( val.toTime() );
4377 QtxPageNamedPrefItem::setOptionValue( name, val );
4381 \brief Update date/time widget.
4383 void QtxPagePrefDateTimeItem::updateDateTime()
4386 switch ( inputType() )
4389 dispFmt = QDateEdit().displayFormat();
4392 dispFmt = QTimeEdit().displayFormat();
4395 dispFmt = QDateTimeEdit().displayFormat();
4399 myDateTime->setDisplayFormat( dispFmt );
4404 \param title preference item title
4405 \param parent parent preference item
4406 \param sect resource file section associated with the preference item
4407 \param param resource file parameter associated with the preference item
4409 QtxPagePrefShortcutBtnsItem::QtxPagePrefShortcutBtnsItem( const QString& title, QtxPreferenceItem* parent, const QString& sect,
4410 const QString& param ): QtxPageNamedPrefItem( title, parent, sect, param )
4412 setControl( myShortcut = new QtxShortcutEdit() );
4418 QtxPagePrefShortcutBtnsItem::~QtxPagePrefShortcutBtnsItem()
4423 \brief Store preference item to the resource manager.
4426 void QtxPagePrefShortcutBtnsItem::store()
4428 setString( myShortcut->shortcut().toString() );
4432 \brief Retrieve preference item from the resource manager.
4435 void QtxPagePrefShortcutBtnsItem::retrieve()
4437 myShortcut->setShortcut( QKeySequence::fromString( getString() ) );
4443 Creates preference item for editing of key bindings
4445 \param title preference item title
4446 \param parent parent preference item
4447 \param sect resource file section associated with the preference item
4448 \param param resource file parameter associated with the preference item
4450 QtxPagePrefShortcutTreeItem::QtxPagePrefShortcutTreeItem( const QString& title, QtxPreferenceItem* parent, const QString& sect,
4451 const QString& param ): QtxPageNamedPrefItem( title, parent, sect, "" )
4455 myShortcutTree = new QtxShortcutTree();
4457 // Retrieve shortcuts common sections from resources
4458 QtxResourceMgr* resMgr = resourceMgr();
4460 QString generalSections = resourceMgr()->stringValue( "shortcuts_settings", "general_sections", QString() );
4461 QStringList sectionsList = generalSections.split( ";", QString::SkipEmptyParts );
4462 myShortcutTree->setGeneralSections( sectionsList );
4465 setControl( myShortcutTree );
4471 QtxPagePrefShortcutTreeItem::~QtxPagePrefShortcutTreeItem()
4476 \brief Retrieve preference item from the resource manager.
4479 void QtxPagePrefShortcutTreeItem::retrieve()
4481 QtxResourceMgr* resMgr = resourceMgr();
4483 QStringList secLst = resMgr->subSections( mySection, false );
4484 ShortcutMap aMap; QStringList paramLst;
4485 for( int i = 0; i < secLst.size(); i++ ) {
4486 paramLst = resMgr->parameters( QStringList() << mySection << secLst.at( i ) );
4487 for( int j = 0; j < paramLst.size(); j++ )
4488 resMgr->value( mySection + resMgr->sectionsToken() + secLst.at( i ), paramLst.at( j ),aMap[ paramLst.at( j ) ], false );
4489 myShortcutTree->setBindings( secLst.at( i ), aMap );
4496 \brief Store preference item to the resource manager.
4499 void QtxPagePrefShortcutTreeItem::store()
4501 QStringList lst = myShortcutTree->sections();
4503 QtxResourceMgr* resMgr = resourceMgr();
4506 for( int i = 0; i < lst.size(); i++ ) {
4507 ShortcutMap* aMap( myShortcutTree->bindings( lst.at( i ) ) );
4508 aSection = mySection + resMgr->sectionsToken() + lst.at( i );
4509 for( ShortcutMap::const_iterator it = aMap->constBegin(); it != aMap->constEnd(); ++it )
4510 resMgr->setValue( aSection, it.key(), it.value() );
4516 \class QtxPagePrefBackgroundItem
4517 \brief GUI implementation of the resources item to store background data.
4519 Preference item allows specifying background data in different ways:
4521 - texture image file
4522 - simple two-color gradient
4523 - complex custom gradient (NOT IMPLEMENTED YET)
4525 Allowed background modes can be specified using setModeAllowed() method.
4526 Texture modes can be enabled/disabled using setTextureModeAllowed() method.
4527 Also, showing texture controls can be enabled/disabled by means of
4528 setTextureAllowed() method.
4529 Verical or horizontal orientation of the widget can be chosen via setOrientation()
4530 method (default orientation is horizontal).
4532 Simple gradient types can be specified using setGradients() method.
4534 \sa Qtx::BackgroundData, QtxBackgroundTool
4539 \param title preference item title
4540 \param parent parent preference item
4541 \param sect resource file section associated with the preference item
4542 \param param resource file parameter associated with the preference item
4544 QtxPagePrefBackgroundItem::QtxPagePrefBackgroundItem( const QString& title, QtxPreferenceItem* parent,
4545 const QString& sect, const QString& param )
4546 : QtxPageNamedPrefItem( title, parent, sect, param )
4548 setControl( myBgTool = new QtxBackgroundTool( 0 ) );
4554 QtxPagePrefBackgroundItem::~QtxPagePrefBackgroundItem()
4559 \brief Get allowed two-color gradients to the widget
4560 \param gradients gradients names are returned via this parameter
4561 \param ids gradients identifiers are returned via this parameter (empty list can be returned)
4563 void QtxPagePrefBackgroundItem::gradients( QStringList& gradList, QIntList& idList ) const
4565 myBgTool->gradients( gradList, idList );
4569 \brief Set allowed two-color gradients to the widget
4570 \param gradients gradients names
4571 \param ids optional gradients identifiers; if not specified, gradients are automatically numbered starting from 0
4573 void QtxPagePrefBackgroundItem::setGradients( const QStringList& gradients, const QIntList& ids )
4575 myBgTool->setGradients( gradients, ids );
4579 \brief Check if specific background mode is allowed
4580 \param mode background mode
4581 \return \c true if specified background mode is enabled or \c false otherwise
4582 \sa setModeAllowed()
4584 bool QtxPagePrefBackgroundItem::isModeAllowed( Qtx::BackgroundMode mode ) const
4586 return myBgTool->isModeAllowed( mode );
4590 \brief Enable / disable specific background mode
4591 \param mode background mode
4592 \param on enable / disable flag
4595 void QtxPagePrefBackgroundItem::setModeAllowed( Qtx::BackgroundMode mode, bool on )
4597 myBgTool->setModeAllowed( mode, on );
4601 \brief Check if specific texture mode is allowed
4602 \param mode texture mode
4603 \return \c true if specified texture mode is enabled or \c false otherwise
4604 \sa setTextureModeAllowed(), setTextureAllowed()
4606 bool QtxPagePrefBackgroundItem::isTextureModeAllowed( Qtx::TextureMode mode ) const
4608 return myBgTool->isTextureModeAllowed( mode );
4612 \brief Enable / disable specific texture mode
4613 \param mode texture mode
4614 \param on enable / disable flag (\c true by default)
4615 \sa isTextureModeAllowed(), setTextureAllowed()
4617 void QtxPagePrefBackgroundItem::setTextureModeAllowed( Qtx::TextureMode mode, bool on )
4619 myBgTool->setTextureModeAllowed( mode, on );
4623 \brief Check if texture controls are allowed (shown)
4624 \return \c true if texture controls are enabled or \c false otherwise
4625 \sa setTextureAllowed(), setTextureModeAllowed()
4627 bool QtxPagePrefBackgroundItem::isTextureAllowed() const
4629 return myBgTool->isTextureAllowed();
4633 \brief Enable / disable texture controls
4634 \param on enable / disable flag (\c true by default)
4635 \sa isTextureAllowed(), setTextureModeAllowed()
4637 void QtxPagePrefBackgroundItem::setTextureAllowed( bool on )
4639 myBgTool->setTextureAllowed( on );
4643 \brief Get allowed image formats
4644 \return image formats
4646 QString QtxPagePrefBackgroundItem::imageFormats() const
4648 return myBgTool->imageFormats();
4652 \brief Set allowed image formats
4653 \param formats image formats
4655 void QtxPagePrefBackgroundItem::setImageFormats( const QString& formats )
4657 myBgTool->setImageFormats( formats );
4661 \brief Get widget editor orientation
4664 Qt::Orientation QtxPagePrefBackgroundItem::orientation() const
4666 return myBgTool->orientation();
4670 \brief Set widget editor orientation
4671 \param o orientation
4673 void QtxPagePrefBackgroundItem::setOrientation( Qt::Orientation o )
4675 myBgTool->setOrientation( o );
4679 \brief Store preference item to the resource manager.
4682 void QtxPagePrefBackgroundItem::store()
4684 setString( Qtx::backgroundToString( myBgTool->data() ) );
4688 \brief Retrieve preference item from the resource manager.
4691 void QtxPagePrefBackgroundItem::retrieve()
4693 myBgTool->setData( Qtx::stringToBackground( getString() ) );
4697 \brief Get preference item option value.
4698 \param name option name
4699 \return property value or null QVariant if option is not set
4700 \sa setOptionValue()
4702 QVariant QtxPagePrefBackgroundItem::optionValue( const QString& name ) const
4704 if ( name == "texture_enabled" )
4705 return isTextureAllowed();
4706 else if ( name == "color_enabled" )
4707 return isModeAllowed( Qtx::ColorBackground );
4708 else if ( name == "gradient_enabled" )
4709 return isModeAllowed( Qtx::SimpleGradientBackground );
4710 else if ( name == "custom_enabled" )
4711 return isModeAllowed( Qtx::CustomGradientBackground );
4712 else if ( name == "texture_center_enabled" )
4713 return isTextureModeAllowed( Qtx::CenterTexture );
4714 else if ( name == "texture_tile_enabled" )
4715 return isTextureModeAllowed( Qtx::TileTexture );
4716 else if ( name == "texture_stretch_enabled" )
4717 return isTextureModeAllowed( Qtx::StretchTexture );
4718 else if ( name == "orientation" )
4719 return orientation();
4720 else if ( name == "image_formats" )
4721 return imageFormats();
4722 else if ( name == "gradient_names" ) {
4725 gradients( grList, idList );
4728 else if ( name == "gradient_ids" ) {
4731 gradients( grList, idList );
4732 QList<QVariant> lst;
4733 for ( QIntList::const_iterator it = idList.begin(); it != idList.end(); ++it )
4738 return QtxPageNamedPrefItem::optionValue( name );
4742 \brief Set preference item option value.
4743 \param name option name
4744 \param val new property value
4747 void QtxPagePrefBackgroundItem::setOptionValue( const QString& name, const QVariant& val )
4749 if ( name == "texture_enabled" ) {
4750 if ( val.canConvert( QVariant::Bool ) )
4751 setTextureAllowed( val.toBool() );
4753 else if ( name == "color_enabled" ) {
4754 if ( val.canConvert( QVariant::Bool ) )
4755 setModeAllowed( Qtx::ColorBackground, val.toBool() );
4757 else if ( name == "gradient_enabled" ) {
4758 if ( val.canConvert( QVariant::Bool ) )
4759 setModeAllowed( Qtx::SimpleGradientBackground, val.toBool() );
4761 else if ( name == "custom_enabled" ) {
4762 if ( val.canConvert( QVariant::Bool ) )
4763 setModeAllowed( Qtx::CustomGradientBackground, val.toBool() );
4765 else if ( name == "texture_center_enabled" ) {
4766 if ( val.canConvert( QVariant::Bool ) )
4767 setTextureModeAllowed( Qtx::CenterTexture, val.toBool() );
4769 else if ( name == "texture_tile_enabled" ) {
4770 if ( val.canConvert( QVariant::Bool ) )
4771 setTextureModeAllowed( Qtx::TileTexture, val.toBool() );
4773 else if ( name == "texture_stretch_enabled" ) {
4774 if ( val.canConvert( QVariant::Bool ) )
4775 setTextureModeAllowed( Qtx::StretchTexture, val.toBool() );
4777 else if ( name == "orientation" ) {
4778 if ( val.canConvert( QVariant::Int ) )
4779 setOrientation( (Qt::Orientation)val.toInt() );
4781 else if ( name == "image_formats" ) {
4782 if ( val.canConvert( QVariant::String ) )
4783 setImageFormats( val.toString() );
4785 else if ( name == "gradient_names" ) {
4786 if ( val.canConvert( QVariant::StringList ) )
4787 setGradients( val.toStringList() );
4789 else if ( name == "gradient_ids" ) {
4790 if ( val.canConvert( QVariant::List ) ) {
4793 gradients( grList, idList );
4795 QList<QVariant> varList = val.toList();
4796 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it ) {
4797 if ( (*it).canConvert( QVariant::Int ) )
4798 idList.append( (*it).toInt() );
4800 setGradients( grList, idList );
4804 QtxPageNamedPrefItem::setOptionValue( name, val );
4810 Creates preference item of user defined widget. The item widget has to be inherited from
4811 QtxUserDefinedContent class. An instance of this class has to be installed into the item
4812 with help of setContent method. Methods optionValue and setOptionValue use pointer on the
4813 content widget an qint64 value.
4815 \param parent parent preference item
4817 QtxUserDefinedItem::QtxUserDefinedItem( QtxPreferenceItem* parent )
4818 : QtxPageNamedPrefItem(QString(), parent), myContent(0)
4823 \brief Lets to Store preferences for content instance
4826 void QtxUserDefinedItem::store()
4829 myContent->store( resourceMgr(), preferenceMgr());
4834 \brief Lets to Retrieve preferences for content instance
4837 void QtxUserDefinedItem::retrieve()
4840 myContent->retrieve( resourceMgr(), preferenceMgr());
4845 * \brief Returns option value
4846 * \param theName is a string "content"
4847 * \return pointer on QtxUserDefinedContent class instance as a qint64 value
4849 QVariant QtxUserDefinedItem::optionValue( const QString& theName ) const
4851 if ( theName == "content" )
4852 return (qint64) myContent;
4854 return QtxPreferenceItem::optionValue( theName );
4858 * \brief Sets option value
4859 * \param theName is a string "content"
4860 * \param theVal is a pointer on QtxUserDefinedContent class instance represented as qint64 value
4862 void QtxUserDefinedItem::setOptionValue( const QString& theName, const QVariant& theVal)
4864 if ( theName == "content" ) {
4865 if ( theVal.canConvert( QVariant::ULongLong ) ) {
4866 setContent( (QtxUserDefinedContent*)theVal.toULongLong() );
4869 QtxPreferenceItem::setOptionValue( theName, theVal );
4873 * \brief Defines content of the property item as a Widget which has to be inherited from
4874 * QtxUserDefinedContent class.
4875 * \param theContent is an QtxUserDefinedContent class instance.
4877 void QtxUserDefinedItem::setContent( QtxUserDefinedContent* theContent )
4879 myContent = theContent;
4880 setControl(myContent);