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
BasicmLearningEditor Class Reference
Collaboration diagram for BasicmLearningEditor:
Collaboration graph

Public Member Functions

 BasicmLearningEditor (TemplateCore *core, QWidget *parent=0)
 
QList< BasicmLearningItemactiveItems () const
 
bool canGenerateApplications ()
 Specifies if template can generate applications or not. More...
 
QString generateBundleData ()
 Generates RAW data which represent data of this template. More...
 
bool loadBundleData (const QString &bundle_data)
 Loads editor state from XML bundle. More...
 
QString projectName ()
 Access to project name of current editor. More...
 
QString authorName ()
 Access to author name of current editor. More...
 
- Public Member Functions inherited from TemplateEditor
 TemplateEditor (TemplateCore *core, QWidget *parent=0)
 
virtual QString generationStatusDescription ()
 Access to description of current state. More...
 
virtual void launch ()
 Executed when given template with this editor is launched. More...
 
TemplateCorecore () const
 Access to associated template core. More...
 
bool isDirty () const
 Check if editor contains unsaved contents. More...
 
void setIsDirty (bool is_dirty)
 Sets new dirtiness status. More...
 

Friends

class BasicmLearningCore
 

Additional Inherited Members

- Public Slots inherited from TemplateEditor
void dirtify ()
 Dirtifies (sets m_isDirty to true) the editor.
 
- Signals inherited from TemplateEditor
void changed ()
 Emitted everytime any child widget of editor changes its contents. More...
 
void canGenerateChanged (bool can_generate, const QString &message=QString())
 Emitted if status, which specifies if mobile application can be generated from the template, changes. More...
 
- Protected Member Functions inherited from TemplateEditor
void issueNewGenereationStatus (bool can_generate, const QString &message=QString())
 Emits new signal notifying other components about state of creating of APK application. More...
 
- Protected Attributes inherited from TemplateEditor
bool m_canGenerate
 
QString m_generateMessage
 
bool m_isDirty
 
TemplateCorem_core
 

Detailed Description

Definition at line 47 of file basicmlearningeditor.h.

Member Function Documentation

QString BasicmLearningEditor::authorName ( )
virtual

Access to author name of current editor.

Returns
Returns string of author name. This is usually text in some text box in the editor.

Implements TemplateEditor.

Definition at line 139 of file basicmlearningeditor.cpp.

139  {
140  return m_ui->m_txtAuthor->lineEdit()->text();
141 }
bool BasicmLearningEditor::canGenerateApplications ( )
virtual

Specifies if template can generate applications or not.

Returns
Returns true if editor contains enough data for generating of applications.
Warning
This is used in cooperation with canGenerateStatusChanged(bool can_generate).

Reimplemented from TemplateEditor.

Definition at line 250 of file basicmlearningeditor.cpp.

250  {
251  return !activeItems().isEmpty();
252 }
QString BasicmLearningEditor::generateBundleData ( )
virtual

Generates RAW data which represent data of this template.

Remarks
Generated data are stored in XML bundle file.
Warning
Generated data of this method must be compatible with custom implementation of TemplateEntryPoint::loadCoreFromBundleData(const QString &raw_data) method!!!
Returns
Returns string with generated data.

Implements TemplateEditor.

Definition at line 254 of file basicmlearningeditor.cpp.

254  {
255  /*if (!canGenerateApplications()) {
256  return QString();
257  }*/
258 
259  QDomDocument source_document = qApp->templateManager()->generateBundleHeader(core()->entryPoint()->typeIndentifier(),
260  m_ui->m_txtAuthor->lineEdit()->text(),
261  QString(),
262  m_ui->m_txtName->lineEdit()->text(),
263  QString(),
264  "1");
265  FIND_DATA_ELEMENT(data_element, source_document);
266 
267  foreach (const BasicmLearningItem &item, activeItems()) {
268  QDomElement item_element = source_document.createElement("item");
269 
270  // Fill in details about question.
271  QDomElement title_element = source_document.createElement("item_title");
272  QDomElement description_element = source_document.createElement("item_description");
273 
274  title_element.appendChild(source_document.createTextNode(item.title()));
275  description_element.appendChild(source_document.createTextNode(item.description()));
276 
277  item_element.appendChild(title_element);
278  item_element.appendChild(description_element);
279 
280  data_element.appendChild(item_element);
281  }
282 
283  return source_document.toString(XML_BUNDLE_INDENTATION);
284 }
TemplateCore * core() const
Access to associated template core.

Here is the call graph for this function:

bool BasicmLearningEditor::loadBundleData ( const QString &  bundle_data)
virtual

Loads editor state from XML bundle.

Parameters
bundle_dataRaw XML bundle data.
Returns
Returns true if editor loaded bundle data, otherwise returns false.

Implements TemplateEditor.

Definition at line 102 of file basicmlearningeditor.cpp.

102  {
103  QDomDocument bundle_document;
104  bundle_document.setContent(bundle_data);
105 
106  QDomNodeList items = bundle_document.documentElement().elementsByTagName("item");
107 
108  for (int i = 0; i < items.size(); i++) {
109  QDomNode item = items.at(i);
110 
111  if (item.isElement()) {
112  QString title = item.namedItem("item_title").toElement().text();
113  QString description = item.namedItem("item_description").toElement().text();
114 
115  if (title.isEmpty() || description.isEmpty()) {
116  // TODO: error
117  continue;
118  }
119  else {
120  addNewItem(title, description);
121  }
122  }
123  else {
124  continue;
125  }
126  }
127 
128  // Load author & name.
129  m_ui->m_txtAuthor->lineEdit()->setText(bundle_document.documentElement().namedItem("author").namedItem("name").toElement().text());
130  m_ui->m_txtName->lineEdit()->setText(bundle_document.documentElement().namedItem("title").toElement().text());
131 
132  return true;
133 }
QString BasicmLearningEditor::projectName ( )
virtual

Access to project name of current editor.

Returns
Returns string of project name of current editor. This is usually text in some text box in the editor.

Implements TemplateEditor.

Definition at line 135 of file basicmlearningeditor.cpp.

135  {
136  return m_ui->m_txtName->lineEdit()->text();
137 }

The documentation for this class was generated from the following files: