BuildmLearn Toolkit  2.0.4
BuildmLearn Toolkit is an easy-to-use program that helps users make mobile apps without any knowledge of application development.
 All Classes Functions Enumerations Groups Pages
templatecore.h
1 /*
2  Copyright (c) 2012, BuildmLearn Contributors listed at http://buildmlearn.org/people/
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 
11  * Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  * Neither the name of the BuildmLearn nor the names of its
16  contributors may be used to endorse or promote products derived from
17  this software without specific prior written permission.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 
31 #ifndef TEMPLATECORE_H
32 #define TEMPLATECORE_H
33 
34 #include <QObject>
35 
36 
37 class TemplateEditor;
38 class TemplateSimulator;
39 class TemplateEntryPoint;
40 
41 /// \brief The core class container for single template.
42 /// \ingroup template-interfaces
43 class TemplateCore : public QObject {
44  Q_OBJECT
45 
46  public:
47  /// \brief Possible results of generation of bundle data.
49  Success,
50  ZipProblem,
51  SignApkProblem,
52  JavaProblem,
53  BundleProblem,
54  CopyProblem,
55  Aborted,
56  OtherProblem
57  };
58 
59  // Constructors and destructors.
60  explicit TemplateCore(TemplateEntryPoint *entry_point, QObject *parent = 0);
61  virtual ~TemplateCore();
62 
63  /// \brief Generates APK file from current project with active settings
64  /// \return Returns true on success, otherwise returns false.
65  /// \warning This is used only if template can actually
66  /// generate mobile application, so that editor of the template
67  /// must contain sufficient data for doing so.
68  virtual GenerationResult generateMobileApplication(const QString &input_apk_file, QString &output_file) = 0;
69 
70  /// \brief Called after this template is fully loaded in toolkit.
71  /// \note Template is fully loaded only and only if its editor is set as
72  /// active and its simulator is set as active. During "launching" usually
73  /// some common signals are emitted and input data of editor are checked.
74  virtual void launch();
75 
76  /// \brief Access to entry point of the template.
77  /// \return Returns entry point pointer.
78  virtual TemplateEntryPoint *entryPoint() const {
79  return m_entryPoint;
80  }
81 
82  /// \brief Access to editor widget of the template.
83  /// \return Returns editor widget pointer.
84  virtual TemplateEditor *editor() const {
85  return m_editor;
86  }
87 
88  /// \brief Access to simulator widget of the template.
89  /// \return Returns simulator widget pointer.
90  virtual TemplateSimulator *simulator() const {
91  return m_simulator;
92  }
93 
94  /// \brief Access to assigned XML "bundle" file.
95  /// \return Returns full path to assigned XML "bundle" file.
96  ///
97  /// Template core gets assigned path to XML "bundle" file,
98  /// when it is loaded from that XML bundle file or when it is saved
99  /// into some XML bundle file.
100  ///
101  /// \note This is used when using "Save" functionality, it asks
102  /// if currently active core has assigned some file and if it does,
103  /// then "Save" feature saves unsaved work into that file, otherwise
104  /// it transfers the flow to "Save as" feature.
105  QString assignedFile() const;
106 
107  /// \brief Sets new assigned file.
108  /// \param assigned_file New assigned file.
109  void setAssignedFile(const QString &assigned_file);
110 
111  signals:
112  /// \brief Emitted when there is something new concerning generating of
113  /// mobile APK application.
114  /// \param percent_completed Percent of mobile application generating
115  /// completed.
116  /// \param progress_info Description text of status of current
117  /// generating process.
118  void generationProgress(int percent_completed, const QString &progress_info);
119 
120  protected:
121  TemplateEntryPoint *m_entryPoint;
122  TemplateEditor *m_editor;
123  TemplateSimulator *m_simulator;
124  QString m_assignedFile;
125 };
126 
127 #endif // TEMPLATECORE_H
virtual TemplateEditor * editor() const
Access to editor widget of the template.
Definition: templatecore.h:84
virtual TemplateSimulator * simulator() const
Access to simulator widget of the template.
Definition: templatecore.h:90
void setAssignedFile(const QString &assigned_file)
Sets new assigned file.
Represents the editor of the template.
virtual GenerationResult generateMobileApplication(const QString &input_apk_file, QString &output_file)=0
Generates APK file from current project with active settings.
void generationProgress(int percent_completed, const QString &progress_info)
Emitted when there is something new concerning generating of mobile APK application.
virtual void launch()
Called after this template is fully loaded in toolkit.
virtual TemplateEntryPoint * entryPoint() const
Access to entry point of the template.
Definition: templatecore.h:78
The entry point for a template.
QString assignedFile() const
Access to assigned XML "bundle" file.
The core class container for single template.
Definition: templatecore.h:43
GenerationResult
Possible results of generation of bundle data.
Definition: templatecore.h:48
Base widget which represents simulator of the template.