1
/* This file is part of the KDE project
2
Copyright (C) 2003 Julian Rockey <linux@jrockey.com>
3
Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
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 as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
Boston, MA 02111-1307, USA.
20
#ifndef KDEVCREATEFILE_H
21
#define KDEVCREATEFILE_H
25
#include <kdevplugin.h>
28
@file kdevcreatefile.h
29
File creation facility interface.
33
File creation facility interface.
35
An abstract class for all extensions that are responsible for file creation.
37
Instances that implement this interface are available through extension architecture:
39
KDevCreateFile *cf = extension<KDevCreateFile>("KDevelop/CreateFile");
46
@sa KDevPlugin::extension method documentation.
48
class KDevCreateFile : public KDevPlugin
52
/**File created with @ref KDevCreateFile implementation.*/
56
/**The status of a file.*/
58
STATUS_OK /**<File was successfuly created.*/,
59
STATUS_CANCELED /**<File was not created due to user intervention.*/,
60
STATUS_NOTCREATED /**<File was not created due to error.*/,
61
STATUS_NOTWITHINPROJECT /**<File was successfuly created but not added to a project.*/
65
Sets status to STATUS_NOTCREATED.*/
67
: status( STATUS_NOTCREATED ) {}
69
CreatedFile( const CreatedFile& source )
70
: dir( source.dir ), filename( source.filename ),
71
ext( source.ext ), subtype( source.subtype ),
72
status( source.status ), addToProject(false) {}
74
CreatedFile& operator = ( const CreatedFile& source )
77
filename = source.filename;
79
subtype = source.subtype;
80
status = source.status;
81
addToProject = source.addToProject;
85
bool operator == ( const CreatedFile& source ) const
89
filename == source.filename &&
91
subtype == source.subtype &&
92
status == source.status &&
93
addToProject == source.addToProject;
96
// this should be private
99
/**The name (without directory path).*/
101
/**The extension of a file. Extension defines a "type" of the file template
102
to use during file creation.*/
104
/**The subtype of a file. "Subtype" defines a file template to use when
105
there are several file templates for each extension.*/
109
/**true if the file should be added to a project.*/
117
@param info Important information about the plugin - plugin internal and generic
118
(GUI) name, description, a list of authors, etc. That information is used to show
119
plugin information in various places like "about application" dialog, plugin selector
120
dialog, etc. Plugin does not take ownership on info object, also its lifetime should
121
be equal to the lifetime of the plugin.
122
@param parent The parent object for the plugin. Parent object must implement @ref KDevApi
123
interface. Otherwise the plugin will not be constructed.
124
@param name The internal name which identifies the plugin.*/
125
KDevCreateFile(const KDevPluginInfo *info, QObject * parent = 0, const char * name = 0)
126
:KDevPlugin(info, parent, name) {}
128
/**Creates a new file, within or without the project.
129
Supply as much information as you know. Leave what you don't know as QString::null.
130
The user will be prompted as necessary for the missing information, and the
131
file created, and added to the project as necessary.
132
@param ext File extension (type).
133
@param dir The absolute path to a directory.
134
@param name The name of a file.
135
@param subtype The subtype, pass this only if an extension is not enough to find the
137
@return @ref CreatedFile instance with information about file and file creation process.*/
138
virtual CreatedFile createNewFile(QString ext = QString::null,
139
QString dir = QString::null,
140
QString name = QString::null,
141
QString subtype = QString::null) = 0;