~ubuntu-branches/ubuntu/vivid/kate/vivid-updates

« back to all changes in this revision

Viewing changes to addons/tabswitcher/tabswitcher.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-12-04 16:49:41 UTC
  • mfrom: (1.6.6)
  • Revision ID: package-import@ubuntu.com-20141204164941-l3qbvsly83hhlw2v
Tags: 4:14.11.97-0ubuntu1
* New upstream release
* Update build-deps and use pkg-kde v3 for Qt 5 build
* kate-data now kate5-data for co-installability

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
 
 
3
   Copyright (C) 2014 Dominik Haumann <dhaumann@kde.org>
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Library General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2 of the License, or (at your option) any later version.
 
9
 
 
10
   This library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Library General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Library General Public License
 
16
   along with this library; see the file COPYING.LIB.  If not, write to
 
17
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
   Boston, MA 02110-1301, USA.
 
19
*/
 
20
 
 
21
#ifndef KTEXTEDITOR_TAB_SWITCHER_PLUGIN_H
 
22
#define KTEXTEDITOR_TAB_SWITCHER_PLUGIN_H
 
23
 
 
24
#include <KTextEditor/Plugin>
 
25
#include <KTextEditor/MainWindow>
 
26
 
 
27
#include <QList>
 
28
#include <QVariant>
 
29
 
 
30
#include <KXMLGUIClient>
 
31
 
 
32
class TabSwitcherPluginView;
 
33
class TabSwitcherTreeView;
 
34
class QStandardItemModel;
 
35
class QModelIndex;
 
36
 
 
37
class TabSwitcherPlugin : public KTextEditor::Plugin
 
38
{
 
39
    Q_OBJECT
 
40
 
 
41
    friend TabSwitcherPluginView;
 
42
 
 
43
public:
 
44
    /**
 
45
     * Plugin constructor.
 
46
     */
 
47
    explicit TabSwitcherPlugin(QObject *parent = 0, const QList<QVariant> & = QList<QVariant>());
 
48
 
 
49
    /**
 
50
     * Plugin destructor.
 
51
     */
 
52
    virtual ~TabSwitcherPlugin();
 
53
 
 
54
    /**
 
55
     * Create a new tab switcher for @p mainWindow.
 
56
     */
 
57
    QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE;
 
58
 
 
59
private:
 
60
    QList<TabSwitcherPluginView *> m_views;
 
61
};
 
62
 
 
63
class TabSwitcherPluginView : public QObject, public KXMLGUIClient
 
64
{
 
65
    Q_OBJECT
 
66
 
 
67
public:
 
68
    /**
 
69
     * View constructor.
 
70
     */
 
71
    TabSwitcherPluginView(TabSwitcherPlugin *plugin, KTextEditor::MainWindow *mainWindow);
 
72
 
 
73
    /**
 
74
     * View destructor.
 
75
     */
 
76
    virtual ~TabSwitcherPluginView();
 
77
 
 
78
    /**
 
79
     * Setup the shortcut actions.
 
80
     */
 
81
    void setupActions();
 
82
 
 
83
    /**
 
84
     * Initial fill of model with documents from the application.
 
85
     */
 
86
    void setupModel();
 
87
 
 
88
public Q_SLOTS:
 
89
    /**
 
90
     * Adds @p document to the model.
 
91
     */
 
92
    void registerDocument(KTextEditor::Document * document);
 
93
 
 
94
    /**
 
95
     * Removes @p document from the model.
 
96
     */
 
97
    void unregisterDocument(KTextEditor::Document * document);
 
98
 
 
99
    /**
 
100
     * Update the name in the model for @p document.
 
101
     */
 
102
    void updateDocumentName(KTextEditor::Document * document);
 
103
 
 
104
    /**
 
105
     * Raise @p view in a lru fasion.
 
106
     */
 
107
    void raiseView(KTextEditor::View * view);
 
108
 
 
109
    /**
 
110
     * Focus next item in the treeview.
 
111
     */
 
112
    void walkForward();
 
113
 
 
114
    /**
 
115
     * Focus previous item in the treeview.
 
116
     */
 
117
    void walkBackward();
 
118
 
 
119
    /**
 
120
     * Activate the document for @p index.
 
121
     */
 
122
    void switchToClicked(const QModelIndex& index);
 
123
 
 
124
    /**
 
125
     * Show the document for @p index.
 
126
     */
 
127
    void activateView(const QModelIndex& index);
 
128
 
 
129
protected:
 
130
    /**
 
131
     * Move through the list.
 
132
     */
 
133
    void walk(const int from, const int to);
 
134
 
 
135
    /**
 
136
     * Make sure the popup view has a sane size.
 
137
     */
 
138
    void updateViewGeometry();
 
139
 
 
140
private:
 
141
    TabSwitcherPlugin *m_plugin;
 
142
    KTextEditor::MainWindow *m_mainWindow;
 
143
    QStandardItemModel * m_model;
 
144
    TabSwitcherTreeView * m_treeView;
 
145
};
 
146
 
 
147
#endif // KTEXTEDITOR_TAB_SWITCHER_PLUGIN_H