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
LearnSpellingsEditor Class Reference

Editor widget of Learn Spellings template. More...

#include <learnspellingseditor.h>

Collaboration diagram for LearnSpellingsEditor:
Collaboration graph

Public Member Functions

 LearnSpellingsEditor (TemplateCore *core, QWidget *parent=0)
 
QList< LearnSpellingsItemactiveWords () const
 
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...
 
bool canGenerateApplications ()
 Specifies if template can generate applications or not. 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 LearnSpellingsSimulator
 
class LearnSpellingsCore
 

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

Editor widget of Learn Spellings template.

Definition at line 46 of file learnspellingseditor.h.

Member Function Documentation

QString LearnSpellingsEditor::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 287 of file learnspellingseditor.cpp.

287  {
288  return m_ui->m_txtAuthor->lineEdit()->text();
289 }
bool LearnSpellingsEditor::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 276 of file learnspellingseditor.cpp.

276  {
277  return
278  !activeWords().isEmpty() &&
279  !m_ui->m_txtAuthor->lineEdit()->text().simplified().isEmpty() &&
280  !m_ui->m_txtName->lineEdit()->text().simplified().isEmpty();
281 }
QString LearnSpellingsEditor::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 104 of file learnspellingseditor.cpp.

104  {
105  /*if (!canGenerateApplications()) {
106  return QString();
107  }*/
108 
109  QDomDocument source_document = qApp->templateManager()->generateBundleHeader(core()->entryPoint()->typeIndentifier(),
110  m_ui->m_txtAuthor->lineEdit()->text(),
111  QString(),
112  m_ui->m_txtName->lineEdit()->text(),
113  QString(),
114  "1");
115  FIND_DATA_ELEMENT(data_element, source_document);
116 
117  foreach (const LearnSpellingsItem &item, activeWords()) {
118  QDomElement item_element = source_document.createElement("item");
119 
120  // Fill in details about question.
121  QDomElement word_element = source_document.createElement("word");
122  QDomElement meaning_element = source_document.createElement("meaning");
123 
124  word_element.appendChild(source_document.createTextNode(item.word()));
125  meaning_element.appendChild(source_document.createTextNode(item.meaning()));
126 
127  item_element.appendChild(word_element);
128  item_element.appendChild(meaning_element);
129 
130  data_element.appendChild(item_element);
131  }
132 
133  return source_document.toString(XML_BUNDLE_INDENTATION);
134 }
TemplateCore * core() const
Access to associated template core.
Class which represents single word for Learn Spellings template.

Here is the call graph for this function:

bool LearnSpellingsEditor::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 136 of file learnspellingseditor.cpp.

136  {
137  QDomDocument bundle_document;
138  bundle_document.setContent(bundle_data);
139 
140  QDomNodeList items = bundle_document.documentElement().elementsByTagName("item");
141 
142  for (int i = 0; i < items.size(); i++) {
143  QDomNode item = items.at(i);
144 
145  if (item.isElement()) {
146  QString word = item.namedItem("word").toElement().text();
147  QString meaning = item.namedItem("meaning").toElement().text();
148 
149  if (word.isEmpty()) {
150  // TODO: error
151  continue;
152  }
153  else {
154  addSampleWord(word, meaning);
155  }
156  }
157  else {
158  continue;
159  }
160  }
161 
162  // Load author & name.
163  m_ui->m_txtAuthor->lineEdit()->setText(bundle_document.documentElement().namedItem("author").namedItem("name").toElement().text());
164  m_ui->m_txtName->lineEdit()->setText(bundle_document.documentElement().namedItem("title").toElement().text());
165 
166  return true;
167 }
QString LearnSpellingsEditor::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 283 of file learnspellingseditor.cpp.

283  {
284  return m_ui->m_txtName->lineEdit()->text();
285 }

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