kformula/flake
FormulaCommand.hGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef FORMULACOMMAND_H
00024 #define FORMULACOMMAND_H
00025
00026 #include <QUndoCommand>
00027 #include <QList>
00028 #include <QHash>
00029 #include <QMetaType>
00030 #include "FormulaCursor.h"
00031 class BasicElement;
00032 class TokenElement;
00033 class FormulaData;
00034 class GlyphElement;
00035 class TableElement;
00036 class TableRowElement;
00037
00047 class FormulaCommand : public QUndoCommand {
00048 public:
00049 FormulaCommand(QUndoCommand* parent=0);
00050
00051 virtual void changeCursor(FormulaCursor& cursor, bool undo) const;
00052
00053 void setUndoCursorPosition(const FormulaCursor& position);
00054 void setRedoCursorPosition(const FormulaCursor& position);
00055
00056 protected:
00057 bool m_done;
00058
00059 private:
00060 FormulaCursor m_undoCursorPosition;
00061 FormulaCursor m_redoCursorPosition;
00062 };
00063
00064 Q_DECLARE_METATYPE(FormulaCommand*)
00065
00066
00067 class FormulaCommandReplaceText : public FormulaCommand {
00068 public:
00069 FormulaCommandReplaceText( TokenElement* owner, int position,int length, const QString& added , QUndoCommand *parent=0);
00070
00071 ~FormulaCommandReplaceText();
00072
00074 void redo();
00075
00077 void undo();
00078
00079 private:
00081 TokenElement* m_ownerElement;
00082
00084 int m_position;
00085
00086 int m_length;
00087
00088 int m_glyphpos;
00089
00091 QString m_added;
00092
00093 QString m_removed;
00094
00095 QList<GlyphElement*> m_removedGlyphs;
00096 };
00097
00098 class FormulaCommandReplaceElements : public FormulaCommand {
00099 public:
00100 FormulaCommandReplaceElements( RowElement* owner, int position, int length, QList<BasicElement*> elements , bool wrap=false, QUndoCommand *parent=0);
00101
00102 ~FormulaCommandReplaceElements();
00103
00105 void redo();
00106
00108 void undo();
00109
00110 private:
00112 RowElement* m_ownerElement;
00113
00115 int m_position;
00116
00117 int m_placeholderPosition;
00118
00119 int m_length;
00120
00121 bool m_wrap;
00122
00123 RowElement* m_placeholderParent;
00124
00125
00126
00128 QList<BasicElement*> m_added;
00129
00131 QList<BasicElement*> m_removed;
00132 };
00133
00134 class FormulaCommandLoad : public FormulaCommand {
00135 public:
00136 FormulaCommandLoad( FormulaData* data, FormulaElement* newelement, QUndoCommand *parent=0);
00137
00138 ~FormulaCommandLoad ();
00139
00141 void redo();
00142
00144 void undo();
00145
00146 private:
00147 FormulaData* m_data;
00148 FormulaElement* m_oldel;
00149 FormulaElement* m_newel;
00150 };
00151
00152 class FormulaCommandReplaceRow : public FormulaCommand {
00153 public:
00154 FormulaCommandReplaceRow ( FormulaData* data, FormulaCursor oldPosition, TableElement* table, int number, int oldlength, int newlength );
00155
00156 ~FormulaCommandReplaceRow ();
00157
00159 void redo();
00160
00162 void undo();
00163
00164 private:
00165 FormulaData* m_data;
00166 TableElement* m_table;
00167 TableRowElement* m_empty;
00168 int m_number;
00169 QList<BasicElement*> m_newRows;
00170 QList<BasicElement*> m_oldRows;
00171 };
00172
00173 class FormulaCommandReplaceColumn : public FormulaCommand {
00174 public:
00175 FormulaCommandReplaceColumn ( FormulaData* data, FormulaCursor oldPosition, TableElement* table, int number, int oldlength, int newlength );
00176
00177 ~FormulaCommandReplaceColumn ();
00178
00180 void redo();
00181
00183 void undo();
00184
00185 private:
00186 FormulaData* m_data;
00187
00189 TableElement* m_table;
00190
00192 TableRowElement* m_empty;
00193
00195 QList<BasicElement*> m_oldRows;
00196
00198 int m_position;
00199
00201 QList< QList<BasicElement*> > m_newColumns;
00202
00204 QList< QList<BasicElement*> > m_oldColumns;
00205 };
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 #endif // FORMULACOMMAND_H
|