summaryrefslogtreecommitdiffstats
path: root/konqueror/sidebar/sidebar_widget.h
blob: b45f79b7c87ebc423f077cd19fb997ba9b18d56e (plain)
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
216
217
218
219
220
221
222
223
224
225
226
227
/***************************************************************************
                               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 <tqptrvector.h>
#include <tqtimer.h>
#include <tqstring.h>
#include <tqguardedptr.h>

#include <kdockwidget.h>
#include <kurl.h>
#include <tdetoolbar.h>
#include <tdeparts/part.h>
#include <tdemultitabbar.h>

#include "konqsidebarplugin.h"
#include "konqsidebariface_p.h"

class KDockWidget;
class TQHBoxLayout;
class TQSplitter;
class TQStringList;

class ButtonInfo: public TQObject, public KonqSidebarIface
{
	Q_OBJECT
public:
	ButtonInfo(const TQString& file_, class KonqSidebarIface *part, class KDockWidget *dock_,
			const TQString &url_,const TQString &lib,
			const TQString &dispName_, const TQString &iconName_,
			TQObject *parent)
		: TQObject(parent), file(file_), dock(dock_), URL(url_),
		libName(lib), displayName(dispName_), iconName(iconName_), m_part(part)
		{
		copy = cut = paste = trash = del = rename =false;
		}

	~ButtonInfo() {}

	TQString file;
	KDockWidget *dock;
	KonqSidebarPlugin *module;
	TQString URL;
	TQString libName;
	TQString displayName;
	TQString iconName;
	bool copy;
	bool cut;
	bool paste;
	bool trash;
	bool del;
        bool rename;
        KonqSidebarIface *m_part;
	virtual bool universalMode() {return m_part->universalMode();}
};


class addBackEnd: public TQObject
{
	Q_OBJECT
public:
	addBackEnd(TQWidget *parent,class TQPopupMenu *addmenu, bool universal,
                   const TQString &currentProfile, const char *name=0);
	~addBackEnd(){;}
protected slots:
	void aboutToShowAddMenu();
	void activatedAddMenu(int);
signals:
	void updateNeeded();
	void initialCopyNeeded();
private:
	TQGuardedPtr<class TQPopupMenu> menu;
	TQPtrVector<TQString> libNames;
	TQPtrVector<TQString> libParam;
	bool m_universal;
	TQString m_currentProfile;
	void doRollBack();
	TQWidget *m_parent;
};

class KDE_EXPORT Sidebar_Widget: public TQWidget
{
	Q_OBJECT
public:
	friend class ButtonInfo;
public:
	Sidebar_Widget(TQWidget *parent, KParts::ReadOnlyPart *par,
						const char * name,bool universalMode, 
						const TQString &currentProfile);
	~Sidebar_Widget();
	bool openURL(const class KURL &url);
	void stdAction(const char *handlestd);
	//virtual KParts::ReadOnlyPart *getPart();
	KParts::BrowserExtension *getExtension();
        virtual TQSize sizeHint() const;	

public slots:
	void addWebSideBar(const KURL& url, const TQString& name);

protected:
	void customEvent(TQCustomEvent* ev);
	void resizeEvent(TQResizeEvent* ev);
	virtual bool eventFilter(TQObject*,TQEvent*);
	virtual void mousePressEvent(TQMouseEvent*);

protected slots:
	void showHidePage(int value);
	void createButtons();
	void updateButtons();
	void finishRollBack();
	void activatedMenu(int id);
	void buttonPopupActivate(int);
  	void dockWidgetHasUndocked(KDockWidget*);
	void aboutToShowConfigMenu();
	void saveConfig();

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

public:
	/* interface KonqSidebar_PluginInterface*/
	TDEInstance  *getInstance();
//        virtual void showError(TQString &);      for later extension
//        virtual void showMessage(TQString &);    for later extension
	/* end of interface implementation */

	TQStringList getRestrictedViews() const { return m_restrictedViews; }

 /* The following public slots are wrappers for browserextension fields */
public slots:
	void openURLRequest( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
	/* @internal
	 * @since 3.2
	 * ### KDE4 remove me
	 */
	void submitFormRequest(const char*,const TQString&,const TQByteArray&,const TQString&,const TQString&,const TQString&);
  	void createNewWindow( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
	void createNewWindow( const KURL &url, const KParts::URLArgs &args,
             const KParts::WindowArgs &windowArgs, KParts::ReadOnlyPart *&part );

	void popupMenu( const TQPoint &global, const KFileItemList &items );
  	void popupMenu( KXMLGUIClient *client, const TQPoint &global, const KFileItemList &items );
	void popupMenu( const TQPoint &global, const KURL &url,
		const TQString &mimeType, mode_t mode = (mode_t)-1 );
	void popupMenu( KXMLGUIClient *client,
		const TQPoint &global, const KURL &url,
		const TQString &mimeType, mode_t mode = (mode_t)-1 );
	void enableAction( const char * name, bool enabled );
	void userMovedSplitter();
	
private:
	TQSplitter *splitter() const;
	bool addButton(const TQString &desktoppath,int pos=-1);
	bool createView(ButtonInfo *data);
	KonqSidebarPlugin *loadModule(TQWidget *par,TQString &desktopName,TQString lib_name,ButtonInfo *bi);
	void readConfig();
	void initialCopy();
	void doLayout();
	void connectModule(TQObject *mod);
	void collapseExpandSidebar();
	bool doEnableActions();
	bool m_universalMode;
	bool m_userMovedSplitter;
private:
	KParts::ReadOnlyPart *m_partParent;
	KDockArea *m_area;
	KDockWidget *m_mainDockWidget;

	KMultiTabBar *m_buttonBar;
        TQPtrVector<ButtonInfo> m_buttons;
	TQHBoxLayout *m_layout;
	TDEPopupMenu *m_buttonPopup;
	TQPopupMenu *m_menu;
	TQGuardedPtr<ButtonInfo> m_activeModule;
	TQGuardedPtr<ButtonInfo> m_currentButton;
	
	TDEConfig *m_config;
	TQTimer m_configTimer;
	
	KURL m_storedUrl;
	int m_savedWidth;
	int m_latestViewed;

	bool m_hasStoredUrl;
	bool m_singleWidgetMode;
        bool m_immutableSingleWidgetMode;
	bool m_showTabsLeft;
        bool m_immutableShowTabsLeft;
	bool m_hideTabs;
        bool m_immutableHideTabs;
        bool m_disableConfig;
	bool m_showExtraButtons;
        bool m_immutableShowExtraButtons;
	bool m_somethingVisible;
	bool m_noUpdate;
	bool m_initial;

	TQString m_path;
	TQString m_relPath;
	TQString m_currentProfile;
	TQStringList m_visibleViews; // The views that are actually open
	TQStringList m_openViews; // The views that should be opened
	TQStringList m_restrictedViews;

signals:
	void panelHasBeenExpanded(bool);
};

#endif