KDevelop API Documentation

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:

KDevCreateFile KDevPlugin QObject KXMLGUIClient List of all members.

Public Slots

void slotProjectOpened ()
void slotProjectClosed ()
void slotInitialize ()
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.


Public Member Functions

 FileCreatePart (QObject *parent, const char *name, const QStringList &)
virtual ~FileCreatePart ()
QPtrList< FileTypegetFileTypes () 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.

TypeChoosertypeChooserWidget () const
 Returns the current type chooser as a TypeChooser* type.

QWidgettypeChooserWidgetAsQWidget () const
 Returns the current type chooser as a QWidget* type.

FileTypegetType (const QString &ext, const QString subtype=QString::null)
 Finds the file type object for a given extension and optionally subtype.

FileTypegetEnabledType (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 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< FileTypem_filetypes
 List of file types from which the user can choose.

TypeChooserm_availableWidgets [2]
 List of available chooser widgets.

int m_numWidgets
 Number of chooser widgets.

const FileTypem_filedialogFiletype
 The file type selected by the new file dialog, if appropriate.

bool m_useSideTab
ConfigWidgetProxy_configProxy

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.

Author(s):
Julian Rockey

Alexander Dymo

Maintainer(s):
Julian Rockey

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 37 of file filecreate_part.h.


Constructor & Destructor Documentation

FileCreatePart::FileCreatePart QObject parent,
const char *  name,
const QStringList
 

Definition at line 57 of file filecreate_part.cpp.

References GLOBALSETTINGSPAGE, KStdAction::openNew(), PROJECTSETTINGSPAGE, KAction::setToolTip(), and KAction::setWhatsThis().

FileCreatePart::~FileCreatePart  )  [virtual]
 

Definition at line 89 of file filecreate_part.cpp.

References _configProxy, m_availableWidgets, m_numWidgets, KDevPlugin::mainWindow(), and KDevMainWindow::removeView().


Member Function Documentation

void FileCreatePart::addFileType const QString filename  )  [private]
 

Add a file type.

Definition at line 171 of file filecreate_part.cpp.

References addFileType(), getType(), m_filetypes, FileCreate::FileType::setCreateMethod(), FileCreate::FileType::setEnabled(), FileCreate::FileType::setExt(), and FileCreate::FileType::setName().

Referenced by addFileType(), and slotInitialize().

KDevCreateFile::CreatedFile FileCreatePart::createNewFile QString  ext = QString::null,
QString  dir = QString::null,
QString  name = QString::null,
QString  subtype = QString::null
[virtual]
 

Call this method to create a new file, within or without the project.

Supply as much information as you know. Leave what you don't know as QString::null. The user will be prompted as necessary for the missing information, and the file created, and added to the project as necessary.

Implements KDevCreateFile.

Definition at line 309 of file filecreate_part.cpp.

References KDevProject::activeDirectory(), KDevProject::addFile(), FileCreate::NewFileChooser::addToProject(), KDevCreateFile::CreatedFile::addToProject, createNewFile(), KDevCreateFile::CreatedFile::dir, URLUtil::directory(), KDevPartController::editDocument(), endl(), FileCreate::FileType::ext(), KDevCreateFile::CreatedFile::filename, URLUtil::filename(), getEnabledType(), KURL::isParentOf(), kdDebug(), m_filetypes, KDevPlugin::partController(), KURL::path(), KDevPlugin::project(), URLUtil::relativePath(), FileCreate::NewFileChooser::selectedType(), FileCreate::NewFileChooser::setCurrent(), FileCreate::NewFileChooser::setDirectory(), FileCreate::NewFileChooser::setFileTypes(), FileCreate::NewFileChooser::setName(), KURL::setPath(), KDevCreateFile::CreatedFile::status, FileCreate::FileType::subtypeRef(), and FileCreate::NewFileChooser::url().

Referenced by createNewFile(), slotFiletypeSelected(), and slotNewFile().

FileType * FileCreatePart::getEnabledType const QString ext,
const QString  subtype = QString::null
 

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 280 of file filecreate_part.cpp.

References FileCreate::FileType::enabled(), FileCreate::FileType::ext(), getEnabledType(), getFileTypes(), FileCreate::FileType::subtypeRef(), and FileCreate::FileType::subtypes().

Referenced by createNewFile(), and getEnabledType().

QPtrList<FileType> FileCreatePart::getFileTypes  )  const [inline]
 

Returns the list of available file types.

Definition at line 49 of file filecreate_part.h.

References m_filetypes.

Referenced by getEnabledType(), getType(), FileCreate::ListWidget::refresh(), and FileCreate::FriendlyWidget::refresh().

FileType * FileCreatePart::getType const QString ext,
const QString  subtype = QString::null
 

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 253 of file filecreate_part.cpp.

References FileCreate::FileType::ext(), getFileTypes(), getType(), FileCreate::FileType::subtypeRef(), and FileCreate::FileType::subtypes().

Referenced by addFileType(), getType(), FileCreate::FileDialog::slotActionTextChanged(), and slotInitialize().

void FileCreatePart::insertConfigWidget const KDialogBase dlg,
QWidget page,
unsigned  int
[protected, slot]
 

Definition at line 103 of file filecreate_part.cpp.

References endl(), GLOBALSETTINGSPAGE, insertConfigWidget(), k_funcinfo, kdDebug(), and PROJECTSETTINGSPAGE.

Referenced by insertConfigWidget().

void FileCreatePart::openCreatedFile const KDevCreateFile::CreatedFile createdFile  )  [private]
 

If a file has been successfully created, open it.

Definition at line 200 of file filecreate_part.cpp.

References KDevCreateFile::CreatedFile::dir, KDevPartController::editDocument(), KDevCreateFile::CreatedFile::filename, openCreatedFile(), KDevPlugin::partController(), KDevPlugin::project(), and KDevCreateFile::CreatedFile::status.

Referenced by openCreatedFile(), slotFiletypeSelected(), and slotNewFile().

int FileCreatePart::readTypes const QDomDocument dom,
QPtrList< FileType > &  m_filetypes,
bool  enable
[private]
 

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 207 of file filecreate_part.cpp.

References FileCreate::FileType::addSubtype(), FileCreate::FileType::createMethod(), endl(), FileCreate::FileType::ext(), kdDebug(), FileCreate::FileType::name(), readTypes(), 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(), readTypes(), and slotInitialize().

void FileCreatePart::refresh  )  [private]
 

Refreshes the widget in use - i.e.

updates list of filetypes in the widget.

Definition at line 158 of file filecreate_part.cpp.

References FileCreate::TypeChooser::refresh(), and typeChooserWidget().

Referenced by slotInitialize(), and slotProjectClosed().

void FileCreatePart::selectWidget int  widgetNumber  ) 
 

Selects a docked widget.

Definition at line 125 of file filecreate_part.cpp.

References m_availableWidgets, m_numWidgets, m_selectedWidget, selectWidget(), and setWidget().

Referenced by selectWidget(), and setShowSideTab().

void FileCreatePart::setShowSideTab bool  on  ) 
 

Show file creation friendly side tab, yes or no.

Definition at line 427 of file filecreate_part.cpp.

References selectWidget(), and setShowSideTab().

Referenced by FCConfigWidget::accept(), setShowSideTab(), and slotInitialize().

bool FileCreatePart::setWidget TypeChooser widget  )  [private]
 

Set the current widget.

Argument of null sets no widget.

Definition at line 133 of file filecreate_part.cpp.

References KDevMainWindow::embedSelectView(), endl(), kdDebug(), kdWarning(), KDevPlugin::mainWindow(), KDevMainWindow::removeView(), setWidget(), FileCreate::TypeChooser::signaller(), slotFiletypeSelected(), and typeChooserWidget().

Referenced by selectWidget(), and setWidget().

void FileCreatePart::slotFiletypeSelected const FileType  )  [slot]
 

Called when a file type is selected from the docked widget.

Definition at line 188 of file filecreate_part.cpp.

References createNewFile(), FileCreate::FileType::ext(), KDevMainWindow::lowerView(), KDevPlugin::mainWindow(), openCreatedFile(), slotFiletypeSelected(), FileCreate::FileType::subtypeRef(), and typeChooserWidgetAsQWidget().

Referenced by setWidget(), and slotFiletypeSelected().

void FileCreatePart::slotInitialize  )  [slot]
 

Definition at line 436 of file filecreate_part.cpp.

References addFileType(), endl(), getType(), kdDebug(), m_filetypes, m_useSideTab, KDevPlugin::project(), KDevPlugin::projectDom(), readTypes(), refresh(), FileCreate::FileType::setEnabled(), setShowSideTab(), FileCreate::FileType::setSubtypesEnabled(), and FileCreate::FileType::subtypes().

Referenced by slotProjectOpened().

void FileCreatePart::slotNewFile  )  [slot]
 

Called when a new file is required - for example, from the "New.." menu action.

Definition at line 162 of file filecreate_part.cpp.

References createNewFile(), and openCreatedFile().

void FileCreatePart::slotNoteFiletype const FileType filetype  )  [protected, slot]
 

Definition at line 431 of file filecreate_part.cpp.

References endl(), FileCreate::FileType::ext(), kdDebug(), m_filedialogFiletype, and slotNoteFiletype().

Referenced by slotNoteFiletype().

void FileCreatePart::slotProjectClosed  )  [slot]
 

Definition at line 183 of file filecreate_part.cpp.

References m_filetypes, and refresh().

void FileCreatePart::slotProjectOpened  )  [slot]
 

Definition at line 167 of file filecreate_part.cpp.

References slotInitialize().

Referenced by FCConfigWidget::accept().

TypeChooser* FileCreatePart::typeChooserWidget  )  const [inline]
 

Returns the current type chooser as a TypeChooser* type.

Definition at line 75 of file filecreate_part.h.

References m_availableWidgets, m_numWidgets, and m_selectedWidget.

Referenced by refresh(), setWidget(), and typeChooserWidgetAsQWidget().

QWidget* FileCreatePart::typeChooserWidgetAsQWidget  )  const [inline]
 

Returns the current type chooser as a QWidget* type.

Definition at line 83 of file filecreate_part.h.

References typeChooserWidget().

Referenced by slotFiletypeSelected().


Member Data Documentation

ConfigWidgetProxy* FileCreatePart::_configProxy [private]
 

Definition at line 175 of file filecreate_part.h.

Referenced by ~FileCreatePart().

TypeChooser* FileCreatePart::m_availableWidgets[2] [private]
 

List of available chooser widgets.

Definition at line 152 of file filecreate_part.h.

Referenced by selectWidget(), typeChooserWidget(), and ~FileCreatePart().

const FileType* FileCreatePart::m_filedialogFiletype [private]
 

The file type selected by the new file dialog, if appropriate.

Definition at line 172 of file filecreate_part.h.

Referenced by slotNoteFiletype().

QPtrList<FileType> FileCreatePart::m_filetypes [private]
 

List of file types from which the user can choose.

Definition at line 147 of file filecreate_part.h.

Referenced by FCConfigWidget::accept(), addFileType(), createNewFile(), getFileTypes(), slotInitialize(), and slotProjectClosed().

int FileCreatePart::m_numWidgets [private]
 

Number of chooser widgets.

Definition at line 157 of file filecreate_part.h.

Referenced by selectWidget(), typeChooserWidget(), and ~FileCreatePart().

int FileCreatePart::m_selectedWidget [private]
 

The number (index to m_availableWidgets) of the widget currently in use, or -1 if none.

Definition at line 142 of file filecreate_part.h.

Referenced by selectWidget(), and typeChooserWidget().

bool FileCreatePart::m_useSideTab [private]
 

Definition at line 174 of file filecreate_part.h.

Referenced by FCConfigWidget::accept(), FCConfigWidget::FCConfigWidget(), FCConfigWidget::saveGlobalConfig(), and slotInitialize().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Oct 19 08:02:02 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003