[prev in list] [next in list] [prev in thread] [next in thread]
List: kwrite-devel
Subject: Save time/cpu for config page apply()
From: Anders Lund <anders.lund () lund ! tdcadsl ! dk>
Date: 2003-12-18 23:07:24
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Hi,
The time it would take for Kate to apply() changes in the config dialog has
been bugging me for a while.
This is the first part of a solution: don't spend time in apply() unless
something actually changed.
The patch adds a bool variable to the Kate::ConfigPage class, and a few lines
to manage the variable and test in the individual pages in kate/part/
katedialogs.cpp
TODO: Fix the dialog for schemes, and the pages in kdebase/kate and pages for
plugins.
Comments?
-anders
--
*** NEW ID *** Jabber: anderslund@jabber.dk
GPG fingerprint: 4B50 66DE CF6E 35E3 4446 5DC1 CB23 1264 0F2C 0826
["apply.diff" (text/x-diff)]
Index: interfaces/document.h
===================================================================
RCS file: /home/kde/kdelibs/kate/interfaces/document.h,v
retrieving revision 1.72
diff -u -r1.72 document.h
--- interfaces/document.h 3 Dec 2003 20:56:52 -0000 1.72
+++ interfaces/document.h 18 Dec 2003 22:57:17 -0000
@@ -55,7 +55,7 @@
Q_OBJECT
public:
- ConfigPage ( QWidget *parent=0, const char *name=0 ) : KTextEditor::ConfigPage \
(parent, name) { ; }; + ConfigPage ( QWidget *parent=0, const char *name=0 ) : \
KTextEditor::ConfigPage (parent, name), m_changed( true ) { ; }; virtual ~ConfigPage \
() { ; };
public slots:
@@ -66,6 +66,8 @@
protected slots:
void slotChanged();
+ protected:
+ bool m_changed;
};
class ActionMenu : public KActionMenu
Index: interfaces/interfaces.cpp
===================================================================
RCS file: /home/kde/kdelibs/kate/interfaces/interfaces.cpp,v
retrieving revision 1.22
diff -u -r1.22 interfaces.cpp
--- interfaces/interfaces.cpp 3 Dec 2003 20:56:52 -0000 1.22
+++ interfaces/interfaces.cpp 18 Dec 2003 22:57:17 -0000
@@ -86,6 +86,7 @@
void ConfigPage::slotChanged()
{
+ m_changed = true;
emit changed();
}
Index: part/katedialogs.cpp
===================================================================
RCS file: /home/kde/kdelibs/kate/part/katedialogs.cpp,v
retrieving revision 1.98
diff -u -r1.98 katedialogs.cpp
--- part/katedialogs.cpp 16 Dec 2003 22:43:11 -0000 1.98
+++ part/katedialogs.cpp 18 Dec 2003 22:57:18 -0000
@@ -129,9 +129,13 @@
void SpellConfigPage::apply ()
{
// kspell
+ if ( ! m_changed ) return;
+ m_changed = false;
cPage->writeGlobalSettings ();
}
+//FIXME add SpellConfigPage::reload()
+
//BEGIN GotoLineDialog
GotoLineDialog::GotoLineDialog(QWidget *parent, int line, int max)
: KDialogBase(parent, 0L, true, i18n("Go to Line"), Ok | Cancel, Ok) {
@@ -252,6 +256,9 @@
void IndentConfigTab::apply ()
{
+ if ( ! m_changed ) return;
+ m_changed = false;
+
int configFlags, z;
configFlags = KateDocumentConfig::global()->configFlags();
@@ -270,6 +277,7 @@
void IndentConfigTab::reload ()
{
+ m_changed = false; // FIXME It seems not everything is reloaded??
if (KateDocumentConfig::global()->configFlags() & \
KateDocumentConfig::cfTabIndentsMode) m_tabs->setButton (2);
else if (KateDocumentConfig::global()->configFlags() & \
KateDocumentConfig::cfTabInsertsTab) @@ -311,6 +319,7 @@
void SelectConfigTab::apply ()
{
+ if ( ! m_changed ) return;
int configFlags = KateDocumentConfig::global()->configFlags();
configFlags &= ~KateDocumentConfig::cfPersistent; // clear persistent
@@ -321,12 +330,15 @@
KateDocumentConfig::global()->setConfigFlags(configFlags);
}
+// FIXME reload *everything*
void SelectConfigTab::reload ()
{
if (KateDocumentConfig::global()->configFlags() & \
KateDocumentConfig::cfPersistent) m_tabs->setButton (1);
else
m_tabs->setButton (0);
+
+ m_changed = false;
}
//END SelectConfigTab
@@ -457,6 +469,9 @@
void EditConfigTab::apply ()
{
+ if ( ! m_changed ) return;
+ m_changed = false;
+
int configFlags, z;
configFlags = KateDocumentConfig::global()->configFlags();
@@ -480,6 +495,7 @@
KateDocumentConfig::global()->setPageUpDownMovesCursor(e6->isChecked());
}
+// FIXME fill this in and use it
void EditConfigTab::reload ()
{
@@ -582,6 +598,9 @@
void ViewDefaultsConfig::apply ()
{
+ if ( ! m_changed ) return;
+ m_changed = false;
+
KateViewConfig::global()->setDynWordWrap (m_dynwrap->isChecked());
KateViewConfig::global()->setDynWordWrapIndicators \
(m_dynwrapIndicatorsCombo->currentItem ()); \
KateViewConfig::global()->setDynWordWrapAlignIndent(m_dynwrapAlignLevel->value()); @@ \
-594,6 +613,8 @@
void ViewDefaultsConfig::reload ()
{
+ m_changed = false;
+
m_dynwrap->setChecked(KateViewConfig::global()->dynWordWrap());
m_dynwrapIndicatorsCombo->setCurrentItem( \
KateViewConfig::global()->dynWordWrapIndicators() ); \
m_dynwrapAlignLevel->setValue(KateViewConfig::global()->dynWordWrapAlignIndent()); @@ \
-902,6 +923,7 @@ //END
//BEGIN PluginConfigPage
+// FIXME -- *why* doesn't this one follow the usual apply() reload() scheme ?!?
PluginConfigPage::PluginConfigPage (QWidget *parent, KateDocument *doc) : \
Kate::ConfigPage (parent, "") {
m_doc = doc;
@@ -935,6 +957,7 @@
else
unloadPlugin(item);
emit changed();
+ m_changed = true;
}
void PluginConfigPage::loadPlugin (PluginListItem *item)
@@ -1035,6 +1058,8 @@
void HlConfigPage::apply ()
{
+ if ( ! m_changed ) return;
+ m_changed = false;
writeback();
for ( QIntDictIterator<HlData> it( hlDataDict ); it.current(); ++it )
@@ -1043,6 +1068,7 @@
HlManager::self()->getKConfig()->sync ();
}
+// FIXME ?!
void HlConfigPage::reload ()
{
}
[Attachment #8 (application/pgp-signature)]
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic