1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef ModuleBase_ListView_H_
22 #define ModuleBase_ListView_H_
24 #include "ModuleBase.h"
26 #include <QModelIndex>
37 * An extension of QListWidget to provide Undo/Redo functionality
39 class MODULEBASE_EXPORT ModuleBase_ListView : public QObject
45 ModuleBase_ListView(QWidget* theParent = 0, const QString& theObjectName = QString(),
46 const QString& theToolTip = QString());
48 virtual ~ModuleBase_ListView() {}
50 /// Returns current control
51 /// \return list view instance
52 QListWidget* getControl() const { return myListControl; }
54 /// Adds a new list widget item to the end of the list and connect it to the given index
55 /// \param theTextValue value visualized in the view
56 /// \param theIndex an item internal index
57 void addItem(const QString& theTextValue, const int theIndex);
59 /// Returns list of internal list view item indices
60 /// \param theIndices an output container for indices
61 void getSelectedIndices(std::set<int>& theIndices);
63 /// Removes selected items from the list widget
64 void removeSelectedItems();
66 /// Remove items contain parameter indices
67 /// \param theIndices an indices
68 void removeItems(std::set<int>& theIndices);
70 /// Set selected items if possible
71 /// \param theIndices container of indices to be selected
72 void restoreSelection(const QModelIndexList& theIndices);
74 /// Update enable/disable state of context menu actions
75 void updateActionsStatus();
78 /// Slot for copy command in a list pop-up menu
81 /// Slot is called on selection of list of selected items
82 void onListSelection();
85 /// Signal about delete action click
86 void deleteActionClicked();
89 QListWidget* myListControl; ///< List control
91 QAction* myCopyAction; ///< A copy action for pop-up menu in a list control
92 QAction* myDeleteAction; ///< A delete action for pop-up menu in a list control