kwave  18.07.70
Kwave::UndoDeleteMetaDataAction Class Reference

#include <UndoDeleteMetaDataAction.h>

Inheritance diagram for Kwave::UndoDeleteMetaDataAction:
Inheritance graph
Collaboration diagram for Kwave::UndoDeleteMetaDataAction:
Collaboration graph

Public Member Functions

 UndoDeleteMetaDataAction (const Kwave::MetaDataList &meta_data)
 
virtual ~UndoDeleteMetaDataAction () Q_DECL_OVERRIDE
 
virtual QString description () Q_DECL_OVERRIDE
 
virtual qint64 undoSize () Q_DECL_OVERRIDE
 
virtual qint64 redoSize () Q_DECL_OVERRIDE
 
virtual bool store (Kwave::SignalManager &manager) Q_DECL_OVERRIDE
 
virtual Kwave::UndoActionundo (Kwave::SignalManager &manager, bool with_redo) Q_DECL_OVERRIDE
 
virtual void dump (const QString &indent) Q_DECL_OVERRIDE
 
- Public Member Functions inherited from Kwave::UndoAction
virtual ~UndoAction ()
 
virtual bool containsModification () const
 

Protected Attributes

Kwave::MetaDataList m_meta_data
 

Detailed Description

Undo action for deleting a list of meta data items.

Definition at line 36 of file UndoDeleteMetaDataAction.h.

Constructor & Destructor Documentation

◆ UndoDeleteMetaDataAction()

Kwave::UndoDeleteMetaDataAction::UndoDeleteMetaDataAction ( const Kwave::MetaDataList meta_data)
explicit

Constructor

Parameters
meta_datareference to the meta data that should be deleted

Definition at line 30 of file UndoDeleteMetaDataAction.cpp.

32  :UndoAction(), m_meta_data(meta_data)
33 {
34 }

◆ ~UndoDeleteMetaDataAction()

Kwave::UndoDeleteMetaDataAction::~UndoDeleteMetaDataAction ( )
virtual

Destructor

Definition at line 37 of file UndoDeleteMetaDataAction.cpp.

38 {
39 }

Member Function Documentation

◆ description()

QString Kwave::UndoDeleteMetaDataAction::description ( )
virtual

Returns a verbose short description of the action.

Implements Kwave::UndoAction.

Definition at line 42 of file UndoDeleteMetaDataAction.cpp.

References _, Kwave::MetaData::hasProperty(), m_meta_data, name, and Kwave::MetaData::STDPROP_TYPE.

43 {
44  // sanity check: list should not be empty
45  Q_ASSERT(!m_meta_data.isEmpty());
46  if (m_meta_data.isEmpty()) return _("");
47 
48  QString name;
49  {
50  const Kwave::MetaData &m = m_meta_data.values().first();
52  name = m[Kwave::MetaData::STDPROP_TYPE].toString();
53  }
54 
55  // if the meta data list contains only one object: try to find
56  // out the object's name
57  if ((m_meta_data.count() == 1) && name.length()) {
58  return i18nc(
59  "name of the undo action for deleting a meta data object",
60  "Delete %1",
61  name
62  );
63  }
64 
65  // check if the list contains only objects of the same type
66  bool all_same_type = true;
67  foreach (const Kwave::MetaData &m, m_meta_data) {
68  QString n = m[Kwave::MetaData::STDPROP_TYPE].toString();
69  if (!n.length() || (n != name)) {
70  all_same_type = false;
71  break;
72  }
73  }
74  if (all_same_type) {
75  return i18nc(
76  "name of the undo action for deleting multiple "
77  "meta data objects of the same type: "
78  "%1=number of elements, %2=name of one element in singular",
79  "Delete %1 %2 objects", m_meta_data.count(), name
80  );
81  }
82 
83  return i18n("Delete Meta Data");
84 }
bool hasProperty(const QString &p) const
Definition: MetaData.cpp:104
const char name[16]
Definition: memcpy.c:510
static const QString STDPROP_TYPE
Definition: MetaData.h:41
#define _(m)
Definition: memcpy.c:66
Here is the call graph for this function:

◆ dump()

void Kwave::UndoDeleteMetaDataAction::dump ( const QString &  indent)
virtual

dump, for debugging purposes

Reimplemented from Kwave::UndoAction.

Definition at line 129 of file UndoDeleteMetaDataAction.cpp.

References _, DBG, Kwave::MetaData::id(), Kwave::MetaData::keys(), and m_meta_data.

130 {
131  foreach (const Kwave::MetaData &m, m_meta_data) {
132  qDebug("%sundo delete meta data object '%s'",
133  DBG(indent), DBG(m.id()));
134 
135  // dump all properties of the object
136  foreach (const QString &key, m.keys()) {
137  QVariant v = m[key];
138  QString value;
139  if (v.type() == QVariant::List) {
140  foreach (const QVariant &v1, v.toList())
141  value += _("'") + v1.toString() + _("' ");
142  } else {
143  value = v.toString();
144  }
145  qDebug("%s '%s' = '%s", DBG(indent), DBG(key), DBG(value));
146  }
147  }
148 }
QStringList keys() const
Definition: MetaData.cpp:149
QString id() const
Definition: MetaData.cpp:75
#define _(m)
Definition: memcpy.c:66
#define DBG(qs)
Definition: String.h:55
Here is the call graph for this function:

◆ redoSize()

qint64 Kwave::UndoDeleteMetaDataAction::redoSize ( )
virtual

◆ store()

bool Kwave::UndoDeleteMetaDataAction::store ( Kwave::SignalManager manager)
virtual
See also
UndoAction::store()

Implements Kwave::UndoAction.

Definition at line 99 of file UndoDeleteMetaDataAction.cpp.

100 {
101  // nothing to do, all data has already
102  // been stored in the constructor
103  return true;
104 }

◆ undo()

Kwave::UndoAction * Kwave::UndoDeleteMetaDataAction::undo ( Kwave::SignalManager manager,
bool  with_redo 
)
virtual
See also
UndoAction::undo()

Implements Kwave::UndoAction.

Definition at line 107 of file UndoDeleteMetaDataAction.cpp.

References m_meta_data, Kwave::MetaDataList::merge(), Kwave::SignalManager::metaData(), and Kwave::UndoAction::store().

109 {
110  Q_ASSERT(!m_meta_data.isEmpty());
111  if (m_meta_data.isEmpty()) return Q_NULLPTR;
112 
113  Kwave::UndoAction *redo = Q_NULLPTR;
114 
115  // add the stored meta data to the signal managers' meta data
116  manager.metaData().merge(m_meta_data);
117 
118  // store data for redo
119  if (with_redo) {
120  redo = new(std::nothrow) Kwave::UndoAddMetaDataAction(m_meta_data);
121  Q_ASSERT(redo);
122  if (redo) redo->store(manager);
123  }
124 
125  return redo;
126 }
Kwave::MetaDataList & metaData()
void merge(const MetaDataList &meta_data)
virtual bool store(Kwave::SignalManager &manager)=0
Here is the call graph for this function:

◆ undoSize()

qint64 Kwave::UndoDeleteMetaDataAction::undoSize ( )
virtual
See also
UndoAction::undoSize()

Implements Kwave::UndoAction.

Definition at line 87 of file UndoDeleteMetaDataAction.cpp.

88 {
89  return sizeof(*this);
90 }

Member Data Documentation

◆ m_meta_data

Kwave::MetaDataList Kwave::UndoDeleteMetaDataAction::m_meta_data
protected

the list of deleted meta data items

Definition at line 73 of file UndoDeleteMetaDataAction.h.

Referenced by description(), dump(), and undo().


The documentation for this class was generated from the following files: