add more spacing
[personal-kdebase.git] / apps / lib / konq / knewmenu.h
blobe427ab1d34a48fff36aa6c25906e500ab3503615
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 parent the parent KActionCollection this KAction should be
56 * added to.
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 );
63 virtual ~KNewMenu();
65 /**
66 * Set the files the popup is shown for
67 * Call this before showing up the menu
69 void setPopupFiles(const KUrl::List& files);
71 public Q_SLOTS:
72 /**
73 * Checks if updating the list is necessary
74 * IMPORTANT : Call this in the slot for aboutToShow.
76 void slotCheckUpToDate();
78 protected Q_SLOTS:
79 /**
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 );
86 private Q_SLOTS:
87 /**
88 * Called when New->* is clicked
90 void slotActionTriggered(QAction*);
92 /**
93 * Fills the templates list.
95 void slotFillTemplates();
97 private:
98 void newDir();
101 * Fills the menu from the templates list.
103 void fillMenu();
106 * Opens the desktop files and completes the Entry list
107 * Input: the entry list. Output: the entry list ;-)
109 void parseFiles();
112 * Make the main menus on the startup.
114 void makeMenus();
117 * For entryType
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;
126 KNewMenuPrivate* d;
129 #endif