#include <knewfilemenu.h>

Public Slots | |
| void | checkUpToDate () |
| void | createDirectory () |
Signals | |
| void | directoryCreated (const KUrl &url) |
| void | fileCreated (const KUrl &url) |
Public Member Functions | |
| KNewFileMenu (KActionCollection *collection, const QString &name, QObject *parent) | |
| virtual | ~KNewFileMenu () |
| bool | isModal () const |
| KUrl::List | popupFiles () const |
| void | setModal (bool modality) |
| void | setParentWidget (QWidget *parentWidget) |
| void | setPopupFiles (const KUrl::List &files) |
| void | setSupportedMimeTypes (const QStringList &mime) |
| void | setViewShowsHiddenFiles (bool b) |
| QStringList | supportedMimeTypes () const |
Protected Slots | |
| virtual void | slotResult (KJob *job) |
Detailed Description
The 'Create New' submenu, for creating files using templates (e.g.
"new HTML file") and directories.
The same instance can be used by both for the File menu and the RMB popup menu, in a file manager. This is also used in the file dialog's RMB menu.
To use this class, you need to connect aboutToShow() of the File menu with slotCheckUpToDate() and to call slotCheckUpToDate() before showing the RMB popupmenu.
KNewFileMenu automatically updates the list of templates shown if installed templates are added/updated/deleted.
- Since:
- 4.5
Constructor & Destructor Documentation
| KNewFileMenu::KNewFileMenu | ( | KActionCollection * | collection, |
| const QString & | name, | ||
| QObject * | parent | ||
| ) |
Constructor.
- Parameters:
-
collection the KActionCollection this KAction should be added to. name action name, when adding the action to the collection parent the parent object, for ownership. If the parent object is a widget, it will also used as parent widget for any dialogs that this class might show. Otherwise, call setParentWidget.
Definition at line 946 of file knewfilemenu.cpp.
| KNewFileMenu::~KNewFileMenu | ( | ) | [virtual] |
Destructor.
KNewMenu uses internally a globally shared cache, so that multiple instances of it don't need to parse the installed templates multiple times. Therefore you can safely create and delete KNewMenu instances without a performance issue.
Definition at line 963 of file knewfilemenu.cpp.
Member Function Documentation
| void KNewFileMenu::checkUpToDate | ( | ) | [slot] |
Checks if updating the list is necessary IMPORTANT : Call this in the slot for aboutToShow.
And while you're there, you probably want to call setViewShowsHiddenFiles ;)
Definition at line 969 of file knewfilemenu.cpp.
| void KNewFileMenu::createDirectory | ( | ) | [slot] |
Call this to create a new directory as if the user had done it using a popupmenu.
This is useful to make sure that creating a directory with a key shortcut (e.g. F10) triggers the exact same code as when using the New menu. Requirements: call setPopupFiles first, and keep this KNewFileMenu instance alive (the mkdir is async).
Definition at line 999 of file knewfilemenu.cpp.
| void KNewFileMenu::directoryCreated | ( | const KUrl & | url | ) | [signal] |
Emitted once the directory url has been successfully created.
| void KNewFileMenu::fileCreated | ( | const KUrl & | url | ) | [signal] |
Emitted once the file (or symlink) url has been successfully created.
| bool KNewFileMenu::isModal | ( | ) | const |
Returns the modality of dialogs.
Definition at line 1044 of file knewfilemenu.cpp.
| KUrl::List KNewFileMenu::popupFiles | ( | ) | const |
Returns the files that the popup is shown for.
Definition at line 1049 of file knewfilemenu.cpp.
| void KNewFileMenu::setModal | ( | bool | modality | ) |
Sets the modality of dialogs created by KNewFile.
Set to false if you do not want to block your application window when entering a new directory name i.e.
Definition at line 1054 of file knewfilemenu.cpp.
| void KNewFileMenu::setParentWidget | ( | QWidget * | parentWidget | ) |
Sets a parent widget for the dialogs shown by KNewFileMenu.
This is strongly recommended, for apps with a main window.
Definition at line 1078 of file knewfilemenu.cpp.
| void KNewFileMenu::setPopupFiles | ( | const KUrl::List & | files | ) |
Set the files the popup is shown for Call this before showing up the menu.
Definition at line 1059 of file knewfilemenu.cpp.
| void KNewFileMenu::setSupportedMimeTypes | ( | const QStringList & | mime | ) |
Only show the files in a given set of mimetypes.
This is useful in specialized applications (while file managers, on the other hand, want to show all mimetypes).
Definition at line 1083 of file knewfilemenu.cpp.
| void KNewFileMenu::setViewShowsHiddenFiles | ( | bool | b | ) |
Set if the directory view currently shows dot files.
Definition at line 1088 of file knewfilemenu.cpp.
| void KNewFileMenu::slotResult | ( | KJob * | job | ) | [protected, virtual, slot] |
Called when the job that copied the template has finished.
This method is virtual so that error handling can be reimplemented. Make sure to call the base class slotResult when !job->error() though.
Definition at line 1093 of file knewfilemenu.cpp.
| QStringList KNewFileMenu::supportedMimeTypes | ( | ) | const |
Returns the mimetypes set in supportedMimeTypes()
Definition at line 1123 of file knewfilemenu.cpp.
The documentation for this class was generated from the following files:
KDE 4.7 API Reference