[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Thu Oct 2 12:55:52 CEST 2003
CVS commit by staikos:
Early results from profiling:
- cache the label width where possible to avoid recalculation (very expensive)
- don't update dialogs that aren't shown()
- cache the font families
M +5 -1 kstdatamanager_i.cpp 1.36
M +18 -1 kstlabel.cpp 1.18
M +8 -6 kstplotdialog_i.cpp 1.24
--- kdeextragear-2/kst/kst/kstdatamanager_i.cpp #1.35:1.36
@@ -223,11 +223,15 @@ KstDataManagerI::~KstDataManagerI() {
void KstDataManagerI::show_I() {
- update();
show();
raise();
+ update();
}
void KstDataManagerI::update() {
+if (!isShown()) {
+ return;
+}
+
QPtrStack<QListViewItem> trash;
--- kdeextragear-2/kst/kst/kstlabel.cpp #1.17:1.18
@@ -49,4 +49,5 @@ KstLabel::KstLabel(const QString &in_tex
doScalarReplacement = true;
IsSample = is_sample;
+ Width = -1; // invalidate the width
}
@@ -55,8 +56,14 @@ KstLabel::~KstLabel(){
void KstLabel::setText(const QString &in_text) {
+ if (Text != in_text) {
+ Width = -1; // invalidate the width
+ }
Text = in_text;
}
void KstLabel::setRotation(float in_rotation) {
+ if (Rotation != in_rotation) {
+ Width = -1; // invalidate the width
+ }
Rotation = in_rotation;
}
@@ -68,4 +75,7 @@ void KstLabel::setRelPosition(float in_X
void KstLabel::setJustification(KstJustifyType in_j) {
+ if (Justify != in_j) {
+ Width = -1; // invalidate the width
+ }
Justify = in_j;
}
@@ -73,4 +83,6 @@ void KstLabel::setJustification(KstJusti
/** Return the width of the label */
int KstLabel::width(QPainter &p) {
+ // FIXME: this is still expensive.
+ if (Width < 0)
draw(p, 0, 0, false); // Do a dummy draw to evaluate the width
return int(Width);
@@ -380,8 +392,10 @@ void KstLabel::read(QDomElement &e) {
void KstLabel::setSize(int in_size) {
+ Width = -1; // invalidate the width
Size = in_size;
}
void KstLabel::setFontName(const QString &in_fontName) {
+ Width = -1; // invalidate the width
FontName = in_fontName;
}
@@ -427,4 +441,7 @@ QString KstLabel::fontName() {
void KstLabel::setDoScalarReplacement(bool in_do) {
+ if (in_do != doScalarReplacement) {
+ Width = -1; // invalidate the width
+ }
doScalarReplacement = in_do;
}
--- kdeextragear-2/kst/kst/kstplotdialog_i.cpp #1.23:1.24
@@ -116,4 +116,6 @@ KstPlotDialogI::KstPlotDialogI(KstDoc *i
SampleLabel = new KstLabel("\0", CxCy, 0.0, 0.0, 0.0, true);
+ QFontDatabase qfd;
+ FontComboBox->setFonts(qfd.families());
}
@@ -135,5 +137,8 @@ void KstPlotDialogI::update(int new_inde
KstBaseCurvePtr curve;
double xmin, ymin, xmax, ymax;
- QFontDatabase qfd;
+
+ if (!isShown()) {
+ return;
+ }
KstBaseCurveList curves = kstObjectSubList<KstDataObject, KstBaseCurve>(KST::dataObjectList);
@@ -145,7 +150,7 @@ void KstPlotDialogI::update(int new_inde
/* Fill the Select combo, and set it to the right item */
- if (new_index>=0) {
+ if (new_index >= 0) {
index = new_index;
- } else if (Select->count()>0) {
+ } else if (Select->count() > 0) {
index = Select->currentItem();
} else {
@@ -246,7 +251,4 @@ void KstPlotDialogI::update(int new_inde
TopLabelFontSize->setValue(plot->TopLabel->size());
- FontComboBox->clear();
-
- FontComboBox->setFonts(qfd.families());
FontComboBox->setCurrentFont(plot->TopLabel->fontName());
More information about the Kst
mailing list