![]() |
XML Mill
1.0.0
A GUI based XML editor with a memory.
|
Allows the user to add whole snippets to the active document. More...
#include <gcaddsnippetsform.h>
Signals | |
void | snippetAdded (GCTreeWidgetItem *parent, QDomElement elementToAdd) |
Informs the listener that a new snippet has been added. | |
Public Member Functions | |
GCAddSnippetsForm (const QString &elementName, GCTreeWidgetItem *parentItem, QWidget *parent=0) | |
Constructor. | |
~GCAddSnippetsForm () | |
Destructor. | |
Private Slots | |
void | elementSelected (GCTreeWidgetItem *item, int column) |
Triggered when an element is selected in the tree widget. | |
void | attributeChanged (QTableWidgetItem *item) const |
Triggered whenever a user clicks on an attribute in the attribute table, or changes an attribute's "include" state. | |
void | attributeValueChanged () const |
Triggered whenever an attribute's value changes. | |
void | addSnippet () |
Triggered whenever the "Add" button is clicked. | |
void | showHelp () |
Displays help information for this form. | |
Private Member Functions | |
void | updateCheckStates (GCTreeWidgetItem *item) const |
Whenever a user checks or unchecks an element to include or exclude it from the snippet being built, the element's parent(s) and children need to be updated accordingly. | |
Private Attributes | |
Ui::GCAddSnippetsForm * | ui |
GCTreeWidgetItem * | m_parentItem |
bool | m_treeItemActivated |
Allows the user to add whole snippets to the active document.
This form allows the user to add multiple XML snippets of the same structure to the current document (with whichever default values the user specifies). It furthermore allows for the option to increment the default values for each snippet (i.e. if the user specifies "1" as an attribute value with the option to increment, then the next snippet generated will have "2" as the value for the same attribute and so on and so forth (strings will have the incremented value appended to the name). Only one element of each type can be inserted into any specific snippet as it makes no sense to insert multiple elements of the same type - for those use cases the user must create a smaller snippet subset.
Also, the Qt::WA_DeleteOnClose flag is set for all instances of this form. If you're unfamiliar with Qt, this means that Qt will delete this widget as soon as the widget accepts the close event (i.e. you don't need to worry about clean-up of dynamically created instances of this object).
Definition at line 60 of file gcaddsnippetsform.h.
GCAddSnippetsForm::GCAddSnippetsForm | ( | const QString & | elementName, |
GCTreeWidgetItem * | parentItem, | ||
QWidget * | parent = 0 |
||
) | [explicit] |
Constructor.
elementName | - the name of the element that will form the basis of the snippet, i.e. this element will be at the top of the snippet's DOM hierarchy. |
parentItem | - the tree item and corresponding element in the active document to which the snippet will be added. |
Definition at line 48 of file gcaddsnippetsform.cpp.
Destructor.
Definition at line 77 of file gcaddsnippetsform.cpp.
void GCAddSnippetsForm::addSnippet | ( | ) | [private, slot] |
Triggered whenever the "Add" button is clicked.
This function builds the snippet(s) that must be added to the active document and furthermore informs all listeners that a snippet has been added via the "snippetAdded" signal.
Definition at line 225 of file gcaddsnippetsform.cpp.
void GCAddSnippetsForm::attributeChanged | ( | QTableWidgetItem * | item | ) | const [private, slot] |
Triggered whenever a user clicks on an attribute in the attribute table, or changes an attribute's "include" state.
Definition at line 166 of file gcaddsnippetsform.cpp.
void GCAddSnippetsForm::attributeValueChanged | ( | ) | const [private, slot] |
Triggered whenever an attribute's value changes.
Definition at line 191 of file gcaddsnippetsform.cpp.
void GCAddSnippetsForm::elementSelected | ( | GCTreeWidgetItem * | item, |
int | column | ||
) | [private, slot] |
Triggered when an element is selected in the tree widget.
This function populates the attributes table with the known attributes and values associated with the selected element.
Definition at line 84 of file gcaddsnippetsform.cpp.
void GCAddSnippetsForm::showHelp | ( | ) | [private, slot] |
Displays help information for this form.
Definition at line 324 of file gcaddsnippetsform.cpp.
void GCAddSnippetsForm::snippetAdded | ( | GCTreeWidgetItem * | parent, |
QDomElement | elementToAdd | ||
) | [signal] |
Informs the listener that a new snippet has been added.
The GCTreeWidgetItem thus emitted is the item to which the snippet must be added and the QDomElement is the element corresponding to this item. As always, we depend on QDomElement's shallow copy constructor. The GCTreeWidgetItem thus emitted is not owned by this class, but is the same one that was passed in as constructor argument.
void GCAddSnippetsForm::updateCheckStates | ( | GCTreeWidgetItem * | item | ) | const [private] |
Whenever a user checks or unchecks an element to include or exclude it from the snippet being built, the element's parent(s) and children need to be updated accordingly.
I.e. including/excluding an element must also include/exclude all of its children (and their children, etc) as well as its parent (and its parent's parent, etc), for a smooth and intuitive user experience.
Definition at line 291 of file gcaddsnippetsform.cpp.