libkonq Library API Documentation

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., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #ifndef __konqpopupmenu_h
00022 #define __konqpopupmenu_h
00023 
00024 #include <sys/types.h>
00025 
00026 #include <qpopupmenu.h>
00027 #include <qmap.h>
00028 #include <kaction.h>
00029 
00030 #include <qstringlist.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 QValueList<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 QPopupMenu, public KonqXMLGUIClient
00056 {
00057   Q_OBJECT
00058 public:
00059 
00064   typedef uint KonqPopupFlags;
00065   enum { NoFlags = 0,
00066          ShowProperties = 1,  // whether to show the "Properties" menu item
00067          IsLink = 2,          // HTML link. If set, we won't have cut/copy/paste, and we'll say "bookmark this link"
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          QWidget * parentWidget,
00093          bool showPropertiesAndFileType = true ) KDE_DEPRECATED;
00094 
00113   KonqPopupMenu( KBookmarkManager* manager,
00114                  const KFileItemList &items,
00115                  const KURL& viewURL,
00116                  KActionCollection & actions,
00117                  KNewMenu * newMenu,
00118                  QWidget * parentWidget,
00119                  KonqPopupFlags kpf,
00120                  KParts::BrowserExtension::PopupFlags f /*= KParts::BrowserExtension::DefaultPopupItems*/);
00121 
00125   ~KonqPopupMenu();
00126 
00131   void setURLTitle( const QString& urlTitle );
00132 
00133   class LIBKONQ_EXPORT ProtocolInfo {
00134    public:
00135     ProtocolInfo();
00136     bool supportsReading()  const;
00137     bool supportsWriting()  const;
00138     bool supportsDeleting() const;
00139     bool supportsMoving()   const;
00140     bool trashIncluded()    const;
00141    private:
00142     friend class KonqPopupMenu;
00143     bool m_Reading:1;
00144     bool m_Writing:1;
00145     bool m_Deleting:1;
00146     bool m_Moving:1;
00147     bool m_TrashIncluded:1;
00148   };
00152   virtual KAction *action( const QDomElement &element ) const;
00153 
00154 
00155   virtual KActionCollection *actionCollection() const;
00156   QString mimeType( ) const;
00157   KURL url( ) const;
00158   KFileItemList fileItemList() const;
00159   KURL::List popupURLList( ) const;
00160   ProtocolInfo protocolInfo() const;
00161 
00162 public slots: // KDE4: why public?
00163   void slotPopupNewDir();
00164   void slotPopupNewView();
00165   void slotPopupEmptyTrashBin();
00166   void slotPopupRestoreTrashedItems();
00167   void slotPopupOpenWith();
00168   void slotPopupAddToBookmark();
00169   void slotRunService();
00170   void slotPopupMimeType();
00171   void slotPopupProperties();
00172   void slotOpenShareFileDialog();
00173 protected:
00174   KActionCollection &m_actions;
00175   KActionCollection m_ownActions;
00176 
00177 private:
00178   void init (QWidget * parentWidget, KonqPopupFlags kpf, KParts::BrowserExtension::PopupFlags itemFlags);
00179   void setup(KonqPopupFlags kpf);
00180   void addPlugins( );
00181   int  insertServicesSubmenus(const QMap<QString, ServiceList>& list, QDomElement& menu, bool isBuiltin);
00182   int  insertServices(const ServiceList& list, QDomElement& menu, bool isBuiltin);
00183   bool KIOSKAuthorizedAction(KConfig& cfg);
00184   KPropertiesDialog* showPropertiesDialog();
00185 
00186   class KonqPopupMenuPrivate;
00187   KonqPopupMenuPrivate *d;
00188   KNewMenu *m_pMenuNew;
00189   KURL m_sViewURL;
00190   QString m_sMimeType;
00191   KFileItemList m_lstItems;
00192   KURL::List m_lstPopupURLs;
00193   QMap<int,KService::Ptr> m_mapPopup;
00194   QMap<int,KDEDesktopMimeType::Service> m_mapPopupServices;
00195   bool m_bHandleEditOperations;
00196   KXMLGUIFactory *m_factory;
00197   KXMLGUIBuilder *m_builder;
00198   QString attrName;
00199   ProtocolInfo m_info;
00200   QPtrList<KonqPopupMenuPlugin> m_pluginList;
00201   KBookmarkManager* m_pManager;
00202 };
00203 
00204 class LIBKONQ_EXPORT KonqPopupMenuPlugin : public QObject, public KonqXMLGUIClient {
00205     Q_OBJECT
00206 public:
00214   KonqPopupMenuPlugin( KonqPopupMenu *_popup, const char *name ); // this should also be the parent
00215   virtual ~KonqPopupMenuPlugin ( );
00216 };
00217 
00218 #endif
00219 
KDE Logo
This file is part of the documentation for libkonq Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 13 19:27:50 2006 by doxygen 1.4.3 written by Dimitri van Heesch, © 1997-2003