kbookmarkmenu.h
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 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef __kbookmarkmenu_h__ 00023 #define __kbookmarkmenu_h__ 00024 00025 #include <sys/types.h> 00026 00027 #include <tqptrlist.h> 00028 #include <tqptrstack.h> 00029 #include <tqobject.h> 00030 #include <tqlistview.h> 00031 00032 #include <kdialogbase.h> 00033 #include <tdelocale.h> 00034 #include <tdeaction.h> 00035 00036 #include "kbookmark.h" 00037 #include "kbookmarkmanager.h" 00038 00039 class TQString; 00040 class TQPopupMenu; 00041 class TQPushButton; 00042 class TQListView; 00043 class KLineEdit; 00044 class KBookmark; 00045 class KBookmarkGroup; 00046 class TDEAction; 00047 class TDEActionMenu; 00048 class TDEActionCollection; 00049 class KBookmarkOwner; 00050 class KBookmarkMenu; 00051 class TDEPopupMenu; 00052 00053 namespace TDEIO { class Job; } 00054 00079 class TDEIO_EXPORT KBookmarkMenu : public TQObject 00080 { 00081 Q_OBJECT 00082 friend class KBookmarkMenuNSImporter; 00083 friend class RMB; 00084 public: 00104 KBookmarkMenu( KBookmarkManager* mgr, 00105 KBookmarkOwner * owner, TDEPopupMenu * parentMenu, 00106 TDEActionCollection * collec, bool root, bool add = true, 00107 const TQString & parentAddress = "" ); 00108 00109 ~KBookmarkMenu(); 00110 00116 void fillBookmarkMenu(); 00117 00122 void ensureUpToDate(); 00123 00129 // TODO - transform into class 00130 struct DynMenuInfo { 00131 bool show; 00132 TQString location; 00133 TQString type; 00134 TQString name; 00135 class DynMenuInfoPrivate *d; 00136 }; 00137 00142 static DynMenuInfo showDynamicBookmarks( const TQString &id ); 00143 00152 static void setDynamicBookmarks( const TQString &id, const DynMenuInfo &info ); 00153 00158 static TQStringList dynamicBookmarksList(); 00159 00160 signals: 00161 void aboutToShowContextMenu( const KBookmark &, TQPopupMenu * ); 00165 void openBookmark( const TQString& url, TQt::ButtonState state ); 00166 00167 public slots: // public for bookmark bar 00168 void slotBookmarksChanged( const TQString & ); 00169 00170 protected slots: 00171 void slotAboutToShow(); 00172 void slotAboutToShowContextMenu( TDEPopupMenu *, int, TQPopupMenu * ); 00173 void slotActionHighlighted( TDEAction * ); 00174 00175 void slotRMBActionRemove( int ); 00176 void slotRMBActionInsert( int ); 00177 void slotRMBActionCopyLocation( int ); 00178 void slotRMBActionEditAt( int ); 00179 void slotRMBActionProperties( int ); 00180 00181 void slotBookmarkSelected(); 00185 void slotBookmarkSelected( TDEAction::ActivationReason reason, TQt::ButtonState state ); 00186 void slotAddBookmarksList(); 00187 void slotAddBookmark(); 00188 void slotNewFolder(); 00189 00193 void slotNSLoad(); 00194 00195 protected: 00196 KExtendedBookmarkOwner* extOwner(); 00197 void refill(); 00198 void addAddBookmark(); 00199 void addAddBookmarksList(); 00200 void addEditBookmarks(); 00201 void addNewFolder(); 00202 00203 void fillContextMenu( TQPopupMenu *, const TQString &, int ); 00204 00205 bool m_bIsRoot:1; 00206 bool m_bAddBookmark:1; 00207 bool m_bDirty:1; 00208 bool m_bNSBookmark:1; 00209 bool m_bAddShortcuts:1; 00210 00211 KBookmarkManager * m_pManager; 00212 KBookmarkOwner *m_pOwner; 00217 TDEPopupMenu * m_parentMenu; 00221 TQPtrList<KBookmarkMenu> m_lstSubMenus; 00222 TDEActionCollection * m_actionCollection; 00226 TQPtrList<TDEAction> m_actions; 00230 TQString m_parentAddress; 00231 00232 // TODO make non static! 00233 static TQString s_highlightedAddress; 00234 static TQString s_highlightedImportLocation; 00235 static TQString s_highlightedImportType; 00236 }; 00237 00241 class TDEIO_EXPORT KBookmarkMenuNSImporter : public TQObject 00242 { 00243 Q_OBJECT 00244 public: 00245 KBookmarkMenuNSImporter( KBookmarkManager* mgr, KBookmarkMenu * menu, TDEActionCollection * act ) : 00246 m_menu(menu), m_actionCollection(act), m_pManager(mgr) {} 00247 00248 void openNSBookmarks(); 00249 void openBookmarks( const TQString &location, const TQString &type ); 00250 void connectToImporter( const TQObject &importer ); 00251 00252 protected slots: 00253 void newBookmark( const TQString & text, const TQCString & url, const TQString & ); 00254 void newFolder( const TQString & text, bool, const TQString & ); 00255 void newSeparator(); 00256 void endFolder(); 00257 00258 protected: 00259 TQPtrStack<KBookmarkMenu> mstack; 00260 KBookmarkMenu * m_menu; 00261 TDEActionCollection * m_actionCollection; 00262 KBookmarkManager* m_pManager; 00263 }; 00264 00265 #endif