~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to lib/interfaces/extensions/kdevcreatefile.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
4
 
 
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.
9
 
 
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.
14
 
 
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.
19
 
*/
20
 
#ifndef KDEVCREATEFILE_H
21
 
#define KDEVCREATEFILE_H
22
 
 
23
 
#include <qstring.h>
24
 
 
25
 
#include <kdevplugin.h>
26
 
 
27
 
/**
28
 
@file kdevcreatefile.h
29
 
File creation facility interface.
30
 
*/
31
 
 
32
 
/**
33
 
File creation facility interface.
34
 
 
35
 
An abstract class for all extensions that are responsible for file creation.
36
 
 
37
 
Instances that implement this interface are available through extension architecture:
38
 
@code
39
 
KDevCreateFile *cf = extension<KDevCreateFile>("KDevelop/CreateFile");
40
 
if (cf) {
41
 
    // do something
42
 
} else {
43
 
    // fail
44
 
}
45
 
@endcode
46
 
@sa KDevPlugin::extension method documentation.
47
 
*/
48
 
class KDevCreateFile : public KDevPlugin
49
 
{
50
 
 
51
 
public:
52
 
  /**File created with @ref KDevCreateFile implementation.*/
53
 
  class CreatedFile {
54
 
 
55
 
  public:
56
 
    /**The status of a file.*/
57
 
    enum Status {
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.*/
62
 
    };
63
 
 
64
 
    /**Constructor.
65
 
    Sets status to STATUS_NOTCREATED.*/
66
 
    CreatedFile()
67
 
      : status( STATUS_NOTCREATED ) {}
68
 
 
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) {}
73
 
 
74
 
    CreatedFile& operator = ( const CreatedFile& source )
75
 
    {
76
 
      dir = source.dir;
77
 
      filename = source.filename;
78
 
      ext = source.ext;
79
 
      subtype = source.subtype;
80
 
      status = source.status;
81
 
      addToProject = source.addToProject;
82
 
      return( *this );
83
 
    }
84
 
 
85
 
    bool operator == ( const CreatedFile& source ) const
86
 
    {
87
 
      return
88
 
        dir == source.dir &&
89
 
        filename == source.filename &&
90
 
        ext == source.ext &&
91
 
        subtype == source.subtype &&
92
 
        status == source.status &&
93
 
        addToProject == source.addToProject;
94
 
    }
95
 
 
96
 
    // this should be private
97
 
    /**The directory.*/
98
 
    QString dir;
99
 
    /**The name (without directory path).*/
100
 
    QString filename;
101
 
    /**The extension of a file. Extension defines a "type" of the file template
102
 
    to use during file creation.*/
103
 
    QString ext;
104
 
    /**The subtype of a file. "Subtype" defines a file template to use when
105
 
    there are several file templates for each extension.*/
106
 
    QString subtype;
107
 
    /**Current status.*/
108
 
    Status status;
109
 
    /**true if the file should be added to a project.*/
110
 
    bool addToProject;
111
 
  };
112
 
 
113
 
 
114
 
public:
115
 
 
116
 
  /**Constructor.
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) {}
127
 
 
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
136
 
  file template.
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;
142
 
 
143
 
 
144
 
};
145
 
 
146
 
#endif