labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

abstractcolumncommands.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  File : abstractcolumncommands.cpp
3  Project : LabPlot
4  Description : Commands to be called by AbstractColumn to modify AbstractColumnPrivate
5  --------------------------------------------------------------------
6  Copyright : (C) 2007-2009 Tilman Benkert (thzs@gmx.net)
7  Copyright : (C) 2010 Knut Franke (knut.franke@gmx.de)
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 
30 #include "abstractcolumncommands.h"
31 #include <KLocalizedString>
32 
33 /** ***************************************************************************
34  * \class AbstractColumnClearMasksCmd
35  * \brief Clear masking information
36  ** ***************************************************************************/
37 
38 /**
39  * \var AbstractColumnClearMasksCmd::m_col
40  * \brief The private column data to modify
41  */
42 
43 /**
44  * \var AbstractColumnClearMasksCmd::m_masking
45  * \brief The old masks
46  */
47 
48 /**
49  * \var AbstractColumnClearMasksCmd::m_copied
50  * \brief A status flag
51  */
52 
53 /**
54  * \brief Ctor
55  */
57 : QUndoCommand( parent ), m_col(col) {
58  setText(i18n("%1: clear masks", col->name()));
59  m_copied = false;
60 }
61 
62 /**
63  * \brief Dtor
64  */
66 = default;
67 
68 /**
69  * \brief Execute the command
70  */
72  if (!m_copied) {
74  m_copied = true;
75  }
77  emit m_col->owner()->dataChanged(m_col->owner());
78 }
79 
80 /**
81  * \brief Undo the command
82  */
85  emit m_col->owner()->dataChanged(m_col->owner());
86 }
87 
88 /** ***************************************************************************
89  * \class AbstractColumnSetMaskedCmd
90  * \brief Mark an interval of rows as masked
91  ** ***************************************************************************/
92 
93 /**
94  * \var AbstractColumnSetMaskedCmd::m_col
95  * \brief The private AbstractColumn data to modify
96  */
97 
98 /**
99  * \var AbstractColumnSetMaskedCmd::m_interval
100  * \brief The interval
101  */
102 
103 /**
104  * \var AbstractColumnSetMaskedCmd::m_masked
105  * \brief Mask/unmask flag
106  */
107 
108 /**
109  * \var AbstractColumnSetMaskedCmd::m_masking
110  * \brief Interval attribute backup
111  */
112 
113 /**
114  * \var AbstractColumnSetMaskedCmd::m_copied
115  * \brief A status flag
116  */
117 
118 /**
119  * \brief Ctor
120  */
121 AbstractColumnSetMaskedCmd::AbstractColumnSetMaskedCmd(AbstractColumnPrivate * col, const Interval<int>& interval, bool masked, QUndoCommand * parent )
122 : QUndoCommand(parent), m_col(col), m_interval(interval), m_masked(masked) {
123  if (masked)
124  setText(i18n("%1: mask cells", col->name()));
125  else
126  setText(i18n("%1: unmask cells", col->name()));
127  m_copied = false;
128 }
129 
130 /**
131  * \brief Dtor
132  */
134 = default;
135 
136 /**
137  * \brief Execute the command
138  */
140  if (!m_copied) {
142  m_copied = true;
143  }
145  emit m_col->owner()->dataChanged(m_col->owner());
146 }
147 
148 /**
149  * \brief Undo the command
150  */
153  emit m_col->owner()->dataChanged(m_col->owner());
154 }
155 
156 /** ***************************************************************************
157  * \class AbstractColumnInsertRowsCmd
158  * \brief Insert empty rows into a column
159  ** ***************************************************************************/
160 
161 /**
162  * \var AbstractColumnInsertRowsCmd::m_col
163  * \brief Private object of AbstractColumn to be modified.
164  */
165 
166 /**
167  * \var AbstractColumnInsertRowsCmd::m_before
168  * \brief Row number before which to insert the new rows.
169  */
170 
171 /**
172  * \var AbstractColumnInsertRowsCmd::m_count
173  * \brief Number of rows to be inserted.
174  */
175 
176 /**
177  * \brief Ctor
178  */
180  int count, QUndoCommand *parent) :
181  QUndoCommand(parent),
182  m_col(col->d),
183  m_before(before),
184  m_count(count) {
185 }
186 
187 /**
188  * \brief Dtor
189  */
191 
194 }
195 
198 }
199 
200 /** ***************************************************************************
201  * \class AbstractColumnRemoveRowsCmd
202  * \brief Remove rows from a column
203  *
204  * See AbstractColumnInsertRowsCmd for a discussion of the design.
205  ** ***************************************************************************/
206 
207 /**
208  * \var AbstractColumnRemoveRowsCmd::m_col
209  * \brief Private object of AbstractColumn to be modified.
210  */
211 
212 /**
213  * \var AbstractColumnRemoveRowsCmd::m_first
214  * \brief First row number to be removed.
215  */
216 
217 /**
218  * \var AbstractColumnRemoveRowsCmd::m_count
219  * \brief Number of rows to be removed.
220  */
221 
222 /**
223  * \brief Ctor
224  */
226  int count, QUndoCommand *parent) :
227  QUndoCommand(parent),
228  m_col(col->d),
229  m_first(first),
230  m_count(count) {
231 }
232 
233 /**
234  * \brief Dtor
235  */
237 
241 }
242 
245 }
246 
void redo() override
Execute the command.
~AbstractColumnClearMasksCmd() override
Dtor.
IntervalAttribute< bool > m_masking
The old masks.
AbstractColumnClearMasksCmd(AbstractColumnPrivate *col, QUndoCommand *parent=nullptr)
Ctor.
AbstractColumnPrivate * m_col
The private column data to modify.
void undo() override
Undo the command.
~AbstractColumnInsertRowsCmd() override
Dtor.
int m_before
Row number before which to insert the new rows.
AbstractColumnPrivate * m_col
Private object of AbstractColumn to be modified.
int m_count
Number of rows to be inserted.
AbstractColumnInsertRowsCmd(AbstractColumn *col, int before, int count, QUndoCommand *parent=nullptr)
Ctor.
Private data class of AbstractColumn.
AbstractColumn * owner()
IntervalAttribute< bool > m_masking
~AbstractColumnRemoveRowsCmd() override
Dtor.
int m_count
Number of rows to be removed.
AbstractColumnPrivate * m_col
Private object of AbstractColumn to be modified.
int m_first
First row number to be removed.
IntervalAttribute< bool > m_masking
AbstractColumnRemoveRowsCmd(AbstractColumn *col, int first, int count, QUndoCommand *parent=nullptr)
Ctor.
IntervalAttribute< bool > m_masking
Interval attribute backup.
void undo() override
Undo the command.
AbstractColumnSetMaskedCmd(AbstractColumnPrivate *col, const Interval< int > &interval, bool masked, QUndoCommand *parent=nullptr)
Ctor.
void redo() override
Execute the command.
AbstractColumnPrivate * m_col
The private AbstractColumn data to modify.
bool m_masked
Mask/unmask flag.
~AbstractColumnSetMaskedCmd() override
Dtor.
Interval< int > m_interval
The interval.
Interface definition for data with column logic.
void dataChanged(const AbstractColumn *source)
Data of the column has changed.
void removeRows(int first, int count)
void setValue(const Interval< int > &i, bool value=true)
void insertRows(int before, int count)
Auxiliary class for interval based data.
Definition: Interval.h:212
#define i18n(m)
Definition: nsl_common.h:38