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

List:       koffice-devel
Subject:    KWord Doc Structure Area refreshing
From:       Gary Cramblitt <garycramblitt () comcast ! net>
Date:       2005-12-23 21:19:40
Message-ID: 200512231619.41034.garycramblitt () comcast ! net
[Download RAW message or body]

I have committed the attached changes (rev 490953)  to 
lib/kofficeui/kocommandhistory, kword/KWDocument, and kword/KWDocStruct so 
that the document structure area (panel on left) will refresh as user makes 
changes to the document.  I'm a bit concerned about performance impact.

The simplest way to get the dsa to refresh was to emit a signal whenever a 
command is added to the command history, hence I added commandHistoryChanged 
signal to kocommandhistory.  To get the paragraph names to properly update, I 
also added an "emit docStructureChanged" to KWDocument::paragraphModified.  
The latter particularly concerns me because it generates repaints (in 
KWView::docStructChanged) for every character typed.  Perhaps I should add a 
new signal to KWDocument and hook that?  Or maybe there's a better way to do 
this?

Performance seems fine on my machine, but I have an amd 3700.  Does anyone 
with a slower machine notice a performance impact?

-- 
Gary Cramblitt (aka PhantomsDad)

["koffice.diff" (text/x-diff)]

Index: kword/KWDocStruct.h
===================================================================
--- kword/KWDocStruct.h	(revision 490946)
+++ kword/KWDocStruct.h	(working copy)
@@ -335,6 +335,10 @@
     /** Set focus to the tree, if visible. */
     void setFocusHere();
 
+public slots:
+    /** Refresh the entire tree. */
+    void refreshEntireTree();
+
 protected:
     KWDocStructTree* m_tree;
     QVBoxLayout* m_layout;
Index: kword/KWDocument.cpp
===================================================================
--- kword/KWDocument.cpp	(revision 490946)
+++ kword/KWDocument.cpp	(working copy)
@@ -5237,6 +5237,7 @@
 void KWDocument::paragraphModified(KoTextParag* /*parag*/, int \
/*KoTextParag::ParagModifyType*/ /*type*/, int /*start*/, int /*lenght*/)  {
     //kdDebug()<<" parag :"<<parag<<" start :"<<start<<" lenght :"<<lenght<<endl;
+    emit docStructureChanged(Tables | TextFrames);
 }
 
 
Index: kword/KWDocStruct.cpp
===================================================================
--- kword/KWDocStruct.cpp	(revision 490946)
+++ kword/KWDocStruct.cpp	(working copy)
@@ -1200,6 +1200,9 @@
     searchBar->setStretchableWidget( searchLine );
     connect( eraseButton, SIGNAL( clicked() ), searchLine, SLOT( clear() ) );
 
+    connect( m_doc->commandHistory(), SIGNAL( commandHistoryChanged() ),
+        this, SLOT( refreshEntireTree() ) );
+
     m_layout->addWidget(searchBar);
     m_layout->addWidget(m_tree);
     m_tree->setup();
@@ -1223,6 +1226,11 @@
     }
 }
 
+void KWDocStruct::refreshEntireTree()
+{
+    refreshTree((int)(TextFrames | FormulaFrames | Tables | Pictures | Embedded));
+}
+
 void KWDocStruct::setFocusHere()
 {
     if (m_tree)
Index: lib/kofficeui/kocommandhistory.h
===================================================================
--- lib/kofficeui/kocommandhistory.h	(revision 490946)
+++ lib/kofficeui/kocommandhistory.h	(working copy)
@@ -164,6 +164,10 @@
      * saved the document for the last time. See @ref #documentSaved
      */
     void documentRestored();
+    /**
+     * Emitted whenever addCommand (executed or not), undo, or redo is called.
+     */
+    void commandHistoryChanged();
 
 private:
     void clipCommands();  // ensures that the limits are kept
Index: lib/kofficeui/kocommandhistory.cpp
===================================================================
--- lib/kofficeui/kocommandhistory.cpp	(revision 490946)
+++ lib/kofficeui/kocommandhistory.cpp	(working copy)
@@ -153,6 +153,7 @@
     }
     d->m_present = 0L;
     d->m_savedAt=-42;
+    emit commandHistoryChanged();
 }
 
 void KoCommandHistory::addCommand(KCommand *command, bool execute) {
@@ -204,6 +205,7 @@
         command->execute();
         emit commandExecuted();
     }
+    emit commandHistoryChanged();
 }
 
 void KoCommandHistory::undo() {
@@ -238,6 +240,7 @@
         m_first=true;
     }
     clipCommands(); // only needed here and in addCommand, NOT in redo
+    emit commandHistoryChanged();
 }
 
 void KoCommandHistory::redo() {
@@ -277,6 +280,7 @@
             m_redo->setText(i18n("&Redo"));
         }
     }
+    emit commandHistoryChanged();
 }
 
 void KoCommandHistory::documentSaved() {



_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


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

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