OpenMS
EnhancedTabBar.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Marc Sturm $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 // OpenMS_GUI config
12 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
13 
14 //QT
15 #include <QTabBar>
16 class QMouseEvent;
17 class QMimeData;
18 
19 namespace OpenMS
20 {
21  class String;
22 
34  class OPENMS_GUI_DLLAPI EnhancedTabBar :
35  public QTabBar
36  {
37  Q_OBJECT
38 public:
40  EnhancedTabBar(QWidget * parent = nullptr);
41 
43  ~EnhancedTabBar() override;
44 
46  void setTabText(const QString& text);
47 
49  int addTab(const String & text, int id);
50 
52  void show(int id);
53 
54 public slots:
56  void removeId(int id);
57 
58 signals:
60  void currentIdChanged(int id);
61 
63  void closeRequested(int id);
64 
66  void dropOnTab(const QMimeData * data, QWidget * source, int id);
67 
69  void dropOnWidget(const QMimeData * data, QWidget * source);
70 
71 protected:
73 
74  void mouseDoubleClickEvent(QMouseEvent * e) override;
75  void contextMenuEvent(QContextMenuEvent * e) override;
76  void dragEnterEvent(QDragEnterEvent * e) override;
77  void dropEvent(QDropEvent * e) override;
79 
81  int tabAt_(const QPoint & pos);
82 
83 protected slots:
85  void currentChanged_(int id);
86  };
87 
88 }
Convenience tab bar implementation.
Definition: EnhancedTabBar.h:36
void closeRequested(int id)
Signal that indicates that the tab with identifier id is requested to be removed (double click or con...
void setTabText(const QString &text)
sets the text of the current tab
void dropEvent(QDropEvent *e) override
int tabAt_(const QPoint &pos)
Returns the QTabBar index of the tab at position pos. If there is no tab at that position -1 is retur...
void removeId(int id)
Remove the tab with identifier id.
void dragEnterEvent(QDragEnterEvent *e) override
void show(int id)
Selects the tab with identifier id.
void currentIdChanged(int id)
Signal that indicates that the current tab changed, giving the id of the Tab.
int addTab(const String &text, int id)
Adds a new tab with the name text and the identifier id.
void contextMenuEvent(QContextMenuEvent *e) override
~EnhancedTabBar() override
Destructor.
EnhancedTabBar(QWidget *parent=nullptr)
Constructor.
void mouseDoubleClickEvent(QMouseEvent *e) override
void dropOnWidget(const QMimeData *data, QWidget *source)
Signal that is emitted, when a drag-and-drop action ends on the unused space on the right side of the...
void dropOnTab(const QMimeData *data, QWidget *source, int id)
Signal that is emitted, when a drag-and-drop action ends on a tab.
void currentChanged_(int id)
Slot that translates the currentChanged(int) signal to currentIdChanged(int)
A more convenient string class.
Definition: String.h:34
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22