LCOV - code coverage report
Current view: top level - src/tools/qt-gui/src - copykeycommand.cpp (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 16 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 "copykeycommand.hpp"
      10             : #include "treeviewmodel.hpp"
      11             : 
      12           0 : CopyKeyCommand::CopyKeyCommand (QString type, ConfigNodePtr source, ConfigNodePtr target, QUndoCommand * parent)
      13           0 : : QUndoCommand (parent), m_source (new ConfigNode (*source)), m_target (target), m_isExpanded (target->isExpanded ()), m_index (-1)
      14             : {
      15           0 :         setText (type);
      16             : 
      17           0 :         QString newPath = m_target->getPath () + "/" + m_source->getName ();
      18           0 :         m_source->setPath (newPath);
      19           0 : }
      20             : 
      21           0 : void CopyKeyCommand::undo ()
      22             : {
      23           0 :         m_isExpanded = m_target->isExpanded ();
      24           0 :         m_target->getChildren ()->removeRow (m_index);
      25             : 
      26           0 :         if (m_target->isExpanded () && m_target->childrenHaveNoChildren ()) m_target->setIsExpanded (false);
      27           0 : }
      28             : 
      29           0 : void CopyKeyCommand::redo ()
      30             : {
      31           0 :         m_target->setIsExpanded (m_isExpanded);
      32           0 :         m_target->appendChild (m_source);
      33           0 :         m_index = m_target->getChildCount () - 1;
      34           0 : }

Generated by: LCOV version 1.13