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 <tdeaction.h> 00029 00030 #include <tqstringlist.h> 00031 00032 #include <tdefileitem.h> 00033 #include <kmimetype.h> // for KDEDesktopMimeType 00034 #include <libkonq_export.h> 00035 00036 #include <tdeparts/browserextension.h> 00037 #include <tdeio/jobclasses.h> 00038 00039 #include "konq_xmlguiclient.h" 00040 00041 typedef TQValueList<KDEDesktopMimeType::Service> ServiceList; 00042 00043 class KPropertiesDialog; 00044 class KNewMenu; 00045 class KService; 00046 class KonqPopupMenuPlugin; 00047 class KBookmarkManager; 00048 00049 // TODO KDE4: change base class to TDEPopupMenu, see TDEAction::slotPopupActivated() 00056 class LIBKONQ_EXPORT KonqPopupMenu : public TQPopupMenu, public KonqXMLGUIClient 00057 { 00058 Q_OBJECT 00059 public: 00060 00065 typedef uint KonqPopupFlags; 00066 enum { NoFlags = 0, 00067 ShowProperties = 1, 00068 IsLink = 2, 00069 ShowNewWindow = 4 }; 00070 // WARNING: bitfield. Next item is 8 00071 00077 KonqPopupMenu( KBookmarkManager* manager, 00078 const KFileItemList &items, 00079 KURL viewURL, 00080 TDEActionCollection & actions, 00081 KNewMenu * newMenu, 00082 bool showPropertiesAndFileType = true ) KDE_DEPRECATED; 00083 00088 KonqPopupMenu( KBookmarkManager* manager, 00089 const KFileItemList &items, 00090 KURL viewURL, 00091 TDEActionCollection & actions, 00092 KNewMenu * newMenu, 00093 TQWidget * parentWidget, 00094 bool showPropertiesAndFileType = true ) KDE_DEPRECATED; 00095 00116 KonqPopupMenu( KBookmarkManager* manager, 00117 const KFileItemList &items, 00118 const KURL& viewURL, 00119 TDEActionCollection & actions, 00120 KNewMenu * newMenu, 00121 TQWidget * parentWidget, 00122 KonqPopupFlags kpf, 00123 KParts::BrowserExtension::PopupFlags f /*= KParts::BrowserExtension::DefaultPopupItems*/); 00124 00128 ~KonqPopupMenu(); 00129 00134 void setURLTitle( const TQString& urlTitle ); 00135 00136 class LIBKONQ_EXPORT ProtocolInfo { 00137 public: 00138 ProtocolInfo(); 00139 bool supportsReading() const; 00140 bool supportsWriting() const; 00141 bool supportsDeleting() const; 00142 bool supportsMoving() const; 00143 bool trashIncluded() const; 00144 private: 00145 friend class KonqPopupMenu; 00146 bool m_Reading:1; 00147 bool m_Writing:1; 00148 bool m_Deleting:1; 00149 bool m_Moving:1; 00150 bool m_TrashIncluded:1; 00151 }; 00155 virtual TDEAction *action( const TQDomElement &element ) const; 00156 00157 00158 virtual TDEActionCollection *actionCollection() const; 00159 TQString mimeType( ) const; 00160 KURL url( ) const; 00161 KFileItemList fileItemList() const; 00162 KURL::List popupURLList( ) const; 00163 ProtocolInfo protocolInfo() const; 00164 00165 public slots: // KDE4: why public? 00166 void slotPopupNewDir(); 00167 void slotPopupNewView(); 00168 void slotPopupEmptyTrashBin(); 00169 void slotPopupRestoreTrashedItems(); 00170 void slotPopupOpenWith(); 00171 void slotPopupAddToBookmark(); 00172 void slotRunService(); 00173 void slotPopupMimeType(); 00174 void slotPopupProperties(); 00175 void slotOpenShareFileDialog(); 00176 00177 protected: 00178 TDEActionCollection &m_actions; 00179 TDEActionCollection m_ownActions; 00180 00181 private slots: 00182 void slotLocalURL( TDEIO::LocalURLJob *, const KURL&, bool ); 00183 void slotLocalURLKIODestroyed( ); 00184 00185 private: 00186 void init (TQWidget * parentWidget, KonqPopupFlags kpf, KParts::BrowserExtension::PopupFlags itemFlags); 00187 void setup(KonqPopupFlags kpf); 00188 void addPlugins( ); 00189 int insertServicesSubmenus(const TQMap<TQString, ServiceList>& list, TQDomElement& menu, bool isBuiltin); 00190 int insertServices(const ServiceList& list, TQDomElement& menu, bool isBuiltin); 00191 bool KIOSKAuthorizedAction(TDEConfig& cfg); 00192 KPropertiesDialog* showPropertiesDialog(); 00193 00194 class KonqPopupMenuPrivate; 00195 KonqPopupMenuPrivate *d; 00196 KNewMenu *m_pMenuNew; 00197 KURL m_sViewURL; 00198 TQString m_sMimeType; 00199 KFileItemList m_lstItems; 00200 KURL::List m_lstPopupURLs; 00201 TQMap<int,KService::Ptr> m_mapPopup; 00202 TQMap<int,KDEDesktopMimeType::Service> m_mapPopupServices; 00203 bool m_bHandleEditOperations; 00204 KXMLGUIFactory *m_factory; 00205 KXMLGUIBuilder *m_builder; 00206 TQString attrName; 00207 ProtocolInfo m_info; 00208 TQPtrList<KonqPopupMenuPlugin> m_pluginList; 00209 KBookmarkManager* m_pManager; 00210 }; 00211 00212 class LIBKONQ_EXPORT KonqPopupMenuPlugin : public TQObject, public KonqXMLGUIClient { 00213 Q_OBJECT 00214 public: 00222 KonqPopupMenuPlugin( KonqPopupMenu *_popup, const char *name ); // this should also be the parent 00223 virtual ~KonqPopupMenuPlugin ( ); 00224 }; 00225 00226 #endif 00227