OpenMS
EnhancedTabBar Class Reference

Convenience tab bar implementation. More...

#include <OpenMS/VISUAL/EnhancedTabBar.h>

Inheritance diagram for EnhancedTabBar:
[legend]
Collaboration diagram for EnhancedTabBar:
[legend]

Public Slots

void removeId (int id)
 Remove the tab with identifier id. More...
 

Signals

void currentIdChanged (int id)
 Signal that indicates that the current tab changed, giving the id of the Tab. More...
 
void closeRequested (int id)
 Signal that indicates that the tab with identifier id is requested to be removed (double click or context menu) More...
 
void dropOnTab (const QMimeData *data, QWidget *source, int id)
 Signal that is emitted, when a drag-and-drop action ends on a tab. More...
 
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 tabs. More...
 

Public Member Functions

 EnhancedTabBar (QWidget *parent=nullptr)
 Constructor. More...
 
 ~EnhancedTabBar () override
 Destructor. More...
 
void setTabText (const QString &text)
 sets the text of the current tab More...
 
int addTab (const String &text, int id)
 Adds a new tab with the name text and the identifier id. More...
 
void show (int id)
 Selects the tab with identifier id. More...
 

Reimplemented Qt events

void mouseDoubleClickEvent (QMouseEvent *e) override
 
void contextMenuEvent (QContextMenuEvent *e) override
 
void dragEnterEvent (QDragEnterEvent *e) override
 
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 returned. More...
 
void currentChanged_ (int id)
 Slot that translates the currentChanged(int) signal to currentIdChanged(int) More...
 

Detailed Description

Convenience tab bar implementation.

This tab bar differs in several ways form the QTabBar:

  • you can close a tab by double-clicking it or through its context menu.
  • it works based on tab identifiers (a fixed id stored in tab data) rather than on tab indices, which might change when inserting or removing a tab.
  • it accepts all drag-and-drop actions and emits signals to handle them.

Constructor & Destructor Documentation

◆ EnhancedTabBar()

EnhancedTabBar ( QWidget parent = nullptr)

Constructor.

◆ ~EnhancedTabBar()

~EnhancedTabBar ( )
override

Destructor.

Member Function Documentation

◆ addTab()

int addTab ( const String text,
int  id 
)

Adds a new tab with the name text and the identifier id.

Referenced by TOPPASBase::TOPPASBase(), and TOPPViewBase::TOPPViewBase().

◆ closeRequested

void closeRequested ( int  id)
signal

Signal that indicates that the tab with identifier id is requested to be removed (double click or context menu)

Referenced by TOPPASBase::TOPPASBase(), and TOPPViewBase::TOPPViewBase().

◆ contextMenuEvent()

void contextMenuEvent ( QContextMenuEvent *  e)
overrideprotected

◆ currentChanged_

void currentChanged_ ( int  id)
protectedslot

Slot that translates the currentChanged(int) signal to currentIdChanged(int)

◆ currentIdChanged

void currentIdChanged ( int  id)
signal

Signal that indicates that the current tab changed, giving the id of the Tab.

Referenced by TOPPASBase::TOPPASBase(), and TOPPViewBase::TOPPViewBase().

◆ dragEnterEvent()

void dragEnterEvent ( QDragEnterEvent *  e)
overrideprotected

◆ dropEvent()

void dropEvent ( QDropEvent *  e)
overrideprotected

◆ dropOnTab

void dropOnTab ( const QMimeData *  data,
QWidget source,
int  id 
)
signal

Signal that is emitted, when a drag-and-drop action ends on a tab.

Referenced by TOPPViewBase::TOPPViewBase().

◆ dropOnWidget

void dropOnWidget ( const QMimeData *  data,
QWidget source 
)
signal

Signal that is emitted, when a drag-and-drop action ends on the unused space on the right side of the tabs.

Referenced by TOPPViewBase::TOPPViewBase().

◆ mouseDoubleClickEvent()

void mouseDoubleClickEvent ( QMouseEvent *  e)
overrideprotected

◆ removeId

void removeId ( int  id)
slot

Remove the tab with identifier id.

Referenced by TOPPASBase::TOPPASBase(), and TOPPViewBase::TOPPViewBase().

◆ setTabText()

void setTabText ( const QString &  text)

◆ show()

void show ( int  id)

Selects the tab with identifier id.

Referenced by TOPPASBase::updateTabBar().

◆ tabAt_()

int tabAt_ ( const QPoint &  pos)
protected

Returns the QTabBar index of the tab at position pos. If there is no tab at that position -1 is returned.