konq_popupmenu.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 1998, 1999 David Faure <faure@kde.org> 00003 Copyright (C) 2001 Holger Freyther <freyther@yahoo.com> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef __konqpopupmenu_h 00022 #define __konqpopupmenu_h 00023 00024 #include <sys/types.h> 00025 00026 #include <tqpopupmenu.h> 00027 #include <tqmap.h> 00028 #include <kaction.h> 00029 00030 #include <tqstringlist.h> 00031 00032 #include <kfileitem.h> 00033 #include <kmimetype.h> // for KDEDesktopMimeType 00034 #include <libkonq_export.h> 00035 00036 #include <kparts/browserextension.h> 00037 00038 #include "konq_xmlguiclient.h" 00039 00040 typedef TQValueList<KDEDesktopMimeType::Service> ServiceList; 00041 00042 class KPropertiesDialog; 00043 class KNewMenu; 00044 class KService; 00045 class KonqPopupMenuPlugin; 00046 class KBookmarkManager; 00047 00048 // TODO KDE4: change base class to KPopupMenu, see KAction::slotPopupActivated() 00055 class LIBKONQ_EXPORT KonqPopupMenu : public TQPopupMenu, public KonqXMLGUIClient 00056 { 00057 Q_OBJECT 00058 public: 00059 00064 typedef uint KonqPopupFlags; 00065 enum { NoFlags = 0, 00066 ShowProperties = 1, 00067 IsLink = 2, 00068 ShowNewWindow = 4 }; 00069 // WARNING: bitfield. Next item is 8 00070 00076 KonqPopupMenu( KBookmarkManager* manager, 00077 const KFileItemList &items, 00078 KURL viewURL, 00079 KActionCollection & actions, 00080 KNewMenu * newMenu, 00081 bool showPropertiesAndFileType = true ) KDE_DEPRECATED; 00082 00087 KonqPopupMenu( KBookmarkManager* manager, 00088 const KFileItemList &items, 00089 KURL viewURL, 00090 KActionCollection & actions, 00091 KNewMenu * newMenu, 00092 TQWidget * parentWidget, 00093 bool showPropertiesAndFileType = true ) KDE_DEPRECATED; 00094 00115 KonqPopupMenu( KBookmarkManager* manager, 00116 const KFileItemList &items, 00117 const KURL& viewURL, 00118 KActionCollection & actions, 00119 KNewMenu * newMenu, 00120 TQWidget * parentWidget, 00121 KonqPopupFlags kpf, 00122 KParts::BrowserExtension::PopupFlags f /*= KParts::BrowserExtension::DefaultPopupItems*/); 00123 00127 ~KonqPopupMenu(); 00128 00133 void setURLTitle( const TQString& urlTitle ); 00134 00135 class LIBKONQ_EXPORT ProtocolInfo { 00136 public: 00137 ProtocolInfo(); 00138 bool supportsReading() const; 00139 bool supportsWriting() const; 00140 bool supportsDeleting() const; 00141 bool supportsMoving() const; 00142 bool trashIncluded() const; 00143 private: 00144 friend class KonqPopupMenu; 00145 bool m_Reading:1; 00146 bool m_Writing:1; 00147 bool m_Deleting:1; 00148 bool m_Moving:1; 00149 bool m_TrashIncluded:1; 00150 }; 00154 virtual KAction *action( const TQDomElement &element ) const; 00155 00156 00157 virtual KActionCollection *actionCollection() const; 00158 TQString mimeType( ) const; 00159 KURL url( ) const; 00160 KFileItemList fileItemList() const; 00161 KURL::List popupURLList( ) const; 00162 ProtocolInfo protocolInfo() const; 00163 00164 public slots: // KDE4: why public? 00165 void slotPopupNewDir(); 00166 void slotPopupNewView(); 00167 void slotPopupEmptyTrashBin(); 00168 void slotPopupRestoreTrashedItems(); 00169 void slotPopupOpenWith(); 00170 void slotPopupAddToBookmark(); 00171 void slotRunService(); 00172 void slotPopupMimeType(); 00173 void slotPopupProperties(); 00174 void slotOpenShareFileDialog(); 00175 protected: 00176 KActionCollection &m_actions; 00177 KActionCollection m_ownActions; 00178 00179 private: 00180 void init (TQWidget * parentWidget, KonqPopupFlags kpf, KParts::BrowserExtension::PopupFlags itemFlags); 00181 void setup(KonqPopupFlags kpf); 00182 void addPlugins( ); 00183 int insertServicesSubmenus(const TQMap<TQString, ServiceList>& list, TQDomElement& menu, bool isBuiltin); 00184 int insertServices(const ServiceList& list, TQDomElement& menu, bool isBuiltin); 00185 bool KIOSKAuthorizedAction(KConfig& cfg); 00186 KPropertiesDialog* showPropertiesDialog(); 00187 00188 class KonqPopupMenuPrivate; 00189 KonqPopupMenuPrivate *d; 00190 KNewMenu *m_pMenuNew; 00191 KURL m_sViewURL; 00192 TQString m_sMimeType; 00193 KFileItemList m_lstItems; 00194 KURL::List m_lstPopupURLs; 00195 TQMap<int,KService::Ptr> m_mapPopup; 00196 TQMap<int,KDEDesktopMimeType::Service> m_mapPopupServices; 00197 bool m_bHandleEditOperations; 00198 KXMLGUIFactory *m_factory; 00199 KXMLGUIBuilder *m_builder; 00200 TQString attrName; 00201 ProtocolInfo m_info; 00202 TQPtrList<KonqPopupMenuPlugin> m_pluginList; 00203 KBookmarkManager* m_pManager; 00204 }; 00205 00206 class LIBKONQ_EXPORT KonqPopupMenuPlugin : public TQObject, public KonqXMLGUIClient { 00207 Q_OBJECT 00208 public: 00216 KonqPopupMenuPlugin( KonqPopupMenu *_popup, const char *name ); // this should also be the parent 00217 virtual ~KonqPopupMenuPlugin ( ); 00218 }; 00219 00220 #endif 00221