summaryrefslogtreecommitdiffstats
path: root/kio/bookmarks/kbookmarkmenu_p.h
blob: 4ea245b1ad6dc60f1cfec2dbebdbf456063094b4 (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
//  -*- c-basic-offset:4; indent-tabs-mode:nil -*-
// vim: set ts=4 sts=4 sw=4 et:
/* This file is part of the KDE project
   Copyright (C) 2003 Alexander Kellett <lypanov@kde.org>

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

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef __kbookmarkmenu_p_h__
#define __kbookmarkmenu_p_h__

#include <sys/types.h>

#include <tqptrlist.h>
#include <tqptrstack.h>
#include <tqobject.h>
#include <tqlistview.h>

#include <kdialogbase.h>
#include <klocale.h>
#include <kaction.h>

#include "kbookmark.h"
#include "kbookmarkimporter.h"
#include "kbookmarkmanager.h"

class TQString;
class TQPopupMenu;
class TQPushButton;
class TQListView;
class KLineEdit;
class KBookmark;
class KBookmarkGroup;
class KAction;
class KActionMenu;
class KActionCollection;
class KBookmarkOwner;
class KBookmarkMenu;
class KBookmarkBar;
class KPopupMenu;

class KImportedBookmarksActionMenu : public KActionMenu {
  Q_OBJECT
  Q_PROPERTY( TQString type READ type WRITE setType )
  Q_PROPERTY( TQString location READ location WRITE setLocation )
public:
  const TQString type() const { return m_type; }
  void setType(const TQString &type) { m_type = type; }
  const TQString location() const { return m_location; }
  void setLocation(const TQString &location) { m_location = location; }
private:
  TQString m_type;
  TQString m_location;
public:
  KImportedBookmarksActionMenu( 
    const TQString &text, const TQString& sIconName,
    KActionCollection* parent, const char* name)
  : KActionMenu(text, sIconName, parent, name) {
     ;
  }
};

class KBookmarkActionMenu : public KActionMenu {
  Q_OBJECT
  Q_PROPERTY( TQString url READ url WRITE setUrl )
  Q_PROPERTY( TQString address READ address WRITE setAddress )
  Q_PROPERTY( bool readOnly READ readOnly WRITE setReadOnly )
public:
  const TQString url() const { return m_url; }
  void setUrl(const TQString &url) { m_url = url; }
  const TQString address() const { return m_address; }
  void setAddress(const TQString &address) { m_address = address; }
  bool readOnly() const { return m_readOnly; }
  void setReadOnly(bool readOnly) { m_readOnly = readOnly; }
private:
  TQString m_url;
  TQString m_address;
  bool m_readOnly;
public:
  KBookmarkActionMenu( 
    const TQString &text, const TQString& sIconName,
    KActionCollection* parent, const char* name)
  : KActionMenu(text, sIconName, parent, name) {
     ;
  }
};

class KBookmarkAction : public KAction {
  Q_OBJECT
  Q_PROPERTY( TQString url READ url WRITE setUrl )
  Q_PROPERTY( TQString address READ address WRITE setAddress )
public:
  const TQString url() const { return m_url; }
  void setUrl(const TQString &url) { m_url = url; }
  const TQString address() const { return m_address; }
  void setAddress(const TQString &address) { m_address = address; }
private:
  TQString m_url;
  TQString m_address;
public:
  // KDE4: remove
  KBookmarkAction(
    const TQString& text, const TQString& sIconName, const KShortcut& cut,
    const TQObject* receiver, const char* slot,
    KActionCollection* parent, const char* name)
  : KAction(text, sIconName, cut, receiver, slot, parent, name) {
  }
  KBookmarkAction(
    const TQString& text, const TQString& sIconName, const KShortcut& cut,
    KActionCollection* parent, const char* name)
  : KAction(text, sIconName, cut, parent, name) {
  }
};

class KBookmarkEditFields {
public:
  typedef enum { FolderFieldsSet, BookmarkFieldsSet } FieldsSet;
  KLineEdit * m_url;
  KLineEdit * m_title;
  KBookmarkEditFields(TQWidget *main, TQBoxLayout *vbox, FieldsSet isFolder);
  void setName(const TQString &str);
  void setLocation(const TQString &str);
};

class KBookmarkEditDialog : public KDialogBase
{
  Q_OBJECT

public:
  typedef enum { ModifyMode, InsertionMode } BookmarkEditType;

  KBookmarkEditDialog( const TQString& title, const TQString& url, KBookmarkManager *, BookmarkEditType editType, const TQString& address = TQString::null,
                       TQWidget * = 0, const char * = 0, const TQString& caption = i18n( "Add Bookmark" ) );

  TQString finalUrl() const;
  TQString finalTitle() const;
  TQString finalAddress() const;

protected slots:
  void slotOk();
  void slotCancel();
  void slotUser1();
  void slotDoubleClicked(TQListViewItem* item);

private:
  TQWidget * m_main;
  KBookmarkEditFields * m_fields;
  TQListView * m_folderTree;
  TQPushButton * m_button;
  KBookmarkManager * m_mgr;
  BookmarkEditType m_editType;
  TQString m_address;
};

class KBookmarkFolderTreeItem : public TQListViewItem
{
  // make this an accessor
  friend class KBookmarkFolderTree;
public:
  KBookmarkFolderTreeItem( TQListView *, const KBookmark & );
  KBookmarkFolderTreeItem( KBookmarkFolderTreeItem *, TQListViewItem *, const KBookmarkGroup & );
private:
  KBookmark m_bookmark;
};

class KBookmarkFolderTree
{
public:
  static TQListView* createTree( KBookmarkManager *, TQWidget * = 0, const char * = 0, const TQString& = TQString::null );
  static void fillTree( TQListView*, KBookmarkManager *, const TQString& = TQString::null );
  static TQString selectedAddress( TQListView* );
  static void setAddress( TQListView *, const TQString & );
};

class KBookmarkSettings 
{
public:
  bool m_advancedaddbookmark;
  bool m_contextmenu;
  bool m_quickactions;
  bool m_filteredtoolbar;
  static KBookmarkSettings *s_self;
  static void readSettings();
  static KBookmarkSettings *self();
};

class RMB
{
public:
  static void begin_rmb_action(KBookmarkMenu *);
  static void begin_rmb_action(KBookmarkBar *);
  bool invalid( int val );
  KBookmark atAddress(const TQString & address);
  void fillContextMenu( TQPopupMenu* contextMenu, const TQString & address, int val );
  void fillContextMenu2( TQPopupMenu* contextMenu, const TQString & address, int val );
  void slotRMBActionEditAt( int val );
  void slotRMBActionProperties( int val );
  void slotRMBActionInsert( int val );
  void slotRMBActionRemove( int val );
  void slotRMBActionCopyLocation( int val );
  void hidePopup();
public:
  TQObject *recv;
  KBookmarkManager *m_pManager;
  TQString s_highlightedAddress;
  TQString m_parentAddress;
  KBookmarkOwner *m_pOwner;
  TQWidget *m_parentMenu;
};

#endif