// 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
\param parent parent object
*/
QtxMRUAction::QtxMRUAction( QObject* parent )
-: QtxAction( "Most Recently Used", "Most Recently Used", 0, parent ),
+: QtxAction( tr( "Most Recently Used" ), tr( "Most Recently Used" ), 0, parent ),
myVisCount( 5 ),
+ myHistoryCount( -1 ),
+ myLinkType( LinkAuto ),
myInsertMode( MoveFirst )
{
+ myClear = new QAction( tr( "Clear" ), this );
+ myClear->setVisible( false );
+
setMenu( new QMenu( 0 ) );
+
connect( menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) );
+ connect( myClear, SIGNAL( triggered( bool ) ), this, SLOT( onCleared( bool ) ) );
}
/*!
QtxMRUAction::QtxMRUAction( const QString& text, const QString& menuText, QObject* parent )
: QtxAction( text, menuText, 0, parent ),
myVisCount( 5 ),
+ myHistoryCount( -1 ),
+ myLinkType( LinkAuto ),
myInsertMode( MoveFirst )
{
+ myClear = new QAction( tr( "Clear" ), this );
+ myClear->setVisible( false );
+
setMenu( new QMenu( 0 ) );
connect( menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) );
+ connect( myClear, SIGNAL( triggered( bool ) ), this, SLOT( onCleared( bool ) ) );
}
/*!
QtxMRUAction::QtxMRUAction( const QString& text, const QIcon& icon,
const QString& menuText, QObject* parent )
: QtxAction( text, icon, menuText, 0, parent ),
-myVisCount( 5 ),
-myInsertMode( MoveFirst )
+ myVisCount( 5 ),
+ myHistoryCount( -1 ),
+ myLinkType( LinkAuto ),
+ myInsertMode( MoveFirst )
{
+ myClear = new QAction( tr( "Clear" ), this );
+ myClear->setVisible( false );
+
setMenu( new QMenu( 0 ) );
connect( menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) );
+ connect( myClear, SIGNAL( triggered( bool ) ), this, SLOT( onCleared( bool ) ) );
}
/*!
myInsertMode = mode;
}
+/*!
+ \brief Get the type of link menu name.
+ \return link type (QtxMRUAction::LinkType)
+*/
+int QtxMRUAction::linkType() const
+{
+ return myLinkType;
+}
+
+/*!
+ \brief Set the type of link menu name.
+ \param link type (QtxMRUAction::LinkType)
+*/
+void QtxMRUAction::setLinkType( const int type )
+{
+ myLinkType = type;
+}
+
/*!
\brief Get number of MRU items.
\return number of MRU items
/*!
\brief Set number of visible MRU items.
-
+
This method sets the maximum number of MRU items
to be displayed in the popup menu (5 by default).
myVisCount = num;
}
+/*!
+ \brief Return visible status of the menu item which clear all MRU items.
+*/
+bool QtxMRUAction::isClearPossible() const
+{
+ return myClear->isVisible();
+}
+
+/*!
+ \brief Set visible the menu item which clear all MRU items.
+*/
+void QtxMRUAction::setClearPossible( const bool on )
+{
+ myClear->setVisible( on );
+}
+
+/*!
+ \brief Get number of totally stored MRU items.
+ \return number of MRU items stored in the preferences
+ \sa setHistoryCount(), saveLinks(), loadLinks()
+*/
+int QtxMRUAction::historyCount() const
+{
+ return myHistoryCount;
+}
+
+/*!
+ \brief Set number of totally stored MRU items.
+
+ This option allows setting number of MRU items to be stored
+ in the preferences file.
+
+ If \a num < 0, then number of stored MRU items is not limited.
+
+ \return number of MRU items stored in the preferences
+ \sa historyCount(), saveLinks(), loadLinks()
+*/
+void QtxMRUAction::setHistoryCount( const int num )
+{
+ myHistoryCount = num;
+}
+
/*!
\brief Insert MRU item.
myLinks.removeAll( link );
}
+/*!
+ \brief Remove all MRU items.
+*/
+void QtxMRUAction::clear()
+{
+ myLinks.clear();
+}
+
/*!
\brief Get MRU item
\param idx MRU item index
if ( !(*it).startsWith( itemPrefix ) )
continue;
- QString link = resMgr->stringValue( section, *it, QString::null );
+ QString link = resMgr->stringValue( section, *it, QString() );
if ( link.isEmpty() || map.contains( link ) )
continue;
if ( !resMgr || section.isEmpty() )
return;
- if ( clear )
- resMgr->remove( section );
+ QString itemPrefix( "item_" );
+
+ if ( clear ) {
+ QStringList items = resMgr->parameters( section );
+ for ( QStringList::const_iterator it = items.begin(); it != items.end(); ++it )
+ {
+ if ( (*it).startsWith( itemPrefix ) )
+ resMgr->remove( section, *it );
+ }
+ }
QStringList lst;
QMap<QString, int> map;
map.insert( *itr, 0 );
}
- QString itemPrefix( "item_" );
QStringList items = resMgr->parameters( section );
for ( QStringList::const_iterator it = items.begin(); it != items.end(); ++it )
{
if ( !(*it).startsWith( itemPrefix ) )
continue;
- QString link = resMgr->stringValue( section, *it, QString::null );
+ QString link = resMgr->stringValue( section, *it, QString() );
if ( !link.isEmpty() && !map.contains( link ) )
{
lst.append( link );
}
int counter = 0;
- for ( QStringList::const_iterator iter = lst.begin(); iter != lst.end(); ++iter, counter++ )
+ for ( QStringList::const_iterator iter = lst.begin();
+ iter != lst.end() && ( myHistoryCount < 0 || counter < myHistoryCount );
+ ++iter, counter++ )
resMgr->setValue( section, itemPrefix + QString().sprintf( "%03d", counter ), *iter );
}
/*!
\brief Prepare MRU items popup menu.
-
+
This method is called when the parent menu is shown.
Enables or disables sub menu item according to the number of MRU items.
*/
if ( !a )
return;
- QString link = a->text();
+ QString link = a->data().toString();
if ( !link.isEmpty() && myLinks.contains( link ) )
emit activated( link );
}
+void QtxMRUAction::onCleared( bool )
+{
+ clear();
+}
+
/*!
\brief Update MRU items popup menu.
*/
pm->clear();
+ QStringList links;
+ QMap<QString, int> map;
int count = visibleCount() < 0 ? myLinks.count() : visibleCount();
- for ( QStringList::const_iterator it = myLinks.begin(); it != myLinks.end() && count > 0; ++it, count-- )
- pm->addAction( *it, this, SLOT( onActivated() ) );
+ int i = insertMode() == AddLast || insertMode() == MoveLast ? qMax( 0, myLinks.count()-count ) : 0;
+ for ( ; i < myLinks.count() && count > 0; ++i, count-- )
+ {
+ links.append( myLinks[i] );
+ if ( linkType() == LinkAuto )
+ {
+ QString shortName = Qtx::file( myLinks[i] );
+ if ( map.contains( shortName ) )
+ map[shortName]++;
+ else
+ map.insert( shortName, 0 );
+ }
+ }
+
+ i = 1;
+ for ( QStringList::const_iterator it = links.begin(); it != links.end(); ++it, i++ )
+ {
+ QString linkName;
+ switch( linkType() )
+ {
+ case LinkAuto:
+ linkName = Qtx::file( *it );
+ if ( map.contains( linkName ) && map[linkName] )
+ linkName = *it;
+ break;
+ case LinkShort:
+ linkName = Qtx::file( *it );
+ break;
+ case LinkFull:
+ default:
+ linkName = *it;
+ break;
+ }
+
+ if ( links.count() < 10 )
+ linkName = QString( "&%1 %2" ).arg( i ).arg( linkName );
+
+ pm->addAction( linkName, this, SLOT( onActivated() ) )->setData( *it );
+ }
+
+ if ( pm->isEmpty() )
+ pm->addAction( tr( "<Empty>" ) )->setEnabled( false );
+
+ if ( isClearPossible() )
+ {
+ pm->addSeparator();
+ pm->addAction( myClear );
+ myClear->setEnabled( !pm->isEmpty() );
+ }
}
/*!
// 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
#include <QSplitter>
#include <QTabWidget>
#include <QListWidget>
+#include <QApplication>
#include <QDateTimeEdit>
#include <QStackedWidget>
{
myBox = new QtxGridBox( 1, Qt::Horizontal, this, 0 );
QVBoxLayout* base = new QVBoxLayout( this );
- base->setMargin( 0 );
+ base->setMargin( 5 );
base->setSpacing( 0 );
base->addWidget( myBox );
}
*/
QSize QtxPagePrefMgr::sizeHint() const
{
- initialize();
-
return QFrame::sizeHint();
}
*/
QSize QtxPagePrefMgr::minimumSizeHint() const
{
- initialize();
-
return QFrame::minimumSizeHint();
}
/*!
\brief Customize show/hide widget operation.
- \param on if \c true the widget is being shown, otherswise
+ \param on if \c true the widget is being shown, otherswise
it is being hidden
*/
void QtxPagePrefMgr::setVisible( bool on )
{
- if ( on && !myInit )
- updateContents();
+ if ( on )
+ initialize();
+
+ QApplication::instance()->processEvents();
QFrame::setVisible( on );
}
QList<QtxPreferenceItem*> lst = childItems();
for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
{
- if ( (*it)->rtti() == QtxPagePrefItem::RTTI() )
- {
- QtxPagePrefItem* item = (QtxPagePrefItem*)(*it);
- if ( item->widget() && item->widget()->parent() != myBox )
- item->widget()->setParent( myBox );
- }
+ QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
+ if ( item && item->widget() && item->widget()->parent() != myBox )
+ item->widget()->setParent( myBox );
}
setWindowIcon( icon() );
*/
void QtxPagePrefMgr::initialize() const
{
- if ( myInit )
- return;
+ // if ( myInit )
+ // return;
QtxPagePrefMgr* that = (QtxPagePrefMgr*)this;
-
- that->updateContents();
+ that->initialize( that );
+
+ // that->myInit = true;
+}
+
+void QtxPagePrefMgr::initialize( QtxPreferenceItem* item )
+{
+ if ( !item )
+ return;
- QList<QtxPreferenceItem*> lst = childItems( true );
+ QList<QtxPreferenceItem*> lst = item->childItems( false );
for ( QList<QtxPreferenceItem*>::iterator it = lst.begin(); it != lst.end(); ++it )
- (*it)->updateContents();
+ initialize( *it );
- that->myInit = true;
+ updateContents();
}
/*!
preference items.
*/
+class QtxPagePrefItem::Listener : public QObject
+{
+public:
+ Listener( QtxPagePrefItem* );
+ virtual ~Listener();
+
+ virtual bool eventFilter( QObject*, QEvent* );
+
+private:
+ QtxPagePrefItem* myItem;
+};
+
+QtxPagePrefItem::Listener::Listener( QtxPagePrefItem* item )
+: QObject( 0 ),
+ myItem( item )
+{
+}
+
+QtxPagePrefItem::Listener::~Listener()
+{
+}
+
+bool QtxPagePrefItem::Listener::eventFilter( QObject* o, QEvent* e )
+{
+ if ( !myItem || myItem->widget() != o )
+ return false;
+
+ if ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent )
+ myItem->widgetShown();
+ if ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent )
+ myItem->widgetHided();
+
+ return false;
+}
+
/*!
\brief Constructor.
\param title preference item title
QtxPagePrefItem::QtxPagePrefItem( const QString& title, QtxPreferenceItem* parent,
const QString& sect, const QString& param )
: QtxPreferenceItem( title, sect, param, parent ),
- myWidget( 0 )
+ myWidget( 0 ),
+ myListener( 0 )
{
}
QtxPagePrefItem::~QtxPagePrefItem()
{
delete myWidget;
-}
-
-/*!
- \brief Get unique item type identifier.
- \return item type ID
-*/
-int QtxPagePrefItem::rtti() const
-{
- return QtxPagePrefItem::RTTI();
+ delete myListener;
}
/*!
return myWidget;
}
-/*!
- \brief Specify unique item class identifier.
- \return item class ID
-*/
-int QtxPagePrefItem::RTTI()
-{
- return 1000;
-}
-
/*!
\brief Set preference item editor widget.
\param wid editor widget
*/
void QtxPagePrefItem::setWidget( QWidget* wid )
{
+ if ( myWidget && myListener )
+ myWidget->removeEventFilter( myListener );
+
myWidget = wid;
+
+ if ( myWidget )
+ {
+ if ( !myListener )
+ myListener = new Listener( this );
+ myWidget->installEventFilter( myListener );
+ }
+
sendItemChanges();
}
/*!
\brief Store preference item to the resource manager.
-
+
This method should be reimplemented in the subclasses.
Base implementation does nothing.
/*!
\brief Retrieve preference item from the resource manager.
-
+
This method should be reimplemented in the subclasses.
Base implementation does nothing.
{
}
+/*!
+ \brief Invoked when preference item widget is shown.
+*/
+void QtxPagePrefItem::widgetShown()
+{
+}
+
+/*!
+ \brief Invoked when preference item widget is hided.
+*/
+void QtxPagePrefItem::widgetHided()
+{
+}
+
+void QtxPagePrefItem::ensureVisible( QtxPreferenceItem* i )
+{
+ QtxPreferenceItem::ensureVisible();
+
+ QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
+ if ( item && item->widget() )
+ item->widget()->setVisible( true );
+}
+
/*!
\brief Find all child items of the QtxPagePrefItem type.
\param list used to return list of child items
QList<QtxPreferenceItem*> lst = childItems( rec );
for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
{
- if ( (*it)->rtti() == QtxPagePrefItem::RTTI() )
- list.append( (QtxPagePrefItem*)*it );
+ QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
+ if ( item )
+ list.append( item );
}
}
/*!
\brief Called when contents is changed (item is added, removed or modified).
-
+
Triggers the item update.
*/
void QtxPagePrefItem::contentChanged()
myControl( 0 )
{
QWidget* main = new QWidget();
- QHBoxLayout* base = new QHBoxLayout( main );
- base->setMargin( 0 );
- base->setSpacing( 5 );
- myLabel = new QLabel( title, main );
- base->addWidget( myLabel );
+ // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parent);
+ // if ( !aGroup )
+ // {
+ QHBoxLayout* base = new QHBoxLayout( main );
+ base->setMargin( 0 );
+ base->setSpacing( 5 );
+
+ myLabel = new QLabel( title, main );
+ base->addWidget( myLabel );
+ // }
+ // else
+ // myLabel = new QLabel( title, aGroup->gridBox() );
setWidget( main );
myControl = wid;
if ( myControl )
- widget()->layout()->addWidget( myControl );
+ {
+ // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parentItem());
+ // if ( !aGroup )
+ widget()->layout()->addWidget( myControl );
+ // else myControl->setParent( aGroup->gridBox() );
+ }
+}
+
+void QtxPageNamedPrefItem::adjustLabels( QtxPagePrefItem* parent )
+{
+ if ( !parent )
+ return;
+
+ QList<QtxPreferenceItem*> childList = parent->childItems();
+
+ QList<QtxPageNamedPrefItem*> namedItems;
+ for ( QList<QtxPreferenceItem*>::iterator it = childList.begin(); it != childList.end(); ++it )
+ {
+ QtxPageNamedPrefItem* item = dynamic_cast<QtxPageNamedPrefItem*>( *it );
+ if ( item )
+ namedItems.append( item );
+ }
+
+ int sz = 0;
+ for ( QList<QtxPageNamedPrefItem*>::iterator it1 = namedItems.begin(); it1 != namedItems.end(); ++it1 )
+ {
+ QtxPageNamedPrefItem* item = *it1;
+ if ( item->label() )
+ sz = qMax( sz, item->label()->sizeHint().width() );
+ }
+
+ for ( QList<QtxPageNamedPrefItem*>::iterator it2 = namedItems.begin(); it2 != namedItems.end(); ++it2 )
+ {
+ QtxPageNamedPrefItem* item = *it2;
+ if ( item->label() )
+ item->label()->setMinimumWidth( sz );
+ }
}
/*!
*/
void QtxPagePrefListItem::updateContents()
{
+ QtxPagePrefItem::updateContents();
updateVisible();
}
QtxPagePrefItem::setOptionValue( name, val );
}
+void QtxPagePrefListItem::widgetShown()
+{
+ updateState();
+}
+
+void QtxPagePrefListItem::ensureVisible( QtxPreferenceItem* i )
+{
+ if ( !i )
+ return;
+
+ QtxPreferenceItem::ensureVisible( i );
+
+ setSelected( i->id() );
+ updateState();
+}
+
/*!
\brief Called when the selection in the list box is changed.
*/
/*!
\class QtxPagePrefToolBoxItem
+ \brief GUI implementation of the tool box container preference item.
*/
+/*!
+ \brief Constructor.
+ \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
+*/
QtxPagePrefToolBoxItem::QtxPagePrefToolBoxItem( const QString& title, QtxPreferenceItem* parent,
const QString& sect, const QString& param )
: QtxPagePrefItem( title, parent, sect, param )
setWidget( myToolBox = new QToolBox( 0 ) );
}
+/*!
+ \brief Destructor.
+*/
QtxPagePrefToolBoxItem::~QtxPagePrefToolBoxItem()
{
}
+/*!
+ \brief Update widget contents.
+*/
void QtxPagePrefToolBoxItem::updateContents()
{
+ QtxPagePrefItem::updateContents();
updateToolBox();
}
+/*!
+ \brief Update tool box widget.
+*/
void QtxPagePrefToolBoxItem::updateToolBox()
{
QList<QtxPagePrefItem*> items;
myToolBox->setCurrentWidget( cur );
}
+void QtxPagePrefToolBoxItem::ensureVisible( QtxPreferenceItem* i )
+{
+ if ( !i )
+ return;
+
+ QtxPreferenceItem::ensureVisible( i );
+
+ QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
+ if ( item && item->widget() )
+ myToolBox->setCurrentWidget( item->widget() );
+}
+
/*!
\class QtxPagePrefTabsItem
\brief GUI implementation of the tab widget container.
*/
void QtxPagePrefTabsItem::updateContents()
{
+ QtxPagePrefItem::updateContents();
updateTabs();
}
QtxPagePrefItem::setOptionValue( name, val );
}
+void QtxPagePrefTabsItem::ensureVisible( QtxPreferenceItem* i )
+{
+ if ( !i )
+ return;
+
+ QtxPreferenceItem::ensureVisible( i );
+
+ QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
+ if ( item && item->widget() )
+ myTabs->setCurrentWidget( item->widget() );
+}
+
/*!
\brief Update tabs.
*/
*/
void QtxPagePrefFrameItem::updateContents()
{
+ QtxPagePrefItem::updateContents();
+
updateFrame();
+
+ QtxPageNamedPrefItem::adjustLabels( this );
}
/*!
myBox->setOrientation( o );
}
+/*!
+ \brief Check if the frame widget stretching is enabled.
+ \return \c true if the widget is stretchable
+ \sa setStretch()
+*/
bool QtxPagePrefFrameItem::stretch() const
{
QSpacerItem* s = 0;
for ( int i = 0; l && i < l->count() && !s; i++ )
s = l->itemAt( i )->spacerItem();
- return s ? ( s->expandingDirections() & Qt::Vertical ) != 0 : false;
+ return s ? (bool)( s->expandingDirections() & Qt::Vertical ) : false;
}
+/*!
+ \brief Enable/disable frame widget stretching.
+ \param on new stretchable state
+ \sa stretch()
+*/
void QtxPagePrefFrameItem::setStretch( const bool on )
{
QSpacerItem* s = 0;
QtxPagePrefItem::setOptionValue( name, val );
}
+void QtxPagePrefFrameItem::widgetShown()
+{
+ QtxPagePrefItem::widgetShown();
+
+ QtxPageNamedPrefItem::adjustLabels( this );
+}
+
/*!
\brief Update frame widget.
*/
myGroup->setWidget( myBox );
setWidget( myGroup );
+
+ updateState();
}
/*!
myGroup->setWidget( myBox );
setWidget( myGroup );
+
+ updateState();
}
/*!
*/
void QtxPagePrefGroupItem::updateContents()
{
+ QtxPagePrefItem::updateContents();
+
myGroup->setTitle( title() );
updateState();
updateGroup();
+
+ QtxPageNamedPrefItem::adjustLabels( this );
}
/*!
setBoolean( myGroup->isChecked() );
}
+/*!
+ \brief Return widget contained grid layout of this group.
+*/
+QtxGridBox* QtxPagePrefGroupItem::gridBox() const
+{
+ return myBox;
+}
+
/*!
\brief Retrieve preference item from the resource manager.
\sa store()
QtxPagePrefItem::setOptionValue( name, val );
}
+void QtxPagePrefGroupItem::widgetShown()
+{
+ QtxPagePrefItem::widgetShown();
+
+ QtxPageNamedPrefItem::adjustLabels( this );
+}
+
/*!
\brief Update widget state.
*/
/*!
\brief Constructor.
- Creates spacer item with zero width and height and expanding
+ Creates spacer item with zero width and height and expanding
on both directions (by height and width).
\param parent parent preference item
/*!
\brief Constructor.
- Creates spacer item with zero width and height and expanding
+ Creates spacer item with zero width and height and expanding
according to the specified orientation.
\param o spacer orientation
sp.setVerticalStretch( sf );
sp.setVerticalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
}
-
+
widget()->setSizePolicy( sp );
}
QSizePolicy sp;
sp.setHorizontalPolicy( hs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
sp.setVerticalPolicy( vs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
-
+
sp.setHorizontalStretch( hs );
sp.setVerticalStretch( vs );
wid->setSizePolicy( sp );
wid->setMinimumSize( w, h );
-
+
setWidget( wid );
}
myCheck->setText( title() );
}
-
+
/*!
\brief Store preference item to the resource manager.
\sa retrieve()
\param param resource file parameter associated with the preference item
*/
QtxPagePrefEditItem::QtxPagePrefEditItem( const int type, const QString& title,
- QtxPreferenceItem* parent, const QString& sect,
+ QtxPreferenceItem* parent, const QString& sect,
const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param ),
myType( type )
/*!
\class QtxPagePrefSelectItem
- \brief GUI implementation of the resources selector item
+ \brief GUI implementation of the resources selector item
(string, integer or double values list).
All items in the list (represented as combo box) should be specified
/*!
\brief Constructor.
-
+
Creates preference item with combo box widget which is not editable
(direct value entering is disabled).
/*!
\brief Constructor.
-
+
Creates preference item with combo box widget which is editable
according to the specified input type (integer, double or string values).
QStringList QtxPagePrefSelectItem::strings() const
{
QStringList res;
- for ( int i = 0; i < mySelector->count(); i++ )
+ for ( uint i = 0; i < mySelector->count(); i++ )
res.append( mySelector->itemText( i ) );
return res;
}
QList<int> QtxPagePrefSelectItem::numbers() const
{
QList<int> res;
- for ( int i = 0; i < mySelector->count(); i++ )
+ for ( uint i = 0; i < mySelector->count(); i++ )
{
if ( mySelector->hasId( i ) )
res.append( mySelector->id( i ) );
*/
void QtxPagePrefSelectItem::setNumbers( const QList<int>& ids )
{
- int i = 0;
+ uint i = 0;
for ( QList<int>::const_iterator it = ids.begin(); it != ids.end() && i < mySelector->count(); ++it, i++ )
mySelector->setId( i, *it );
}
idx = mySelector->index( num );
else
{
- for ( int i = 0; i < mySelector->count() && idx == -1; i++ )
+ for ( uint i = 0; i < mySelector->count() && idx == -1; i++ )
{
if ( mySelector->itemText( i ) == txt )
idx = i;
\param param resource file parameter associated with the preference item
*/
QtxPagePrefSpinItem::QtxPagePrefSpinItem( const int type, const QString& title,
- QtxPreferenceItem* parent, const QString& sect,
+ QtxPreferenceItem* parent, const QString& sect,
const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param ),
myType( type )
}
/*!
- \brief Get spin box preference item special value text (which is shown
+ \brief Get spin box preference item special value text (which is shown
when the spin box reaches minimum value).
\return spin box special value text
\sa setSpecialValueText()
}
/*!
- \brief Set spin box preference item special value text (which is shown
+ \brief Set spin box preference item special value text (which is shown
when the spin box reaches minimum value).
\param txt new spin box special value text
\sa specialValueText()
\param sect resource file section associated with the preference item
\param param resource file parameter associated with the preference item
*/
-QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect,
+QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect,
const QString& param )
: QtxPageNamedPrefItem( QString(), parent, sect, param )
{
const QString& sect, const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param )
{
- setControl( myColor = new QtxColorButton() );
+ // QtxPagePrefGroupItem* aGroup 0; //= dynamic_cast<QtxPagePrefGroupItem*>( parent );
+
+ // setControl( myColor = new QtxColorButton( aGroup ? aGroup->gridBox() : 0 ) );
+ setControl( myColor = new QtxColorButton( 0 ) );
myColor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
}
\param param resource file parameter associated with the preference item
*/
QtxPagePrefFontItem::QtxPagePrefFontItem( const int feat, const QString& title,
- QtxPreferenceItem* parent, const QString& sect,
+ QtxPreferenceItem* parent, const QString& sect,
const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param )
{
}
/*!
- \class QtxPagePrefPathListItem
- \brief GUI implementation of resources directory list item.
+ \class QtxPagePrefPathListItem
+ \brief GUI implementation of the resources files/directories list item.
*/
/*!
\brief GUI implementation of resources date/time item.
*/
+/*!
+ \brief Constructor.
+
+ Creates an item to enter date and time.
+
+ \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
+*/
QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const QString& title, QtxPreferenceItem* parent,
const QString& sect, const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param ),
-myType( DateTime )
+ myType( DateTime )
{
setControl( myDateTime = new QDateTimeEdit() );
myDateTime->setCalendarPopup( true );
updateDateTime();
}
+/*!
+ \brief Constructor.
+
+ Creates preference item for editing of the date and/or time value:
+ the type is specified by parameter \a type.
+
+ \param type preference item input type (QtxPagePrefDateTimeItem::InputType)
+ \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
+*/
QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const int type, const QString& title, QtxPreferenceItem* parent,
const QString& sect, const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param ),
-myType( type )
+ myType( type )
{
setControl( myDateTime = new QDateTimeEdit() );
myDateTime->setCalendarPopup( true );
updateDateTime();
}
+/*!
+ \brief Destructor.
+*/
QtxPagePrefDateTimeItem::~QtxPagePrefDateTimeItem()
{
}
+/*!
+ \brief Get date/time box preference item input type.
+ \return preference item input type (QtxPagePrefDateTimeItem::InputType)
+ \sa setInputType()
+*/
int QtxPagePrefDateTimeItem::inputType() const
{
return myType;
}
+/*!
+ \brief Set date/time box preference item input type.
+ \param type new preference item input type (QtxPagePrefDateTimeItem::InputType)
+ \sa inputType()
+*/
void QtxPagePrefDateTimeItem::setInputType( const int type )
{
if ( myType == type )
updateDateTime();
}
+/*!
+ \brief Check if the popup calendar menu is enabled.
+ \return \c true if calendar popup menu is enabled
+*/
bool QtxPagePrefDateTimeItem::calendar() const
{
return myDateTime->calendarPopup();
}
+/*!
+ \brief Enable/disable popup calendar menu.
+ \param on new flag state
+*/
void QtxPagePrefDateTimeItem::setCalendar( const bool on )
{
myDateTime->setCalendarPopup( on );
}
+/*!
+ \brief Get maximum date value.
+ \return maximum date value
+ \sa setMaximumDate(), minimumDate(), maximumTime(), minimumTime()
+*/
QDate QtxPagePrefDateTimeItem::maximumDate() const
{
return myDateTime->maximumDate();
}
+/*!
+ \brief Get maximum time value.
+ \return maximum time value
+ \sa setMaximumTime(), minimumTime(), maximumDate(), minimumDate()
+*/
QTime QtxPagePrefDateTimeItem::maximumTime() const
{
return myDateTime->maximumTime();
}
+/*!
+ \brief Get minimum date value.
+ \return minimum date value
+ \sa setMinimumDate(), maximumDate(), maximumTime(), minimumTime()
+*/
QDate QtxPagePrefDateTimeItem::minimumDate() const
{
return myDateTime->minimumDate();
}
+/*!
+ \brief Get minimum time value.
+ \return maximum time value
+ \sa setMinimumTime(), maximumTime(), maximumDate(), minimumDate()
+*/
QTime QtxPagePrefDateTimeItem::minimumTime() const
{
return myDateTime->minimumTime();
}
+/*!
+ \brief Set maximum date value.
+ \param d new maximum date value
+ \sa maximumDate(), minimumDate(), maximumTime(), minimumTime()
+*/
void QtxPagePrefDateTimeItem::setMaximumDate( const QDate& d )
{
if ( d.isValid() )
myDateTime->clearMaximumDate();
}
+/*!
+ \brief Set maximum time value.
+ \param t new maximum time value
+ \sa maximumTime(), minimumTime(), maximumDate(), minimumDate()
+*/
void QtxPagePrefDateTimeItem::setMaximumTime( const QTime& t )
{
if ( t.isValid() )
myDateTime->clearMaximumTime();
}
+/*!
+ \brief Set minimum date value.
+ \param d new minimum date value
+ \sa minimumDate(), maximumDate(), maximumTime(), minimumTime()
+*/
void QtxPagePrefDateTimeItem::setMinimumDate( const QDate& d )
{
if ( d.isValid() )
myDateTime->clearMinimumDate();
}
+/*!
+ \brief Set minimum time value.
+ \param t new minimum time value
+ \sa minimumTime(), maximumTime(), maximumDate(), minimumDate()
+*/
void QtxPagePrefDateTimeItem::setMinimumTime( const QTime& t )
{
if ( t.isValid() )
myDateTime->clearMinimumTime();
}
+/*!
+ \brief Store preference item to the resource manager.
+ \sa retrieve()
+*/
void QtxPagePrefDateTimeItem::store()
{
QString str;
setString( str );
}
+/*!
+ \brief Retrieve preference item from the resource manager.
+ \sa store()
+*/
void QtxPagePrefDateTimeItem::retrieve()
{
QString str = getString();
}
}
+/*!
+ \brief Get preference item option value.
+ \param name option name
+ \return property value or null QVariant if option is not set
+ \sa setOptionValue()
+*/
QVariant QtxPagePrefDateTimeItem::optionValue( const QString& name ) const
{
if ( name == "input_type" || name == "type" )
return QtxPageNamedPrefItem::optionValue( name );
}
+/*!
+ \brief Set preference item option value.
+ \param name option name
+ \param val new property value
+ \sa optionValue()
+*/
void QtxPagePrefDateTimeItem::setOptionValue( const QString& name, const QVariant& val )
{
if ( name == "input_type" || name == "type" )
QtxPageNamedPrefItem::setOptionValue( name, val );
}
+/*!
+ \brief Update date/time widget.
+*/
void QtxPagePrefDateTimeItem::updateDateTime()
{
QString dispFmt;
// 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
\class QtxPreferenceItem
\brief Base class for implementing of all the preference items.
- To implement any specific preference item, cubclass from the
+ To implement any specific preference item, cubclass from the
QtxPreferenceItem and redefine store() and retrieve() methods.
*/
return item;
}
+void QtxPreferenceItem::ensureVisible()
+{
+ if ( parentItem() )
+ parentItem()->ensureVisible( this );
+}
/*!
\brief Get integer resources value corresponding to the item.
/*!
\brief Callback function which is called when the child
preference item is added.
-
+
This function can be reimplemented in the subclasses to customize
child item addition operation. Base implementation does nothing.
/*!
\brief Callback function which is called when the child
preference item is removed.
-
+
This function can be reimplemented in the subclasses to customize
child item removal operation. Base implementation does nothing.
/*!
\brief Callback function which is called when the child
preference item is modified.
-
+
This function can be reimplemented in the subclasses to customize
child item modifying operation. Base implementation does nothing.
\param item child item being modified
\sa itemAdded(), itemRemoved()
*/
-void QtxPreferenceItem::itemChanged( QtxPreferenceItem* /*item*/ )
+void QtxPreferenceItem::itemChanged( QtxPreferenceItem* )
+{
+}
+
+void QtxPreferenceItem::ensureVisible( QtxPreferenceItem* )
{
+ ensureVisible();
}
/*!
This function can be reimplemented in the subclasses.
Base implementation does nothing.
-
+
\param name option name
\return property value or null QVariant if option is not set
\sa setOptionValue()
This function can be reimplemented in the subclasses.
Base implementation does nothing.
-
+
\param name option name
\param val new property value
\sa optionValue()
return (QtxPreferenceMgr*)this;
}
-/*
- \brief Add new preference item.
- \param label label of widget to edit preference item
- \param pId parent preference item id
- \param type preference item type
- \param section resource file section associated to the preference item
- \param param resource file parameter associated to the preference item
-*/
-/*
-int QtxPreferenceMgr::addItem( const QString& label, const int pId, const int type,
- const QString& section, const QString& param )
-{
- Item* i = createItem( label, type, pId );
- if ( !i )
- return -1;
-
- if ( !myItems.contains( i->id() ) )
- {
- myItems.insert( i->id(), i );
-
- i->setTitle( label );
- i->setResource( section, param );
-
- if ( !i->parentItem() && !myChildren.contains( i ) )
- myChildren.append( i );
-
- itemAdded( i );
- }
-
- return i->id();
-}
-*/
-
/*!
\brief Get preference item option value.
\param id preference item ID
/*!
\brief Update preferences manager.
-
+
Base implementation does nothing.
*/
void QtxPreferenceMgr::update()
{
}
-/*
- \brief Create preference item.
- \param label preference item title
- \param type preference item type
- \param pId parent preference item ID
- \return new item
-*/
-/*
-QtxPreferenceItem* QtxPreferenceMgr::createItem( const QString& label, const int type, const int pId )
-{
- Item* i = 0;
- if ( pId < 0 )
- i = createItem( label, type );
- else
- {
- Item* pItem = item( pId );
- if ( pItem )
- {
- i = pItem->createItem( label, type );
- pItem->insertChild( i );
- }
- }
-
- return i;
-}
-*/
-
/*!
\brief Get all resources items values.
\param map used as container filled with the resources values (<ID>:<value>)
This method is called from store() and fromBackup() methods.
Base implementation does nothing.
-
+
\sa store(), fromBackup()
*/
void QtxPreferenceMgr::changedResources( const ResourceMap& )