File indexing completed on 2024-04-21 04:50:14

0001 /*
0002     SPDX-FileCopyrightText: 2009-2010 Michal Malek <michalm@jabster.pl>
0003     SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef K3BPROJECTTABWIDGET_H
0009 #define K3BPROJECTTABWIDGET_H
0010 
0011 #include <QTabWidget>
0012 
0013 class QAction;
0014 class KActionMenu;
0015 namespace K3b {
0016     class Doc;
0017 }
0018 
0019 
0020 /**
0021  * An enhanced Tab Widget that shows a context menu fpr K3b projects.
0022  *
0023  * @author Sebastian Trueg
0024  */
0025 namespace K3b {
0026     class ProjectTabWidget : public QTabWidget
0027     {
0028         Q_OBJECT
0029 
0030     public:
0031         explicit ProjectTabWidget( QWidget *parent = 0 );
0032         ~ProjectTabWidget() override;
0033 
0034         void addTab( Doc* doc );
0035         void removeTab( Doc* doc );
0036         void setCurrentTab( Doc* doc );
0037         Doc* currentTab() const;
0038 
0039         /**
0040          * adds the given action into the popup menu for the tabs
0041          */
0042         void addAction( QAction* action );
0043         
0044     Q_SIGNALS:
0045         void tabCloseRequested( Doc* doc );
0046         
0047     protected:
0048         /**
0049          * \return the project for the tab at position \p pos or 0 in case the tab is
0050          * not a project tab.
0051          */
0052         Doc* projectAt( const QPoint& pos ) const;
0053 
0054         bool eventFilter( QObject* o, QEvent* e ) override;
0055 
0056     private Q_SLOTS:
0057         void slotDocChanged( K3b::Doc* );
0058         void slotDocSaved( K3b::Doc* );
0059         void slotTabCloseRequested( int index );
0060 
0061     private:
0062         class Private;
0063         Private* d;
0064     };
0065 }
0066 
0067 #endif