// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
{
if ( myCleared == isClear )
return;
-
+
myCleared = isClear;
}
\class QtxComboBox
\brief Enhanced version of Qt combo box class.
- In addition to the QComboBox class, QtxComboBox supports
+ In addition to the QComboBox class, QtxComboBox supports
adding/removing the items with the associated unique identifiers.
It also provides a way to set "cleared" state to the combo box -
when no item is selected.
{
if ( myCleared == isClear )
return;
-
+
myCleared = isClear;
if ( lineEdit() )
{
if ( !myCleared )
return;
-
+
myCleared = false;
update();
}
\brief Emitted when the item with identificator \a id is activated.
\param id item ID
*/
+
+bool QtxComboBox::event( QEvent* e )
+{
+ if ( e->type() == QEvent::StyleChange ) {
+ setEditable( !isEditable() );
+ setEditable( !isEditable() );
+ }
+
+ return QComboBox::event( e );
+}
#include "QtxColorButton.h"
#include "QtxDoubleSpinBox.h"
-#include <QEvent>
-#include <QLayout>
-#include <QToolBox>
-#include <QLineEdit>
-#include <QTextEdit>
-#include <QCheckBox>
-#include <QSplitter>
-#include <QTabWidget>
-#include <QListWidget>
-#include <QApplication>
-#include <QDateTimeEdit>
-#include <QStackedWidget>
+#include <QtCore/QEvent>
+
+#include <QtGui/QLayout>
+#include <QtGui/QToolBox>
+#include <QtGui/QLineEdit>
+#include <QtGui/QTextEdit>
+#include <QtGui/QCheckBox>
+#include <QtGui/QSplitter>
+#include <QtGui/QTabWidget>
+#include <QtGui/QListWidget>
+#include <QtGui/QApplication>
+#include <QtGui/QDateTimeEdit>
+#include <QtGui/QStyleFactory>
+#include <QtGui/QStackedWidget>
/*!
\class QtxPagePrefMgr
QStringList QtxPagePrefSelectItem::strings() const
{
QStringList res;
- for ( uint i = 0; i < mySelector->count(); i++ )
+ for ( int i = 0; i < mySelector->count(); i++ )
res.append( mySelector->itemText( i ) );
return res;
}
QList<int> QtxPagePrefSelectItem::numbers() const
{
QList<int> res;
- for ( uint i = 0; i < mySelector->count(); i++ )
+ for ( int i = 0; i < mySelector->count(); i++ )
{
if ( mySelector->hasId( i ) )
res.append( mySelector->id( i ) );
QList<QIcon> QtxPagePrefSelectItem::icons() const
{
QList<QIcon> res;
- for ( uint i = 0; i < mySelector->count(); i++ )
+ for ( int i = 0; i < mySelector->count(); i++ )
res.append( mySelector->itemIcon( i ) );
return res;
}
*/
void QtxPagePrefSelectItem::setNumbers( const QList<int>& ids )
{
- uint i = 0;
+ int i = 0;
for ( QList<int>::const_iterator it = ids.begin(); it != ids.end() && i < mySelector->count(); ++it, i++ )
mySelector->setId( i, *it );
}
*/
void QtxPagePrefSelectItem::setIcons( const QList<QIcon>& icons )
{
- uint i = 0;
+ int i = 0;
for ( QList<QIcon>::const_iterator it = icons.begin(); it != icons.end() && i < mySelector->count(); ++it, i++ )
mySelector->setItemIcon( i, *it );
}
idx = mySelector->index( num );
else
{
- for ( uint i = 0; i < mySelector->count() && idx == -1; i++ )
+ for ( int i = 0; i < mySelector->count() && idx == -1; i++ )
{
if ( mySelector->itemText( i ) == txt )
idx = i;
myDateTime->setDisplayFormat( dispFmt );
}
+
+/*!
+ \class QtxPagePrefStyleItem
+ \brief GUI implementation of the GUI style selector item
+
+ All items in the list (represented as combo box) defined by Qt style system
+*/
+
+/*!
+ \brief Constructor.
+
+ Creates preference item with combo box widget which is not editable.
+
+ \param title preference item title
+ \param parent parent preference item
+ \param sect resource file section associated with the preference item
+ \param param resource file parameter associated with the preference item
+*/
+QtxPagePrefStyleItem::QtxPagePrefStyleItem( const QString& title, QtxPreferenceItem* parent,
+ const QString& sect, const QString& param )
+: QtxPageNamedPrefItem( title, parent, sect, param )
+{
+ setControl( myStyle = new QtxComboBox() );
+
+ myStyle->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+ myStyle->addItems( QStyleFactory::keys() );
+}
+
+/*!
+ \brief Destructor.
+*/
+QtxPagePrefStyleItem::~QtxPagePrefStyleItem()
+{
+}
+
+/*!
+ \brief Store preference item to the resource manager.
+ \sa retrieve()
+*/
+void QtxPagePrefStyleItem::store()
+{
+ /*
+ if ( myStyle->isCleared() )
+ return;
+ */
+ setString( myStyle->itemText( myStyle->currentIndex() ) );
+}
+
+/*!
+ \brief Retrieve preference item from the resource manager.
+ \sa store()
+*/
+void QtxPagePrefStyleItem::retrieve()
+{
+ QString txt = getString();
+
+ int idx = -1;
+ for ( int i = 0; i < myStyle->count() && idx == -1; i++ ) {
+ if ( myStyle->itemText( i ) == txt )
+ idx = i;
+ }
+
+ if ( idx != -1 )
+ myStyle->setCurrentIndex( idx );
+ /* else
+ myStyle->setCleared( true );
+ */
+}