UndoStepQt.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. Copyright (C) 2007 Staikos Computing Services Inc.
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this library; see the file COPYING.LIB. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. Boston, MA 02110-1301, USA.
  15. */
  16. #include "config.h"
  17. #include "UndoStepQt.h"
  18. #include <qobject.h>
  19. using namespace WebCore;
  20. static QString undoNameForEditAction(const EditAction editAction)
  21. {
  22. switch (editAction) {
  23. case EditActionUnspecified:
  24. return QString();
  25. case EditActionSetColor:
  26. return QObject::tr("Set Color");
  27. case EditActionSetBackgroundColor:
  28. return QObject::tr("Set Background Color");
  29. case EditActionTurnOffKerning:
  30. return QObject::tr("Turn Off Kerning");
  31. case EditActionTightenKerning:
  32. return QObject::tr("Tighten Kerning");
  33. case EditActionLoosenKerning:
  34. return QObject::tr("Loosen Kerning");
  35. case EditActionUseStandardKerning:
  36. return QObject::tr("Use Standard Kerning");
  37. case EditActionTurnOffLigatures:
  38. return QObject::tr("Turn Off Ligatures");
  39. case EditActionUseStandardLigatures:
  40. return QObject::tr("Use Standard Ligatures");
  41. case EditActionUseAllLigatures:
  42. return QObject::tr("Use All Ligatures");
  43. case EditActionRaiseBaseline:
  44. return QObject::tr("Raise Baseline");
  45. case EditActionLowerBaseline:
  46. return QObject::tr("Lower Baseline");
  47. case EditActionSetTraditionalCharacterShape:
  48. return QObject::tr("Set Traditional Character Shape");
  49. case EditActionSetFont:
  50. return QObject::tr("Set Font");
  51. case EditActionChangeAttributes:
  52. return QObject::tr("Change Attributes");
  53. case EditActionAlignLeft:
  54. return QObject::tr("Align Left");
  55. case EditActionAlignRight:
  56. return QObject::tr("Align Right");
  57. case EditActionCenter:
  58. return QObject::tr("Center");
  59. case EditActionJustify:
  60. return QObject::tr("Justify");
  61. case EditActionSetWritingDirection:
  62. return QObject::tr("Set Writing Direction");
  63. case EditActionSubscript:
  64. return QObject::tr("Subscript");
  65. case EditActionBold:
  66. return QObject::tr("Bold");
  67. case EditActionItalics:
  68. return QObject::tr("Italic");
  69. case EditActionSuperscript:
  70. return QObject::tr("Superscript");
  71. case EditActionUnderline:
  72. return QObject::tr("Underline");
  73. case EditActionOutline:
  74. return QObject::tr("Outline");
  75. case EditActionUnscript:
  76. return QObject::tr("Unscript");
  77. case EditActionDrag:
  78. return QObject::tr("Drag");
  79. case EditActionCut:
  80. return QObject::tr("Cut");
  81. case EditActionPaste:
  82. return QObject::tr("Paste");
  83. case EditActionPasteFont:
  84. return QObject::tr("Paste Font");
  85. case EditActionPasteRuler:
  86. return QObject::tr("Paste Ruler");
  87. case EditActionTyping:
  88. return QObject::tr("Typing");
  89. case EditActionCreateLink:
  90. return QObject::tr("Create Link");
  91. case EditActionUnlink:
  92. return QObject::tr("Unlink");
  93. case EditActionInsertList:
  94. return QObject::tr("Insert List");
  95. case EditActionFormatBlock:
  96. return QObject::tr("Formatting");
  97. case EditActionIndent:
  98. return QObject::tr("Indent");
  99. case EditActionOutdent:
  100. return QObject::tr("Outdent");
  101. }
  102. ASSERT_NOT_REACHED();
  103. return QString();
  104. }
  105. UndoStepQt::UndoStepQt(WTF::RefPtr<UndoStep> step)
  106. : m_step(step)
  107. , m_first(true)
  108. {
  109. m_text = undoNameForEditAction(step->editingAction());
  110. }
  111. UndoStepQt::~UndoStepQt()
  112. {
  113. }
  114. void UndoStepQt::redo()
  115. {
  116. if (m_first) {
  117. m_first = false;
  118. return;
  119. }
  120. if (m_step)
  121. m_step->reapply();
  122. }
  123. void UndoStepQt::undo()
  124. {
  125. if (m_step)
  126. m_step->unapply();
  127. }
  128. QString UndoStepQt::text() const
  129. {
  130. return m_text;
  131. }
  132. // vim: ts=4 sw=4 et