File: sidebar_widget.h

package info (click to toggle)
kde-baseapps 4:16.08.3-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 12,308 kB
  • ctags: 12,389
  • sloc: cpp: 109,033; ansic: 2,197; python: 943; xml: 853; sh: 197; ruby: 112; makefile: 7
file content (215 lines) | stat: -rw-r--r-- 6,912 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/***************************************************************************
                               sidebar_widget.h
                             -------------------
    begin                : Sat June 2 16:25:27 CEST 2001
    copyright            : (C) 2001 Joseph Wenninger
    email                : jowenn@kde.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef _SIDEBAR_WIDGET_
#define _SIDEBAR_WIDGET_

#include <QActionGroup>
#include <kconfiggroup.h>
#include <QtCore/QTimer>

#include <QtCore/QPointer>

#include <kurl.h>
#include <kparts/part.h>

#include "konqsidebarplugin.h"
#include "module_manager.h"

class KonqMultiTabBar;
class KonqSidebarPlugin;
class QMenu;
class KMultiTabBar;
class QHBoxLayout;
class QSplitter;
class QStringList;
class KMenu;

class ButtonInfo
{
public:
    ButtonInfo()
        : module(NULL), m_plugin(NULL)
    {
    }
    ButtonInfo(const KSharedConfig::Ptr& configFile_,
               const QString& file_,
               const QString &url_,const QString &lib,
               const QString &dispName_, const QString &iconName_)
        : configFile(configFile_),
          file(file_), dock(NULL),
          module(NULL), m_plugin(NULL),
          URL(url_), libName(lib), displayName(dispName_), iconName(iconName_)
    {
    }

    ~ButtonInfo() {}

    KonqSidebarPlugin* plugin(QObject* parent);

    KSharedConfig::Ptr configFile;
    QString file;
    QPointer<QWidget> dock;
    KonqSidebarModule *module;
    KonqSidebarPlugin* m_plugin;
    QString URL; // TODO remove
    QString libName;
    QString displayName;
    QString iconName;
};

class Sidebar_Widget: public QWidget
{
    Q_OBJECT
public:
    friend class ButtonInfo;
public:
    Sidebar_Widget(QWidget *parent, KParts::ReadOnlyPart *par,
                   const QString &currentProfile);
    ~Sidebar_Widget();
    bool openUrl(const KUrl &url);
    void stdAction(const char *handlestd);

    KParts::BrowserExtension *getExtension();
    virtual QSize sizeHint() const;

public Q_SLOTS:
    void addWebSideBar(const KUrl& url, const QString& name);

protected:
    void customEvent(QEvent* ev);
    //void resizeEvent(QResizeEvent* ev);
    virtual bool eventFilter(QObject*,QEvent*);
    virtual void mousePressEvent(QMouseEvent*);

protected Q_SLOTS:
    void showHidePage(int value);
    void createButtons();
    void updateButtons();
    void slotRollback();
    void aboutToShowConfigMenu();
    void saveConfig();

    void slotMultipleViews();
    void slotShowTabsLeft();
    void slotShowConfigurationButton();

    void slotSetName();
    void slotSetURL();
    void slotSetIcon();
    void slotRemove();

    void slotUrlsDropped(const KUrl::List& urls);

Q_SIGNALS:
    void started(KIO::Job *);
    void completed();
    void fileSelection(const KFileItemList& iems);
    void fileMouseOver(const KFileItem& item);

    /* The following public slots are wrappers for browserextension signals */
public Q_SLOTS:
    void openUrlRequest( const KUrl &url, const KParts::OpenUrlArguments& args, const KParts::BrowserArguments& browserArgs );
    /* @internal
     * ### KDE4 remove me
     */
    void submitFormRequest(const char*,const QString&,const QByteArray&,const QString&,const QString&,const QString&);
    void createNewWindow(const KUrl &url, const KParts::OpenUrlArguments& args, const KParts::BrowserArguments& browserArgs,
                         const KParts::WindowArgs &windowArgs);

    void slotEnableAction(KonqSidebarModule* module, const char * name, bool enabled);

private:

    bool addButton(const QString &desktopFileName, int pos = -1);
    bool createView(ButtonInfo &buttonInfo);
    KonqSidebarModule *loadModule(QWidget *par, const QString &desktopName,
                                  ButtonInfo& buttonInfo, const KSharedConfig::Ptr& config);
    void readConfig();
    void doLayout();
    void connectModule(KonqSidebarModule *mod);
    void collapseExpandSidebar();
    void doEnableActions();
    ButtonInfo& currentButtonInfo() { return m_buttons[m_currentButtonIndex]; }

    /**
     * Create a module without the interactive "createNewModule" implemented
     * in the plugin.
     */
    bool createDirectModule(const QString& templ,
                            const QString& name,
                            const KUrl& url,
                            const QString& icon,
                            const QString& module,
                            const QString& treeModule = QString());
private Q_SLOTS:
    void aboutToShowAddMenu();
    void triggeredAddMenu(QAction* action);

    void slotPopupMenu(KonqSidebarModule*, const QPoint &global, const KFileItemList &items,
                       const KParts::OpenUrlArguments &args = KParts::OpenUrlArguments(),
                       const KParts::BrowserArguments &browserArgs = KParts::BrowserArguments(),
                       KParts::BrowserExtension::PopupFlags flags = KParts::BrowserExtension::DefaultPopupItems,
                       const KParts::BrowserExtension::ActionGroupMap& actionGroups = KParts::BrowserExtension::ActionGroupMap());

    void slotAddItem(const KFileItem& item);

private:
    KParts::ReadOnlyPart *m_partParent;
    QSplitter *m_area;

    KonqMultiTabBar *m_buttonBar;
    QVector<ButtonInfo> m_buttons;
    QHBoxLayout *m_layout;
    QAction *m_showTabLeft;
    QMenu *m_menu;

    QMenu *m_addMenu;
    QActionGroup m_addMenuActionGroup;
    QMap<QAction*, KonqSidebarPlugin*> m_pluginForAction;

    QPointer<KonqSidebarModule> m_activeModule; // during RMB popups inside the module

    int m_currentButtonIndex; // during RMB popups (over tabs) only, see currentButtonInfo

    KConfigGroup *m_config;
    QTimer m_configTimer;

    KUrl m_storedUrl;
    int m_savedWidth;
    int m_latestViewed;

    bool m_hasStoredUrl;
    bool m_singleWidgetMode;
    bool m_showTabsLeft;
    bool m_hideTabs;
    bool m_showExtraButtons;
    bool m_somethingVisible;
    bool m_noUpdate;

    QAction *m_multiViews;
    QAction *m_showConfigButton;

    QStringList m_visibleViews; // The views that are actually open
    QStringList m_openViews; // The views that should be opened

    ModuleManager m_moduleManager;

Q_SIGNALS:
    void panelHasBeenExpanded(bool);
};

#endif