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 : #include "importconfigurationcommand.hpp"
10 :
11 : using namespace kdb;
12 :
13 0 : ImportConfigurationCommand::ImportConfigurationCommand (TreeViewModel * model, int index, DataContainer * data, QUndoCommand * parent)
14 0 : : QUndoCommand (parent), m_model (model), m_index (index), m_before (new ConfigNode (*model->model ().at (index))), m_after (nullptr),
15 0 : m_name (data->importName ()), m_format (data->format ()), m_file (data->file ()), m_mergeStrategies (data->mergeStrategies ())
16 : {
17 0 : setText ("import");
18 :
19 0 : m_model->importConfiguration (m_name, m_format, m_file, m_mergeStrategies);
20 0 : m_after = model->model ().at (index);
21 0 : }
22 :
23 0 : void ImportConfigurationCommand::undo ()
24 : {
25 0 : m_model->removeRow (m_index);
26 0 : m_model->insertRow (m_index, m_before);
27 0 : }
28 :
29 0 : void ImportConfigurationCommand::redo ()
30 : {
31 0 : m_model->removeRow (m_index);
32 0 : m_model->insertRow (m_index, m_after);
33 0 : }
|