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

List:       kde-commits
Subject:    [calligra/calligra/2.9] libs/kotext: Loop optimalization at table cell formatting
From:       Sven Langkamp <sven.langkamp () gmail ! com>
Date:       2015-07-20 9:23:32
Message-ID: E1ZH7IK-0006H0-JV () scm ! kde ! org
[Download RAW message or body]

Git commit 4ae68ee708ed34f167dad0eb222ed1b4934e0bd5 by Sven Langkamp.
Committed on 20/07/2015 at 09:23.
Pushed by langkamp into branch 'calligra/2.9'.

Loop optimalization at table cell formatting
Patch by Soma Schliszka
REVIEW:124291

M  +11   -10   libs/kotext/KoTextEditor.cpp

http://commits.kde.org/calligra/4ae68ee708ed34f167dad0eb222ed1b4934e0bd5

diff --git a/libs/kotext/KoTextEditor.cpp b/libs/kotext/KoTextEditor.cpp
index 7191db5..6041ce9 100644
--- a/libs/kotext/KoTextEditor.cpp
+++ b/libs/kotext/KoTextEditor.cpp
@@ -981,19 +981,20 @@ void KoTextEditor::insertTable(int rows, int columns)
     blockFormat.setProperty(KoParagraphStyle::HiddenByTable, true);
     cursor.setBlockFormat(blockFormat);
 
-    // Format the cells a bit.
+    // Define the initial cell format
+    QTextTableCellFormat format;
+    KoTableCellStyle cellStyle;
+    cellStyle.setEdge(KoBorder::TopBorder, KoBorder::BorderSolid, 2, QColor(Qt::black));
+    cellStyle.setEdge(KoBorder::LeftBorder, KoBorder::BorderSolid, 2, QColor(Qt::black));
+    cellStyle.setEdge(KoBorder::BottomBorder, KoBorder::BorderSolid, 2, QColor(Qt::black));
+    cellStyle.setEdge(KoBorder::RightBorder, KoBorder::BorderSolid, 2, QColor(Qt::black));
+    cellStyle.setPadding(5);
+    cellStyle.applyStyle(format);
+
+    // Apply formatting to all cells
     for (int row = 0; row < table->rows(); ++row) {
         for (int col = 0; col < table->columns(); ++col) {
             QTextTableCell cell = table->cellAt(row, col);
-            QTextTableCellFormat format;
-            KoTableCellStyle cellStyle;
-            cellStyle.setEdge(KoBorder::TopBorder, KoBorder::BorderSolid, 2, QColor(Qt::black));
-            cellStyle.setEdge(KoBorder::LeftBorder, KoBorder::BorderSolid, 2, QColor(Qt::black));
-            cellStyle.setEdge(KoBorder::BottomBorder, KoBorder::BorderSolid, 2, QColor(Qt::black));
-            cellStyle.setEdge(KoBorder::RightBorder, KoBorder::BorderSolid, 2, QColor(Qt::black));
-            cellStyle.setPadding(5);
-
-            cellStyle.applyStyle(format);
             cell.setFormat(format);
         }
     }
[prev in list] [next in list] [prev in thread] [next in thread] 

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