-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+// Copyright (C) 2007-2023 CEA, EDF, 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/ or email : webmaster.salome@opencascade.com
//
-// File: QtxListAction.hxx
-// Author: Sergey TELKOV (Based on code by Eugene AKSENOV)
+// File: QtxListAction.h
+// Author: Sergey TELKOV
+//
#ifndef QTXLISTACTION_H
#define QTXLISTACTION_H
+#include "Qtx.h"
#include "QtxAction.h"
-
-#include <qmap.h>
-#include <qframe.h>
-#include <qstringlist.h>
-
-class QLabel;
-class QListBox;
-class QPopupMenu;
-class QToolButton;
-class QToolTipGroup;
-
-class QtxListFrame;
+#include <QStringList>
#ifdef WIN32
#pragma warning( disable:4251 )
class QTX_EXPORT QtxListAction : public QtxAction
{
- Q_OBJECT
-
- Q_PROPERTY( QStringList names READ names WRITE addNames )
-
- class ToolButton;
+ Q_OBJECT
-public:
- enum { Item, SubMenu } PopupMode;
+ class ListFrame;
+ class ListWidget;
+ class ScrollEvent;
public:
- QtxListAction( QObject* = 0, const char* = 0, bool = false );
- QtxListAction( const QString&, const QIconSet&, const QString&, int, QObject*, const char* = 0, bool = false );
- QtxListAction( const QString&, const QString&, int, QObject*, const char* = 0, bool = false );
- virtual ~QtxListAction();
+ //! Popup mode
+ enum {
+ Item, //!< action is added to popup menu as menu item
+ SubMenu //!< action is added to popup menu as sub menu with list of items
+ } PopupMode;
public:
- virtual bool addTo( QWidget* );
- virtual bool addTo( QWidget*, const int );
+ QtxListAction( QObject* = 0 );
+ QtxListAction( const QString&, int, QObject* );
+ QtxListAction( const QString&, const QString&, int, QObject* );
+ QtxListAction( const QIcon&, const QString&, int, QObject* );
+ QtxListAction( const QString&, const QIcon&, const QString&, int, QObject* );
+ virtual ~QtxListAction();
- virtual bool removeFrom( QWidget* );
- virtual bool eventFilter( QObject*, QEvent* );
+ int popupMode() const;
+ void setPopupMode( const int );
- int popupMode() const;
- void setPopupMode( const int );
+ QStringList names() const;
+ void addNames( const QStringList&, bool = true );
+ void setComment( const QString&, const QString& = QString() );
- QStringList names() const;
- void addNames( const QStringList&, bool = true );
- void setComment( const QString&, const QString& = QString::null );
+ int linesNumber() const;
+ int charsNumber() const;
- void setMaxLines( int );
- void setMaxLineChars( int );
+ void setLinesNumber( const int );
+ void setCharsNumber( const int );
signals:
- void activated( int );
-
-public slots:
- virtual void setEnabled( bool );
+ void triggered( int );
private slots:
- void onHided();
- void onSingle();
- void onExpand( bool );
- void onMultiple( int );
- void onActivated( int );
- void onDestroyed( QObject* );
+ void onChanged();
+ void onMultiple( const int );
+ void onSingle( bool = false );
+ void onTriggered( bool = false );
protected:
- virtual void addedTo( QWidget*, QWidget* );
+ virtual QWidget* createWidget( QWidget* );
+ virtual void deleteWidget( QWidget* );
private:
- void initialize();
- QWidget* widget( QWidget* ) const;
- QPopupMenu* listPopup( QWidget* ) const;
- QToolButton* mainButton( QWidget* ) const;
- QToolButton* dropButton( QWidget* ) const;
-
- void controlDeleted( QWidget* );
+ void initialize();
private:
- typedef struct { int id; QPopupMenu* popup; } Popups;
- typedef struct { QToolButton* main; QToolButton* drop; } Buttons;
- typedef QMap<QWidget*, Popups> PopupsMap;
- typedef QMap<QWidget*, Buttons> ButtonsMap;
-
-private:
- int myMode;
- QtxListFrame* myFrame;
- bool myRaise;
- PopupsMap myPopups;
- ButtonsMap myButtons;
- QToolTipGroup* myTipGroup;
-
- friend class ToolButton;
- friend class QtxListFrame;
-};
-
-/*!
- \class QtxListFrame
-*/
-class QtxListFrame : public QFrame
-{
- Q_OBJECT
-
- class ScrollEvent;
+ ListFrame* myFrame; //!< list of actions shown as submenu
-public:
- QtxListFrame( QtxListAction*, QWidget* parent, WFlags f = 0 );
- virtual ~QtxListFrame();
-
- void clear();
- const QStringList names() const;
- void addNames( const QStringList& );
-
- void setSingleComment( const QString& );
- void setMultipleComment( const QString& );
-
- int selected() const;
- void setSelected( const int );
-
- void setMaxLines( int );
- void setMaxLineChars( int );
-
- virtual bool event( QEvent* );
- virtual bool eventFilter( QObject*, QEvent* );
-
- void setOwner( QWidget* );
-
- void updateComment();
-
-signals:
- void hided();
- void selected( int );
-
-public slots:
- virtual void show();
- virtual void hide();
-
-private slots:
- void reject();
- void accept();
-
- void onScroll( int, int );
-
-private:
- void setNames( const QStringList& );
- bool handleKeyEvent( QObject*, QKeyEvent* );
- bool handleMouseEvent( QObject*, QMouseEvent* );
-
- friend class QtxListAction;
-
-private:
- QListBox* myList;
- QStringList myNames;
- QWidget* myOwner;
- QtxListAction* myAction;
- QLabel* myComment;
-
- QString mySingleComment;
- QString myMultipleComment;
-
- int myMaxLines;
- int myMaxLineChars;
-
- int myScrollVal;
- bool myScrollBlock;
+ friend class QtxListAction::ListFrame;
};
#ifdef WIN32