]> SALOME platform Git repositories - modules/gui.git/blob - src/Qtx/QtxPagePrefMgr.cxx
Salome HOME
4d333f8845fb07f84a516213a8de93f6289fa47a
[modules/gui.git] / src / Qtx / QtxPagePrefMgr.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File:      QtxPagePrefMgr.cxx
23 // Author:    Sergey TELKOV
24 //
25 #include "QtxPagePrefMgr.h"
26
27 #include "QtxGridBox.h"
28 #include "QtxFontEdit.h"
29 #include "QtxGroupBox.h"
30 #include "QtxComboBox.h"
31 #include "QtxIntSpinBox.h"
32 #include "QtxColorButton.h"
33 #include "QtxDoubleSpinBox.h"
34
35 #include <QEvent>
36 #include <QLayout>
37 #include <QToolBox>
38 #include <QLineEdit>
39 #include <QTextEdit>
40 #include <QCheckBox>
41 #include <QSplitter>
42 #include <QTabWidget>
43 #include <QListWidget>
44 #include <QApplication>
45 #include <QDateTimeEdit>
46 #include <QStackedWidget>
47
48 /*!
49   \class QtxPagePrefMgr
50   \brief GUI implementation of the QtxPreferenceMgr class: preferences manager.
51 */
52
53 /*!
54   \brief Constructor.
55   \param resMgr resource manager
56   \param parent parent widget
57 */
58 QtxPagePrefMgr::QtxPagePrefMgr( QtxResourceMgr* resMgr, QWidget* parent )
59 : QFrame( parent ),
60   QtxPreferenceMgr( resMgr ),
61   myInit( false )
62 {
63   myBox = new QtxGridBox( 1, Qt::Horizontal, this, 0 );
64   QVBoxLayout* base = new QVBoxLayout( this );
65   base->setMargin( 5 );
66   base->setSpacing( 0 );
67   base->addWidget( myBox );
68 }
69
70 /*!
71   \brief Destructor
72 */
73 QtxPagePrefMgr::~QtxPagePrefMgr()
74 {
75 }
76
77 /*!
78   \brief Get recommended size for the widget.
79   \return recommended widget size
80 */
81 QSize QtxPagePrefMgr::sizeHint() const
82 {
83   return QFrame::sizeHint();
84 }
85
86 /*!
87   \brief Get recommended minimum size for the widget.
88   \return recommended minimum widget size
89 */
90 QSize QtxPagePrefMgr::minimumSizeHint() const
91 {
92   return QFrame::minimumSizeHint();
93 }
94
95 /*!
96   \brief Customize show/hide widget operation.
97   \param on if \c true the widget is being shown, otherswise
98   it is being hidden
99 */
100 void QtxPagePrefMgr::setVisible( bool on )
101 {
102   if ( on )
103     initialize();
104
105   QApplication::instance()->processEvents();
106
107   QFrame::setVisible( on );
108 }
109
110 /*!
111   \brief Update widget contents.
112 */
113 void QtxPagePrefMgr::updateContents()
114 {
115   QtxPreferenceMgr::updateContents();
116
117   QList<QtxPreferenceItem*> lst = childItems();
118   for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
119   {
120     QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
121     if ( item && item->widget() && item->widget()->parent() != myBox )
122       item->widget()->setParent( myBox );
123   }
124
125   setWindowIcon( icon() );
126 }
127
128 /*!
129   \brief Callback function which is called when the child
130   preference item is added.
131   \param item child item being added
132   \sa itemRemoved(), itemChanged()
133 */
134 void QtxPagePrefMgr::itemAdded( QtxPreferenceItem* /*item*/ )
135 {
136   triggerUpdate();
137 }
138
139 /*!
140   \brief Callback function which is called when the child
141   preference item is removed.
142   \param item child item being removed
143   \sa itemAdded(), itemChanged()
144 */
145 void QtxPagePrefMgr::itemRemoved( QtxPreferenceItem* /*item*/ )
146 {
147   triggerUpdate();
148 }
149
150 /*!
151   \brief Callback function which is called when the child
152   preference item is modified.
153   \param item child item being modified
154   \sa itemAdded(), itemRemoved()
155 */
156 void QtxPagePrefMgr::itemChanged( QtxPreferenceItem* /*item*/ )
157 {
158   triggerUpdate();
159 }
160
161 /*!
162   \brief Get preference item option value.
163   \param name option name
164   \return property value or null QVariant if option is not set
165   \sa setOptionValue()
166 */
167 QVariant QtxPagePrefMgr::optionValue( const QString& name ) const
168 {
169   if ( name == "orientation" )
170     return myBox->orientation() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
171   else
172     return QtxPreferenceMgr::optionValue( name );
173 }
174
175 /*!
176   \brief Set preference item option value.
177   \param name option name
178   \param val new property value
179   \sa optionValue()
180 */
181 void QtxPagePrefMgr::setOptionValue( const QString& name, const QVariant& val )
182 {
183   if ( name == "orientation" )
184   {
185     if ( val.canConvert( QVariant::Int ) )
186       myBox->setOrientation( val.toInt() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal );
187   }
188   else
189     QtxPreferenceMgr::setOptionValue( name, val );
190 }
191
192 /*!
193   \brief Perform internal initialization.
194 */
195 void QtxPagePrefMgr::initialize() const
196 {
197   //  if ( myInit )
198   //    return;
199
200   QtxPagePrefMgr* that = (QtxPagePrefMgr*)this;
201   that->initialize( that );
202
203   //  that->myInit = true;
204 }
205
206 void QtxPagePrefMgr::initialize( QtxPreferenceItem* item )
207 {
208   if ( !item )
209     return;
210
211   QList<QtxPreferenceItem*> lst = item->childItems( false );
212   for ( QList<QtxPreferenceItem*>::iterator it = lst.begin(); it != lst.end(); ++it )
213     initialize( *it );
214
215   updateContents();
216 }
217
218 /*!
219   \class QtxPagePrefItem
220   \brief Base class for implementation of all the widget-based
221   preference items.
222 */
223
224 class QtxPagePrefItem::Listener : public QObject
225 {
226 public:
227   Listener( QtxPagePrefItem* );
228   virtual ~Listener();
229
230   virtual bool eventFilter( QObject*, QEvent* );
231
232 private:
233   QtxPagePrefItem* myItem;
234 };
235
236 QtxPagePrefItem::Listener::Listener( QtxPagePrefItem* item )
237 : QObject( 0 ),
238   myItem( item )
239 {
240 }
241
242 QtxPagePrefItem::Listener::~Listener()
243 {
244 }
245
246 bool QtxPagePrefItem::Listener::eventFilter( QObject* o, QEvent* e )
247 {
248   if ( !myItem || myItem->widget() != o )
249     return false;
250
251   if ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent )
252     myItem->widgetShown();
253   if ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent )
254     myItem->widgetHided();
255
256   return false;
257 }
258
259 /*!
260   \brief Constructor.
261   \param title preference item title
262   \param parent parent preference item
263   \param sect resource file section associated with the preference item
264   \param param resource file parameter associated with the preference item
265 */
266 QtxPagePrefItem::QtxPagePrefItem( const QString& title, QtxPreferenceItem* parent,
267                                   const QString& sect, const QString& param )
268 : QtxPreferenceItem( title, sect, param, parent ),
269   myWidget( 0 ),
270   myListener( 0 )
271 {
272 }
273
274 /*!
275   \brief Destructor.
276 */
277 QtxPagePrefItem::~QtxPagePrefItem()
278 {
279   delete myWidget;
280   delete myListener;
281 }
282
283 void QtxPagePrefItem::activate()
284 {
285   QtxPreferenceItem::activate();
286
287   if ( widget() )
288     widget()->setFocus();
289 }
290
291 /*!
292   \brief Get preference item editor widget.
293   \return editor widget
294   \sa setWidget()
295 */
296 QWidget* QtxPagePrefItem::widget() const
297 {
298   return myWidget;
299 }
300
301 /*!
302   \brief Set preference item editor widget.
303   \param wid editor widget
304   \sa widget()
305 */
306 void QtxPagePrefItem::setWidget( QWidget* wid )
307 {
308   if ( myWidget && myListener )
309     myWidget->removeEventFilter( myListener );
310
311   myWidget = wid;
312
313   if ( myWidget )
314   {
315     if ( !myListener )
316       myListener = new Listener( this );
317     myWidget->installEventFilter( myListener );
318   }
319
320   sendItemChanges();
321 }
322
323 /*!
324   \brief Callback function which is called when the child
325   preference item is added.
326   \param item child item being added
327   \sa itemRemoved(), itemChanged()
328 */
329 void QtxPagePrefItem::itemAdded( QtxPreferenceItem* /*item*/ )
330 {
331   contentChanged();
332 }
333
334 /*!
335   \brief Callback function which is called when the child
336   preference item is removed.
337   \param item child item being removed
338   \sa itemAdded(), itemChanged()
339 */
340 void QtxPagePrefItem::itemRemoved( QtxPreferenceItem* /*item*/ )
341 {
342   contentChanged();
343 }
344
345 /*!
346   \brief Callback function which is called when the child
347   preference item is modified.
348   \param item child item being modified
349   \sa itemAdded(), itemRemoved()
350 */
351 void QtxPagePrefItem::itemChanged( QtxPreferenceItem* /*item*/ )
352 {
353   contentChanged();
354 }
355
356 /*!
357   \brief Store preference item to the resource manager.
358
359   This method should be reimplemented in the subclasses.
360   Base implementation does nothing.
361
362   \sa retrieve()
363 */
364 void QtxPagePrefItem::store()
365 {
366 }
367
368 /*!
369   \brief Retrieve preference item from the resource manager.
370
371   This method should be reimplemented in the subclasses.
372   Base implementation does nothing.
373
374   \sa store()
375 */
376 void QtxPagePrefItem::retrieve()
377 {
378 }
379
380 /*!
381   \brief Invoked when preference item widget is shown.
382 */
383 void QtxPagePrefItem::widgetShown()
384 {
385 }
386
387 /*!
388   \brief Invoked when preference item widget is hided.
389 */
390 void QtxPagePrefItem::widgetHided()
391 {
392 }
393
394 void QtxPagePrefItem::ensureVisible( QtxPreferenceItem* i )
395 {
396   QtxPreferenceItem::ensureVisible();
397
398   QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
399   if ( item && item->widget() )
400     item->widget()->setVisible( true );
401 }
402
403 /*!
404   \brief Find all child items of the QtxPagePrefItem type.
405   \param list used to return list of child items
406   \param rec if \c true, perform recursive search
407 */
408 void QtxPagePrefItem::pageChildItems( QList<QtxPagePrefItem*>& list, const bool rec ) const
409 {
410   QList<QtxPreferenceItem*> lst = childItems( rec );
411   for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
412   {
413     QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
414     if ( item )
415       list.append( item );
416   }
417 }
418
419 /*!
420   \brief Called when contents is changed (item is added, removed or modified).
421
422   Triggers the item update.
423 */
424 void QtxPagePrefItem::contentChanged()
425 {
426   triggerUpdate();
427 }
428
429 /*!
430   \class QtxPageNamedPrefItem
431   \brief Base class for implementation of the named preference items
432   (items with text labels).
433 */
434
435 /*!
436   \brief Constructor.
437   \param title preference item title
438   \param parent parent preference item
439   \param sect resource file section associated with the preference item
440   \param param resource file parameter associated with the preference item
441 */
442 QtxPageNamedPrefItem::QtxPageNamedPrefItem( const QString& title, QtxPreferenceItem* parent,
443                                             const QString& sect, const QString& param )
444 : QtxPagePrefItem( title, parent, sect, param ),
445   myControl( 0 )
446 {
447   QWidget* main = new QWidget();
448
449   //  QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parent);
450   //  if ( !aGroup )
451   //  {
452     QHBoxLayout* base = new QHBoxLayout( main );
453     base->setMargin( 0 );
454     base->setSpacing( 5 );
455
456     myLabel = new QLabel( title, main );
457     base->addWidget( myLabel );
458     //  }
459     //  else
460     //    myLabel = new QLabel( title, aGroup->gridBox() );
461
462   setWidget( main );
463
464   myLabel->setVisible( !title.isEmpty() );
465 }
466
467 /*!
468   \brief Destructor.
469 */
470 QtxPageNamedPrefItem::~QtxPageNamedPrefItem()
471 {
472 }
473
474 /*!
475   \brief Set preference title.
476   \param txt new preference title.
477 */
478 void QtxPageNamedPrefItem::setTitle( const QString& txt )
479 {
480   QtxPagePrefItem::setTitle( txt );
481
482   label()->setText( title() );
483   if ( !title().isEmpty() )
484     label()->setVisible( true );
485 }
486
487 /*!
488   \brief Get label widget corresponding to the preference item.
489   \return label widget
490 */
491 QLabel* QtxPageNamedPrefItem::label() const
492 {
493   return myLabel;
494 }
495
496 /*!
497   \brief Get control widget corresponding to the preference item.
498   \return control widget
499   \sa setControl()
500 */
501 QWidget* QtxPageNamedPrefItem::control() const
502 {
503   return myControl;
504 }
505
506 /*!
507   \brief Set control widget corresponding to the preference item.
508   \param wid control widget
509   \sa control()
510 */
511 void QtxPageNamedPrefItem::setControl( QWidget* wid )
512 {
513   if ( myControl == wid )
514     return;
515
516   delete myControl;
517   myControl = wid;
518
519   if ( myControl )
520   {
521     //    QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parentItem());
522     //    if ( !aGroup )
523     widget()->layout()->addWidget( myControl );
524     widget()->setFocusProxy( myControl );
525       //    else myControl->setParent( aGroup->gridBox() );
526   }
527 }
528
529 void QtxPageNamedPrefItem::adjustLabels( QtxPagePrefItem* parent )
530 {
531   if ( !parent )
532     return;
533
534   QList<QtxPreferenceItem*> childList = parent->childItems();
535
536   QList<QtxPageNamedPrefItem*> namedItems;
537   for ( QList<QtxPreferenceItem*>::iterator it = childList.begin(); it != childList.end(); ++it )
538   {
539     QtxPageNamedPrefItem* item = dynamic_cast<QtxPageNamedPrefItem*>( *it );
540     if ( item )
541       namedItems.append( item );
542   }
543
544   int sz = 0;
545   for ( QList<QtxPageNamedPrefItem*>::iterator it1 = namedItems.begin(); it1 != namedItems.end(); ++it1 )
546   {
547     QtxPageNamedPrefItem* item = *it1;
548     if ( item->label() )
549       sz = qMax( sz, item->label()->sizeHint().width() );
550   }
551
552   for ( QList<QtxPageNamedPrefItem*>::iterator it2 = namedItems.begin(); it2 != namedItems.end(); ++it2 )
553   {
554     QtxPageNamedPrefItem* item = *it2;
555     if ( item->label() )
556       item->label()->setMinimumWidth( sz );
557   }
558 }
559
560 /*!
561   \class QtxPagePrefListItem
562   \brief GUI implementation of the list container preference item.
563 */
564
565 /*!
566   \brief Constructor.
567   \param title preference item title
568   \param parent parent preference item
569   \param sect resource file section associated with the preference item
570   \param param resource file parameter associated with the preference item
571 */
572 QtxPagePrefListItem::QtxPagePrefListItem( const QString& title, QtxPreferenceItem* parent,
573                                           const QString& sect, const QString& param )
574 : QtxPagePrefItem( title, parent, sect, param ),
575   myFix( false )
576 {
577   QSplitter* main = new QSplitter( Qt::Horizontal );
578   main->setChildrenCollapsible( false );
579
580   main->addWidget( myList = new QListWidget( main ) );
581   main->addWidget( myStack = new QStackedWidget( main ) );
582
583   myList->setSelectionMode( QListWidget::SingleSelection );
584
585   myStack->addWidget( myInfLabel = new QLabel( myStack ) );
586   myInfLabel->setAlignment( Qt::AlignCenter );
587
588   connect( myList, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) );
589
590   setWidget( main );
591 }
592
593 /*!
594   \brief Destructor.
595 */
596 QtxPagePrefListItem::~QtxPagePrefListItem()
597 {
598 }
599
600 /*!
601   \brief Get message text which is shown if the container is empty.
602   \return message text
603   \sa setEmptyInfo()
604 */
605 QString QtxPagePrefListItem::emptyInfo() const
606 {
607   return myInfText;
608 }
609
610 /*!
611   \brief Set message text which is shown if the container is empty.
612   \param new message text
613   \sa emptyInfo()
614 */
615 void QtxPagePrefListItem::setEmptyInfo( const QString& inf )
616 {
617   if ( myInfText == inf )
618     return;
619
620   myInfText = inf;
621
622   updateVisible();
623 }
624
625 /*!
626   \brief Check if the preference item widget is of fixed size.
627   \return \c true if the widget has the fixed size
628   \sa setFixedSize()
629 */
630 bool QtxPagePrefListItem::isFixedSize() const
631 {
632   return myFix;
633 }
634
635 /*!
636   \brief Set the preference item widget to be of fixed size.
637   \param on if \c true, the widget will have the fixed size
638   \sa isFixedSize()
639 */
640 void QtxPagePrefListItem::setFixedSize( const bool on )
641 {
642   if ( myFix == on )
643     return;
644
645   myFix = on;
646
647   updateGeom();
648 }
649
650 /*!
651   \brief Update widget contents.
652 */
653 void QtxPagePrefListItem::updateContents()
654 {
655   QtxPagePrefItem::updateContents();
656   updateVisible();
657 }
658
659 /*!
660   \brief Get preference item option value.
661   \param name option name
662   \return property value or null QVariant if option is not set
663   \sa setOptionValue()
664 */
665 QVariant QtxPagePrefListItem::optionValue( const QString& name ) const
666 {
667   if ( name == "fixed_size" )
668     return isFixedSize();
669   else if ( name == "empty_info" || name == "info" )
670     return emptyInfo();
671   else
672     return QtxPagePrefItem::optionValue( name );
673 }
674
675 /*!
676   \brief Set preference item option value.
677   \param name option name
678   \param val new property value
679   \sa optionValue()
680 */
681 void QtxPagePrefListItem::setOptionValue( const QString& name, const QVariant& val )
682 {
683   if ( name == "fixed_size" )
684   {
685     if ( val.canConvert( QVariant::Bool ) )
686       setFixedSize( val.toBool() );
687   }
688   else if ( name == "empty_info" || name == "info" )
689   {
690     if ( val.canConvert( QVariant::String ) )
691       setEmptyInfo( val.toString() );
692   }
693   else
694     QtxPagePrefItem::setOptionValue( name, val );
695 }
696
697 void QtxPagePrefListItem::widgetShown()
698 {
699   updateState();
700 }
701
702 void QtxPagePrefListItem::ensureVisible( QtxPreferenceItem* i )
703 {
704   if ( !i )
705     return;
706
707   QtxPreferenceItem::ensureVisible( i );
708
709   setSelected( i->id() );
710   updateState();
711 }
712
713 /*!
714   \brief Called when the selection in the list box is changed.
715 */
716 void QtxPagePrefListItem::onItemSelectionChanged()
717 {
718   updateState();
719 }
720
721 /*!
722   \brief Update information label widget.
723 */
724 void QtxPagePrefListItem::updateInfo()
725 {
726   QString infoText;
727   QtxPagePrefItem* item = selectedItem();
728   if ( item )
729   {
730     infoText = emptyInfo();
731     QRegExp rx( "%([%|N])" );
732
733     int idx = 0;
734     while ( ( idx = rx.indexIn( infoText ) ) != -1 )
735     {
736       if ( rx.cap() == QString( "%%" ) )
737         infoText.replace( idx, rx.matchedLength(), "%" );
738       else if ( rx.cap() == QString( "%N" ) )
739         infoText.replace( idx, rx.matchedLength(), item->title() );
740     }
741   }
742   myInfLabel->setText( infoText );
743 }
744
745 /*!
746   \brief Update widget state.
747 */
748 void QtxPagePrefListItem::updateState()
749 {
750   QtxPagePrefItem* item = selectedItem();
751   QWidget* wid = item && !item->isEmpty() ? item->widget() : myInfLabel;
752   if ( wid )
753     myStack->setCurrentWidget( wid );
754
755   updateInfo();
756 }
757
758 /*!
759   \brief Update visibile child widgets.
760 */
761 void QtxPagePrefListItem::updateVisible()
762 {
763   QList<QtxPagePrefItem*> items;
764   pageChildItems( items );
765
766   QMap<QWidget*, int> map;
767   for ( int i = 0; i < (int)myStack->count(); i++ )
768     map.insert( myStack->widget( i ), 0 );
769
770   int selId = selected();
771   myList->clear();
772   for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
773   {
774     if ( (*it)->isEmpty() && myInfText.isEmpty() )
775       continue;
776
777     myList->addItem( (*it)->title() );
778     myList->item( myList->count() - 1 )->setIcon( (*it)->icon() );
779     myList->item( myList->count() - 1 )->setData( Qt::UserRole, (*it)->id() );
780
781     QWidget* wid = (*it)->widget();
782     if ( !map.contains( wid ) )
783       myStack->addWidget( wid );
784
785     map.remove( wid );
786   }
787
788   map.remove( myInfLabel );
789
790   for ( QMap<QWidget*, int>::const_iterator it = map.begin(); it != map.end(); ++it )
791     myStack->removeWidget( it.key() );
792
793   setSelected( selId );
794   if ( selected() == -1 && myList->count() )
795     setSelected( myList->item( 0 )->data( Qt::UserRole ).toInt() );
796
797   //myList->setVisible( myList->count() > 1 );
798
799   updateState();
800   updateGeom();
801 }
802
803 /*!
804   \brief Update widget geometry.
805 */
806 void QtxPagePrefListItem::updateGeom()
807 {
808   if ( myFix )
809     myList->setFixedWidth( myList->minimumSizeHint().width() + 10 );
810   else
811   {
812     myList->setMinimumWidth( 0 );
813     myList->setMaximumWidth( 16777215 );
814
815     QSplitter* s = ::qobject_cast<QSplitter*>( widget() );
816     if ( s )
817     {
818       int w = myList->minimumSizeHint().width() + 30;
819       QList<int> szList;
820       szList.append( w );
821       szList.append( s->width() - w );
822       s->setSizes( szList );
823     }
824   }
825 }
826
827 /*!
828   \brief Get identifier of the currently selected preference item.
829   \return identifier of the currently selected item or -1 if no item is selected
830   \sa setSelected()
831 */
832 int QtxPagePrefListItem::selected() const
833 {
834   QList<QListWidgetItem*> selList = myList->selectedItems();
835   if ( selList.isEmpty() )
836     return -1;
837
838   QVariant v = selList.first()->data( Qt::UserRole );
839   return v.canConvert( QVariant::Int ) ? v.toInt() : -1;
840 }
841
842 /*!
843   \brief Get currently selected preference item.
844   \return currently selected item or 0 if no item is selected
845   \sa setSelected()
846 */
847 QtxPagePrefItem* QtxPagePrefListItem::selectedItem() const
848 {
849   int selId = selected();
850
851   QList<QtxPagePrefItem*> items;
852   pageChildItems( items );
853
854   QtxPagePrefItem* item = 0;
855   for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end() && !item; ++it )
856   {
857     if ( (*it)->id() == selId )
858       item = *it;
859   }
860   return item;
861 }
862
863 /*!
864   \brief Set currently selected preference item.
865   \param id identifier of the preference item to make selected
866 */
867 void QtxPagePrefListItem::setSelected( const int id )
868 {
869   int idx = -1;
870   for ( int i = 0; i < (int)myList->count() && idx < 0; i++ )
871   {
872     QVariant v = myList->item( i )->data( Qt::UserRole );
873     if ( v.canConvert( QVariant::Int ) && v.toInt() == id )
874       idx = i;
875   }
876
877   QItemSelection sel;
878   QItemSelectionModel* selModel = myList->selectionModel();
879
880   if ( idx >= 0 )
881     sel.select( myList->model()->index( idx, 0 ), myList->model()->index( idx, 0 ) );
882
883   selModel->select( sel, QItemSelectionModel::ClearAndSelect );
884 }
885
886 /*!
887   \class QtxPagePrefToolBoxItem
888   \brief GUI implementation of the tool box container preference item.
889 */
890
891 /*!
892   \brief Constructor.
893   \param title preference item title
894   \param parent parent preference item
895   \param sect resource file section associated with the preference item
896   \param param resource file parameter associated with the preference item
897 */
898 QtxPagePrefToolBoxItem::QtxPagePrefToolBoxItem( const QString& title, QtxPreferenceItem* parent,
899                                                 const QString& sect, const QString& param )
900 : QtxPagePrefItem( title, parent, sect, param )
901 {
902   setWidget( myToolBox = new QToolBox( 0 ) );
903 }
904
905 /*!
906   \brief Destructor.
907 */
908 QtxPagePrefToolBoxItem::~QtxPagePrefToolBoxItem()
909 {
910 }
911
912 /*!
913   \brief Update widget contents.
914 */
915 void QtxPagePrefToolBoxItem::updateContents()
916 {
917   QtxPagePrefItem::updateContents();
918   updateToolBox();
919 }
920
921 /*!
922   \brief Update tool box widget.
923 */
924 void QtxPagePrefToolBoxItem::updateToolBox()
925 {
926   QList<QtxPagePrefItem*> items;
927   pageChildItems( items );
928
929   QWidget* cur = myToolBox->currentWidget();
930
931   int i = 0;
932   QMap<QWidget*, int> map;
933   for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
934   {
935     QWidget* wid = (*it)->widget();
936     if ( !wid )
937       continue;
938
939     if ( myToolBox->widget( i ) != wid )
940     {
941       if ( myToolBox->indexOf( wid ) != -1 )
942         myToolBox->removeItem( myToolBox->indexOf( wid ) );
943
944       myToolBox->insertItem( i, wid, (*it)->title() );
945     }
946     else
947       myToolBox->setItemText( i, (*it)->title() );
948
949     myToolBox->setItemIcon( i, (*it)->icon() );
950
951     i++;
952     map.insert( wid, 0 );
953   }
954
955   QList<QWidget*> del;
956   for ( int idx = 0; idx < (int)myToolBox->count(); idx++ )
957   {
958     QWidget* w = myToolBox->widget( idx );
959     if ( !map.contains( w ) )
960       del.append( w );
961   }
962
963   for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
964     myToolBox->removeItem( myToolBox->indexOf( *itr ) );
965
966   if ( cur )
967     myToolBox->setCurrentWidget( cur );
968 }
969
970 void QtxPagePrefToolBoxItem::ensureVisible( QtxPreferenceItem* i )
971 {
972   if ( !i )
973     return;
974
975   QtxPreferenceItem::ensureVisible( i );
976
977   QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
978   if ( item && item->widget() )
979     myToolBox->setCurrentWidget( item->widget() );
980 }
981
982 /*!
983   \class QtxPagePrefTabsItem
984   \brief GUI implementation of the tab widget container.
985 */
986
987 /*!
988   \brief Constructor.
989   \param title preference item title
990   \param parent parent preference item
991   \param sect resource file section associated with the preference item
992   \param param resource file parameter associated with the preference item
993 */
994 QtxPagePrefTabsItem::QtxPagePrefTabsItem( const QString& title, QtxPreferenceItem* parent,
995                                           const QString& sect, const QString& param )
996 : QtxPagePrefItem( title, parent, sect, param )
997 {
998   setWidget( myTabs = new QTabWidget( 0 ) );
999 }
1000
1001 /*!
1002   \brief Destructor.
1003 */
1004 QtxPagePrefTabsItem::~QtxPagePrefTabsItem()
1005 {
1006 }
1007
1008 /*!
1009   \brief Update widget contents.
1010 */
1011 void QtxPagePrefTabsItem::updateContents()
1012 {
1013   QtxPagePrefItem::updateContents();
1014   updateTabs();
1015 }
1016
1017 /*!
1018   \brief Get tabs position.
1019   \return current tabs position (QTabWidget::TabPosition)
1020   \sa setTabPosition()
1021 */
1022 int QtxPagePrefTabsItem::tabPosition() const
1023 {
1024   return myTabs->tabPosition();
1025 }
1026
1027 /*!
1028   \brief Set tabs position.
1029   \param tp new tabs position (QTabWidget::TabPosition)
1030   \sa tabPosition()
1031 */
1032 void QtxPagePrefTabsItem::setTabPosition( const int tp )
1033 {
1034   myTabs->setTabPosition( (QTabWidget::TabPosition)tp );
1035 }
1036
1037 /*!
1038   \brief Get tabs shape.
1039   \return current tabs shape (QTabWidget::TabShape)
1040   \sa setTabShape()
1041 */
1042 int QtxPagePrefTabsItem::tabShape() const
1043 {
1044   return myTabs->tabShape();
1045 }
1046
1047 /*!
1048   \brief Set tabs shape.
1049   \param ts new tabs shape (QTabWidget::TabShape)
1050   \sa tabShape()
1051 */
1052 void QtxPagePrefTabsItem::setTabShape( const int ts )
1053 {
1054   myTabs->setTabShape( (QTabWidget::TabShape)ts );
1055 }
1056
1057 /*!
1058   \brief Get tabs icon size.
1059   \return current tabs icon size
1060   \sa setTabIconSize()
1061 */
1062 QSize QtxPagePrefTabsItem::tabIconSize() const
1063 {
1064   return myTabs->iconSize();
1065 }
1066
1067 /*!
1068   \brief Set tabs icon size.
1069   \param sz new tabs icon size
1070   \sa tabIconSize()
1071 */
1072 void QtxPagePrefTabsItem::setTabIconSize( const QSize& sz )
1073 {
1074   myTabs->setIconSize( sz );
1075 }
1076
1077 /*!
1078   \brief Get preference item option value.
1079   \param name option name
1080   \return property value or null QVariant if option is not set
1081   \sa setOptionValue()
1082 */
1083 QVariant QtxPagePrefTabsItem::optionValue( const QString& name ) const
1084 {
1085   if ( name == "position" )
1086     return tabPosition();
1087   else if ( name == "shape" )
1088     return tabShape();
1089   else if ( name == "icon_size" )
1090     return tabIconSize();
1091   else
1092     return QtxPagePrefItem::optionValue( name );
1093 }
1094
1095 /*!
1096   \brief Set preference item option value.
1097   \param name option name
1098   \param val new property value
1099   \sa optionValue()
1100 */
1101 void QtxPagePrefTabsItem::setOptionValue( const QString& name, const QVariant& val )
1102 {
1103   if ( name == "position" )
1104   {
1105     if ( val.canConvert( QVariant::Int ) )
1106       setTabPosition( val.toInt() );
1107   }
1108   else if ( name == "shape" )
1109   {
1110     if ( val.canConvert( QVariant::Int ) )
1111       setTabShape( val.toInt() );
1112   }
1113   else if ( name == "icon_size" )
1114   {
1115     if ( val.canConvert( QVariant::Size ) )
1116       setTabIconSize( val.toSize() );
1117   }
1118   else
1119     QtxPagePrefItem::setOptionValue( name, val );
1120 }
1121
1122 void QtxPagePrefTabsItem::ensureVisible( QtxPreferenceItem* i )
1123 {
1124   if ( !i )
1125     return;
1126
1127   QtxPreferenceItem::ensureVisible( i );
1128
1129   QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
1130   if ( item && item->widget() )
1131     myTabs->setCurrentWidget( item->widget() );
1132 }
1133
1134 /*!
1135   \brief Update tabs.
1136 */
1137 void QtxPagePrefTabsItem::updateTabs()
1138 {
1139   QList<QtxPagePrefItem*> items;
1140   pageChildItems( items );
1141
1142   QWidget* cur = myTabs->currentWidget();
1143
1144   int i = 0;
1145   QMap<QWidget*, int> map;
1146   for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1147   {
1148     QWidget* wid = (*it)->widget();
1149     if ( !wid )
1150       continue;
1151
1152     if ( myTabs->widget( i ) != wid )
1153     {
1154       if ( myTabs->indexOf( wid ) != -1 )
1155         myTabs->removeTab( myTabs->indexOf( wid ) );
1156
1157       myTabs->insertTab( i, wid, (*it)->title() );
1158     }
1159     else
1160       myTabs->setTabText( i, (*it)->title() );
1161
1162     myTabs->setTabIcon( i, (*it)->icon() );
1163
1164     i++;
1165     map.insert( wid, 0 );
1166   }
1167
1168   QList<QWidget*> del;
1169   for ( int idx = 0; idx < (int)myTabs->count(); idx++ )
1170   {
1171     QWidget* w = myTabs->widget( idx );
1172     if ( !map.contains( w ) )
1173       del.append( w );
1174   }
1175
1176   for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
1177     myTabs->removeTab( myTabs->indexOf( *itr ) );
1178
1179   if ( cur )
1180     myTabs->setCurrentWidget( cur );
1181 }
1182
1183 /*!
1184   \class QtxPagePrefFrameItem
1185   \brief GUI implementation of the frame widget container.
1186 */
1187
1188 /*!
1189   \brief Constructor.
1190   \param title preference item title
1191   \param parent parent preference item
1192   \param sect resource file section associated with the preference item
1193   \param param resource file parameter associated with the preference item
1194 */
1195 QtxPagePrefFrameItem::QtxPagePrefFrameItem( const QString& title, QtxPreferenceItem* parent,
1196                                             const QString& sect, const QString& param )
1197 : QtxPagePrefItem( title, parent, sect, param )
1198 {
1199   QWidget* main = new QWidget();
1200   QVBoxLayout* base = new QVBoxLayout( main );
1201   base->setMargin( 0 );
1202   base->setSpacing( 0 );
1203
1204   base->addWidget( myBox = new QtxGridBox( 1, Qt::Horizontal, main, 5, 5 ) );
1205   base->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
1206
1207   setWidget( main );
1208 }
1209
1210 /*!
1211   \brief Destructor.
1212 */
1213 QtxPagePrefFrameItem::~QtxPagePrefFrameItem()
1214 {
1215 }
1216
1217 /*!
1218   \brief Update widget contents.
1219 */
1220 void QtxPagePrefFrameItem::updateContents()
1221 {
1222   QtxPagePrefItem::updateContents();
1223
1224   updateFrame();
1225
1226   QtxPageNamedPrefItem::adjustLabels( this );
1227 }
1228
1229 /*!
1230   \brief Get frame margin.
1231   \return current frame margin
1232   \sa setMargin()
1233 */
1234 int QtxPagePrefFrameItem::margin() const
1235 {
1236   return myBox->insideMargin();
1237 }
1238
1239 /*!
1240   \brief Get frame margin.
1241   \param m new frame margin
1242   \sa margin()
1243 */
1244 void QtxPagePrefFrameItem::setMargin( const int m )
1245 {
1246   myBox->setInsideMargin( m );
1247 }
1248
1249 /*!
1250   \brief Get frame spacing.
1251   \return current frame spacing
1252   \sa setSpacing()
1253 */
1254 int QtxPagePrefFrameItem::spacing() const
1255 {
1256   return myBox->insideSpacing();
1257 }
1258
1259 /*!
1260   \brief Set frame spacing.
1261   \param s new frame spacing
1262   \sa spacing()
1263 */
1264 void QtxPagePrefFrameItem::setSpacing( const int s )
1265 {
1266   myBox->setInsideSpacing( s );
1267 }
1268
1269 /*!
1270   \brief Get number of frame columns.
1271   \return current columns number
1272   \sa setColumns()
1273 */
1274 int QtxPagePrefFrameItem::columns() const
1275 {
1276   return myBox->columns();
1277 }
1278
1279 /*!
1280   \brief Set number of frame columns.
1281   \param c new columns number
1282   \sa columns()
1283 */
1284 void QtxPagePrefFrameItem::setColumns( const int c )
1285 {
1286   myBox->setColumns( c );
1287 }
1288
1289 /*!
1290   \brief Get frame box orientation.
1291   \return current frame orientation
1292   \sa setOrientation()
1293 */
1294 Qt::Orientation QtxPagePrefFrameItem::orientation() const
1295 {
1296   return myBox->orientation();
1297 }
1298
1299 /*!
1300   \brief Set frame box orientation.
1301   \param o new frame orientation
1302   \sa orientation()
1303 */
1304 void QtxPagePrefFrameItem::setOrientation( const Qt::Orientation o )
1305 {
1306   myBox->setOrientation( o );
1307 }
1308
1309 /*!
1310   \brief Check if the frame widget stretching is enabled.
1311   \return \c true if the widget is stretchable
1312   \sa setStretch()
1313 */
1314 bool QtxPagePrefFrameItem::stretch() const
1315 {
1316   QSpacerItem* s = 0;
1317   QLayout* l = widget() ? widget()->layout() : 0;
1318   for ( int i = 0; l && i < l->count() && !s; i++ )
1319     s = l->itemAt( i )->spacerItem();
1320
1321   return s ? (bool)( s->expandingDirections() & Qt::Vertical ) : false;
1322 }
1323
1324 /*!
1325   \brief Enable/disable frame widget stretching.
1326   \param on new stretchable state
1327   \sa stretch()
1328 */
1329 void QtxPagePrefFrameItem::setStretch( const bool on )
1330 {
1331   QSpacerItem* s = 0;
1332   QLayout* l = widget() ? widget()->layout() : 0;
1333   for ( int i = 0; l && i < l->count() && !s; i++ )
1334     s = l->itemAt( i )->spacerItem();
1335
1336   if ( s )
1337     s->changeSize( 0, 0, QSizePolicy::Minimum, on ? QSizePolicy::Expanding : QSizePolicy::Minimum );
1338 }
1339
1340 /*!
1341   \brief Get preference item option value.
1342   \param name option name
1343   \return property value or null QVariant if option is not set
1344   \sa setOptionValue()
1345 */
1346 QVariant QtxPagePrefFrameItem::optionValue( const QString& name ) const
1347 {
1348   if ( name == "margin" )
1349     return margin();
1350   else if ( name == "spacing" )
1351     return spacing();
1352   else if ( name == "columns" )
1353     return columns();
1354   else if ( name == "orientation" )
1355     return orientation();
1356   else if ( name == "stretch" )
1357     return stretch();
1358   else
1359     return QtxPagePrefItem::optionValue( name );
1360 }
1361
1362 /*!
1363   \brief Set preference item option value.
1364   \param name option name
1365   \param val new property value
1366   \sa optionValue()
1367 */
1368 void QtxPagePrefFrameItem::setOptionValue( const QString& name, const QVariant& val )
1369 {
1370   if ( name == "margin" )
1371   {
1372     if ( val.canConvert( QVariant::Int ) )
1373       setMargin( val.toInt() );
1374   }
1375   else if ( name == "spacing" )
1376   {
1377     if ( val.canConvert( QVariant::Int ) )
1378       setSpacing( val.toInt() );
1379   }
1380   else if ( name == "columns" )
1381   {
1382     if ( val.canConvert( QVariant::Int ) )
1383       setColumns( val.toInt() );
1384   }
1385   else if ( name == "orientation" )
1386   {
1387     if ( val.canConvert( QVariant::Int ) )
1388       setOrientation( (Qt::Orientation)val.toInt() );
1389   }
1390   else if ( name == "stretch" )
1391   {
1392     if ( val.canConvert( QVariant::Bool ) )
1393       setStretch( val.toBool() );
1394   }
1395   else
1396     QtxPagePrefItem::setOptionValue( name, val );
1397 }
1398
1399 void QtxPagePrefFrameItem::widgetShown()
1400 {
1401   QtxPagePrefItem::widgetShown();
1402
1403   QtxPageNamedPrefItem::adjustLabels( this );
1404 }
1405
1406 /*!
1407   \brief Update frame widget.
1408 */
1409 void QtxPagePrefFrameItem::updateFrame()
1410 {
1411   QList<QtxPagePrefItem*> items;
1412   pageChildItems( items );
1413
1414   for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1415   {
1416     QWidget* wid = (*it)->widget();
1417     if ( !wid )
1418       continue;
1419
1420     if ( wid->parent() != myBox )
1421       wid->setParent( myBox );
1422   }
1423 }
1424
1425 /*!
1426   \class QtxPagePrefGroupItem
1427   \brief GUI implementation of the group widget container.
1428 */
1429
1430 /*!
1431   \brief Constructor.
1432   \param title preference item title
1433   \param parent parent preference item
1434   \param sect resource file section associated with the preference item
1435   \param param resource file parameter associated with the preference item
1436 */
1437 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const QString& title, QtxPreferenceItem* parent,
1438                                             const QString& sect, const QString& param )
1439 : QtxPagePrefItem( title, parent, sect, param )
1440 {
1441   myGroup = new QtxGroupBox( title, 0 );
1442   myBox = new QtxGridBox( 1, Qt::Horizontal, myGroup, 5, 5 );
1443   myGroup->setWidget( myBox );
1444
1445   setWidget( myGroup );
1446
1447   updateState();
1448 }
1449
1450 /*!
1451   \brief Constructor.
1452   \param cols columns number
1453   \param title preference item title
1454   \param parent parent preference item
1455   \param sect resource file section associated with the preference item
1456   \param param resource file parameter associated with the preference item
1457 */
1458 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const int cols, const QString& title, QtxPreferenceItem* parent,
1459                                             const QString& sect, const QString& param )
1460 : QtxPagePrefItem( title, parent, sect, param )
1461 {
1462   myGroup = new QtxGroupBox( title, 0 );
1463   myBox = new QtxGridBox( cols, Qt::Horizontal, myGroup, 5, 5 );
1464   myGroup->setWidget( myBox );
1465
1466   setWidget( myGroup );
1467
1468   updateState();
1469 }
1470
1471 /*!
1472   \brief Destructor.
1473 */
1474 QtxPagePrefGroupItem::~QtxPagePrefGroupItem()
1475 {
1476 }
1477
1478 /*!
1479   \brief Assign resource file settings to the preference item.
1480   \param sect resource file section name
1481   \param param resource file parameter name
1482   \sa resource()
1483 */
1484 void QtxPagePrefGroupItem::setResource( const QString& sect, const QString& param )
1485 {
1486   QtxPagePrefItem::setResource( sect, param );
1487   updateState();
1488 }
1489
1490 /*!
1491   \brief Update widget contents.
1492 */
1493 void QtxPagePrefGroupItem::updateContents()
1494 {
1495   QtxPagePrefItem::updateContents();
1496
1497   myGroup->setTitle( title() );
1498
1499   updateState();
1500   updateGroup();
1501
1502   QtxPageNamedPrefItem::adjustLabels( this );
1503 }
1504
1505 /*!
1506   \brief Get group box margin.
1507   \return current group box margin
1508   \sa setMargin()
1509 */
1510 int QtxPagePrefGroupItem::margin() const
1511 {
1512   return myBox->insideMargin();
1513 }
1514
1515 /*!
1516   \brief Get group box margin.
1517   \param m new group box margin
1518   \sa margin()
1519 */
1520 void QtxPagePrefGroupItem::setMargin( const int m )
1521 {
1522   myBox->setInsideMargin( m );
1523 }
1524
1525 /*!
1526   \brief Get group box spacing.
1527   \return current group box spacing
1528   \sa setSpacing()
1529 */
1530 int QtxPagePrefGroupItem::spacing() const
1531 {
1532   return myBox->insideSpacing();
1533 }
1534
1535 /*!
1536   \brief Set group box spacing.
1537   \param s new group box spacing
1538   \sa spacing()
1539 */
1540 void QtxPagePrefGroupItem::setSpacing( const int s )
1541 {
1542   myBox->setInsideSpacing( s );
1543 }
1544
1545 /*!
1546   \brief Get number of group box columns.
1547   \return current columns number
1548   \sa setColumns()
1549 */
1550 int QtxPagePrefGroupItem::columns() const
1551 {
1552   return myBox->columns();
1553 }
1554
1555 /*!
1556   \brief Set number of group box columns.
1557   \param c new columns number
1558   \sa columns()
1559 */
1560 void QtxPagePrefGroupItem::setColumns( const int c )
1561 {
1562   myBox->setColumns( c );
1563 }
1564
1565 /*!
1566   \brief Get group box orientation.
1567   \return current group box orientation
1568   \sa setOrientation()
1569 */
1570 Qt::Orientation QtxPagePrefGroupItem::orientation() const
1571 {
1572   return myBox->orientation();
1573 }
1574
1575 /*!
1576   \brief Set group box orientation.
1577   \param o new group box orientation
1578   \sa orientation()
1579 */
1580 void QtxPagePrefGroupItem::setOrientation( const Qt::Orientation o )
1581 {
1582   myBox->setOrientation( o );
1583 }
1584
1585 /*!
1586   \brief Get 'flat' flag of the group box widget.
1587   \return \c true if the group box is flat
1588 */
1589 bool QtxPagePrefGroupItem::isFlat() const
1590 {
1591   return myGroup->isFlat();
1592 }
1593
1594 /*!
1595   \brief Get 'flat' flag of the group box widget.
1596   \param on if \c true the group box will be made flat
1597 */
1598 void QtxPagePrefGroupItem::setFlat( const bool on )
1599 {
1600   myGroup->setFlat( on );
1601 }
1602
1603 /*!
1604   \brief Store preference item to the resource manager.
1605   \sa retrieve()
1606 */
1607 void QtxPagePrefGroupItem::store()
1608 {
1609   if ( myGroup->isCheckable() )
1610     setBoolean( myGroup->isChecked() );
1611 }
1612
1613 /*!
1614   \brief Return widget contained grid layout of this group.
1615 */
1616 QtxGridBox* QtxPagePrefGroupItem::gridBox() const
1617 {
1618   return myBox;
1619 }
1620
1621 /*!
1622   \brief Retrieve preference item from the resource manager.
1623   \sa store()
1624 */
1625 void QtxPagePrefGroupItem::retrieve()
1626 {
1627   if ( myGroup->isCheckable() )
1628     myGroup->setChecked( getBoolean() );
1629 }
1630
1631 /*!
1632   \brief Get preference item option value.
1633   \param name option name
1634   \return property value or null QVariant if option is not set
1635   \sa setOptionValue()
1636 */
1637 QVariant QtxPagePrefGroupItem::optionValue( const QString& name ) const
1638 {
1639   if ( name == "margin" )
1640     return margin();
1641   else if ( name == "spacing" )
1642     return spacing();
1643   else if ( name == "columns" )
1644     return columns();
1645   else if ( name == "orientation" )
1646     return orientation();
1647   else if ( name == "flat" )
1648     return isFlat();
1649   else
1650     return QtxPagePrefItem::optionValue( name );
1651 }
1652
1653 /*!
1654   \brief Set preference item option value.
1655   \param name option name
1656   \param val new property value
1657   \sa optionValue()
1658 */
1659 void QtxPagePrefGroupItem::setOptionValue( const QString& name, const QVariant& val )
1660 {
1661   if ( name == "margin" )
1662   {
1663     if ( val.canConvert( QVariant::Int ) )
1664       setMargin( val.toInt() );
1665   }
1666   else if ( name == "spacing" )
1667   {
1668     if ( val.canConvert( QVariant::Int ) )
1669       setSpacing( val.toInt() );
1670   }
1671   else if ( name == "columns" )
1672   {
1673     if ( val.canConvert( QVariant::Int ) )
1674       setColumns( val.toInt() );
1675   }
1676   else if ( name == "orientation" )
1677   {
1678     if ( val.canConvert( QVariant::Int ) )
1679       setOrientation( (Qt::Orientation)val.toInt() );
1680   }
1681   else if ( name == "flat" )
1682   {
1683     if ( val.canConvert( QVariant::Bool ) )
1684       setFlat( val.toBool() );
1685   }
1686   else
1687     QtxPagePrefItem::setOptionValue( name, val );
1688 }
1689
1690 void QtxPagePrefGroupItem::widgetShown()
1691 {
1692   QtxPagePrefItem::widgetShown();
1693
1694   QtxPageNamedPrefItem::adjustLabels( this );
1695 }
1696
1697 /*!
1698   \brief Update widget state.
1699 */
1700 void QtxPagePrefGroupItem::updateState()
1701 {
1702   QString section, param;
1703   resource( section, param );
1704   myGroup->setCheckable( !title().isEmpty() && !section.isEmpty() && !param.isEmpty() );
1705 }
1706
1707 /*!
1708   \brief Update group box widget.
1709 */
1710 void QtxPagePrefGroupItem::updateGroup()
1711 {
1712   QList<QtxPagePrefItem*> items;
1713   pageChildItems( items );
1714
1715   for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1716   {
1717     QWidget* wid = (*it)->widget();
1718     if ( !wid )
1719       continue;
1720
1721     if ( wid->parent() != myBox )
1722       wid->setParent( myBox );
1723   }
1724 }
1725
1726 /*!
1727   \class QtxPagePrefLabelItem
1728   \brief Label item which can be used in the preferences editor dialog box.
1729 */
1730
1731 /*!
1732   \brief Constructor.
1733
1734   Creates label item with specified title.
1735
1736   \param text label text
1737   \param parent parent preference item
1738 */
1739 QtxPagePrefLabelItem::QtxPagePrefLabelItem( const QString& text, QtxPreferenceItem* parent )
1740 : QtxPagePrefItem( text, parent )
1741 {
1742   setWidget( myLabel = new QLabel( text ) );
1743 }
1744
1745 QtxPagePrefLabelItem::QtxPagePrefLabelItem( Qt::Alignment align, const QString& text, QtxPreferenceItem* parent )
1746 : QtxPagePrefItem( text, parent )
1747 {
1748   setWidget( myLabel = new QLabel( text ) );
1749   myLabel->setAlignment( align );
1750 }
1751
1752 QtxPagePrefLabelItem::~QtxPagePrefLabelItem()
1753 {
1754 }
1755
1756 void QtxPagePrefLabelItem::setTitle( const QString& text )
1757 {
1758   QtxPagePrefItem::setTitle( text );
1759
1760   if ( myLabel )
1761     myLabel->setText( text );
1762 }
1763
1764 Qt::Alignment QtxPagePrefLabelItem::alignment() const
1765 {
1766   return myLabel->alignment();
1767 }
1768
1769 void QtxPagePrefLabelItem::setAlignment( Qt::Alignment align )
1770 {
1771   myLabel->setAlignment( align );
1772 }
1773
1774 QVariant QtxPagePrefLabelItem::optionValue( const QString& name ) const
1775 {
1776   QVariant val;
1777   if ( name == "alignment" )
1778     val = (int)alignment();
1779   return val;
1780 }
1781
1782 void QtxPagePrefLabelItem::setOptionValue( const QString& name, const QVariant& val )
1783 {
1784   if ( name == "alignment" )
1785   {
1786     if ( val.canConvert( QVariant::Int ) )
1787       setAlignment( (Qt::Alignment)val.toInt() );
1788   }
1789 }
1790
1791 /*!
1792   \class QtxPagePrefSpaceItem
1793   \brief Simple spacer item which can be used in the preferences
1794   editor dialog box.
1795 */
1796
1797 /*!
1798   \brief Constructor.
1799
1800   Creates spacer item with zero width and height and expanding
1801   on both directions (by height and width).
1802
1803   \param parent parent preference item
1804 */
1805 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( QtxPreferenceItem* parent )
1806 : QtxPagePrefItem( QString(), parent )
1807 {
1808   initialize( 0, 0, 1, 1 );
1809 }
1810
1811 /*!
1812   \brief Constructor.
1813
1814   Creates spacer item with zero width and height and expanding
1815   according to the specified orientation.
1816
1817   \param o spacer orientation
1818   \param parent parent preference item
1819 */
1820 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( Qt::Orientation o, QtxPreferenceItem* parent )
1821 : QtxPagePrefItem( QString(), parent )
1822 {
1823   if ( o == Qt::Horizontal )
1824     initialize( 0, 0, 1, 0 );
1825   else
1826     initialize( 0, 0, 0, 1 );
1827 }
1828
1829 /*!
1830   \brief Constructor.
1831
1832   Creates spacer item with specified width and height. The spacing
1833   item is expanding horizontally if \a w <= 0 and vertically
1834   if \a h <= 0.
1835
1836   \param w spacer width
1837   \param h spacer height
1838   \param parent parent preference item
1839 */
1840 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( const int w, const int h, QtxPreferenceItem* parent )
1841 : QtxPagePrefItem( QString(), parent )
1842 {
1843   initialize( w, h, w > 0 ? 0 : 1, h > 0 ? 0 : 1 );
1844 }
1845
1846 /*!
1847   \brief Destructor.
1848 */
1849 QtxPagePrefSpaceItem::~QtxPagePrefSpaceItem()
1850 {
1851 }
1852
1853 /*!
1854   \brief Get spacer item size for the specified direction.
1855   \param o direction
1856   \return size for the specified direction
1857   \sa setSize()
1858 */
1859 int QtxPagePrefSpaceItem::size( Qt::Orientation o ) const
1860 {
1861   return o == Qt::Horizontal ? widget()->minimumWidth() : widget()->minimumHeight();
1862 }
1863
1864 /*!
1865   \brief Set spacer item size for the specified direction.
1866   \param o direction
1867   \param sz new size for the specified direction
1868   \sa size()
1869 */
1870 void QtxPagePrefSpaceItem::setSize( Qt::Orientation o, const int sz )
1871 {
1872   if ( o == Qt::Horizontal )
1873     widget()->setMinimumWidth( sz );
1874   else
1875     widget()->setMinimumHeight( sz );
1876 }
1877
1878 /*!
1879   \brief Get spacer item stretch factor for the specified direction.
1880   \param o direction
1881   \return stretch factor for the specified direction
1882   \sa setStretch()
1883 */
1884 int QtxPagePrefSpaceItem::stretch( Qt::Orientation o ) const
1885 {
1886   QSizePolicy sp = widget()->sizePolicy();
1887   return o == Qt::Horizontal ? sp.horizontalStretch() : sp.verticalStretch();
1888 }
1889
1890 /*!
1891   \brief Set spacer item stretch factor for the specified direction.
1892   \param o direction
1893   \param sf new stretch factor for the specified direction
1894   \sa stretch()
1895 */
1896 void QtxPagePrefSpaceItem::setStretch( Qt::Orientation o, const int sf )
1897 {
1898   QSizePolicy sp = widget()->sizePolicy();
1899   if ( o == Qt::Horizontal )
1900   {
1901     sp.setHorizontalStretch( sf );
1902     sp.setHorizontalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1903   }
1904   else
1905   {
1906     sp.setVerticalStretch( sf );
1907     sp.setVerticalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1908   }
1909
1910   widget()->setSizePolicy( sp );
1911 }
1912
1913 /*!
1914   \brief Get preference item option value.
1915   \param name option name
1916   \return property value or null QVariant if option is not set
1917   \sa setOptionValue()
1918 */
1919 QVariant QtxPagePrefSpaceItem::optionValue( const QString& name ) const
1920 {
1921   if ( name == "horizontal_size" || name == "hsize" )
1922     return size( Qt::Horizontal );
1923   else if ( name == "vertical_size" || name == "vsize" )
1924     return size( Qt::Vertical );
1925   else if ( name == "horizontal_stretch" || name == "hstretch" )
1926     return stretch( Qt::Horizontal );
1927   else if ( name == "vertical_stretch" || name == "vstretch" )
1928     return stretch( Qt::Vertical );
1929   else
1930     return QtxPagePrefItem::optionValue( name );
1931 }
1932
1933 /*!
1934   \brief Set preference item option value.
1935   \param name option name
1936   \param val new property value
1937   \sa optionValue()
1938 */
1939 void QtxPagePrefSpaceItem::setOptionValue( const QString& name, const QVariant& val )
1940 {
1941   if ( name == "horizontal_size" || name == "hsize" )
1942   {
1943     if ( val.canConvert( QVariant::Int ) )
1944       setSize( Qt::Horizontal, val.toInt() );
1945   }
1946   else if ( name == "vertical_size" || name == "vsize" )
1947   {
1948     if ( val.canConvert( QVariant::Int ) )
1949       setSize( Qt::Vertical, val.toInt() );
1950   }
1951   else if ( name == "horizontal_stretch" || name == "hstretch" )
1952   {
1953     if ( val.canConvert( QVariant::Int ) )
1954       setStretch( Qt::Horizontal, val.toInt() );
1955   }
1956   else if ( name == "vertical_stretch" || name == "vstretch" )
1957   {
1958     if ( val.canConvert( QVariant::Int ) )
1959       setStretch( Qt::Vertical, val.toInt() );
1960   }
1961   else
1962     QtxPagePrefItem::setOptionValue( name, val );
1963 }
1964
1965 /*!
1966   \brief Perform internal initialization.
1967   \param w spacer item width
1968   \param h spacer item height
1969   \param ws spacer item horizontal stretch factor
1970   \param hs spacer item vertical stretch factor
1971 */
1972 void QtxPagePrefSpaceItem::initialize( const int w, const int h, const int hs, const int vs )
1973 {
1974   QSizePolicy sp;
1975   sp.setHorizontalPolicy( hs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1976   sp.setVerticalPolicy( vs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1977
1978   sp.setHorizontalStretch( hs );
1979   sp.setVerticalStretch( vs );
1980
1981   QWidget* wid = new QWidget();
1982   wid->setSizePolicy( sp );
1983
1984   wid->setMinimumSize( w, h );
1985
1986   setWidget( wid );
1987 }
1988
1989 /*!
1990   \class  QtxPagePrefCheckItem
1991   \brief GUI implementation of the resources check box item (boolean).
1992 */
1993
1994 /*!
1995   \brief Constructor.
1996   \param title preference item title
1997   \param parent parent preference item
1998   \param sect resource file section associated with the preference item
1999   \param param resource file parameter associated with the preference item
2000 */
2001 QtxPagePrefCheckItem::QtxPagePrefCheckItem( const QString& title, QtxPreferenceItem* parent,
2002                                             const QString& sect, const QString& param )
2003
2004 : QtxPagePrefItem( title, parent, sect, param )
2005 {
2006   myCheck = new QCheckBox( title );
2007   myCheck->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2008   setWidget( myCheck );
2009 }
2010
2011 /*!
2012   \brief Destructor.
2013 */
2014 QtxPagePrefCheckItem::~QtxPagePrefCheckItem()
2015 {
2016 }
2017
2018 /*!
2019   \brief Set preference item title.
2020   \param txt new preference title.
2021 */
2022 void QtxPagePrefCheckItem::setTitle( const QString& txt )
2023 {
2024   QtxPagePrefItem::setTitle( txt );
2025
2026   myCheck->setText( title() );
2027 }
2028
2029 /*!
2030   \brief Store preference item to the resource manager.
2031   \sa retrieve()
2032 */
2033 void QtxPagePrefCheckItem::store()
2034 {
2035   setBoolean( myCheck->isChecked() );
2036 }
2037
2038 /*!
2039   \brief Retrieve preference item from the resource manager.
2040   \sa store()
2041 */
2042 void QtxPagePrefCheckItem::retrieve()
2043 {
2044   myCheck->setChecked( getBoolean() );
2045 }
2046
2047 /*!
2048   \class QtxPagePrefEditItem
2049   \brief GUI implementation of the resources line edit box item
2050   for string, integer and double values.
2051 */
2052
2053 /*!
2054   \brief Constructor.
2055
2056   Creates preference item for string value editing.
2057
2058   \param title preference item title
2059   \param parent parent preference item
2060   \param sect resource file section associated with the preference item
2061   \param param resource file parameter associated with the preference item
2062 */
2063 QtxPagePrefEditItem::QtxPagePrefEditItem( const QString& title, QtxPreferenceItem* parent,
2064                                           const QString& sect, const QString& param )
2065 : QtxPageNamedPrefItem( title, parent, sect, param ),
2066   myType( String )
2067 {
2068   setControl( myEditor = new QLineEdit() );
2069   updateEditor();
2070 }
2071
2072 /*!
2073   \brief Constructor.
2074
2075   Creates preference item for editing of the value which type
2076   is specified by parameter \a type.
2077
2078   \param type preference item input type (QtxPagePrefEditItem::InputType)
2079   \param title preference item title
2080   \param parent parent preference item
2081   \param sect resource file section associated with the preference item
2082   \param param resource file parameter associated with the preference item
2083 */
2084 QtxPagePrefEditItem::QtxPagePrefEditItem( const int type, const QString& title,
2085                                           QtxPreferenceItem* parent, const QString& sect,
2086                                           const QString& param )
2087 : QtxPageNamedPrefItem( title, parent, sect, param ),
2088   myType( type )
2089 {
2090   setControl( myEditor = new QLineEdit() );
2091   updateEditor();
2092 }
2093
2094 /*!
2095   \brief Destructor.
2096 */
2097 QtxPagePrefEditItem::~QtxPagePrefEditItem()
2098 {
2099 }
2100
2101 /*!
2102   \brief Get edit box preference item input type.
2103   \return preference item input type (QtxPagePrefEditItem::InputType)
2104   \sa setInputType()
2105 */
2106 int QtxPagePrefEditItem::inputType() const
2107 {
2108   return myType;
2109 }
2110
2111 /*!
2112   \brief Set edit box preference item input type.
2113   \param type new preference item input type (QtxPagePrefEditItem::InputType)
2114   \sa inputType()
2115 */
2116 void QtxPagePrefEditItem::setInputType( const int type )
2117 {
2118   if ( myType == type )
2119     return;
2120
2121   myType = type;
2122   updateEditor();
2123 }
2124
2125 /*!
2126   \brief Store preference item to the resource manager.
2127   \sa retrieve()
2128 */
2129 void QtxPagePrefEditItem::store()
2130 {
2131   setString( myEditor->text() );
2132 }
2133
2134 /*!
2135   \brief Retrieve preference item from the resource manager.
2136   \sa store()
2137 */
2138 void QtxPagePrefEditItem::retrieve()
2139 {
2140   QString txt = getString();
2141   if ( myEditor->validator() )
2142   {
2143     int pos = 0;
2144     if ( myEditor->validator()->validate( txt, pos ) == QValidator::Invalid )
2145       txt.clear();
2146   }
2147   myEditor->setText( txt );
2148 }
2149
2150 /*!
2151   \brief Get preference item option value.
2152   \param name option name
2153   \return property value or null QVariant if option is not set
2154   \sa setOptionValue()
2155 */
2156 QVariant QtxPagePrefEditItem::optionValue( const QString& name ) const
2157 {
2158   if ( name == "input_type" || name == "type" )
2159     return inputType();
2160   else
2161     return QtxPageNamedPrefItem::optionValue( name );
2162 }
2163
2164 /*!
2165   \brief Set preference item option value.
2166   \param name option name
2167   \param val new property value
2168   \sa optionValue()
2169 */
2170 void QtxPagePrefEditItem::setOptionValue( const QString& name, const QVariant& val )
2171 {
2172   if ( name == "input_type" || name == "type" )
2173   {
2174     if ( val.canConvert( QVariant::Int ) )
2175       setInputType( val.toInt() );
2176   }
2177   else
2178     QtxPageNamedPrefItem::setOptionValue( name, val );
2179 }
2180
2181 /*!
2182   \brief Update edit box widget.
2183 */
2184 void QtxPagePrefEditItem::updateEditor()
2185 {
2186   QValidator* val = 0;
2187   switch ( inputType() )
2188   {
2189   case Integer:
2190     val = new QIntValidator( myEditor );
2191     break;
2192   case Double:
2193     val = new QDoubleValidator( myEditor );
2194     break;
2195   default:
2196     break;
2197   }
2198
2199   if ( !myEditor->text().isEmpty() && val )
2200   {
2201     int pos = 0;
2202     QString str = myEditor->text();
2203     if ( val->validate( str, pos ) == QValidator::Invalid )
2204       myEditor->clear();
2205   }
2206
2207   delete myEditor->validator();
2208   myEditor->setValidator( val );
2209 }
2210
2211 /*!
2212   \class QtxPagePrefSelectItem
2213   \brief GUI implementation of the resources selector item
2214   (string, integer or double values list).
2215
2216   All items in the list (represented as combo box) should be specified
2217   by the unique identifier which is stored to the resource file instead
2218   of the value itself.
2219 */
2220
2221 /*!
2222   \brief Constructor.
2223
2224   Creates preference item with combo box widget which is not editable
2225   (direct value entering is disabled).
2226
2227   \param title preference item title
2228   \param parent parent preference item
2229   \param sect resource file section associated with the preference item
2230   \param param resource file parameter associated with the preference item
2231 */
2232 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const QString& title, QtxPreferenceItem* parent,
2233                                               const QString& sect, const QString& param )
2234 : QtxPageNamedPrefItem( title, parent, sect, param ),
2235   myType( NoInput )
2236 {
2237   setControl( mySelector = new QtxComboBox() );
2238   mySelector->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2239   mySelector->setDuplicatesEnabled( false );
2240   updateSelector();
2241 }
2242
2243 /*!
2244   \brief Constructor.
2245
2246   Creates preference item with combo box widget which is editable
2247   according to the specified input type (integer, double or string values).
2248
2249   \param type input type (QtxPagePrefSelectItem::InputType)
2250   \param title preference item title
2251   \param parent parent preference item
2252   \param sect resource file section associated with the preference item
2253   \param param resource file parameter associated with the preference item
2254 */
2255 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const int type, const QString& title, QtxPreferenceItem* parent,
2256                                               const QString& sect, const QString& param )
2257 : QtxPageNamedPrefItem( title, parent, sect, param ),
2258   myType( type )
2259 {
2260   setControl( mySelector = new QtxComboBox() );
2261   mySelector->setDuplicatesEnabled( false );
2262   updateSelector();
2263 }
2264
2265 /*!
2266   \brief Destructor.
2267 */
2268 QtxPagePrefSelectItem::~QtxPagePrefSelectItem()
2269 {
2270 }
2271
2272 /*!
2273   \brief Get edit box preference item input type.
2274   \return preference item input type (QtxPagePrefSelectItem::InputType)
2275   \sa setInputType()
2276 */
2277 int QtxPagePrefSelectItem::inputType() const
2278 {
2279   return myType;
2280 }
2281
2282 /*!
2283   \brief Set edit box preference item input type.
2284   \param type new preference item input type (QtxPagePrefSelectItem::InputType)
2285   \sa inputType()
2286 */
2287 void QtxPagePrefSelectItem::setInputType( const int type )
2288 {
2289   if ( myType == type )
2290     return;
2291
2292   myType = type;
2293   updateSelector();
2294 }
2295
2296 /*!
2297   \brief Get the list of the values from the selection widget.
2298   \return list of values
2299   \sa numbers(), setStrings()
2300 */
2301 QStringList QtxPagePrefSelectItem::strings() const
2302 {
2303   QStringList res;
2304   for ( uint i = 0; i < mySelector->count(); i++ )
2305     res.append( mySelector->itemText( i ) );
2306   return res;
2307 }
2308
2309 /*!
2310   \brief Get the list of the values identifiers from the selection widget.
2311   \return list of values IDs
2312   \sa strings(), setNumbers()
2313 */
2314 QList<int> QtxPagePrefSelectItem::numbers() const
2315 {
2316   QList<int> res;
2317   for ( uint i = 0; i < mySelector->count(); i++ )
2318   {
2319     if ( mySelector->hasId( i ) )
2320       res.append( mySelector->id( i ) );
2321   }
2322   return res;
2323 }
2324
2325 /*!
2326   \brief Set the list of the values to the selection widget.
2327   \param lst new list of values
2328   \sa strings(), setNumbers()
2329 */
2330 void QtxPagePrefSelectItem::setStrings( const QStringList& lst )
2331 {
2332   mySelector->clear();
2333   mySelector->addItems( lst );
2334 }
2335
2336 /*!
2337   \brief Set the list of the values identifiers to the selection widget.
2338   \param ids new list of values IDs
2339   \sa numbers(), setStrings()
2340 */
2341 void QtxPagePrefSelectItem::setNumbers( const QList<int>& ids )
2342 {
2343   uint i = 0;
2344   for ( QList<int>::const_iterator it = ids.begin(); it != ids.end() && i < mySelector->count(); ++it, i++ )
2345     mySelector->setId( i, *it );
2346 }
2347
2348 /*!
2349   \brief Store preference item to the resource manager.
2350   \sa retrieve()
2351 */
2352 void QtxPagePrefSelectItem::store()
2353 {
2354   if ( mySelector->isCleared() )
2355     return;
2356
2357   int idx = mySelector->currentIndex();
2358
2359   if ( mySelector->hasId( idx ) )
2360     setInteger( mySelector->id( idx ) );
2361   else if ( idx >= 0 )
2362     setString( mySelector->itemText( idx ) );
2363 }
2364
2365 /*!
2366   \brief Retrieve preference item from the resource manager.
2367   \sa store()
2368 */
2369 void QtxPagePrefSelectItem::retrieve()
2370 {
2371   QString txt = getString();
2372
2373   int idx = -1;
2374
2375   bool ok = false;
2376   int num = txt.toInt( &ok );
2377   if ( ok )
2378     idx = mySelector->index( num );
2379   else
2380   {
2381     for ( uint i = 0; i < mySelector->count() && idx == -1; i++ )
2382     {
2383       if ( mySelector->itemText( i ) == txt )
2384         idx = i;
2385     }
2386   }
2387
2388   if ( idx != -1 )
2389     mySelector->setCurrentIndex( idx );
2390   else if ( mySelector->isEditable() )
2391   {
2392     int pos = 0;
2393     if ( mySelector->validator() &&
2394          mySelector->validator()->validate( txt, pos ) == QValidator::Invalid )
2395       mySelector->setCleared( true );
2396     else
2397     {
2398       mySelector->setCleared( false );
2399       mySelector->addItem( txt );
2400       mySelector->setCurrentIndex( mySelector->count() - 1 );
2401     }
2402   }
2403 }
2404
2405 /*!
2406   \brief Get preference item option value.
2407   \param name option name
2408   \return property value or null QVariant if option is not set
2409   \sa setOptionValue()
2410 */
2411 QVariant QtxPagePrefSelectItem::optionValue( const QString& name ) const
2412 {
2413   if ( name == "input_type" || name == "type" )
2414     return inputType();
2415   else if ( name == "strings" || name == "labels" )
2416     return strings();
2417   else if ( name == "numbers" || name == "ids" || name == "indexes" )
2418   {
2419     QList<QVariant> lst;
2420     QList<int> nums = numbers();
2421     for ( QList<int>::const_iterator it = nums.begin(); it != nums.end(); ++it )
2422       lst.append( *it );
2423     return lst;
2424   }
2425   else
2426     return QtxPageNamedPrefItem::optionValue( name );
2427 }
2428
2429 /*!
2430   \brief Set preference item option value.
2431   \param name option name
2432   \param val new property value
2433   \sa optionValue()
2434 */
2435 void QtxPagePrefSelectItem::setOptionValue( const QString& name, const QVariant& val )
2436 {
2437   if ( name == "input_type" || name == "type" )
2438   {
2439     if ( val.canConvert( QVariant::Int ) )
2440       setInputType( val.toInt() );
2441   }
2442   else if ( name == "strings" || name == "labels" )
2443     setStrings( val );
2444   else if ( name == "numbers" || name == "ids" || name == "indexes" )
2445     setNumbers( val );
2446   else
2447     QtxPageNamedPrefItem::setOptionValue( name, val );
2448 }
2449
2450 /*!
2451   \brief Set the list of the values from the resource manager.
2452   \param var new values list
2453   \internal
2454 */
2455 void QtxPagePrefSelectItem::setStrings( const QVariant& var )
2456 {
2457   if ( var.type() != QVariant::StringList )
2458     return;
2459
2460   setStrings( var.toStringList() );
2461 }
2462
2463 /*!
2464   \brief Set the list of the values identifiers from the resource manager.
2465   \param var new values IDs list
2466   \internal
2467 */
2468 void QtxPagePrefSelectItem::setNumbers( const QVariant& var )
2469 {
2470   if ( var.type() != QVariant::List )
2471     return;
2472
2473   QList<int> lst;
2474   QList<QVariant> varList = var.toList();
2475   for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2476   {
2477     if ( (*it).canConvert( QVariant::Int ) )
2478       lst.append( (*it).toInt() );
2479   }
2480   setNumbers( lst );
2481 }
2482
2483 /*!
2484   \brief Update selector widget.
2485 */
2486 void QtxPagePrefSelectItem::updateSelector()
2487 {
2488   QValidator* val = 0;
2489   switch ( inputType() )
2490   {
2491   case Integer:
2492     val = new QIntValidator( mySelector );
2493     break;
2494   case Double:
2495     val = new QDoubleValidator( mySelector );
2496     break;
2497   default:
2498     break;
2499   }
2500
2501   mySelector->setEditable( inputType() != NoInput );
2502
2503   if ( mySelector->isEditable() && !mySelector->currentText().isEmpty() && val )
2504   {
2505     int pos = 0;
2506     QString str = mySelector->currentText();
2507     if ( val->validate( str, pos ) == QValidator::Invalid )
2508       mySelector->clearEditText();
2509   }
2510
2511   delete mySelector->validator();
2512   mySelector->setValidator( val );
2513 }
2514
2515 /*!
2516   \class QtxPagePrefSpinItem
2517   \brief GUI implementation of the resources spin box item
2518   (for integer or double value).
2519 */
2520
2521 /*!
2522   \brief Constructor.
2523
2524   Creates spin box preference item for the entering integer values.
2525
2526   \param title preference item title
2527   \param parent parent preference item
2528   \param sect resource file section associated with the preference item
2529   \param param resource file parameter associated with the preference item
2530 */
2531 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const QString& title, QtxPreferenceItem* parent,
2532                                           const QString& sect, const QString& param )
2533 : QtxPageNamedPrefItem( title, parent, sect, param ),
2534   myType( Integer )
2535 {
2536   updateSpinBox();
2537 }
2538
2539 /*!
2540   \brief Constructor.
2541
2542   Creates spin box preference item for the entering values which type
2543   is specified by the parameter \a type.
2544
2545   \param type input type (QtxPagePrefSpinItem::InputType).
2546   \param title preference item title
2547   \param parent parent preference item
2548   \param sect resource file section associated with the preference item
2549   \param param resource file parameter associated with the preference item
2550 */
2551 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const int type, const QString& title,
2552                                           QtxPreferenceItem* parent, const QString& sect,
2553                                           const QString& param )
2554 : QtxPageNamedPrefItem( title, parent, sect, param ),
2555   myType( type )
2556 {
2557   updateSpinBox();
2558 }
2559
2560 /*!
2561   \brief Destructor.
2562 */
2563 QtxPagePrefSpinItem::~QtxPagePrefSpinItem()
2564 {
2565 }
2566
2567 /*!
2568   \brief Get spin box preference item input type.
2569   \return preference item input type (QtxPagePrefSpinItem::InputType)
2570   \sa setInputType()
2571 */
2572 int QtxPagePrefSpinItem::inputType() const
2573 {
2574   return myType;
2575 }
2576
2577 /*!
2578   \brief Set spin box preference item input type.
2579   \param type new preference item input type (QtxPagePrefSpinItem::InputType)
2580   \sa inputType()
2581 */
2582 void QtxPagePrefSpinItem::setInputType( const int type )
2583 {
2584   if ( myType == type )
2585     return;
2586
2587   myType = type;
2588   updateSpinBox();
2589 }
2590
2591 /*!
2592   \brief Get spin box preference item step value.
2593   \return spin box single step value
2594   \sa setStep()
2595 */
2596 QVariant QtxPagePrefSpinItem::step() const
2597 {
2598   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2599     return isb->singleStep();
2600   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2601     return dsb->singleStep();
2602   else
2603     return QVariant();
2604 }
2605
2606 /*!
2607   \brief Get spin box preference item minimum value.
2608   \return spin box minimum value
2609   \sa setMinimum()
2610 */
2611 QVariant QtxPagePrefSpinItem::minimum() const
2612 {
2613   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2614     return isb->minimum();
2615   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2616     return dsb->minimum();
2617   else
2618     return QVariant();
2619 }
2620
2621 /*!
2622   \brief Get spin box preference item maximum value.
2623   \return spin box maximum value
2624   \sa setMaximum()
2625 */
2626 QVariant QtxPagePrefSpinItem::maximum() const
2627 {
2628   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2629     return isb->maximum();
2630   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2631     return dsb->maximum();
2632   else
2633     return QVariant();
2634 }
2635
2636 /*!
2637   \brief Get spin box preference item prefix string.
2638   \return spin box prefix string
2639   \sa setPrefix()
2640 */
2641 QString QtxPagePrefSpinItem::prefix() const
2642 {
2643   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2644     return isb->prefix();
2645   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2646     return dsb->prefix();
2647   else
2648     return QString();
2649 }
2650
2651 /*!
2652   \brief Get spin box preference item suffix string.
2653   \return spin box suffix string
2654   \sa setSuffix()
2655 */
2656 QString QtxPagePrefSpinItem::suffix() const
2657 {
2658   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2659     return isb->suffix();
2660   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2661     return dsb->suffix();
2662   else
2663     return QString();
2664 }
2665
2666 /*!
2667   \brief Get spin box preference item special value text (which is shown
2668   when the spin box reaches minimum value).
2669   \return spin box special value text
2670   \sa setSpecialValueText()
2671 */
2672 QString QtxPagePrefSpinItem::specialValueText() const
2673 {
2674   QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
2675   if ( sb )
2676     return sb->specialValueText();
2677   else
2678     return QString();
2679 }
2680
2681 /*!
2682   \brief Set spin box preference item step value.
2683   \param step new spin box single step value
2684   \sa step()
2685 */
2686 void QtxPagePrefSpinItem::setStep( const QVariant& step )
2687 {
2688   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2689   {
2690     if ( step.canConvert( QVariant::Int ) )
2691       isb->setSingleStep( step.toInt() );
2692   }
2693   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2694   {
2695     if ( step.canConvert( QVariant::Double ) )
2696       dsb->setSingleStep( step.toDouble() );
2697   }
2698 }
2699
2700 /*!
2701   \brief Set spin box preference item minimum value.
2702   \param min new spin box minimum value
2703   \sa minimum()
2704 */
2705 void QtxPagePrefSpinItem::setMinimum( const QVariant& min )
2706 {
2707   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2708   {
2709     if ( min.canConvert( QVariant::Int ) )
2710       isb->setMinimum( min.toInt() );
2711   }
2712   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2713   {
2714     if ( min.canConvert( QVariant::Double ) )
2715       dsb->setMinimum( min.toDouble() );
2716   }
2717 }
2718
2719 /*!
2720   \brief Set spin box preference item maximum value.
2721   \param min new spin box maximum value
2722   \sa maximum()
2723 */
2724 void QtxPagePrefSpinItem::setMaximum( const QVariant& max )
2725 {
2726   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2727   {
2728     if ( max.canConvert( QVariant::Int ) )
2729       isb->setMaximum( max.toInt() );
2730   }
2731   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2732   {
2733     if ( max.canConvert( QVariant::Double ) )
2734       dsb->setMaximum( max.toDouble() );
2735   }
2736 }
2737
2738 /*!
2739   \brief Set spin box preference item prefix string.
2740   \param txt new spin box prefix string
2741   \sa prefix()
2742 */
2743 void QtxPagePrefSpinItem::setPrefix( const QString& txt )
2744 {
2745   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2746     isb->setPrefix( txt );
2747   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2748     dsb->setPrefix( txt );
2749 }
2750
2751 /*!
2752   \brief Set spin box preference item suffix string.
2753   \param txt new spin box suffix string
2754   \sa suffix()
2755 */
2756 void QtxPagePrefSpinItem::setSuffix( const QString& txt )
2757 {
2758   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2759     isb->setSuffix( txt );
2760   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2761     dsb->setSuffix( txt );
2762 }
2763
2764 /*!
2765   \brief Set spin box preference item special value text (which is shown
2766   when the spin box reaches minimum value).
2767   \param txt new spin box special value text
2768   \sa specialValueText()
2769 */
2770 void QtxPagePrefSpinItem::setSpecialValueText( const QString& txt )
2771 {
2772   QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
2773   if ( sb )
2774     sb->setSpecialValueText( txt );
2775 }
2776
2777 /*!
2778   \brief Store preference item to the resource manager.
2779   \sa retrieve()
2780 */
2781 void QtxPagePrefSpinItem::store()
2782 {
2783   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2784     setInteger( isb->value() );
2785   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2786     setDouble( dsb->value() );
2787 }
2788
2789 /*!
2790   \brief Retrieve preference item from the resource manager.
2791   \sa store()
2792 */
2793 void QtxPagePrefSpinItem::retrieve()
2794 {
2795   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2796     isb->setValue( getInteger( isb->value() ) );
2797   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2798     dsb->setValue( getDouble( dsb->value() ) );
2799 }
2800
2801 /*!
2802   \brief Get preference item option value.
2803   \param name option name
2804   \return property value or null QVariant if option is not set
2805   \sa setOptionValue()
2806 */
2807 QVariant QtxPagePrefSpinItem::optionValue( const QString& name ) const
2808 {
2809   if ( name == "input_type" || name == "type" )
2810     return inputType();
2811   else if ( name == "minimum" || name == "min" )
2812     return minimum();
2813   else if ( name == "maximum" || name == "max" )
2814     return maximum();
2815   else if ( name == "step" )
2816     return step();
2817   else if ( name == "prefix" )
2818     return prefix();
2819   else if ( name == "suffix" )
2820     return suffix();
2821   else if ( name == "special" )
2822     return specialValueText();
2823   else
2824     return QtxPageNamedPrefItem::optionValue( name );
2825 }
2826
2827 /*!
2828   \brief Set preference item option value.
2829   \param name option name
2830   \param val new property value
2831   \sa optionValue()
2832 */
2833 void QtxPagePrefSpinItem::setOptionValue( const QString& name, const QVariant& val )
2834 {
2835   if ( name == "input_type" || name == "type" )
2836   {
2837     if ( val.canConvert( QVariant::Int ) )
2838       setInputType( val.toInt() );
2839   }
2840   else if ( name == "minimum" || name == "min" )
2841     setMinimum( val );
2842   else if ( name == "maximum" || name == "max" )
2843     setMaximum( val );
2844   else if ( name == "step" )
2845     setStep( val );
2846   else if ( name == "prefix" )
2847   {
2848     if ( val.canConvert( QVariant::String ) )
2849       setPrefix( val.toString() );
2850   }
2851   else if ( name == "suffix" )
2852   {
2853     if ( val.canConvert( QVariant::String ) )
2854       setSuffix( val.toString() );
2855   }
2856   else if ( name == "special" )
2857   {
2858     if ( val.canConvert( QVariant::String ) )
2859       setSpecialValueText( val.toString() );
2860   }
2861   else
2862     QtxPageNamedPrefItem::setOptionValue( name, val );
2863 }
2864
2865 /*!
2866   \brief Update spin box widget.
2867 */
2868 void QtxPagePrefSpinItem::updateSpinBox()
2869 {
2870   QVariant val;
2871   QVariant stp = step();
2872   QVariant min = minimum();
2873   QVariant max = maximum();
2874
2875   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2876     val = isb->value();
2877   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2878     val = dsb->value();
2879
2880   switch ( inputType() )
2881   {
2882   case Integer:
2883     setControl( new QtxIntSpinBox() );
2884     break;
2885   case Double:
2886     setControl( new QtxDoubleSpinBox() );
2887     break;
2888   default:
2889     break;
2890   }
2891
2892   control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2893
2894   setStep( stp );
2895   setMinimum( min );
2896   setMaximum( max );
2897
2898   if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
2899   {
2900     if ( val.canConvert( QVariant::Int ) )
2901       isb->setValue( val.toInt() );
2902   }
2903   else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
2904   {
2905     if ( val.canConvert( QVariant::Double ) )
2906       dsb->setValue( val.toDouble() );
2907   }
2908 }
2909
2910 /*!
2911   \class  QtxPagePrefTextItem
2912   \brief GUI implementation of the resources text box edit item
2913   (for large text data).
2914 */
2915
2916 /*!
2917   \brief Constructor.
2918   \param parent parent preference item
2919   \param sect resource file section associated with the preference item
2920   \param param resource file parameter associated with the preference item
2921 */
2922 QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect,
2923                                           const QString& param )
2924 : QtxPageNamedPrefItem( QString(), parent, sect, param )
2925 {
2926   myEditor = new QTextEdit();
2927   myEditor->setAcceptRichText( false );
2928
2929   setControl( myEditor );
2930 }
2931
2932 /*!
2933   \brief Constructor.
2934   \param title preference item title
2935   \param parent parent preference item
2936   \param sect resource file section associated with the preference item
2937   \param param resource file parameter associated with the preference item
2938 */
2939 QtxPagePrefTextItem::QtxPagePrefTextItem( const QString& title, QtxPreferenceItem* parent,
2940                                           const QString& sect, const QString& param )
2941 : QtxPageNamedPrefItem( title, parent, sect, param )
2942 {
2943   myEditor = new QTextEdit();
2944   myEditor->setAcceptRichText( false );
2945
2946   setControl( myEditor );
2947 }
2948
2949 /*!
2950   \brief Destructor.
2951 */
2952 QtxPagePrefTextItem::~QtxPagePrefTextItem()
2953 {
2954 }
2955
2956 /*!
2957   \brief Store preference item to the resource manager.
2958   \sa retrieve()
2959 */
2960 void QtxPagePrefTextItem::store()
2961 {
2962   setString( myEditor->toPlainText() );
2963 }
2964
2965 /*!
2966   \brief Retrieve preference item from the resource manager.
2967   \sa store()
2968 */
2969 void QtxPagePrefTextItem::retrieve()
2970 {
2971   myEditor->setPlainText( getString() );
2972 }
2973
2974 /*!
2975   \class QtxPagePrefColorItem
2976   \brief GUI implementation of the resources color item.
2977 */
2978
2979 /*!
2980   \brief Constructor.
2981   \param title preference item title
2982   \param parent parent preference item
2983   \param sect resource file section associated with the preference item
2984   \param param resource file parameter associated with the preference item
2985 */
2986 QtxPagePrefColorItem::QtxPagePrefColorItem( const QString& title, QtxPreferenceItem* parent,
2987                                             const QString& sect, const QString& param )
2988 : QtxPageNamedPrefItem( title, parent, sect, param )
2989 {
2990   //  QtxPagePrefGroupItem* aGroup 0; //= dynamic_cast<QtxPagePrefGroupItem*>( parent );
2991
2992   //  setControl( myColor = new QtxColorButton( aGroup ? aGroup->gridBox() : 0 ) );
2993   setControl( myColor = new QtxColorButton( 0 ) );
2994   myColor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2995 }
2996
2997 /*!
2998   \brief Destructor.
2999 */
3000 QtxPagePrefColorItem::~QtxPagePrefColorItem()
3001 {
3002 }
3003
3004 /*!
3005   \brief Store preference item to the resource manager.
3006   \sa retrieve()
3007 */
3008 void QtxPagePrefColorItem::store()
3009 {
3010   setColor( myColor->color() );
3011 }
3012
3013 /*!
3014   \brief Retrieve preference item from the resource manager.
3015   \sa store()
3016 */
3017 void QtxPagePrefColorItem::retrieve()
3018 {
3019   myColor->setColor( getColor() );
3020 }
3021
3022 /*!
3023   \class QtxPagePrefFontItem
3024   \brief GUI implementation of the resources font item.
3025 */
3026
3027 /*!
3028   \brief Constructor.
3029   \param feat font editor widget features (QtxFontEdit::Features)
3030   \param title preference item title
3031   \param parent parent preference item
3032   \param sect resource file section associated with the preference item
3033   \param param resource file parameter associated with the preference item
3034 */
3035 QtxPagePrefFontItem::QtxPagePrefFontItem( const int feat, const QString& title,
3036                                           QtxPreferenceItem* parent, const QString& sect,
3037                                           const QString& param )
3038 : QtxPageNamedPrefItem( title, parent, sect, param )
3039 {
3040   setControl( myFont = new QtxFontEdit( feat ) );
3041 }
3042
3043 /*!
3044   \brief Constructor.
3045   \param title preference item title
3046   \param parent parent preference item
3047   \param sect resource file section associated with the preference item
3048   \param param resource file parameter associated with the preference item
3049 */
3050 QtxPagePrefFontItem::QtxPagePrefFontItem( const QString& title, QtxPreferenceItem* parent,
3051                                           const QString& sect, const QString& param )
3052 : QtxPageNamedPrefItem( title, parent, sect, param )
3053 {
3054   setControl( myFont = new QtxFontEdit() );
3055 }
3056
3057 /*!
3058   \brief Destructor.
3059 */
3060 QtxPagePrefFontItem::~QtxPagePrefFontItem()
3061 {
3062 }
3063
3064 /*!
3065   \brief Get font widget features.
3066   \return font widget features (ORed QtxFontEdit::Features flags)
3067   \sa setFeatures()
3068 */
3069 int QtxPagePrefFontItem::features() const
3070 {
3071   return myFont->features();
3072 }
3073
3074 /*!
3075   \brief Set font widget features.
3076   \param f new font widget features (ORed QtxFontEdit::Features flags)
3077   \sa features()
3078 */
3079 void QtxPagePrefFontItem::setFeatures( const int f )
3080 {
3081   myFont->setFeatures( f );
3082 }
3083
3084 /*!
3085   \brief Specifies whether widget works in Native or Custom mode. Native mode 
3086   is intended for working with system fonts. Custom mode is intended for 
3087   working with manually defined set of fonts. Set of custom fonts can be 
3088   specified with setFonts() method 
3089   \param mode mode from QtxFontEdit::Mode enumeration
3090   \sa mode()
3091 */
3092 void QtxPagePrefFontItem::setMode( const int mode )
3093 {
3094   myFont->setMode( mode );
3095 }
3096
3097 /*!
3098   \brief Verifies whether widget works in Native or Custom mode
3099   \return Native or Custom mode
3100   \sa setMode()
3101 */
3102 int QtxPagePrefFontItem::mode() const
3103 {
3104   return myFont->mode();
3105 }
3106
3107 /*!
3108   \brief Sets list of custom fonts. 
3109   <b>This method is intended for working in Custom mode only.</b>
3110   \param fams list of families
3111   \sa fonts(), setMode()
3112 */
3113 void QtxPagePrefFontItem::setFonts( const QStringList& fams )
3114 {
3115   myFont->setFonts( fams );
3116 }
3117
3118 /*!
3119   \brief Gets list of custom fonts 
3120   \return list of families
3121   \sa setFonts(), setMode()
3122 */
3123 QStringList QtxPagePrefFontItem::fonts() const
3124 {
3125   return myFont->fonts();
3126 }
3127
3128 /*!
3129   \brief Sets list of available font sizes. 
3130   <b>This method is intended for working in Custom mode only.</b> The list of sizes can 
3131   be empty. In this case system generate listof size automatically from 8 till 72.
3132   \param sizes list of sizes
3133   \sa sizes(), setMode()
3134 */
3135 void QtxPagePrefFontItem::setSizes( const QList<int>& sizes )
3136 {
3137   myFont->setSizes( sizes );
3138 }
3139
3140 /*!
3141   \brief Gets list of custom fonts 
3142   \return list of families
3143   \sa setFonts(), setMode()
3144 */
3145 QList<int> QtxPagePrefFontItem::sizes() const
3146 {
3147   return myFont->sizes();
3148 }
3149
3150 /*!
3151   \brief Store preference item to the resource manager.
3152   \sa retrieve()
3153 */
3154 void QtxPagePrefFontItem::store()
3155 {
3156   setFont( myFont->currentFont() );
3157 }
3158
3159 /*!
3160   \brief Retrieve preference item from the resource manager.
3161   \sa store()
3162 */
3163 void QtxPagePrefFontItem::retrieve()
3164 {
3165   myFont->setCurrentFont( getFont() );
3166 }
3167
3168 /*!
3169   \brief Get preference item option value.
3170   \param name option name
3171   \return property value or null QVariant if option is not set
3172   \sa setOptionValue()
3173 */
3174 QVariant QtxPagePrefFontItem::optionValue( const QString& name ) const
3175 {
3176   if ( name == "features" )
3177     return features();
3178   else if ( name == "mode" )
3179     return mode();
3180   else if ( name == "fonts" || name == "families" )
3181     return fonts();
3182   else if ( name == "sizes" )
3183   {
3184     QList<QVariant> lst;
3185     QList<int> nums = sizes();
3186     for ( QList<int>::const_iterator it = nums.begin(); it != nums.end(); ++it )
3187       lst.append( *it );
3188     return lst;
3189   }
3190   else
3191     return QtxPageNamedPrefItem::optionValue( name );
3192 }
3193
3194 /*!
3195   \brief Set preference item option value.
3196   \param name option name
3197   \param val new property value
3198   \sa optionValue()
3199 */
3200 void QtxPagePrefFontItem::setOptionValue( const QString& name, const QVariant& val )
3201 {
3202   if ( name == "features" )
3203   {
3204     if ( val.canConvert( QVariant::Int ) )
3205       setFeatures( val.toInt() );
3206   }
3207   else if ( name == "mode" )
3208   {
3209     if ( val.canConvert( QVariant::Int ) )
3210       setMode( val.toInt() );
3211   }
3212   else if ( name == "fonts" || name == "families" )
3213   {
3214     if ( val.canConvert( QVariant::StringList ) )
3215       setFonts( val.toStringList() );
3216   }
3217   else if ( name == "sizes" )
3218   {
3219     if ( val.type() == QVariant::List )
3220     {
3221       QList<int> lst;
3222       QList<QVariant> varList = val.toList();
3223       for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
3224       {
3225         if ( (*it).canConvert( QVariant::Int ) )
3226           lst.append( (*it).toInt() );
3227       }
3228       setSizes( lst );
3229     }
3230   }
3231   else
3232     QtxPageNamedPrefItem::setOptionValue( name, val );
3233 }
3234
3235 /*!
3236   \class  QtxPagePrefPathItem
3237   \brief GUI implementation of the resources file/directory path item.
3238 */
3239
3240 /*!
3241   \brief Constructor.
3242   \param type path widget mode (Qtx::PathType )
3243   \param title preference item title
3244   \param parent parent preference item
3245   \param sect resource file section associated with the preference item
3246   \param param resource file parameter associated with the preference item
3247 */
3248 QtxPagePrefPathItem::QtxPagePrefPathItem( const Qtx::PathType type, const QString& title,
3249                                           QtxPreferenceItem* parent, const QString& sect, const QString& param )
3250 : QtxPageNamedPrefItem( title, parent, sect, param )
3251 {
3252   setControl( myPath = new QtxPathEdit( type ) );
3253 }
3254
3255 /*!
3256   \brief Constructor.
3257   \param title preference item title
3258   \param parent parent preference item
3259   \param sect resource file section associated with the preference item
3260   \param param resource file parameter associated with the preference item
3261 */
3262 QtxPagePrefPathItem::QtxPagePrefPathItem( const QString& title, QtxPreferenceItem* parent,
3263                                           const QString& sect, const QString& param )
3264 : QtxPageNamedPrefItem( title, parent, sect, param )
3265 {
3266   setControl( myPath = new QtxPathEdit() );
3267 }
3268
3269 /*!
3270   \brief Destructor.
3271 */
3272 QtxPagePrefPathItem::~QtxPagePrefPathItem()
3273 {
3274 }
3275
3276 /*!
3277   \brief Get path widget mode.
3278   \return current path widget mode (Qtx::PathType)
3279   \sa setPathType()
3280 */
3281 Qtx::PathType QtxPagePrefPathItem::pathType() const
3282 {
3283   return myPath->pathType();
3284 }
3285
3286 /*!
3287   \brief Set path widget mode.
3288   \param type new path widget mode (Qtx::PathType)
3289   \sa pathType()
3290 */
3291 void QtxPagePrefPathItem::setPathType( const Qtx::PathType type )
3292 {
3293   myPath->setPathType( type );
3294 }
3295
3296 /*!
3297   \brief Get currently used path widget filters.
3298   \return file or directory path filters
3299   \sa setPathFilter()
3300 */
3301 QString QtxPagePrefPathItem::pathFilter() const
3302 {
3303   return myPath->pathFilter();
3304 }
3305
3306 /*!
3307   \brief Set path widget filters.
3308   \param f new file or directory path filters
3309   \sa pathFilter()
3310 */
3311 void QtxPagePrefPathItem::setPathFilter( const QString& f )
3312 {
3313   myPath->setPathFilter( f );
3314 }
3315
3316 /*!
3317   \brief Store preference item to the resource manager.
3318   \sa retrieve()
3319 */
3320 void QtxPagePrefPathItem::store()
3321 {
3322   setString( myPath->path() );
3323 }
3324
3325 /*!
3326   \brief Retrieve preference item from the resource manager.
3327   \sa store()
3328 */
3329 void QtxPagePrefPathItem::retrieve()
3330 {
3331   myPath->setPath( getString() );
3332 }
3333
3334 /*!
3335   \brief Get preference item option value.
3336   \param name option name
3337   \return property value or null QVariant if option is not set
3338   \sa setOptionValue()
3339 */
3340 QVariant QtxPagePrefPathItem::optionValue( const QString& name ) const
3341 {
3342   if ( name == "path_type" )
3343     return pathType();
3344   else if ( name == "path_filter" )
3345     return pathFilter();
3346   else
3347     return QtxPageNamedPrefItem::optionValue( name );
3348 }
3349
3350 /*!
3351   \brief Set preference item option value.
3352   \param name option name
3353   \param val new property value
3354   \sa optionValue()
3355 */
3356 void QtxPagePrefPathItem::setOptionValue( const QString& name, const QVariant& val )
3357 {
3358   if ( name == "path_type" )
3359   {
3360     if ( val.canConvert( QVariant::Int ) )
3361       setPathType( (Qtx::PathType)val.toInt() );
3362   }
3363   else if ( name == "path_filter" )
3364   {
3365     if ( val.canConvert( QVariant::String ) )
3366       setPathFilter( val.toString() );
3367   }
3368   else
3369     QtxPageNamedPrefItem::setOptionValue( name, val );
3370 }
3371
3372 /*!
3373   \class QtxPagePrefPathListItem
3374   \brief GUI implementation of the resources files/directories list item.
3375 */
3376
3377 /*!
3378   \brief Constructor.
3379   \param parent parent preference item
3380   \param sect resource file section associated with the preference item
3381   \param param resource file parameter associated with the preference item
3382 */
3383 QtxPagePrefPathListItem::QtxPagePrefPathListItem( QtxPreferenceItem* parent,
3384                                                   const QString& sect, const QString& param )
3385 : QtxPageNamedPrefItem( QString(), parent, sect, param )
3386 {
3387   setControl( myPaths = new QtxPathListEdit() );
3388 }
3389
3390 /*!
3391   \brief Constructor.
3392   \param type path list widget mode (Qtx::PathType)
3393   \param title preference item title
3394   \param parent parent preference item
3395   \param sect resource file section associated with the preference item
3396   \param param resource file parameter associated with the preference item
3397 */
3398 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const Qtx::PathType type, const QString& title,
3399                                                   QtxPreferenceItem* parent, const QString& sect, const QString& param )
3400 : QtxPageNamedPrefItem( title, parent, sect, param )
3401 {
3402   setControl( myPaths = new QtxPathListEdit( type ) );
3403 }
3404
3405 /*!
3406   \brief Constructor.
3407   \param title preference item title
3408   \param parent parent preference item
3409   \param sect resource file section associated with the preference item
3410   \param param resource file parameter associated with the preference item
3411 */
3412 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const QString& title, QtxPreferenceItem* parent,
3413                                                   const QString& sect, const QString& param )
3414 : QtxPageNamedPrefItem( title, parent, sect, param )
3415 {
3416   setControl( myPaths = new QtxPathListEdit() );
3417 }
3418
3419 /*!
3420   \brief Destructor.
3421 */
3422 QtxPagePrefPathListItem::~QtxPagePrefPathListItem()
3423 {
3424 }
3425
3426 /*!
3427   \brief Get path list widget mode.
3428   \return currently used path list widget mode (Qtx::PathType)
3429   \sa setPathType()
3430 */
3431 Qtx::PathType QtxPagePrefPathListItem::pathType() const
3432 {
3433   return myPaths->pathType();
3434 }
3435
3436 /*!
3437   \brief Set path list widget mode.
3438   \param type new path list widget mode (Qtx::PathType)
3439   \sa pathType()
3440 */
3441 void QtxPagePrefPathListItem::setPathType( const Qtx::PathType type )
3442 {
3443   myPaths->setPathType( type );
3444 }
3445
3446 /*!
3447   \brief Store preference item to the resource manager.
3448   \sa retrieve()
3449 */
3450 void QtxPagePrefPathListItem::store()
3451 {
3452   setString( myPaths->pathList().join( ";" ) );
3453 }
3454
3455 /*!
3456   \brief Retrieve preference item from the resource manager.
3457   \sa store()
3458 */
3459 void QtxPagePrefPathListItem::retrieve()
3460 {
3461   myPaths->setPathList( getString().split( ";" ) );
3462 }
3463
3464 /*!
3465   \brief Get preference item option value.
3466   \param name option name
3467   \return property value or null QVariant if option is not set
3468   \sa setOptionValue()
3469 */
3470 QVariant QtxPagePrefPathListItem::optionValue( const QString& name ) const
3471 {
3472   if ( name == "path_type" )
3473     return pathType();
3474   else
3475     return QtxPageNamedPrefItem::optionValue( name );
3476 }
3477
3478 /*!
3479   \brief Set preference item option value.
3480   \param name option name
3481   \param val new property value
3482   \sa optionValue()
3483 */
3484 void QtxPagePrefPathListItem::setOptionValue( const QString& name, const QVariant& val )
3485 {
3486   if ( name == "path_type" )
3487   {
3488     if ( val.canConvert( QVariant::Int ) )
3489       setPathType( (Qtx::PathType)val.toInt() );
3490   }
3491   else
3492     QtxPageNamedPrefItem::setOptionValue( name, val );
3493 }
3494
3495 /*!
3496   \class  QtxPagePrefDateTimeItem
3497   \brief GUI implementation of resources date/time item.
3498 */
3499
3500 /*!
3501   \brief Constructor.
3502
3503   Creates an item to enter date and time.
3504
3505   \param title preference item title
3506   \param parent parent preference item
3507   \param sect resource file section associated with the preference item
3508   \param param resource file parameter associated with the preference item
3509 */
3510 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const QString& title, QtxPreferenceItem* parent,
3511                                                   const QString& sect, const QString& param )
3512 : QtxPageNamedPrefItem( title, parent, sect, param ),
3513   myType( DateTime )
3514 {
3515   setControl( myDateTime = new QDateTimeEdit() );
3516   myDateTime->setCalendarPopup( true );
3517   myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3518   updateDateTime();
3519 }
3520
3521 /*!
3522   \brief Constructor.
3523
3524   Creates preference item for editing of the date and/or time value:
3525   the type is specified by parameter \a type.
3526
3527   \param type preference item input type (QtxPagePrefDateTimeItem::InputType)
3528   \param title preference item title
3529   \param parent parent preference item
3530   \param sect resource file section associated with the preference item
3531   \param param resource file parameter associated with the preference item
3532 */
3533 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const int type, const QString& title, QtxPreferenceItem* parent,
3534                                                   const QString& sect, const QString& param )
3535 : QtxPageNamedPrefItem( title, parent, sect, param ),
3536   myType( type )
3537 {
3538   setControl( myDateTime = new QDateTimeEdit() );
3539   myDateTime->setCalendarPopup( true );
3540   myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3541   updateDateTime();
3542 }
3543
3544 /*!
3545   \brief Destructor.
3546 */
3547 QtxPagePrefDateTimeItem::~QtxPagePrefDateTimeItem()
3548 {
3549 }
3550
3551 /*!
3552   \brief Get date/time box preference item input type.
3553   \return preference item input type (QtxPagePrefDateTimeItem::InputType)
3554   \sa setInputType()
3555 */
3556 int QtxPagePrefDateTimeItem::inputType() const
3557 {
3558   return myType;
3559 }
3560
3561 /*!
3562   \brief Set date/time box preference item input type.
3563   \param type new preference item input type (QtxPagePrefDateTimeItem::InputType)
3564   \sa inputType()
3565 */
3566 void QtxPagePrefDateTimeItem::setInputType( const int type )
3567 {
3568   if ( myType == type )
3569     return;
3570
3571   myType = type;
3572   updateDateTime();
3573 }
3574
3575 /*!
3576   \brief Check if the popup calendar menu is enabled.
3577   \return \c true if calendar popup menu is enabled
3578 */
3579 bool QtxPagePrefDateTimeItem::calendar() const
3580 {
3581   return myDateTime->calendarPopup();
3582 }
3583
3584 /*!
3585   \brief Enable/disable popup calendar menu.
3586   \param on new flag state
3587 */
3588 void QtxPagePrefDateTimeItem::setCalendar( const bool on )
3589 {
3590   myDateTime->setCalendarPopup( on );
3591 }
3592
3593 /*!
3594   \brief Get maximum date value.
3595   \return maximum date value
3596   \sa setMaximumDate(), minimumDate(), maximumTime(), minimumTime()
3597 */
3598 QDate QtxPagePrefDateTimeItem::maximumDate() const
3599 {
3600   return myDateTime->maximumDate();
3601 }
3602
3603 /*!
3604   \brief Get maximum time value.
3605   \return maximum time value
3606   \sa setMaximumTime(), minimumTime(), maximumDate(), minimumDate()
3607 */
3608 QTime QtxPagePrefDateTimeItem::maximumTime() const
3609 {
3610   return myDateTime->maximumTime();
3611 }
3612
3613 /*!
3614   \brief Get minimum date value.
3615   \return minimum date value
3616   \sa setMinimumDate(), maximumDate(), maximumTime(), minimumTime()
3617 */
3618 QDate QtxPagePrefDateTimeItem::minimumDate() const
3619 {
3620   return myDateTime->minimumDate();
3621 }
3622
3623 /*!
3624   \brief Get minimum time value.
3625   \return maximum time value
3626   \sa setMinimumTime(), maximumTime(), maximumDate(), minimumDate()
3627 */
3628 QTime QtxPagePrefDateTimeItem::minimumTime() const
3629 {
3630   return myDateTime->minimumTime();
3631 }
3632
3633 /*!
3634   \brief Set maximum date value.
3635   \param d new maximum date value
3636   \sa maximumDate(), minimumDate(), maximumTime(), minimumTime()
3637 */
3638 void QtxPagePrefDateTimeItem::setMaximumDate( const QDate& d )
3639 {
3640   if ( d.isValid() )
3641     myDateTime->setMaximumDate( d );
3642   else
3643     myDateTime->clearMaximumDate();
3644 }
3645
3646 /*!
3647   \brief Set maximum time value.
3648   \param t new maximum time value
3649   \sa maximumTime(), minimumTime(), maximumDate(), minimumDate()
3650 */
3651 void QtxPagePrefDateTimeItem::setMaximumTime( const QTime& t )
3652 {
3653   if ( t.isValid() )
3654     myDateTime->setMaximumTime( t );
3655   else
3656     myDateTime->clearMaximumTime();
3657 }
3658
3659 /*!
3660   \brief Set minimum date value.
3661   \param d new minimum date value
3662   \sa minimumDate(), maximumDate(), maximumTime(), minimumTime()
3663 */
3664 void QtxPagePrefDateTimeItem::setMinimumDate( const QDate& d )
3665 {
3666   if ( d.isValid() )
3667     myDateTime->setMinimumDate( d );
3668   else
3669     myDateTime->clearMinimumDate();
3670 }
3671
3672 /*!
3673   \brief Set minimum time value.
3674   \param t new minimum time value
3675   \sa minimumTime(), maximumTime(), maximumDate(), minimumDate()
3676 */
3677 void QtxPagePrefDateTimeItem::setMinimumTime( const QTime& t )
3678 {
3679   if ( t.isValid() )
3680     myDateTime->setMinimumTime( t );
3681   else
3682     myDateTime->clearMinimumTime();
3683 }
3684
3685 /*!
3686   \brief Store preference item to the resource manager.
3687   \sa retrieve()
3688 */
3689 void QtxPagePrefDateTimeItem::store()
3690 {
3691   QString str;
3692   switch ( inputType() )
3693   {
3694   case Date:
3695     str = myDateTime->date().toString( Qt::ISODate );
3696     break;
3697   case Time:
3698     str = myDateTime->time().toString( Qt::ISODate );
3699     break;
3700   case DateTime:
3701     str = myDateTime->dateTime().toString( Qt::ISODate );
3702     break;
3703   }
3704
3705   setString( str );
3706 }
3707
3708 /*!
3709   \brief Retrieve preference item from the resource manager.
3710   \sa store()
3711 */
3712 void QtxPagePrefDateTimeItem::retrieve()
3713 {
3714   QString str = getString();
3715   switch ( inputType() )
3716   {
3717   case Date:
3718     myDateTime->setDate( QDate::fromString( str, Qt::ISODate ) );
3719     break;
3720   case Time:
3721     myDateTime->setTime( QTime::fromString( str, Qt::ISODate ) );
3722     break;
3723   case DateTime:
3724     myDateTime->setDateTime( QDateTime::fromString( str, Qt::ISODate ) );
3725     break;
3726   }
3727 }
3728
3729 /*!
3730   \brief Get preference item option value.
3731   \param name option name
3732   \return property value or null QVariant if option is not set
3733   \sa setOptionValue()
3734 */
3735 QVariant QtxPagePrefDateTimeItem::optionValue( const QString& name ) const
3736 {
3737   if ( name == "input_type" || name == "type" )
3738     return inputType();
3739   else if ( name == "minimum_date" || name == "min_date" )
3740     return minimumDate();
3741   else if ( name == "maximum_date" || name == "max_date" )
3742     return maximumDate();
3743   else if ( name == "minimum_time" || name == "min_time" )
3744     return minimumTime();
3745   else if ( name == "maximum_time" || name == "max_time" )
3746     return maximumTime();
3747   else
3748     return QtxPageNamedPrefItem::optionValue( name );
3749 }
3750
3751 /*!
3752   \brief Set preference item option value.
3753   \param name option name
3754   \param val new property value
3755   \sa optionValue()
3756 */
3757 void QtxPagePrefDateTimeItem::setOptionValue( const QString& name, const QVariant& val )
3758 {
3759   if ( name == "input_type" || name == "type" )
3760   {
3761     if ( val.canConvert( QVariant::Int ) )
3762       setInputType( val.toInt() );
3763   }
3764   else if ( name == "minimum_date" || name == "min_date" )
3765   {
3766     if ( val.canConvert( QVariant::Date ) )
3767       setMinimumDate( val.toDate() );
3768   }
3769   else if ( name == "maximum_date" || name == "max_date" )
3770   {
3771     if ( val.canConvert( QVariant::Date ) )
3772       setMaximumDate( val.toDate() );
3773   }
3774   else if ( name == "minimum_time" || name == "min_time" )
3775   {
3776     if ( val.canConvert( QVariant::Time ) )
3777       setMinimumTime( val.toTime() );
3778   }
3779   else if ( name == "maximum_time" || name == "max_time" )
3780   {
3781     if ( val.canConvert( QVariant::Time ) )
3782       setMaximumTime( val.toTime() );
3783   }
3784   else
3785     QtxPageNamedPrefItem::setOptionValue( name, val );
3786 }
3787
3788 /*!
3789   \brief Update date/time widget.
3790 */
3791 void QtxPagePrefDateTimeItem::updateDateTime()
3792 {
3793   QString dispFmt;
3794   switch ( inputType() )
3795   {
3796   case Date:
3797     dispFmt = QDateEdit().displayFormat();
3798     break;
3799   case Time:
3800     dispFmt = QTimeEdit().displayFormat();
3801     break;
3802   case DateTime:
3803     dispFmt = QDateTimeEdit().displayFormat();
3804     break;
3805   }
3806
3807   myDateTime->setDisplayFormat( dispFmt );
3808 }