itom  4.1.0
tabSwitcherWidget.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 
22  This class is a port of the Python class TabSwitcherWidget
23  of the Spyder IDE (https://github.com/spyder-ide),
24  licensed under the MIT License and developed by the Spyder Project
25  Contributors.
26 *********************************************************************** */
27 
28 #pragma once
29 
30 #include <qlistwidget.h>
31 #include <qpointer.h>
32 #include <qtabwidget.h>
33 #include <qevent.h>
34 #include <qlist.h>
35 
36 
37 
38 namespace ito
39 {
40 class ScriptDockWidget;
41 
43 class TabSwitcherWidget : public QListWidget
44 {
45  Q_OBJECT
46 public:
47  TabSwitcherWidget(QTabWidget *tabWidget, const QList<int> &stackHistory, ScriptDockWidget *scriptDockWidget, QWidget *parent = nullptr);
48  virtual ~TabSwitcherWidget();
49 
50  void selectRow(int steps);
51 
52 protected:
53  void setDialogPosition();
54  int loadData();
55 
56  void keyReleaseEvent(QKeyEvent* ev);
57  void keyPressEvent(QKeyEvent* ev);
58  void focusOutEvent(QFocusEvent* ev);
59 
60 private:
61  QPointer<QTabWidget> m_tabs;
62  ScriptDockWidget* m_pScriptDockWidget;
63  QList<int> m_stackHistory;
64 
65 private slots:
66  void itemSelected(QListWidgetItem *item = nullptr);
67 };
68 
69 } //end namespace ito
widget containing one or multiple script editors (tabbed). This widget can either be a docking widget...
Definition: scriptDockWidget.h:60
Definition: apiFunctionsGraph.cpp:39
Show tabs in mru order and change between them.
Definition: tabSwitcherWidget.h:43