Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : */
8 :
9 : #ifndef NEWKEYCOMMAND_HPP
10 : #define NEWKEYCOMMAND_HPP
11 :
12 : #include "datacontainer.hpp"
13 : #include "treeviewmodel.hpp"
14 : #include <QUndoCommand>
15 :
16 : /**
17 : * @brief The NewKeyCommand class. Will create a new ConfigNode.
18 : */
19 :
20 0 : class NewKeyCommand : public QUndoCommand
21 : {
22 :
23 : public:
24 : /**
25 : * @brief The default constructor.
26 : *
27 : * @param model The TreeViewModel that will contain the new ConfigNode.
28 : * @param index The index of the new ConfigNode.
29 : * @param isBelow Is set when a ConfigNode should be below another ConfigNode. Will trigger an update of the treeview.
30 : * @param parent An optional parent.
31 : */
32 : explicit NewKeyCommand (TreeViewModel * model, int index, DataContainer * data, bool isBelow, QUndoCommand * parent = nullptr);
33 :
34 : virtual void undo () override;
35 : virtual void redo () override;
36 :
37 : private:
38 : ConfigNodePtr m_parentNode;
39 : ConfigNodePtr m_newNode;
40 : QString m_name;
41 : QString m_value;
42 : QVariantMap m_metaData;
43 :
44 : /**
45 : * @brief cutListAtIndex Helper method that cuts a QStringList at an index and returns the rest of the list.
46 : * @param list The QStringList to cut.
47 : * @param index The index where to cut the QStringList.
48 : * @return The cut QStringList.
49 : */
50 : QStringList cutListAtIndex (QStringList & list, int index);
51 : };
52 :
53 : #endif // NEWKEYCOMMAND_HPP
|