~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to kate/plugins/tabbarextension/plugin_katetabbarextension.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-28 10:11:43 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: james.westby@ubuntu.com-20080528101143-gzc3styjz1b70zxu
Tags: upstream-4.0.80
ImportĀ upstreamĀ versionĀ 4.0.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                           plugin_katetabbarextension.h
 
3
                           -------------------
 
4
    begin                : 2004-04-20
 
5
    copyright            : (C) 2004-2005 by Dominik Haumann
 
6
    email                : dhdev@gmx.de
 
7
 ***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
 This program is free software; you can redistribute it and/or
 
11
 modify it under the terms of the GNU General Public License
 
12
 as published by the Free Software Foundation; either version 2
 
13
 of the License, or (at your option) any later version.
 
14
 
 
15
 This program is distributed in the hope that it will be useful,
 
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 GNU General Public License for more details.
 
19
 
 
20
 You should have received a copy of the GNU General Public License
 
21
 along with this program; if not, write to the Free Software
 
22
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
23
 ***************************************************************************/
 
24
 
 
25
#ifndef PLUGIN_KATETABBAREXTENSION_H
 
26
#define PLUGIN_KATETABBAREXTENSION_H
 
27
 
 
28
#include <kate/application.h>
 
29
#include <kate/documentmanager.h>
 
30
#include <kate/mainwindow.h>
 
31
#include <kate/plugin.h>
 
32
#include <kate/pluginconfigpageinterface.h>
 
33
 
 
34
#include <ktexteditor/document.h>
 
35
#include <ktexteditor/view.h>
 
36
#include <ktexteditor/modificationinterface.h>
 
37
 
 
38
#include <klibloader.h>
 
39
#include <klocale.h>
 
40
#include <ktoolbar.h>
 
41
 
 
42
#include <qpushbutton.h>
 
43
//Added by qt3to4:
 
44
#include <QBoxLayout>
 
45
#include <QMap>
 
46
#include <QList>
 
47
 
 
48
class QBoxLayout;
 
49
class QCheckBox;
 
50
 
 
51
class KateTabBarExtension;
 
52
class KateTabBarExtensionConfigPage;
 
53
class KTinyTabBar;
 
54
 
 
55
class PluginView : public Kate::PluginView
 
56
{
 
57
    Q_OBJECT
 
58
    friend class KatePluginTabBarExtension;
 
59
 
 
60
public:
 
61
    PluginView( Kate::MainWindow* mainwindow );
 
62
    virtual ~PluginView();
 
63
 
 
64
    void updateLocation();
 
65
 
 
66
    void readSessionConfig (KConfigBase* config, const QString& groupPrefix);
 
67
    void writeSessionConfig (KConfigBase* config, const QString& groupPrefix);
 
68
 
 
69
public slots:
 
70
    void currentTabChanged( int button_id );
 
71
    void closeTabRequest( int button_id );
 
72
    void slotDocumentCreated( KTextEditor::Document* document );
 
73
    void slotDocumentDeleted( KTextEditor::Document* document );
 
74
    void slotViewChanged();
 
75
    void slotDocumentChanged( KTextEditor::Document* );
 
76
    void slotModifiedOnDisc( KTextEditor::Document* document, bool modified,
 
77
                             KTextEditor::ModificationInterface::ModifiedOnDiskReason reason );
 
78
    void slotNameChanged( KTextEditor::Document* document );
 
79
 
 
80
private:
 
81
    KTinyTabBar* tabbar;
 
82
    QMap<int, KTextEditor::Document*> id2doc;
 
83
    QMap<KTextEditor::Document*, int> doc2id;
 
84
};
 
85
 
 
86
class KatePluginTabBarExtension : public Kate::Plugin, public Kate::PluginConfigPageInterface
 
87
{
 
88
  Q_OBJECT
 
89
  Q_INTERFACES(Kate::PluginConfigPageInterface)
 
90
  public:
 
91
    explicit KatePluginTabBarExtension( QObject* parent = 0, const QStringList& = QStringList() );
 
92
    virtual ~KatePluginTabBarExtension();
 
93
 
 
94
    Kate::PluginView *createView (Kate::MainWindow *mainWindow);
 
95
 
 
96
    void readSessionConfig (KConfigBase* config, const QString& groupPrefix);
 
97
    void writeSessionConfig (KConfigBase* config, const QString& groupPrefix);
 
98
 
 
99
    // Kate::PluginConfigPageInterface
 
100
    uint configPages () const { return 0; } // if changed to 1, the config pages appears
 
101
    Kate::PluginConfigPage *configPage (uint , QWidget *w, const char *name=0);
 
102
    QString configPageName(uint) const { return i18n("Tab Bar Extension"); }
 
103
    QString configPageFullName(uint) const { return i18n("Configure Tab Bar Extension"); }
 
104
    KIcon configPageIcon(uint) const { return KIcon(); }
 
105
 
 
106
  public slots:
 
107
    void applyConfig( KateTabBarExtensionConfigPage* );
 
108
 
 
109
  protected slots:
 
110
    void tabbarSettingsChanged( KTinyTabBar* tabbar );
 
111
    void tabbarHighlightMarksChanged( KTinyTabBar* tabbar );
 
112
 
 
113
  private:
 
114
    void initConfigPage( KateTabBarExtensionConfigPage* );
 
115
 
 
116
  private:
 
117
    QList<PluginView*> m_views;
 
118
    KConfig* pConfig;
 
119
};
 
120
 
 
121
 
 
122
/**
 
123
 * The tabbar's config page
 
124
 */
 
125
class KateTabBarExtensionConfigPage : public Kate::PluginConfigPage
 
126
{
 
127
  Q_OBJECT
 
128
 
 
129
  friend class KatePluginTabBarExtension;
 
130
 
 
131
  public:
 
132
    explicit KateTabBarExtensionConfigPage (QObject* parent = 0L, QWidget *parentWidget = 0L);
 
133
    ~KateTabBarExtensionConfigPage ();
 
134
 
 
135
    /**
 
136
     * Reimplemented from Kate::PluginConfigPage
 
137
     * just emits configPageApplyRequest( this ).
 
138
     */
 
139
    virtual void apply();
 
140
 
 
141
    virtual void reset () { ; }
 
142
    virtual void defaults () { ; }
 
143
 
 
144
  signals:
 
145
    /**
 
146
     * Ask the plugin to set initial values
 
147
     */
 
148
    void configPageApplyRequest( KateTabBarExtensionConfigPage* );
 
149
 
 
150
    /**
 
151
     * Ask the plugin to apply changes
 
152
     */
 
153
    void configPageInitRequest( KateTabBarExtensionConfigPage* );
 
154
 
 
155
  private:
 
156
    QCheckBox* pSortAlpha;
 
157
};
 
158
 
 
159
#endif // PLUGIN_KATETABBAREXTENSION_H