LCOV - code coverage report
Current view: top level - src/tools/qt-gui/src - deletekeycommand.cpp (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 18 0.0 %
Date: 2019-09-12 12:28:41 Functions: 0 1 0.0 %

          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 "deletekeycommand.hpp"
      10             : 
      11           0 : DeleteKeyCommand::DeleteKeyCommand (const QString & type, TreeViewModel * model, int index, QUndoCommand * parent)
      12           0 : : QUndoCommand (parent), m_model (model), m_node (model->model ().at (index)), m_index (index), m_isRoot (false)
      13             : {
      14           0 :         setText (type);
      15             : 
      16           0 :         if (!m_node->getPath ().contains ('/'))
      17             :         {
      18           0 :                 m_isRoot = true;
      19           0 :                 m_root = ConfigNodePtr (new ConfigNode (m_node->getPath (), m_node->getPath (), nullptr, m_model));
      20             :         }
      21           0 : }
      22             : 
      23           0 : void DeleteKeyCommand::undo ()
      24             : {
      25           0 :         if (m_isRoot) m_model->removeRow (m_index);
      26           0 :         m_model->insertRow (m_index, m_node);
      27           0 :         m_model->refreshArrayNumbers ();
      28           0 :         m_model->refresh ();
      29           0 : }
      30             : 
      31           0 : void DeleteKeyCommand::redo ()
      32             : {
      33           0 :         m_model->removeRow (m_index);
      34           0 :         if (m_isRoot) m_model->insertRow (m_index, m_root, false);
      35           0 :         m_model->refreshArrayNumbers ();
      36           0 : }

Generated by: LCOV version 1.13