[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/koffice_trackchange/shapes/text
From: Pierre Stirnweiss <pstirnweiss () googlemail ! com>
Date: 2007-04-24 18:29:37
Message-ID: 1177439377.029606.16385.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 657670 by pstirnweiss:
added align, indent, line break and vert align commands
M +5 -0 CMakeLists.txt
M +71 -83 TextTool.cpp
M +4 -8 TextTool.h
A changetracker (directory)
A changetracker/TextTrackerAgent.cpp [License: LGPL (v2+)]
A changetracker/TextTrackerAgent.h [License: LGPL (v2+)]
A commands/TextAlignCommand.cpp [License: LGPL (v2+)]
A commands/TextAlignCommand.h [License: LGPL (v2+)]
M +0 -1 commands/TextBoldCommand.cpp
A commands/TextDecreaseIndentCommand.cpp [License: LGPL (v2+)]
A commands/TextDecreaseIndentCommand.h [License: LGPL (v2+)]
A commands/TextIncreaseIndentCommand.cpp [License: LGPL (v2+)]
A commands/TextIncreaseIndentCommand.h [License: LGPL (v2+)]
A commands/TextInsertLineBreakCommand.cpp [License: LGPL (v2+)]
A commands/TextInsertLineBreakCommand.h [License: LGPL (v2+)]
M +0 -7 commands/TextInsertTextCommand.cpp
A commands/TextVerticalAlignmentCommand.cpp [License: LGPL (v2+)]
A commands/TextVerticalAlignmentCommand.h [License: LGPL (v2+)]
--- branches/work/koffice_trackchange/shapes/text/CMakeLists.txt #657669:657670
@@ -26,6 +26,11 @@
commands/TextInsertTextCommand.cpp
commands/TextInsertParagraphCommand.cpp
commands/TextDeleteCommand.cpp
+ commands/TextAlignCommand.cpp
+ commands/TextIncreaseIndentCommand.cpp
+ commands/TextDecreaseIndentCommand.cpp
+ commands/TextInsertLineBreakCommand.cpp
+ commands/TextVerticalAlignmentCommand.cpp
)
kde4_add_ui_files(textshape_SRCS
--- branches/work/koffice_trackchange/shapes/text/TextTool.cpp #657669:657670
@@ -28,6 +28,11 @@
#include "commands/TextInsertTextCommand.h"
#include "commands/TextInsertParagraphCommand.h"
#include "commands/TextDeleteCommand.h"
+#include "commands/TextAlignCommand.h"
+#include "commands/TextIncreaseIndentCommand.h"
+#include "commands/TextDecreaseIndentCommand.h"
+#include "commands/TextInsertLineBreakCommand.h"
+#include "commands/TextVerticalAlignmentCommand.h"
#include <KoCanvasBase.h>
#include <KoSelection.h>
@@ -70,8 +75,7 @@
m_textShapeData(0),
m_allowActions(true),
m_allowAddUndoCommand(true),
- m_prevCursorPosition(-1),
- m_commandId(1)
+ m_prevCursorPosition(-1)
{
m_actionFormatBold = new QAction(KIcon("format-text-bold"), i18n("Bold"), \
this); addAction("format_bold", m_actionFormatBold );
@@ -102,28 +106,28 @@
m_actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L);
m_actionAlignLeft->setCheckable(true);
alignmentGroup->addAction(m_actionAlignLeft);
- connect(m_actionAlignLeft, SIGNAL(toggled(bool)), this, SLOT(alignLeft()));
+ connect(m_actionAlignLeft, SIGNAL(toggled(bool)), this, SLOT(alignLeft(bool)));
m_actionAlignRight = new QAction(KIcon("text-right"), i18n("Align Right"), \
this); addAction("format_alignright", m_actionAlignRight );
m_actionAlignRight->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_R);
m_actionAlignRight->setCheckable(true);
alignmentGroup->addAction(m_actionAlignRight);
- connect(m_actionAlignRight, SIGNAL(toggled(bool)), this, SLOT(alignRight()));
+ connect(m_actionAlignRight, SIGNAL(toggled(bool)), this, \
SLOT(alignRight(bool)));
m_actionAlignCenter = new QAction(KIcon("text-center"), i18n("Align Center"), \
this); addAction("format_aligncenter", m_actionAlignCenter );
m_actionAlignCenter->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_C);
m_actionAlignCenter->setCheckable(true);
alignmentGroup->addAction(m_actionAlignCenter);
- connect(m_actionAlignCenter, SIGNAL(toggled(bool)), this, SLOT(alignCenter()));
+ connect(m_actionAlignCenter, SIGNAL(toggled(bool)), this, \
SLOT(alignCenter(bool)));
m_actionAlignBlock = new QAction(KIcon("format-justify-fill"), i18n("Align \
Block"), this); addAction("format_alignblock", m_actionAlignBlock );
m_actionAlignBlock->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_R);
m_actionAlignBlock->setCheckable(true);
alignmentGroup->addAction(m_actionAlignBlock);
- connect(m_actionAlignBlock, SIGNAL(toggled(bool)), this, SLOT(alignBlock()));
+ connect(m_actionAlignBlock, SIGNAL(toggled(bool)), this, \
SLOT(alignBlock(bool)));
m_actionFormatSuper = new QAction(KIcon("text-super"), i18n("Superscript"), \
this); addAction("format_super", m_actionFormatSuper );
@@ -485,17 +489,8 @@
else {
m_prevCursorPosition = m_caret.position();
ensureCursorVisible();
-// m_caret.insertText(event->text());
-// if (m_caret.hasSelection()){
-//kDebug() << "in mcaret has selection " <<m_commandId<< endl;
-// m_canvas->addCommand(new TextInsertTextCommand(m_textShapeData->document(), \
this, &m_caret, event->text() ));
-// m_commandId++;
-// }
-// else {
-//kDebug() << "in caret not have selection "<<m_commandId << endl;
- m_canvas->addCommand(new TextInsertTextCommand(m_textShapeData->document(), this, \
&m_caret, event->text() ));
-// }
- editingPluginEvents();
+ m_canvas->addCommand(new \
TextInsertTextCommand(m_textShapeData->document(), this, &m_caret, event->text() )); \
+ editingPluginEvents(); }
}
if(moveOperation != QTextCursor::NoMove || destinationPosition != -1) {
@@ -727,11 +722,6 @@
m_allowActions = flag;
}
-int TextTool::getCommandUniqueId()
-{
- return m_commandId;
-}
-
void TextTool::addUndoCommand() {
if(! m_allowAddUndoCommand) return;
class UndoTextCommand : public QUndoCommand {
@@ -777,131 +767,129 @@
void TextTool::bold(bool bold)
{
- if(! m_allowActions) return;
- int start = m_caret.position();
- int end = m_caret.anchor();
- if(start == end) { // just set a new one.
- QTextCharFormat format = m_caret.charFormat();
- format.setFontWeight( bold ? QFont::Bold : QFont::Normal );
- m_caret.setCharFormat(format);
- m_commandId++;
- return;
- }
- if (m_commandId>254) m_commandId = 1;
+ if(! m_allowActions) return;
+ int start = m_caret.position();
+ int end = m_caret.anchor();
+ if(start == end) { // just set a new one.
+ QTextCharFormat format = m_caret.charFormat();
+ format.setFontWeight( bold ? QFont::Bold : QFont::Normal );
+ m_caret.setCharFormat(format);
+ return;
+ }
m_canvas->addCommand(new TextBoldCommand(m_textShapeData->document(), this, \
&m_caret, bold)); }
void TextTool::italic(bool italic)
{
- if(! m_allowActions) return;
- int start = m_caret.position();
- int end = m_caret.anchor();
- if(start == end) { // just set a new one.
- QTextCharFormat format = m_caret.charFormat();
- format.setFontItalic( italic );
- m_caret.setCharFormat(format);
- m_commandId++;
- return;
- }
- if (m_commandId>254) m_commandId = 1;
+ if(! m_allowActions) return;
+ int start = m_caret.position();
+ int end = m_caret.anchor();
+ if(start == end) { // just set a new one.
+ QTextCharFormat format = m_caret.charFormat();
+ format.setFontItalic( italic );
+ m_caret.setCharFormat(format);
+ return;
+ }
m_canvas->addCommand(new TextItalicCommand(m_textShapeData->document(), this, \
&m_caret, italic)); }
void TextTool::underline(bool underline)
{
- if(! m_allowActions) return;
- int start = m_caret.position();
- int end = m_caret.anchor();
- if(start == end) { // just set a new one.
- QTextCharFormat format = m_caret.charFormat();
- format.setFontUnderline( underline );
- m_caret.setCharFormat(format);
- m_commandId++;
- return;
- }
- if (m_commandId>254) m_commandId = 1;
+ if(! m_allowActions) return;
+ int start = m_caret.position();
+ int end = m_caret.anchor();
+ if(start == end) { // just set a new one.
+ QTextCharFormat format = m_caret.charFormat();
+ format.setFontUnderline( underline );
+ m_caret.setCharFormat(format);
+ return;
+ }
m_canvas->addCommand(new TextUnderlineCommand(m_textShapeData->document(), this, \
&m_caret, underline)); }
void TextTool::strikeOut(bool strikeOut)
{
- if(! m_allowActions) return;
- int start = m_caret.position();
- int end = m_caret.anchor();
- if(start == end) { // just set a new one.
- QTextCharFormat format = m_caret.charFormat();
- format.setFontStrikeOut( strikeOut );
- m_caret.setCharFormat(format);
- m_commandId++;
- return;
- }
- if (m_commandId>254) m_commandId = 1;
+ if(! m_allowActions) return;
+ int start = m_caret.position();
+ int end = m_caret.anchor();
+ if(start == end) { // just set a new one.
+ QTextCharFormat format = m_caret.charFormat();
+ format.setFontStrikeOut( strikeOut );
+ m_caret.setCharFormat(format);
+ return;
+ }
m_canvas->addCommand(new TextStrikeOutCommand(m_textShapeData->document(), this, \
&m_caret, strikeOut)); }
void TextTool::nonbreakingSpace() {
if(! m_allowActions) return;
- m_selectionHandler.insert(QString(QChar(Qt::Key_nobreakspace)));
+ m_canvas->addCommand(new TextInsertTextCommand(m_textShapeData->document(), \
this, &m_caret, QString(QChar(Qt::Key_nobreakspace)))); }
void TextTool::nonbreakingHyphen() {
if(! m_allowActions) return;
- m_selectionHandler.insert(QString(QChar(0x2013)));
+ m_canvas->addCommand(new TextInsertTextCommand(m_textShapeData->document(), \
this, &m_caret, QString(QChar(0x2013)))); }
void TextTool::softHyphen() {
if(! m_allowActions) return;
- m_selectionHandler.insert(QString(QChar(Qt::Key_hyphen)));
+ m_canvas->addCommand(new TextInsertTextCommand(m_textShapeData->document(), \
this, &m_caret, QString(QChar(Qt::Key_hyphen)))); }
void TextTool::lineBreak() {
if(! m_allowActions) return;
- m_selectionHandler.insert(QString(QChar('\n')));
+ m_canvas->addCommand(new TextInsertLineBreakCommand(m_textShapeData->document(), \
this, &m_caret)); }
-void TextTool::alignLeft() {
+void TextTool::alignLeft(bool on) {
if(! m_allowActions) return;
- m_selectionHandler.setHorizontalTextAlignment(Qt::AlignLeft);
+ if(on)
+ m_canvas->addCommand(new TextAlignCommand(m_textShapeData->document(), this, \
&m_caret, Qt::AlignLeft)); }
-void TextTool::alignRight() {
+void TextTool::alignRight(bool on) {
if(! m_allowActions) return;
- m_selectionHandler.setHorizontalTextAlignment(Qt::AlignRight);
+ if(on)
+ m_canvas->addCommand(new TextAlignCommand(m_textShapeData->document(), this, \
&m_caret, Qt::AlignRight)); }
-void TextTool::alignCenter() {
+void TextTool::alignCenter(bool on) {
if(! m_allowActions) return;
- m_selectionHandler.setHorizontalTextAlignment(Qt::AlignHCenter);
+ if(on)
+ m_canvas->addCommand(new TextAlignCommand(m_textShapeData->document(), this, \
&m_caret, Qt::AlignHCenter)); }
-void TextTool::alignBlock() {
+void TextTool::alignBlock(bool on) {
if(! m_allowActions) return;
- m_selectionHandler.setHorizontalTextAlignment(Qt::AlignJustify);
+ if(on)
+ m_canvas->addCommand(new TextAlignCommand(m_textShapeData->document(), this, \
&m_caret, Qt::AlignJustify)); }
void TextTool::superScript(bool on) {
if(! m_allowActions) return;
if(on)
- m_actionFormatSub->setChecked(false);
- m_selectionHandler.setVerticalTextAlignment(on ? Qt::AlignTop : \
Qt::AlignVCenter); + m_actionFormatSub->setChecked(false);
+ m_canvas->addCommand(new TextVerticalAlignCommand(m_textShapeData->document(), \
this, &m_caret, on ? QTextCharFormat::AlignSuperScript : \
QTextCharFormat::AlignNormal)); +// m_selectionHandler.setVerticalTextAlignment(on \
? Qt::AlignTop : Qt::AlignVCenter); }
void TextTool::subScript(bool on) {
if(! m_allowActions) return;
if(on)
m_actionFormatSuper->setChecked(false);
- m_selectionHandler.setVerticalTextAlignment(on ? Qt::AlignBottom : \
Qt::AlignVCenter); + m_canvas->addCommand(new \
TextVerticalAlignCommand(m_textShapeData->document(), this, &m_caret, on ? \
QTextCharFormat::AlignSubScript : QTextCharFormat::AlignNormal)); +// \
m_selectionHandler.setVerticalTextAlignment(on ? Qt::AlignBottom : Qt::AlignVCenter); \
}
void TextTool::increaseIndent() {
if(! m_allowActions) return;
- m_selectionHandler.increaseIndent();
+ m_canvas->addCommand(new TextIncreaseIndentCommand(m_textShapeData->document(), \
this, &m_caret));
m_actionFormatDecreaseIndent->setEnabled(m_caret.blockFormat().leftMargin() > \
0.); }
void TextTool::decreaseIndent() {
if(! m_allowActions) return;
- m_selectionHandler.decreaseIndent();
+ m_canvas->addCommand(new TextDecreaseIndentCommand(m_textShapeData->document(), \
this, &m_caret));
m_actionFormatDecreaseIndent->setEnabled(m_caret.blockFormat().leftMargin() > \
0.); }
--- branches/work/koffice_trackchange/shapes/text/TextTool.h #657669:657670
@@ -101,8 +101,6 @@
void flagUndoRedo( bool flag );
- int getCommandUniqueId();
-
void updateActions();
signals:
@@ -143,13 +141,13 @@
/// insert a linebreak at the caret position
void lineBreak();
/// align all of the selected text left
- void alignLeft();
+ void alignLeft(bool);
/// align all of the selected text right
- void alignRight();
+ void alignRight(bool);
/// align all of the selected text centered
- void alignCenter();
+ void alignCenter(bool);
/// align all of the selected text block-justified
- void alignBlock();
+ void alignBlock(bool);
/// make the selected text switch to be super-script
void superScript(bool);
/// make the selected text switch to be sub-script
@@ -195,9 +193,7 @@
bool m_allowActions;
bool m_allowAddUndoCommand;
int m_prevCursorPosition; /// used by editingPluginEvents
- int m_commandId;
-
QAction *m_actionFormatBold;
QAction *m_actionFormatItalic;
QAction *m_actionFormatUnderline;
--- branches/work/koffice_trackchange/shapes/text/commands/TextBoldCommand.cpp \
#657669:657670 @@ -32,7 +32,6 @@
m_document(document),
m_tool(tool),
m_caret(caret)
-
{
QTextCharFormat format;
format.setFontWeight( m_bold ? QFont::Bold : QFont::Normal );
--- branches/work/koffice_trackchange/shapes/text/commands/TextInsertTextCommand.cpp \
#657669:657670 @@ -71,23 +71,16 @@
bool TextInsertTextCommand::mergeWith(const QUndoCommand *other)
{
-kDebug() << "in insertText mergeWith" << endl;
if (other->id() != m_id){ // make sure other is also an InsertText command
return false;
}
-kDebug() << "other orig pos: " << static_cast<const \
TextInsertTextCommand*>(other)->m_position - static_cast<const \
TextInsertTextCommand*>(other)->m_text.length() << endl;
-
-kDebug() << "this pos: " << m_position << endl;
if ((m_position == (static_cast<const TextInsertTextCommand*>(other)->m_position \
- static_cast<const TextInsertTextCommand*>(other)->m_text.length())) \
&&
(static_cast<const TextInsertTextCommand*>(other)->m_charFormat == \
m_charFormat) ) {
-kDebug() << "can merge" << endl;
m_text += static_cast<const TextInsertTextCommand*>(other)->m_text;
m_position += static_cast<const \
TextInsertTextCommand*>(other)->m_text.length();
-kDebug() << "final pos: " << m_position << " final text: " << m_text << endl;
return true;
}
-kDebug() << "can't merge" << endl;
return false;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic