• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

lokalize

  • sources
  • kde-4.12
  • kdesdk
  • lokalize
  • src
  • catalog
cmd.h
Go to the documentation of this file.
1 /* ****************************************************************************
2  This file is part of Lokalize
3 
4  Copyright (C) 2007-2011 by Nick Shaforostoff <shafff@ukr.net>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License as
8  published by the Free Software Foundation; either version 2 of
9  the License or (at your option) version 3 or any later version
10  accepted by the membership of KDE e.V. (or its successor approved
11  by the membership of KDE e.V.), which shall act as a proxy
12  defined in Section 14 of version 3 of the license.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see <http://www.gnu.org/licenses/>.
21 
22 **************************************************************************** */
23 
24 
25 #ifndef CMD_H
26 #define CMD_H
27 
28 #include <QUndoCommand>
29 
30 #include "pos.h"
31 #include "note.h"
32 #include "phase.h"
33 #include "state.h"
34 #include "catalogstring.h"
35 class Catalog;
36 
37 enum Commands
38 {
39  Insert, Delete,
40  InsertTag, DeleteTag,
41  ToggleApprovement, EquivTrans,
42  SetNote, UpdatePhase
43 };
44 
45 class LokalizeUnitCmd: public QUndoCommand
46 {
47 public:
48  LokalizeUnitCmd(Catalog *catalog, const DocPosition& pos, const QString& name);
49  virtual ~LokalizeUnitCmd(){};
50  virtual void undo();
51  virtual void redo();
52  DocPosition pos()const{return _pos;}
53 protected:
54  virtual void doRedo()=0;
55  virtual void doUndo()=0;
60  virtual void setJumpingPos();
61 protected:
62  Catalog* _catalog;
63  DocPosition _pos;
64  bool _firstModificationForThisEntry;
65  QString _prevPhase;
66 };
67 
68 class LokalizeTargetCmd: public LokalizeUnitCmd
69 {
70 public:
71  LokalizeTargetCmd(Catalog *catalog, const DocPosition& pos, const QString& name);
72  virtual ~LokalizeTargetCmd(){};
73  void undo();
74  void redo();
75 protected:
76  QString _prevTargetPhase;
77 };
78 
85 class InsTextCmd: public LokalizeTargetCmd
86 {
87 public:
88  InsTextCmd(Catalog *catalog, const DocPosition& pos, const QString& str);
89  ~InsTextCmd(){};
90  int id () const {return Insert;}
91  bool mergeWith(const QUndoCommand *other);
92  void doRedo();
93  void doUndo();
94 private:
95  QString _str;
96 };
97 
99 class DelTextCmd: public LokalizeTargetCmd
100 {
101 public:
102  DelTextCmd(Catalog *catalog, const DocPosition& pos, const QString& str);
103  ~DelTextCmd(){};
104  int id () const {return Delete;}
105  bool mergeWith(const QUndoCommand *other);
106  void doRedo();
107  void doUndo();
108 private:
109  QString _str;
110 };
111 
112 class SetStateCmd: public LokalizeUnitCmd
113 {
114 private:
115  SetStateCmd(Catalog *catalog, const DocPosition& pos, TargetState state);
116 public:
117  ~SetStateCmd(){};
118 
119  int id () const {return ToggleApprovement;}
120  void doRedo();
121  void doUndo();
122 
123  static void push(Catalog *catalog, const DocPosition& pos, bool approved);
124  static void instantiateAndPush(Catalog *catalog, const DocPosition& pos, TargetState state);
125 
126  TargetState _state;
127  TargetState _prevState;
128 };
129 
131 class InsTagCmd: public LokalizeTargetCmd
132 {
133 public:
135  InsTagCmd(Catalog *catalog, const DocPosition& pos, const InlineTag& tag);
136  ~InsTagCmd(){};
137  int id () const {return InsertTag;}
138  void doRedo();
139  void doUndo();
140 private:
141  InlineTag _tag;
142 };
143 
149 class DelTagCmd: public LokalizeTargetCmd
150 {
151 public:
152  DelTagCmd(Catalog *catalog, const DocPosition& pos);
153  ~DelTagCmd(){};
154  int id () const {return DeleteTag;}
155  void doRedo();
156  void doUndo();
157  InlineTag tag()const{return _tag;}//used to get proprties of deleted tag
158 private:
159  InlineTag _tag;
160 };
161 
163 class SetNoteCmd: public LokalizeUnitCmd
164 {
165 public:
167  SetNoteCmd(Catalog *catalog, const DocPosition& pos, const Note& note);
168  ~SetNoteCmd(){};
169  int id () const {return SetNote;}
170 protected:
171  void doRedo();
172  void doUndo();
173  void setJumpingPos();
174 private:
175  Note _note;
176  Note _prevNote;
177 };
178 
180 class UpdatePhaseCmd: public QUndoCommand
181 {
182 public:
184  UpdatePhaseCmd(Catalog *catalog, const Phase& phase);
185  ~UpdatePhaseCmd(){};
186  int id () const {return UpdatePhase;}
187  void redo();
188  void undo();
189 private:
190  Catalog* _catalog;
191  Phase _phase;
192  Phase _prevPhase;
193 };
194 
195 
196 class SetEquivTransCmd: public LokalizeTargetCmd
197 {
198 public:
199  SetEquivTransCmd(Catalog *catalog, const DocPosition& pos, bool equivTrans);
200  ~SetEquivTransCmd(){};
201  int id () const {return EquivTrans;}
202  void doRedo();
203  void doUndo();
204 private:
205  bool _equivTrans;
206 };
207 
216 bool fillTagPlaces(QMap<int,int>& tagPlaces, const CatalogString& catalogString, int start, int len);
217 bool removeTargetSubstring(Catalog* catalog, DocPosition pos, int delStart=0, int delLen=-1);
218 void insertCatalogString(Catalog* catalog, DocPosition pos, const CatalogString& catStr, int start=0);
219 
220 #endif // CMD_H
DelTagCmd
TagRange is filled from document.
Definition: cmd.h:149
LokalizeUnitCmd::redo
virtual void redo()
Definition: cmd.cpp:51
InsertTag
Definition: cmd.h:40
LokalizeUnitCmd::_firstModificationForThisEntry
bool _firstModificationForThisEntry
Definition: cmd.h:64
catalogstring.h
InsTextCmd::doUndo
void doUndo()
Definition: cmd.cpp:128
SetEquivTransCmd::SetEquivTransCmd
SetEquivTransCmd(Catalog *catalog, const DocPosition &pos, bool equivTrans)
Definition: cmd.cpp:307
SetNoteCmd::doRedo
void doRedo()
Definition: cmd.cpp:267
Delete
Definition: cmd.h:39
InsTextCmd
how undo system works: undo() and redo() functions call appropriate private method of Catalog to chan...
Definition: cmd.h:85
LokalizeUnitCmd::_pos
DocPosition _pos
Definition: cmd.h:63
SetStateCmd::push
static void push(Catalog *catalog, const DocPosition &pos, bool approved)
Definition: cmd.cpp:182
LokalizeTargetCmd::LokalizeTargetCmd
LokalizeTargetCmd(Catalog *catalog, const DocPosition &pos, const QString &name)
Definition: cmd.cpp:75
DeleteTag
Definition: cmd.h:40
LokalizeUnitCmd::LokalizeUnitCmd
LokalizeUnitCmd(Catalog *catalog, const DocPosition &pos, const QString &name)
Definition: cmd.cpp:38
phase.h
DelTagCmd::id
int id() const
Definition: cmd.h:154
pos.h
DelTagCmd::DelTagCmd
DelTagCmd(Catalog *catalog, const DocPosition &pos)
Definition: cmd.cpp:231
DelTagCmd::tag
InlineTag tag() const
Definition: cmd.h:157
Note
Definition: note.h:29
removeTargetSubstring
bool removeTargetSubstring(Catalog *catalog, DocPosition pos, int delStart=0, int delLen=-1)
Definition: cmd.cpp:364
LokalizeUnitCmd::doUndo
virtual void doUndo()=0
DelTextCmd::~DelTextCmd
~DelTextCmd()
Definition: cmd.h:103
EquivTrans
Definition: cmd.h:41
InsTagCmd::id
int id() const
Definition: cmd.h:137
InsTagCmd::~InsTagCmd
~InsTagCmd()
Definition: cmd.h:136
SetEquivTransCmd
Definition: cmd.h:196
DelTextCmd::mergeWith
bool mergeWith(const QUndoCommand *other)
Definition: cmd.cpp:141
InsTagCmd::InsTagCmd
InsTagCmd(Catalog *catalog, const DocPosition &pos, const InlineTag &tag)
offset is taken from tag and not from pos
Definition: cmd.cpp:209
LokalizeUnitCmd::doRedo
virtual void doRedo()=0
SetStateCmd::~SetStateCmd
~SetStateCmd()
Definition: cmd.h:117
SetNoteCmd::~SetNoteCmd
~SetNoteCmd()
Definition: cmd.h:168
SetNoteCmd::doUndo
void doUndo()
Definition: cmd.cpp:272
DelTextCmd
Definition: cmd.h:99
DocPosition
This struct represents a position in a catalog.
Definition: pos.h:38
LokalizeUnitCmd::pos
DocPosition pos() const
Definition: cmd.h:52
SetStateCmd::doUndo
void doUndo()
Definition: cmd.cpp:201
SetStateCmd::_prevState
TargetState _prevState
Definition: cmd.h:127
SetStateCmd
Definition: cmd.h:112
LokalizeTargetCmd::~LokalizeTargetCmd
virtual ~LokalizeTargetCmd()
Definition: cmd.h:72
InsTextCmd::id
int id() const
Definition: cmd.h:90
SetEquivTransCmd::doUndo
void doUndo()
Definition: cmd.cpp:317
SetStateCmd::instantiateAndPush
static void instantiateAndPush(Catalog *catalog, const DocPosition &pos, TargetState state)
Definition: cmd.cpp:186
Insert
Definition: cmd.h:39
SetStateCmd::id
int id() const
Definition: cmd.h:119
fillTagPlaces
bool fillTagPlaces(QMap< int, int > &tagPlaces, const CatalogString &catalogString, int start, int len)
CatalogString cmds helper function.
Definition: cmd.cpp:328
Commands
Commands
Definition: cmd.h:37
LokalizeUnitCmd::~LokalizeUnitCmd
virtual ~LokalizeUnitCmd()
Definition: cmd.h:49
SetStateCmd::doRedo
void doRedo()
Definition: cmd.cpp:196
DelTagCmd::doRedo
void doRedo()
Definition: cmd.cpp:235
Phase
Definition: phase.h:34
LokalizeUnitCmd::setJumpingPos
virtual void setJumpingPos()
may be overridden to set customized pos alternatively customized pos may be set manually in do*() ...
Definition: cmd.cpp:68
InsTagCmd
Do insert tag.
Definition: cmd.h:131
UpdatePhaseCmd::id
int id() const
Definition: cmd.h:186
DelTextCmd::doRedo
void doRedo()
Definition: cmd.cpp:168
LokalizeUnitCmd::undo
virtual void undo()
Definition: cmd.cpp:59
UpdatePhaseCmd::undo
void undo()
Definition: cmd.cpp:297
DelTextCmd::id
int id() const
Definition: cmd.h:104
SetNoteCmd::id
int id() const
Definition: cmd.h:169
SetEquivTransCmd::doRedo
void doRedo()
Definition: cmd.cpp:312
DelTagCmd::doUndo
void doUndo()
Definition: cmd.cpp:241
InsTextCmd::InsTextCmd
InsTextCmd(Catalog *catalog, const DocPosition &pos, const QString &str)
Definition: cmd.cpp:93
CatalogString
data structure used to pass info about inline elements a XLIFF tag is represented by a TAGRANGE_IMAGE...
Definition: catalogstring.h:128
SetNoteCmd::SetNoteCmd
SetNoteCmd(Catalog *catalog, const DocPosition &pos, const Note &note)
pos.form is note number
Definition: cmd.cpp:252
insertCatalogString
void insertCatalogString(Catalog *catalog, DocPosition pos, const CatalogString &catStr, int start=0)
Definition: cmd.cpp:421
DelTagCmd::~DelTagCmd
~DelTagCmd()
Definition: cmd.h:153
state.h
UpdatePhase
Definition: cmd.h:42
note.h
SetNoteCmd::setJumpingPos
void setJumpingPos()
may be overridden to set customized pos alternatively customized pos may be set manually in do*() ...
Definition: cmd.cpp:277
SetEquivTransCmd::~SetEquivTransCmd
~SetEquivTransCmd()
Definition: cmd.h:200
InsTextCmd::doRedo
void doRedo()
Definition: cmd.cpp:120
ToggleApprovement
Definition: cmd.h:41
InsTextCmd::mergeWith
bool mergeWith(const QUndoCommand *other)
Definition: cmd.cpp:98
InsTagCmd::doUndo
void doUndo()
Definition: cmd.cpp:224
Catalog
This class represents a catalog It uses CatalogStorage interface to work with catalogs in different f...
Definition: catalog.h:74
InsTagCmd::doRedo
void doRedo()
Definition: cmd.cpp:216
DelTextCmd::doUndo
void doUndo()
Definition: cmd.cpp:172
UpdatePhaseCmd::UpdatePhaseCmd
UpdatePhaseCmd(Catalog *catalog, const Phase &phase)
pos.form is note number
Definition: cmd.cpp:286
InsTextCmd::~InsTextCmd
~InsTextCmd()
Definition: cmd.h:89
DelTextCmd::DelTextCmd
DelTextCmd(Catalog *catalog, const DocPosition &pos, const QString &str)
Definition: cmd.cpp:136
SetNote
Definition: cmd.h:42
UpdatePhaseCmd::redo
void redo()
Definition: cmd.cpp:292
LokalizeUnitCmd::_catalog
Catalog * _catalog
Definition: cmd.h:62
TargetState
TargetState
Definition: state.h:30
LokalizeUnitCmd
Definition: cmd.h:45
QUndoCommand
SetStateCmd::_state
TargetState _state
Definition: cmd.h:126
LokalizeTargetCmd::_prevTargetPhase
QString _prevTargetPhase
Definition: cmd.h:76
LokalizeTargetCmd
Definition: cmd.h:68
SetNoteCmd
Insert or remove (if content is empty) a note.
Definition: cmd.h:163
SetEquivTransCmd::id
int id() const
Definition: cmd.h:201
InlineTag
data structure used to pass info about inline elements a XLIFF tag is represented by a TAGRANGE_IMAGE...
Definition: catalogstring.h:44
LokalizeUnitCmd::_prevPhase
QString _prevPhase
Definition: cmd.h:65
UpdatePhaseCmd
Add or remove (if content is empty) a phase.
Definition: cmd.h:180
LokalizeTargetCmd::redo
void redo()
Definition: cmd.cpp:79
UpdatePhaseCmd::~UpdatePhaseCmd
~UpdatePhaseCmd()
Definition: cmd.h:185
LokalizeTargetCmd::undo
void undo()
Definition: cmd.cpp:85
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:03:45 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

lokalize

Skip menu "lokalize"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal