FileCreatePart Class Reference
FileCreatePart is a template manager and wizard system to assist with creation of new files. More...
#include <filecreate_part.h>
Inheritance diagram for FileCreatePart:


Public Slots | |
void | slotProjectOpened () |
void | slotProjectClosed () |
void | slotInitialize () |
void | slotGlobalInitialize () |
void | slotFiletypeSelected (const FileType *) |
Called when a file type is selected from the docked widget. | |
void | slotNewFile () |
Called when a new file is required - for example, from the "New.." menu action. | |
void | slotNewFilePopup (int pFileType) |
Called from KToolBarPopupMenu to request a new file action. | |
Public Member Functions | |
FileCreatePart (QObject *parent, const char *name, const QStringList &) | |
virtual | ~FileCreatePart () |
QPtrList< FileType > | getFileTypes () const |
Returns the list of available file types. | |
virtual KDevCreateFile::CreatedFile | createNewFile (QString ext=QString::null, QString dir=QString::null, QString name=QString::null, QString subtype=QString::null) |
Call this method to create a new file, within or without the project. | |
void | setShowSideTab (bool on) |
Show file creation friendly side tab, yes or no. | |
void | selectWidget (int widgetNumber) |
Selects a docked widget. | |
TypeChooser * | typeChooserWidget () const |
Returns the current type chooser as a TypeChooser* type. | |
QWidget * | typeChooserWidgetAsQWidget () const |
Returns the current type chooser as a QWidget* type. | |
FileType * | getType (const QString &ext, const QString subtype=QString::null) |
Finds the file type object for a given extension and optionally subtype. | |
FileType * | getEnabledType (const QString &ext, const QString subtype=QString::null) |
Finds the file type object for a given extension and optionally subtype. | |
Protected Slots | |
void | slotNoteFiletype (const FileType *filetype) |
void | slotAboutToShowNewPopupMenu () |
void | insertConfigWidget (const KDialogBase *dlg, QWidget *page, unsigned int) |
Private Member Functions | |
void | openCreatedFile (const KDevCreateFile::CreatedFile &createdFile) |
If a file has been successfully created, open it. | |
int | readTypes (const QDomDocument &dom, QPtrList< FileType > &m_filetypes, bool enable) |
Reads in file type definitions from a config DOM and adds them to the file type list. | |
void | addFileType (const QString &filename) |
Add a file type. | |
bool | setWidget (TypeChooser *widget) |
Set the current widget. | |
void | refresh () |
Refreshes the widget in use - i.e. | |
Private Attributes | |
int | m_selectedWidget |
The number (index to m_availableWidgets) of the widget currently in use, or -1 if none. | |
QPtrList< FileType > | m_filetypes |
List of file types from which the user can choose. | |
TypeChooser * | m_availableWidgets [2] |
List of available chooser widgets. | |
int | m_numWidgets |
Number of chooser widgets. | |
const FileType * | m_filedialogFiletype |
The file type selected by the new file dialog, if appropriate. | |
bool | m_useSideTab |
ConfigWidgetProxy * | _configProxy |
KPopupMenu * | m_newPopupMenu |
QPtrList< KPopupMenu > * | m_subPopups |
Friends | |
class | FCConfigWidget |
Detailed Description
FileCreatePart is a template manager and wizard system to assist with creation of new files.Assists with creation of new files.
For those who want to look beyond the GUI, the following illustrates the XML to configure the FileCreate part for a project. It simply consists of a list of filetypes that the user may wish to create for a particular project. At present, the "create" attribute is ignored.
The file create part looks for a file template called @ext (i.e. the value of the ext attribute) in the *project's* templates directory (see the PyQT appwizard template for an example).
For subtypes, it looks for a template called @ext-@ref, so in the example below the following files would need to be present in the project's templates directory:
py ui ui-dialog ui-mainwin
Example XML:
<kdevfilecreate>
<filetypes>
<type ext="py" name="Python" create="template"/>
<type ext="ui" name="QT Designer" create="template">
<subtype ref="dialog" name="Dialog"/>
<subtype ref="mainwin" name="Main window"/>
</type>
</filetypes>
</kdevfilecreate>
You can also use global template definitions supplied with the FileCreate part:
<kdevfilecreate>
<useglobaltypes>
<type ext="ui" />
</useglobaltypes>
<filetypes>
<type ext="py" name="Python" create="template"/>
</filetypes>
</kdevfilecreate>
If a type has subtypes, and no subtypes are specified, then all subtypes are assumed to be required (as in the example above). Otherwise, specific subtypes should be specified:
<useglobaltypes>
<type ext="ui">
<subtype ref="dialog"/>
</type>
</useglobaltypes>
Usually, this XML forms part of the base .kdevelop file created by the appwizard.
- Feature(s):
- friendly sidebar listing the types of new file that can be created for your project
configurable per-project file types and global file types
- Bug:
- bugs in file create component at Bugzilla database
Arrangement of text in sidebar is not always perfect
Definition at line 39 of file filecreate_part.h.
Constructor & Destructor Documentation
|
Definition at line 60 of file filecreate_part.cpp. References GLOBALSETTINGSPAGE, KToolBarPopupAction::popupMenu(), PROJECTSETTINGSPAGE, KAction::setToolTip(), and KAction::setWhatsThis(). |
|
Definition at line 97 of file filecreate_part.cpp. References m_newPopupMenu. |
Member Function Documentation
|
Add a file type.
Definition at line 244 of file filecreate_part.cpp. References getType(), m_filetypes, FileCreate::FileType::setCreateMethod(), FileCreate::FileType::setEnabled(), FileCreate::FileType::setExt(), and FileCreate::FileType::setName(). Referenced by slotInitialize(). |
|
|
Finds the file type object for a given extension and optionally subtype. You can omit the subtype and specify the extension as ext-subtype if you wish. Returns only enabled type (i.e. used in the project). Definition at line 355 of file filecreate_part.cpp. References FileCreate::FileType::enabled(), FileCreate::FileType::ext(), getFileTypes(), FileCreate::FileType::subtypeRef(), and FileCreate::FileType::subtypes(). Referenced by createNewFile(). |
|
Returns the list of available file types.
Definition at line 51 of file filecreate_part.h. Referenced by getEnabledType(), getType(), FileCreate::ListWidget::refresh(), and FileCreate::FriendlyWidget::refresh(). |
|
Finds the file type object for a given extension and optionally subtype. You can omit the subtype and specify the extension as ext-subtype if you wish. Definition at line 328 of file filecreate_part.cpp. References FileCreate::FileType::ext(), getFileTypes(), FileCreate::FileType::subtypeRef(), and FileCreate::FileType::subtypes(). Referenced by addFileType(), FileCreate::FileDialog::slotActionTextChanged(), and slotInitialize(). |
|
Definition at line 116 of file filecreate_part.cpp. References FCConfigWidget, GLOBALSETTINGSPAGE, k_funcinfo, kdDebug(), and PROJECTSETTINGSPAGE. |
|
If a file has been successfully created, open it.
Definition at line 275 of file filecreate_part.cpp. References KDevCreateFile::CreatedFile::dir, KDevPartController::editDocument(), KDevCreateFile::CreatedFile::filename, KDevPlugin::partController(), KDevPlugin::project(), and KDevCreateFile::CreatedFile::status. Referenced by slotFiletypeSelected(), and slotNewFile(). |
|
Reads in file type definitions from a config DOM and adds them to the file type list. If enable is true, sets them all to enabled=true by default. Definition at line 282 of file filecreate_part.cpp. References FileCreate::FileType::addSubtype(), FileCreate::FileType::createMethod(), DomUtil::elementByPath(), FileCreate::FileType::ext(), kdDebug(), FileCreate::FileType::name(), FileCreate::FileType::setCreateMethod(), FileCreate::FileType::setDescr(), FileCreate::FileType::setEnabled(), FileCreate::FileType::setExt(), FileCreate::FileType::setIcon(), FileCreate::FileType::setName(), FileCreate::FileType::setSubtypeRef(), and text(). Referenced by FCConfigWidget::loadGlobalConfig(), FCConfigWidget::loadProjectConfig(), slotGlobalInitialize(), and slotInitialize(). |
|
Refreshes the widget in use - i.e. updates list of filetypes in the widget. Definition at line 171 of file filecreate_part.cpp. References FileCreate::TypeChooser::refresh(), and typeChooserWidget(). Referenced by slotGlobalInitialize(), slotInitialize(), and slotProjectClosed(). |
|
Selects a docked widget.
Definition at line 138 of file filecreate_part.cpp. References m_availableWidgets, m_selectedWidget, and setWidget(). Referenced by setShowSideTab(). |
|
Show file creation friendly side tab, yes or no.
Definition at line 493 of file filecreate_part.cpp. References selectWidget(). Referenced by FCConfigWidget::accept(), slotGlobalInitialize(), and slotInitialize(). |
|
Set the current widget. Argument of null sets no widget. Definition at line 146 of file filecreate_part.cpp. References KDevMainWindow::embedSelectView(), kdDebug(), kdWarning(), KDevPlugin::mainWindow(), KDevMainWindow::removeView(), FileCreate::TypeChooser::signaller(), slotFiletypeSelected(), and typeChooserWidget(). Referenced by selectWidget(). |
|
Definition at line 175 of file filecreate_part.cpp. References FileCreate::FileType::enabled(), FileCreate::FileType::icon(), KGlobal::iconLoader(), KIconLoader::loadIcon(), m_filetypes, m_newPopupMenu, m_subPopups, FileCreate::FileType::name(), slotNewFilePopup(), and FileCreate::FileType::subtypes(). |
|
Called when a file type is selected from the docked widget.
Definition at line 262 of file filecreate_part.cpp. References createNewFile(), FileCreate::FileType::ext(), openCreatedFile(), KDevPlugin::project(), and FileCreate::FileType::subtypeRef(). Referenced by setWidget(), and slotNewFilePopup(). |
|
Definition at line 575 of file filecreate_part.cpp. References DomUtil::elementByPath(), kdDebug(), m_filetypes, m_useSideTab, DomUtil::openDOMFile(), readTypes(), refresh(), and setShowSideTab(). Referenced by slotInitialize(), and slotProjectClosed(). |
|
Definition at line 502 of file filecreate_part.cpp. References addFileType(), DomUtil::elementByPath(), getType(), m_filetypes, m_useSideTab, KDevPlugin::project(), KDevPlugin::projectDom(), readTypes(), refresh(), FileCreate::FileType::setEnabled(), setShowSideTab(), FileCreate::FileType::setSubtypesEnabled(), slotGlobalInitialize(), and FileCreate::FileType::subtypes(). Referenced by slotProjectOpened(). |
|
Called when a new file is required - for example, from the "New.." menu action.
Definition at line 235 of file filecreate_part.cpp. References createNewFile(), and openCreatedFile(). |
|
Called from KToolBarPopupMenu to request a new file action.
Definition at line 229 of file filecreate_part.cpp. References slotFiletypeSelected(). Referenced by slotAboutToShowNewPopupMenu(). |
|
Definition at line 497 of file filecreate_part.cpp. References FileCreate::FileType::ext(), kdDebug(), and m_filedialogFiletype. |
|
Definition at line 256 of file filecreate_part.cpp. References m_filetypes, refresh(), and slotGlobalInitialize(). |
|
Definition at line 240 of file filecreate_part.cpp. References slotInitialize(). Referenced by FCConfigWidget::accept(). |
|
Returns the current type chooser as a TypeChooser* type.
Definition at line 77 of file filecreate_part.h. References m_availableWidgets, and m_selectedWidget. Referenced by refresh(), setWidget(), and typeChooserWidgetAsQWidget(). |
|
Returns the current type chooser as a QWidget* type.
Definition at line 85 of file filecreate_part.h. References typeChooserWidget(). |
Friends And Related Function Documentation
|
Definition at line 43 of file filecreate_part.h. Referenced by insertConfigWidget(). |
Member Data Documentation
|
Definition at line 185 of file filecreate_part.h. |
|
List of available chooser widgets.
Definition at line 162 of file filecreate_part.h. Referenced by selectWidget(), and typeChooserWidget(). |
|
The file type selected by the new file dialog, if appropriate.
Definition at line 182 of file filecreate_part.h. Referenced by slotNoteFiletype(). |
|
List of file types from which the user can choose.
Definition at line 157 of file filecreate_part.h. Referenced by FCConfigWidget::accept(), addFileType(), createNewFile(), slotAboutToShowNewPopupMenu(), slotGlobalInitialize(), slotInitialize(), and slotProjectClosed(). |
|
Definition at line 187 of file filecreate_part.h. Referenced by slotAboutToShowNewPopupMenu(), and ~FileCreatePart(). |
|
Number of chooser widgets.
Definition at line 167 of file filecreate_part.h. |
|
The number (index to m_availableWidgets) of the widget currently in use, or -1 if none.
Definition at line 152 of file filecreate_part.h. Referenced by selectWidget(), and typeChooserWidget(). |
|
Definition at line 188 of file filecreate_part.h. Referenced by slotAboutToShowNewPopupMenu(). |
|
Definition at line 184 of file filecreate_part.h. Referenced by FCConfigWidget::accept(), FCConfigWidget::FCConfigWidget(), FCConfigWidget::saveGlobalConfig(), slotGlobalInitialize(), and slotInitialize(). |
The documentation for this class was generated from the following files:
- parts/filecreate/filecreate_part.h
- parts/filecreate/filecreate_part.cpp