X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FQtx%2FQtxListBox.cxx;h=c9d56d2095e493bc4fd8a54e8e87731c1ba9964c;hb=389efae83b99d654509671e60af3eecf11b8278e;hp=6d2ce0cd97e05ceeca0c76bfd5e12c505da2ea19;hpb=232b55569765049c7d1cceb5096a45f8584c9369;p=modules%2Fgui.git diff --git a/src/Qtx/QtxListBox.cxx b/src/Qtx/QtxListBox.cxx index 6d2ce0cd9..c9d56d209 100755 --- a/src/Qtx/QtxListBox.cxx +++ b/src/Qtx/QtxListBox.cxx @@ -1,29 +1,36 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// // 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 -// 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// 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/ +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File: QtxListBox.cxx // Author: Sergey TELKOV - +// #include "QtxListBox.h" #include #include +/*! + Constructor +*/ QtxListBox::QtxListBox( QWidget* parent, const char* name, WFlags f ) : QListBox( parent, name, f ), myEditor( 0 ), @@ -36,15 +43,25 @@ myModifEnabled( true ) this, SLOT( onContentsMoving( int, int ) ) ); } +/*! + Destructor +*/ QtxListBox::~QtxListBox() { } +/*! + \return true if editing is enabled +*/ bool QtxListBox::isEditEnabled() const { return myEditState; } +/*! + Enables/disables editing + \param on - new state +*/ void QtxListBox::setEditEnabled( bool on ) { if ( isEditEnabled() == on ) @@ -56,36 +73,66 @@ void QtxListBox::setEditEnabled( bool on ) endEdition( defaultEditAction() ); } +/*! + \return default edit action + \sa setDefaultEditAction() +*/ bool QtxListBox::defaultEditAction() const { return myEditDefault; } +/*! + Changes default edit action. + Pressing of ENTER button always accepts new value of edited item. + But other ways, such as focus out or edition of other item accepts + new value of edited item only if "default edit action" is true + \param def - new value +*/ void QtxListBox::setDefaultEditAction( bool def ) { myEditDefault = def; } +/*! + \return modification enabled state + \sa setModificationEnabled() +*/ bool QtxListBox::isModificationEnabled() const { return myModifEnabled; } +/*! + Changes "modification enabled" state + If it is true, then pressing of CTRL + { Up, Down, Home, End } allows move items in list + \param on - new state +*/ void QtxListBox::setModificationEnabled( bool on ) { myModifEnabled = on; } +/*! + \return current edited item +*/ QListBoxItem* QtxListBox::editedItem() const { return item( editedIndex() ); } +/*! + \return current edited index +*/ int QtxListBox::editedIndex() const { return myEditIndex; } +/*! + Starts edition of item + \param idx - index of item +*/ void QtxListBox::startEdition( const int idx ) { if ( idx < 0 || editedIndex() == idx || !isEditEnabled() ) @@ -108,11 +155,19 @@ void QtxListBox::startEdition( const int idx ) ed->setFocus(); } +/*! + Starts edition of item + \param item - item to be edited +*/ void QtxListBox::startEdition( const QListBoxItem* item ) { startEdition( index( item ) ); } +/*! + Finishes edition of item + \param action - if it is true, then new values must be accepted +*/ void QtxListBox::endEdition( const bool action ) { int idx = editedIndex(); @@ -141,6 +196,10 @@ void QtxListBox::endEdition( const bool action ) } } +/*! + Ensures that the item is visible. + \param idx - index of item +*/ void QtxListBox::ensureItemVisible( const int idx ) { if ( idx < 0 ) @@ -152,11 +211,18 @@ void QtxListBox::ensureItemVisible( const int idx ) setTopItem( idx ); } +/*! + Ensures that the item is visible. + \param item - item to be made visible +*/ void QtxListBox::ensureItemVisible( const QListBoxItem* item ) { ensureItemVisible( index( item ) ); } +/*! + \return validator of item editor +*/ const QValidator* QtxListBox::validator() const { const QValidator* v = 0; @@ -165,28 +231,48 @@ const QValidator* QtxListBox::validator() const return v; } +/*! + Removes validator of item editor +*/ void QtxListBox::clearValidator() { if ( editor() ) editor()->clearValidator(); } +/*! + Changes validator of item editor + \param v - new validator +*/ void QtxListBox::setValidator( const QValidator* v ) { if ( editor() ) editor()->setValidator( v ); } +/*! + Moves item to top + \param idx - index of item +*/ void QtxListBox::moveItemToTop( const int idx ) { moveItem( idx, -idx ); } +/*! + Moves item to bottom + \param idx - index of item +*/ void QtxListBox::moveItemToBottom( const int idx ) { moveItem( idx, count() - idx ); } +/*! + Moves item + \param idx - index of item + \param step - changing of position +*/ void QtxListBox::moveItem( const int idx, const int step ) { QListBoxItem* i = item( idx ); @@ -210,6 +296,10 @@ void QtxListBox::moveItem( const int idx, const int step ) emit itemMoved( idx, pos ); } +/*! + Inserts empty item + \param i - position of item (if it is less than 0, then current position is used) +*/ void QtxListBox::createItem( const int i ) { if ( !isEditEnabled() ) @@ -224,6 +314,10 @@ void QtxListBox::createItem( const int i ) startEdition( idx ); } +/*! + Removes item + \param i - position of item (if it is less than 0, then current position is used) +*/ void QtxListBox::deleteItem( const int i ) { if ( !isEditEnabled() ) @@ -240,6 +334,10 @@ void QtxListBox::deleteItem( const int i ) updateEditor(); } +/*! + Scrolls the content so that the point is in the top-left corner. + \param x, y - point co-ordinates +*/ void QtxListBox::setContentsPos( int x, int y ) { QListBox::setContentsPos( x, y ); @@ -247,6 +345,9 @@ void QtxListBox::setContentsPos( int x, int y ) updateEditor(); } +/*! + Custom event filter, performs finish of edition on focus out, escape/return/enter pressing +*/ bool QtxListBox::eventFilter( QObject* o, QEvent* e ) { if ( editor() == o ) @@ -267,6 +368,10 @@ bool QtxListBox::eventFilter( QObject* o, QEvent* e ) return QListBox::eventFilter( o, e ); } +/*! + Custom key press event handler + Allows to move items by CTRL + { Up, Down, Home, End } +*/ void QtxListBox::keyPressEvent( QKeyEvent* e ) { if ( e->key() == Key_Up && e->state() & ControlButton && isModificationEnabled() ) @@ -285,6 +390,9 @@ void QtxListBox::keyPressEvent( QKeyEvent* e ) QListBox::keyPressEvent( e ); } +/*! + Custom resize event handler +*/ void QtxListBox::viewportResizeEvent( QResizeEvent* e ) { QListBox::viewportResizeEvent( e ); @@ -292,6 +400,9 @@ void QtxListBox::viewportResizeEvent( QResizeEvent* e ) updateEditor(); } +/*! + Custom mouse double click event handler +*/ void QtxListBox::mouseDoubleClickEvent( QMouseEvent* e ) { if ( isEditEnabled() ) @@ -300,11 +411,17 @@ void QtxListBox::mouseDoubleClickEvent( QMouseEvent* e ) QListBox::mouseDoubleClickEvent( e ); } +/*! + Updates editor on contents moving +*/ void QtxListBox::onContentsMoving( int, int ) { updateEditor(); } +/*! + \return item editor +*/ QLineEdit* QtxListBox::editor() const { if ( !myEditor ) @@ -315,6 +432,9 @@ QLineEdit* QtxListBox::editor() const return myEditor; } +/*! + Creates item editor +*/ void QtxListBox::createEditor() { if ( myEditor ) @@ -332,6 +452,9 @@ void QtxListBox::createEditor() addChild( myEditor ); } +/*! + Updates item editor +*/ void QtxListBox::updateEditor() { if ( !editedItem() || !editor() )