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 name action name, when adding the action to the collection
57 KNewMenu( KActionCollection
* parent
, QWidget
* parentWidget
, const QString
& name
);
61 * Set the files the popup is shown for
62 * Call this before showing up the menu
64 void setPopupFiles(const KUrl::List
& files
);
68 * Checks if updating the list is necessary
69 * IMPORTANT : Call this in the slot for aboutToShow.
71 void slotCheckUpToDate();
75 * Called when the job that copied the template has finished.
76 * This method is virtual so that error handling can be reimplemented.
77 * Make sure to call the base class slotResult when !job->error() though.
79 virtual void slotResult( KJob
* job
);
83 * Called when New->* is clicked
85 void slotActionTriggered(QAction
*);
88 * Fills the templates list.
90 void slotFillTemplates();
92 // Special case (filename conflict when creating a link=url file)
93 void slotRenamed( KIO::Job
*, const KUrl
&, const KUrl
& );
99 * Fills the menu from the templates list.
104 * Opens the desktop files and completes the Entry list
105 * Input: the entry list. Output: the entry list ;-)
110 * Make the main menus on the startup.
116 * LINKTOTEMPLATE: a desktop file that points to a file or dir to copy
117 * TEMPLATE: a real file to copy as is (the KDE-1.x solution)
118 * SEPARATOR: to put a separator in the menu
119 * 0 means: not parsed, i.e. we don't know
121 enum { LINKTOTEMPLATE
= 1, TEMPLATE
, SEPARATOR
};
123 class KNewMenuPrivate
;