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

List:       kde-commits
Subject:    =?utf-8?q?=5Bcalligra=5D_libs/kotext=3A_Actually_insert_a_Table_?=
From:       Casper Boemann <cbo () boemann ! dk>
Date:       2011-05-16 9:13:34
Message-ID: 20110516091334.B0BF6A60E1 () git ! kde ! org
[Download RAW message or body]

Git commit 931b8d7d9ac052a8616f95c12d2cde0692ecf34a by Casper Boemann.
Committed on 14/05/2011 at 19:55.
Pushed by boemann into branch 'master'.

Actually insert a Table of Centents and not a table.

Since autogeneration is disabled it's empty for now.

M  +17   -13   libs/kotext/KoTextEditor.cpp     

http://commits.kde.org/calligra/931b8d7d9ac052a8616f95c12d2cde0692ecf34a

diff --git a/libs/kotext/KoTextEditor.cpp b/libs/kotext/KoTextEditor.cpp
index ac70324..be2d695 100644
--- a/libs/kotext/KoTextEditor.cpp
+++ b/libs/kotext/KoTextEditor.cpp
@@ -29,6 +29,7 @@
 #include "KoTextLocator.h"
 #include "KoTextOdfSaveHelper.h"
 #include "KoTextPaste.h"
+#include "KoTableOfContentsGeneratorInfo.h"
 #include "changetracker/KoChangeTracker.h"
 #include "changetracker/KoChangeTrackerElement.h"
 #include "changetracker/KoDeleteChangeMarker.h"
@@ -955,13 +956,15 @@ void KoTextEditor::insertTable(int rows, int columns)
         QString title = i18n("Insert Table");
 
         int changeId;
-        if (!d->caret.atBlockStart())
+        if (!d->caret.atBlockStart()) {
             changeId = changeTracker->mergeableId(KoGenChange::InsertChange, title, \
                charFormat.intProperty(KoCharacterStyle::ChangeTrackerId));
-        else
+        } else {
             changeId = changeTracker->mergeableId(KoGenChange::InsertChange, title, \
blockFormat.intProperty(KoCharacterStyle::ChangeTrackerId)); +        }
 
-        if (!changeId)
+        if (!changeId) {
             changeId = \
KoTextDocument(d->document).changeTracker()->getInsertChangeId(title, 0); +        }
 
         tableFormat.setProperty(KoCharacterStyle::ChangeTrackerId, changeId);
     }
@@ -1102,13 +1105,12 @@ void KoTextEditor::splitTableCells()
 
 void KoTextEditor::insertTableOfContents()
 {
-    int rows=5; int columns=2;
-
     d->updateState(KoTextEditor::Private::Custom, i18n("Insert Table Of Contents"));
-    QTextTableFormat tableFormat;
 
-    tableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
-    tableFormat.setMargin(5);
+    QTextFrameFormat tocFormat;
+    tocFormat.setProperty(KoText::SubFrameType, KoText::TableOfContentsFrameType);
+    KoTableOfContentsGeneratorInfo * info = new KoTableOfContentsGeneratorInfo();
+    tocFormat.setProperty( KoText::TableOfContentsData, \
QVariant::fromValue<KoTableOfContentsGeneratorInfo*>(info) );  
     KoChangeTracker *changeTracker = KoTextDocument(d->document).changeTracker();
     if (changeTracker && changeTracker->recordChanges()) {
@@ -1117,18 +1119,20 @@ void KoTextEditor::insertTableOfContents()
         QString title = i18n("Insert Table Of Contents");
 
         int changeId;
-        if (!d->caret.atBlockStart())
+        if (!d->caret.atBlockStart()) {
             changeId = changeTracker->mergeableId(KoGenChange::InsertChange, title, \
                charFormat.intProperty(KoCharacterStyle::ChangeTrackerId));
-        else
+        } else {
             changeId = changeTracker->mergeableId(KoGenChange::InsertChange, title, \
blockFormat.intProperty(KoCharacterStyle::ChangeTrackerId)); +        }
 
-        if (!changeId)
+        if (!changeId) {
             changeId = \
KoTextDocument(d->document).changeTracker()->getInsertChangeId(title, 0); +        }
 
-        tableFormat.setProperty(KoCharacterStyle::ChangeTrackerId, changeId);
+        tocFormat.setProperty(KoCharacterStyle::ChangeTrackerId, changeId);
     }
 
-    QTextTable *table = d->caret.insertTable(rows, columns, tableFormat);
+    d->caret.insertFrame(tocFormat);
 
     d->updateState(KoTextEditor::Private::NoOp);
 }


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

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