1 /* This file is part of the KDE project
2 Copyright (C) 1998-2006 David Faure <faure@kde.org>
3 2003 Sven Leiber <s.leiber@web.de>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
23 #include <kactionmenu.h>
25 #include <libkonq_export.h>
28 namespace KIO
{ class Job
; }
30 class KActionCollection
;
33 * The 'New' submenu, both for the File menu and the RMB popup menu.
34 * (The same instance can be used by both).
35 * It fills the menu with 'Folder' and one item per installed template.
37 * To use this class, you need to connect aboutToShow() of the File menu
38 * with slotCheckUpToDate() and to call slotCheckUpToDate() before showing
41 * KNewMenu automatically updates the list of templates shown if installed templates
42 * are added/updated/deleted.
44 * @author David Faure <faure@kde.org>
45 * Ideas and code for the new template handling mechanism ('link' desktop files)
46 * from Christoph Pickart <pickart@iam.uni-bonn.de>
48 class LIBKONQ_EXPORT KNewMenu
: public KActionMenu
55 * @param parent the parent KActionCollection this KAction should be
57 * @param parentWidget the parent widget that will be the owner of
58 * this KNewMenu and that will take care of destroying this instance
59 * once the parentWidget itself got destroyed.
60 * @param name action name, when adding the action to the collection
62 KNewMenu( KActionCollection
* parent
, QWidget
* parentWidget
, const QString
& name
);
66 * Set the files the popup is shown for
67 * Call this before showing up the menu
69 void setPopupFiles(const KUrl::List
& files
);
73 * Checks if updating the list is necessary
74 * IMPORTANT : Call this in the slot for aboutToShow.
76 void slotCheckUpToDate();
80 * Called when the job that copied the template has finished.
81 * This method is virtual so that error handling can be reimplemented.
82 * Make sure to call the base class slotResult when !job->error() though.
84 virtual void slotResult( KJob
* job
);
88 * Called when New->* is clicked
90 void slotActionTriggered(QAction
*);
93 * Fills the templates list.
95 void slotFillTemplates();
101 * Fills the menu from the templates list.
106 * Opens the desktop files and completes the Entry list
107 * Input: the entry list. Output: the entry list ;-)
112 * Make the main menus on the startup.
118 * LINKTOTEMPLATE: a desktop file that points to a file or dir to copy
119 * TEMPLATE: a real file to copy as is (the KDE-1.x solution)
120 * SEPARATOR: to put a separator in the menu
121 * 0 means: not parsed, i.e. we don't know
123 enum { LINKTOTEMPLATE
= 1, TEMPLATE
, SEPARATOR
};
125 class KNewMenuPrivate
;