Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / lib / konq / knewmenu.h
blob6646400c76331107f6c4b3f44d1dffbe34dd4eca
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.
20 #ifndef KNEWMENU_H
21 #define KNEWMENU_H
23 #include <kactionmenu.h>
24 #include <kurl.h>
25 #include <libkonq_export.h>
27 class KJob;
28 namespace KIO { class Job; }
30 class KActionCollection;
32 /**
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
39 * the RMB popupmenu.
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
50 Q_OBJECT
51 public:
53 /**
54 * Constructor
55 * @param name action name, when adding the action to the collection
57 KNewMenu( KActionCollection * parent, QWidget* parentWidget, const QString& name );
58 virtual ~KNewMenu();
60 /**
61 * Set the files the popup is shown for
62 * Call this before showing up the menu
64 void setPopupFiles(const KUrl::List& files);
66 public Q_SLOTS:
67 /**
68 * Checks if updating the list is necessary
69 * IMPORTANT : Call this in the slot for aboutToShow.
71 void slotCheckUpToDate();
73 protected Q_SLOTS:
74 /**
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 );
81 private Q_SLOTS:
82 /**
83 * Called when New->* is clicked
85 void slotActionTriggered(QAction*);
87 /**
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& );
95 private:
96 void newDir();
98 /**
99 * Fills the menu from the templates list.
101 void fillMenu();
104 * Opens the desktop files and completes the Entry list
105 * Input: the entry list. Output: the entry list ;-)
107 void parseFiles();
110 * Make the main menus on the startup.
112 void makeMenus();
115 * For entryType
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;
124 KNewMenuPrivate* d;
127 #endif