diff options
Diffstat (limited to 'kate/tabbarextension/plugin_katetabbarextension.h')
-rw-r--r-- | kate/tabbarextension/plugin_katetabbarextension.h | 82 |
1 files changed, 59 insertions, 23 deletions
diff --git a/kate/tabbarextension/plugin_katetabbarextension.h b/kate/tabbarextension/plugin_katetabbarextension.h index 7ce300c..0d16d69 100644 --- a/kate/tabbarextension/plugin_katetabbarextension.h +++ b/kate/tabbarextension/plugin_katetabbarextension.h @@ -48,7 +48,7 @@ class TQCheckBox; class KateTabBarButton; /** - * Same as TQPtrList. Only difference is: overwrite comapreItems() for sorting reason. + * Same as TQPtrList. Only difference is: overwrite compareItems() for sorting reason. */ class MyPtrList : public TQPtrList <KateTabBarButton> { @@ -61,14 +61,14 @@ class MyPtrList : public TQPtrList <KateTabBarButton> class KatePluginFactory : public KLibFactory { Q_OBJECT - + public: - KatePluginFactory(); - virtual ~KatePluginFactory(); + KatePluginFactory() { s_instance = new TDEInstance( "kate" ); } + virtual ~KatePluginFactory() { delete s_instance; } - virtual TQObject* createObject( TQObject* parent = 0, const char* pname = 0, - const char* name = TQOBJECT_OBJECT_NAME_STRING, const TQStringList &args = TQStringList() ); + virtual TQObject* createObject(TQObject *parent = 0, const char *pname = 0, + const char *name = TQOBJECT_OBJECT_NAME_STRING, const TQStringList &args = TQStringList()); private: static TDEInstance* s_instance; @@ -97,12 +97,17 @@ class KateTabBarButton: public TQPushButton /** * standard destructor (emtpy) */ - ~KateTabBarButton(); + ~KateTabBarButton() {} /** * @return the unique document ID */ - uint documentNumber(); + uint documentNumber() { return myDocID; } + + /** + * @return the document pointer + */ + Kate::Document* document() { return doc; } /** * get the document's full name (eg. main.cpp), used for comparison @@ -126,7 +131,13 @@ class KateTabBarButton: public TQPushButton * set text for this tab * @param newText new text */ - virtual void setText( const TQString& newText); + virtual void setText(const TQString& newText); + + /** + * mouse release event handler to provide middle click functionality + * @param e the mouse event + */ + virtual void mouseReleaseEvent(TQMouseEvent *e); signals: /** @@ -135,6 +146,12 @@ class KateTabBarButton: public TQPushButton */ void myToggled(KateTabBarButton* tab); + /** + * signal emitted when the middle button is pressed + * @param tab pointer to the button that emitted the signal + */ + void middleButtonPressed(KateTabBarButton* tab); + public slots: /** * control the ToggleButton @@ -168,22 +185,23 @@ class KateTabBarExtension : public TQWidget * @param name name of widget * @param f widget flags */ - KateTabBarExtension( Kate::DocumentManager *pDocManager, + KateTabBarExtension(Kate::DocumentManager *pDocManager, Kate::MainWindow *win, bool bHorizOrientation, bool bSort, - TQWidget * parent = 0, const char * name = 0, WFlags f = 0 ); + bool bCloseOnMiddleClick, TQWidget *parent = 0, + const char *name = 0, WFlags f = 0); /** standard destructor */ - ~KateTabBarExtension(); + ~KateTabBarExtension() {} /** * @return the tabbar's orientation */ - Qt::Orientation orientation() const; + Qt::Orientation orientation() const { return m_orientation; } /** * @return true, when sorting is alphabetically */ - bool sortByName() const; + bool sortByName() const { return m_sort; } /** * set sorting type @@ -196,6 +214,17 @@ class KateTabBarExtension : public TQWidget */ void updateSort(); + /** + * @return true when closing a document with mouse middle click is allowed + */ + bool closeOnMiddleClick() const { return m_closeOnMiddleClick; } + + /** + * set flag to enable/disable "close document on mouse middle click" feature + * @param cmc true -> enabled, false -> disabled + */ + void setCloseOnMiddleClick(bool cmc) { m_closeOnMiddleClick = cmc; } + public slots: /** * called when a new document is created/loaded @@ -246,15 +275,22 @@ class KateTabBarExtension : public TQWidget */ void slotMoved(Qt::Orientation o); + /** + * called when we want to close the document associated with the tab + * @param tab pointer to the button that represents the active view + */ + void slotRequestDocClose(KateTabBarButton *tab); + private: KateTabBarButton* pCurrentTab; ///< pointer to the current tab - TQBoxLayout* top; ///< layout that contains all tabs + TQBoxLayout* top; ///< layout that contains all tabs Kate::MainWindow* m_win; ///< pointer to the main window Kate::DocumentManager* m_docManager; ///< pointer to the document manager // TQPtrList <KateTabBarButton> m_tabs; ///< list containing all tabs MyPtrList m_tabs; ///< list containing all tabs Qt::Orientation m_orientation; ///< save tabbar's orientation bool m_sort; ///< how to sort + bool m_closeOnMiddleClick; ///< Enable/disable "close document on mouse middle click" feature }; /** @@ -268,17 +304,16 @@ class KateTabBarExtensionConfigPage : public Kate::PluginConfigPage friend class KatePluginTabBarExtension; public: - KateTabBarExtensionConfigPage (TQObject* parent = 0L, TQWidget *parentWidget = 0L); - ~KateTabBarExtensionConfigPage (); + KateTabBarExtensionConfigPage(TQObject* parent = 0L, TQWidget *parentWidget = 0L); + ~KateTabBarExtensionConfigPage() {} /** * Reimplemented from Kate::PluginConfigPage * just emits configPageApplyRequest( this ). */ - virtual void apply(); - - virtual void reset () { ; } - virtual void defaults () { ; } + virtual void apply() { emit configPageApplyRequest(this); } + virtual void reset() {} + virtual void defaults() {} signals: /** @@ -293,6 +328,7 @@ class KateTabBarExtensionConfigPage : public Kate::PluginConfigPage private: TQCheckBox* pSortAlpha; + TQCheckBox* pCloseOnMiddleClick; }; class KatePluginTabBarExtension : public Kate::Plugin, Kate::PluginViewInterface, Kate::PluginConfigInterfaceExtension @@ -301,7 +337,7 @@ class KatePluginTabBarExtension : public Kate::Plugin, Kate::PluginViewInterface public: - KatePluginTabBarExtension( TQObject* parent = 0, const char* name = 0 ); + KatePluginTabBarExtension(TQObject* parent = 0, const char* name = 0); virtual ~KatePluginTabBarExtension(); void addView (Kate::MainWindow *win); @@ -311,7 +347,7 @@ class KatePluginTabBarExtension : public Kate::Plugin, Kate::PluginViewInterface Kate::PluginConfigPage *configPage (uint , TQWidget *w, const char *name=0); TQString configPageName(uint) const { return i18n("Tab Bar Extension"); } TQString configPageFullName(uint) const { return i18n("Configure Tab Bar Extension"); } - TQPixmap configPagePixmap (uint number = 0, int size = TDEIcon::SizeSmall) const { return 0L; } + TQPixmap configPagePixmap (uint = 0, int = TDEIcon::SizeSmall) const { return 0L; } public slots: void applyConfig( KateTabBarExtensionConfigPage* ); |