KIO
kbookmarkmenu.h
Go to the documentation of this file.
00001 // -*- c-basic-offset:4; indent-tabs-mode:nil -*- 00002 // vim: set ts=4 sts=4 sw=4 et: 00003 /* This file is part of the KDE project 00004 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 00005 Copyright (C) 2006 Daniel Teske <teske@squorn.de> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef __kbookmarkmenu_h__ 00024 #define __kbookmarkmenu_h__ 00025 00026 #include <sys/types.h> 00027 00028 #include <QtCore/QObject> 00029 #include <QtCore/QStack> 00030 00031 #include <klocale.h> 00032 #include <kaction.h> 00033 #include <kactionmenu.h> 00034 #include <kicon.h> 00035 #include <krun.h> 00036 #include <kmenu.h> 00037 00038 #include "kbookmark.h" 00039 #include "kbookmarkmanager.h" 00040 00041 class QString; 00042 class QMenu; 00043 class KBookmark; 00044 class KAction; 00045 class QAction; 00046 class KActionMenu; 00047 class KActionCollection; 00048 class KBookmarkOwner; 00049 class KBookmarkMenu; 00050 class KMenu; 00051 class KBookmarkActionInterface; 00052 00053 class KBookmarkMenuPrivate; // Not implemented 00054 00055 namespace KIO { class Job; } 00056 00076 class KIO_EXPORT KBookmarkMenu : public QObject 00077 { 00078 Q_OBJECT 00079 public: 00095 KBookmarkMenu( KBookmarkManager* mgr, KBookmarkOwner * owner, KMenu * parentMenu, KActionCollection *collec); 00096 00103 KBookmarkMenu( KBookmarkManager* mgr, KBookmarkOwner * owner, 00104 KMenu * parentMenu, const QString & parentAddress); 00105 00106 ~KBookmarkMenu(); 00107 00112 void ensureUpToDate(); 00113 00114 public Q_SLOTS: 00115 // public for KonqBookmarkBar 00116 void slotBookmarksChanged( const QString & ); 00117 00118 protected Q_SLOTS: 00119 void slotAboutToShow(); 00120 void slotAddBookmarksList(); 00121 void slotAddBookmark(); 00122 void slotNewFolder(); 00123 void slotOpenFolderInTabs(); 00124 00125 protected: 00126 virtual void clear(); 00127 virtual void refill(); 00128 virtual QAction* actionForBookmark(const KBookmark &bm); 00129 virtual KMenu * contextMenu(QAction * action ); 00130 00131 void addActions(); 00132 void fillBookmarks(); 00133 void addAddBookmark(); 00134 void addAddBookmarksList(); 00135 void addEditBookmarks(); 00136 void addNewFolder(); 00137 void addOpenInTabs(); 00138 00139 00140 bool isRoot() const; 00141 bool isDirty() const; 00142 00146 QString parentAddress() const; 00147 00148 KBookmarkManager * manager() const; 00149 KBookmarkOwner * owner() const; 00154 KMenu * parentMenu() const; 00155 00159 QList<KBookmarkMenu *> m_lstSubMenus; 00160 00161 // This is used to "export" our actions into an actionlist 00162 // we got in the constructor. So that the program can show our 00163 // actions in their shortcut dialog 00164 KActionCollection * m_actionCollection; 00168 QList<QAction *> m_actions; 00169 00170 00171 private Q_SLOTS: 00172 void slotCustomContextMenu( const QPoint & ); 00173 00174 private: 00175 KBookmarkMenuPrivate* d; 00176 00177 bool m_bIsRoot; 00178 bool m_bDirty; 00179 KBookmarkManager * m_pManager; 00180 KBookmarkOwner * m_pOwner; 00181 00182 KMenu * m_parentMenu; 00183 00184 private: 00185 QString m_parentAddress; 00186 }; 00187 00188 class KIO_EXPORT KBookmarkContextMenu : public KMenu 00189 { 00190 Q_OBJECT 00191 00192 public: 00193 KBookmarkContextMenu(const KBookmark & bm, KBookmarkManager * manager, KBookmarkOwner *owner, QWidget * parent = 0); 00194 virtual ~KBookmarkContextMenu(); 00195 virtual void addActions(); 00196 00197 public Q_SLOTS: 00198 void slotEditAt(); 00199 void slotProperties(); 00200 void slotInsert(); 00201 void slotRemove(); 00202 void slotCopyLocation(); 00203 void slotOpenFolderInTabs(); 00204 00205 protected: 00206 void addBookmark(); 00207 void addFolderActions(); 00208 void addProperties(); 00209 void addBookmarkActions(); 00210 void addOpenFolderInTabs(); 00211 00212 KBookmarkManager * manager() const; 00213 KBookmarkOwner * owner() const; 00214 KBookmark bookmark() const; 00215 00216 private Q_SLOTS: 00217 void slotAboutToShow(); 00218 00219 private: 00220 KBookmark bm; 00221 KBookmarkManager * m_pManager; 00222 KBookmarkOwner * m_pOwner; 00223 }; 00224 00225 class KIO_EXPORT KBookmarkActionInterface 00226 { 00227 public: 00228 KBookmarkActionInterface(const KBookmark &bk); 00229 virtual ~KBookmarkActionInterface(); 00230 const KBookmark bookmark() const; 00231 private: 00232 KBookmark bm; 00233 }; 00234 00235 /*** 00236 * A wrapper around KActionMenu to provide a nice constructor for bookmark groups. 00237 * 00238 */ 00239 00240 class KIO_EXPORT KBookmarkActionMenu : public KActionMenu, public KBookmarkActionInterface 00241 { 00242 public: 00243 KBookmarkActionMenu(const KBookmark &bm, QObject *parent); 00244 KBookmarkActionMenu(const KBookmark &bm, const QString & text, QObject *parent); 00245 virtual ~KBookmarkActionMenu(); 00246 }; 00247 00248 /*** 00249 * This class is a KAction for bookmarks. 00250 * It provides a nice constructor. 00251 * And on triggered uses the owner to open the bookmark. 00252 * 00253 */ 00254 00255 class KIO_EXPORT KBookmarkAction : public KAction, public KBookmarkActionInterface 00256 { 00257 Q_OBJECT 00258 public: 00259 KBookmarkAction(const KBookmark &bk, KBookmarkOwner* owner, QObject *parent); 00260 virtual ~KBookmarkAction(); 00261 00262 public Q_SLOTS: 00263 void slotSelected(Qt::MouseButtons mb, Qt::KeyboardModifiers km); 00264 00265 private: 00266 KBookmarkOwner* m_pOwner; 00267 }; 00268 00269 #endif
KDE 4.6 API Reference