[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bcalligra/words-change=5Ftracking-ganeshp=5D_libs/ko?=
From:       Ganesh Paramasivam <ganesh () crystalfab ! com>
Date:       2011-03-01 6:49:19
Message-ID: 20110301064919.0CAD1A60C9 () git ! kde ! org
[Download RAW message or body]

Git commit d7a8c8e1c74c386db3f71cf51ea110b851dc9bdf by Ganesh Paramasivam.
Committed on 01/03/2011 at 07:49.
Pushed by ganeshp into branch 'words-change_tracking-ganeshp'.

Enable tracking of table row deletions

M  +3    -25   libs/kotext/KoTextEditor.cpp     
M  +23   -11   libs/kotext/commands/DeleteTableRowCommand.cpp     
M  +2    -1    libs/kotext/commands/DeleteTableRowCommand.h     

http://commits.kde.org/calligra/d7a8c8e1c74c386db3f71cf51ea110b851dc9bdf

diff --git a/libs/kotext/KoTextEditor.cpp b/libs/kotext/KoTextEditor.cpp
index d1c5628..52f159b 100644
--- a/libs/kotext/KoTextEditor.cpp
+++ b/libs/kotext/KoTextEditor.cpp
@@ -1150,35 +1150,13 @@ void KoTextEditor::deleteTableRow()
 {
     QTextTable *table = d->caret.currentTable();
     if (table) {
-        /*
-        KoTableColumnAndRowStyleManager carsManager = \
                KoTableColumnAndRowStyleManager::getManager(table);
-        int selectionRow;
-        int selectionColumn;
-        int selectionRowSpan;
-        int selectionColumnSpan;
-        if(d->caret.hasComplexSelection()) {
-            d->caret.selectedTableCells(&selectionRow, &selectionRowSpan, \
                &selectionColumn, &selectionColumnSpan);
-        } else {
-            QTextTableCell cell = table->cellAt(d->caret);
-            selectionRow = cell.row();
-            selectionRowSpan = 1;
-        }
-
         KoChangeTracker *changeTracker = \
KoTextDocument(d->document).changeTracker(); +        int changeId = 0;
         if (changeTracker && changeTracker->recordChanges()) {
             QString title(i18n("Delete Row"));
-            int changeId = changeTracker->getDeleteChangeId(title, \
                QTextDocumentFragment(), 0);
-            for (int i=0; i < table->columns(); i++) {
-                QTextTableCellFormat cellFormat = table->cellAt(selectionRow, \
                i).format().toTableCellFormat();
-                cellFormat.setProperty(KoCharacterStyle::ChangeTrackerId, changeId);
-                table->cellAt(selectionRow, i).setFormat(cellFormat);
-            }
-        } else {
-            table->removeRows(selectionRow, selectionRowSpan);
-            carsManager.removeRows(selectionRow, selectionRowSpan);
+            changeId = changeTracker->getDeleteChangeId(title, \
QTextDocumentFragment(), 0);  }
-        */
-        addCommand(new DeleteTableRowCommand(this, table));
+        addCommand(new DeleteTableRowCommand(this, table, changeId));
     }
 }
 
diff --git a/libs/kotext/commands/DeleteTableRowCommand.cpp \
b/libs/kotext/commands/DeleteTableRowCommand.cpp index bb88e17..21f3c18 100644
--- a/libs/kotext/commands/DeleteTableRowCommand.cpp
+++ b/libs/kotext/commands/DeleteTableRowCommand.cpp
@@ -29,23 +29,25 @@
 #include <klocale.h>
 #include <kdebug.h>
 
-DeleteTableRowCommand::DeleteTableRowCommand(KoTextEditor *te, QTextTable *t,
+DeleteTableRowCommand::DeleteTableRowCommand(KoTextEditor *te, QTextTable *t, int \
changeId,  QUndoCommand *parent) :
     QUndoCommand (parent)
     ,m_first(true)
     ,m_textEditor(te)
     ,m_table(t)
+    ,m_changeId(changeId)
 {
     setText(i18n("Delete Row"));
 }
 
 void DeleteTableRowCommand::undo()
 {
-    KoTableColumnAndRowStyleManager carsManager = \
                KoTableColumnAndRowStyleManager::getManager(m_table);
-    for (int i = 0; i < m_selectionRowSpan; ++i) {
-        carsManager.insertRows(m_selectionRow + i, 1, m_deletedStyles.at(i));
+    if (!m_changeId) {
+        KoTableColumnAndRowStyleManager carsManager = \
KoTableColumnAndRowStyleManager::getManager(m_table); +        for (int i = 0; i < \
m_selectionRowSpan; ++i) { +            carsManager.insertRows(m_selectionRow + i, 1, \
m_deletedStyles.at(i)); +        }
     }
-
     QUndoCommand::undo();
 }
 
@@ -53,7 +55,9 @@ void DeleteTableRowCommand::redo()
 {
     KoTableColumnAndRowStyleManager carsManager = \
KoTableColumnAndRowStyleManager::getManager(m_table);  if (!m_first) {
-        carsManager.removeRows(m_selectionRow, m_selectionRowSpan);
+        if (!m_changeId) {
+            carsManager.removeRows(m_selectionRow, m_selectionRowSpan);
+        }
         QUndoCommand::redo();
     } else {
         m_first = false;
@@ -67,11 +71,19 @@ void DeleteTableRowCommand::redo()
             m_selectionRowSpan = 1;
         }
 
-        for (int i = m_selectionRow; i < m_selectionRow + m_selectionRowSpan; ++i) {
-            m_deletedStyles.append(carsManager.rowStyle(i));
+        if (!m_changeId) {
+            for (int i = m_selectionRow; i < m_selectionRow + m_selectionRowSpan; \
++i) { +                m_deletedStyles.append(carsManager.rowStyle(i));
+            }
+            carsManager.removeRows(m_selectionRow, m_selectionRowSpan);
+    
+            m_table->removeRows(m_selectionRow, m_selectionRowSpan);
+        } else {
+            for (int i=0; i < m_table->columns(); i++) {
+                QTextTableCellFormat cellFormat = m_table->cellAt(m_selectionRow, \
i).format().toTableCellFormat(); +                \
cellFormat.setProperty(KoCharacterStyle::ChangeTrackerId, m_changeId); +              \
m_table->cellAt(m_selectionRow, i).setFormat(cellFormat); +            }    
         }
-        carsManager.removeRows(m_selectionRow, m_selectionRowSpan);
-
-        m_table->removeRows(m_selectionRow, m_selectionRowSpan);
     }
 }
diff --git a/libs/kotext/commands/DeleteTableRowCommand.h \
b/libs/kotext/commands/DeleteTableRowCommand.h index 4b86d7c..3aa25b3 100644
--- a/libs/kotext/commands/DeleteTableRowCommand.h
+++ b/libs/kotext/commands/DeleteTableRowCommand.h
@@ -32,7 +32,7 @@ class DeleteTableRowCommand : public QUndoCommand
 {
 public:
 
-    DeleteTableRowCommand(KoTextEditor *te, QTextTable *t, QUndoCommand *parent = \
0); +    DeleteTableRowCommand(KoTextEditor *te, QTextTable *t, int changeId = 0, \
QUndoCommand *parent = 0);  
     virtual void undo();
     virtual void redo();
@@ -43,6 +43,7 @@ private:
     QTextTable *m_table;
     int m_selectionRow;
     int m_selectionRowSpan;
+    int m_changeId;
     QList<KoTableRowStyle> m_deletedStyles;
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic