You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
266 lines
7.6 KiB
266 lines
7.6 KiB
15 years ago
|
// -*- c-basic-offset:4; indent-tabs-mode:nil -*-
|
||
|
// vim: set ts=4 sts=4 sw=4 et:
|
||
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#ifndef __kbookmarkmenu_h__
|
||
|
#define __kbookmarkmenu_h__
|
||
|
|
||
|
#include <sys/types.h>
|
||
|
|
||
14 years ago
|
#include <tqptrlist.h>
|
||
|
#include <tqptrstack.h>
|
||
|
#include <tqobject.h>
|
||
|
#include <tqlistview.h>
|
||
15 years ago
|
|
||
|
#include <kdialogbase.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kaction.h>
|
||
|
|
||
|
#include "kbookmark.h"
|
||
|
#include "kbookmarkmanager.h"
|
||
|
|
||
14 years ago
|
class TQString;
|
||
|
class TQPopupMenu;
|
||
|
class TQPushButton;
|
||
|
class TQListView;
|
||
15 years ago
|
class KLineEdit;
|
||
|
class KBookmark;
|
||
|
class KBookmarkGroup;
|
||
|
class KAction;
|
||
|
class KActionMenu;
|
||
|
class KActionCollection;
|
||
|
class KBookmarkOwner;
|
||
|
class KBookmarkMenu;
|
||
|
class KPopupMenu;
|
||
|
|
||
12 years ago
|
namespace TDEIO { class Job; }
|
||
15 years ago
|
|
||
|
/**
|
||
|
* This class provides a bookmark menu. It is typically used in
|
||
|
* cooperation with KActionMenu but doesn't have to be.
|
||
|
*
|
||
|
* If you use this class by itself, then it will use KDE defaults for
|
||
|
* everything -- the bookmark path, bookmark editor, bookmark launcher..
|
||
|
* everything. These defaults reside in the classes
|
||
|
* KBookmarkOwner (editing bookmarks) and KBookmarkManager
|
||
|
* (almost everything else). If you wish to change the defaults in
|
||
|
* any way, you must reimplement and instantiate those classes
|
||
|
* <em>before</em> this class is ever called.
|
||
|
*
|
||
|
* Using this class is very simple:
|
||
|
*
|
||
|
* 1) Create a popup menu (either KActionMenu or KPopupMenu will do)
|
||
|
* 2) Instantiate a new KBookmarkMenu object using the above popup
|
||
|
* menu as a parameter
|
||
|
* 3) Insert your (now full) popup menu wherever you wish
|
||
|
*
|
||
|
* Again, if you wish to modify any defaults, the procedure is:
|
||
|
*
|
||
|
* 1a) Reimplement your own KBookmarkOwner
|
||
|
* 1b) Reimplement and instantiate your own KBookmarkManager
|
||
|
*/
|
||
12 years ago
|
class TDEIO_EXPORT KBookmarkMenu : public TQObject
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
|
friend class KBookmarkMenuNSImporter;
|
||
|
friend class RMB;
|
||
|
public:
|
||
|
/**
|
||
|
* Fills a bookmark menu
|
||
|
* (one instance of KBookmarkMenu is created for the toplevel menu,
|
||
|
* but also one per submenu).
|
||
|
*
|
||
|
* @param mgr The bookmark manager to use (i.e. for reading and writing)
|
||
|
* @param owner implementation of the KBookmarkOwner callback interface.
|
||
|
* @param parentMenu menu to be filled
|
||
|
* @param collec parent collection for the KActions.
|
||
|
* Only used for other menus than the toplevel one.
|
||
|
* @param root true for the toplevel menu
|
||
|
* @param add true to show the "Add Bookmark" and "New Folder" entries
|
||
|
* @param parentAddress the address of the group containing the items
|
||
|
* that we want to show.
|
||
|
* @see KBookmark::address.
|
||
|
* Be careful :
|
||
|
* A _null_ parentAddress denotes a NS-bookmark menu.
|
||
|
* An _empty_ parentAddress denotes the toplevel bookmark menu
|
||
|
*/
|
||
|
KBookmarkMenu( KBookmarkManager* mgr,
|
||
|
KBookmarkOwner * owner, KPopupMenu * parentMenu,
|
||
|
KActionCollection * collec, bool root, bool add = true,
|
||
14 years ago
|
const TQString & parentAddress = "" );
|
||
15 years ago
|
|
||
|
~KBookmarkMenu();
|
||
|
|
||
|
/**
|
||
|
* Even if you think you need to use this, you are probably wrong.
|
||
|
* It fills a bookmark menu starting a given KBookmark.
|
||
|
* This is public for KBookmarkBar.
|
||
|
*/
|
||
|
void fillBookmarkMenu();
|
||
|
|
||
|
/**
|
||
|
* Call ensureUpToDate() if you need KBookmarkMenu to adjust to its
|
||
|
* final size before it is executed.
|
||
|
**/
|
||
|
void ensureUpToDate();
|
||
|
|
||
|
/**
|
||
|
* Structure used for storing information about
|
||
|
* the dynamic menu setting
|
||
|
* @since 3.2
|
||
|
*/
|
||
|
// TODO - transform into class
|
||
|
struct DynMenuInfo {
|
||
|
bool show;
|
||
14 years ago
|
TQString location;
|
||
|
TQString type;
|
||
|
TQString name;
|
||
15 years ago
|
class DynMenuInfoPrivate *d;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* @return dynmenu info block for the given dynmenu name
|
||
|
* @since 3.2
|
||
|
*/
|
||
14 years ago
|
static DynMenuInfo showDynamicBookmarks( const TQString &id );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Shows an extra menu for the given bookmarks file and type.
|
||
|
* Upgrades from option inside XBEL to option in rc file
|
||
|
* on first call of this function.
|
||
|
* @param id the unique identification for the dynamic menu
|
||
|
* @param info a DynMenuInfo struct containing the to be added/modified data
|
||
|
* @since 3.2
|
||
|
*/
|
||
14 years ago
|
static void setDynamicBookmarks( const TQString &id, const DynMenuInfo &info );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return list of dynamic menu ids
|
||
|
* @since 3.2
|
||
|
*/
|
||
14 years ago
|
static TQStringList dynamicBookmarksList();
|
||
15 years ago
|
|
||
|
signals:
|
||
14 years ago
|
void aboutToShowContextMenu( const KBookmark &, TQPopupMenu * );
|
||
15 years ago
|
/**
|
||
|
* @since 3.4
|
||
|
*/
|
||
14 years ago
|
void openBookmark( const TQString& url, TQt::ButtonState state );
|
||
15 years ago
|
|
||
|
public slots: // public for bookmark bar
|
||
14 years ago
|
void slotBookmarksChanged( const TQString & );
|
||
15 years ago
|
|
||
|
protected slots:
|
||
|
void slotAboutToShow();
|
||
14 years ago
|
void slotAboutToShowContextMenu( KPopupMenu *, int, TQPopupMenu * );
|
||
15 years ago
|
void slotActionHighlighted( KAction * );
|
||
|
|
||
|
void slotRMBActionRemove( int );
|
||
|
void slotRMBActionInsert( int );
|
||
|
void slotRMBActionCopyLocation( int );
|
||
|
void slotRMBActionEditAt( int );
|
||
|
void slotRMBActionProperties( int );
|
||
|
|
||
|
void slotBookmarkSelected();
|
||
|
/**
|
||
|
* @ since 3.4
|
||
|
*/
|
||
14 years ago
|
void slotBookmarkSelected( KAction::ActivationReason reason, TQt::ButtonState state );
|
||
15 years ago
|
void slotAddBookmarksList();
|
||
|
void slotAddBookmark();
|
||
|
void slotNewFolder();
|
||
|
|
||
|
/**
|
||
|
* load Netscape's bookmarks
|
||
|
*/
|
||
|
void slotNSLoad();
|
||
|
|
||
|
protected:
|
||
|
KExtendedBookmarkOwner* extOwner();
|
||
|
void refill();
|
||
|
void addAddBookmark();
|
||
|
void addAddBookmarksList();
|
||
|
void addEditBookmarks();
|
||
|
void addNewFolder();
|
||
|
|
||
14 years ago
|
void fillContextMenu( TQPopupMenu *, const TQString &, int );
|
||
15 years ago
|
|
||
|
bool m_bIsRoot:1;
|
||
|
bool m_bAddBookmark:1;
|
||
|
bool m_bDirty:1;
|
||
|
bool m_bNSBookmark:1;
|
||
|
bool m_bAddShortcuts:1;
|
||
|
|
||
|
KBookmarkManager * m_pManager;
|
||
|
KBookmarkOwner *m_pOwner;
|
||
|
/**
|
||
|
* The menu in which we plug our actions.
|
||
|
* Supplied in the constructor.
|
||
|
*/
|
||
|
KPopupMenu * m_parentMenu;
|
||
|
/**
|
||
|
* List of our sub menus
|
||
|
*/
|
||
14 years ago
|
TQPtrList<KBookmarkMenu> m_lstSubMenus;
|
||
15 years ago
|
KActionCollection * m_actionCollection;
|
||
|
/**
|
||
|
* List of our actions.
|
||
|
*/
|
||
14 years ago
|
TQPtrList<KAction> m_actions;
|
||
15 years ago
|
/**
|
||
|
* Parent bookmark for this menu.
|
||
|
*/
|
||
14 years ago
|
TQString m_parentAddress;
|
||
15 years ago
|
|
||
|
// TODO make non static!
|
||
14 years ago
|
static TQString s_highlightedAddress;
|
||
|
static TQString s_highlightedImportLocation;
|
||
|
static TQString s_highlightedImportType;
|
||
15 years ago
|
};
|
||
|
|
||
|
/**
|
||
|
* A class connected to KNSBookmarkImporter, to fill KActionMenus.
|
||
|
*/
|
||
12 years ago
|
class TDEIO_EXPORT KBookmarkMenuNSImporter : public TQObject
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
KBookmarkMenuNSImporter( KBookmarkManager* mgr, KBookmarkMenu * menu, KActionCollection * act ) :
|
||
|
m_menu(menu), m_actionCollection(act), m_pManager(mgr) {}
|
||
|
|
||
|
void openNSBookmarks();
|
||
14 years ago
|
void openBookmarks( const TQString &location, const TQString &type );
|
||
|
void connectToImporter( const TQObject &importer );
|
||
15 years ago
|
|
||
|
protected slots:
|
||
14 years ago
|
void newBookmark( const TQString & text, const TQCString & url, const TQString & );
|
||
|
void newFolder( const TQString & text, bool, const TQString & );
|
||
15 years ago
|
void newSeparator();
|
||
|
void endFolder();
|
||
|
|
||
|
protected:
|
||
14 years ago
|
TQPtrStack<KBookmarkMenu> mstack;
|
||
15 years ago
|
KBookmarkMenu * m_menu;
|
||
|
KActionCollection * m_actionCollection;
|
||
|
KBookmarkManager* m_pManager;
|
||
|
};
|
||
|
|
||
|
#endif
|