[Kst] branches/work/kst/kst1kde4/kst/src/libkstapp
Andrew Walker
arwalker at sumusltd.com
Wed Mar 24 01:24:22 CET 2010
SVN commit 1106844 by arwalker:
continue kst1kde4
M +1 -1 kst2dplot.cpp
M +6 -7 ksteditviewobjectdialog.h
M +28 -18 kstplotgroup.cpp
M +2 -2 kstplotgroup.h
M +88 -59 kstviewobject.cpp
--- branches/work/kst/kst1kde4/kst/src/libkstapp/kst2dplot.cpp #1106843:1106844
@@ -3868,7 +3868,7 @@
tlv = kst_cast<KstTopLevelView>(KstViewObjectPtr(_topObjectForMenu));
if (tlv) {
- if (QMessageBox::warning(tlv->widget(), i18n("Kst"), i18n("Are you sure you want to delete plot '%1'?").arg(tagName(), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ if (QMessageBox::warning(tlv->widget(), i18n("Kst"), i18n("Are you sure you want to delete plot '%1'?").arg(tagName()), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
remove = true;
}
}
--- branches/work/kst/kst1kde4/kst/src/libkstapp/ksteditviewobjectdialog.h #1106843:1106844
@@ -18,6 +18,9 @@
#ifndef KSTEDITVIEWOBJECTDIALOGI_H
#define KSTEDITVIEWOBJECTDIALOGI_H
+#include <QComboBox>
+#include <QGridLayout>
+#include <QList>
#include <QPointer>
#include "editmultiplewidget.h"
@@ -27,15 +30,12 @@
#include "ksttoplevelview.h"
#include "kst_export.h"
-class QComboBox;
-class QGridLayout;
-
class KST_EXPORT KstEditViewObjectDialog : public QDialog, public Ui::KstEditViewObjectDialog {
Q_OBJECT
public:
KstEditViewObjectDialog(QWidget* parent = 0,
const char* name = 0,
- bool modal = false, WFlags fl = 0 );
+ bool modal = false, Qt::WindowFlags fl = 0 );
virtual ~KstEditViewObjectDialog();
public slots:
@@ -65,9 +65,8 @@
KstViewObjectPtr _viewObject; // the view object we are currently editing
KstTopLevelViewPtr _top; // the top level view that invoked this dialog
- // for layout purposes
- QValueList<QWidget*> _inputWidgets; // the widgets used to change properties
- QValueList<QWidget*> _widgets; // all other widgets
+ QList<QWidget*> _inputWidgets; // the widgets used to change properties
+ QList<QWidget*> _widgets; // all other widgets
QGridLayout* _grid;
QPointer<QWidget> _customWidget;
bool _isNew;
--- branches/work/kst/kst1kde4/kst/src/libkstapp/kstplotgroup.cpp #1106843:1106844
@@ -162,7 +162,7 @@
}
-bool KstPlotGroup::popupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topParent) {
+bool KstPlotGroup::popupMenu(QMenu *menu, const QPoint& pos, KstViewObjectPtr topParent) {
KstMetaPlot::popupMenu(menu, pos, topParent);
KstViewObjectPtr c = findChild(pos + position());
if (c) {
@@ -177,12 +177,15 @@
}
-bool KstPlotGroup::layoutPopupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topParent) {
+bool KstPlotGroup::layoutPopupMenu(QMenu *menu, const QPoint& pos, KstViewObjectPtr topParent) {
+ KstViewObjectPtr c;
+
KstMetaPlot::layoutPopupMenu(menu, pos, topParent);
- menu->insertItem(i18n("&Ungroup"), this, SLOT(flatten()));
- KstViewObjectPtr c = findChild(pos + position());
+ menu->addAction(i18n("&Ungroup"), this, SLOT(flatten()));
+ c = findChild(pos + position());
if (c) {
- KPopupMenu *s = new KPopupMenu(menu);
+ QMenu *s = new QMenu(menu);
+
if (c->layoutPopupMenu(s, pos - c->position(), topParent)) {
menu->insertItem(c->tagName(), s);
} else {
@@ -204,29 +207,36 @@
QMap<QString, QVariant> KstPlotGroup::widgetHints(const QString& propertyName) const {
- // don't ask for borderedviewobject hints because we don't want to set border color
+ //
+ // don't ask for borderedviewobject hints because we don't want to set border color...
+ //
+
QMap<QString, QVariant> map = KstViewObject::widgetHints(propertyName);
- if (!map.empty()) {
- return map;
+
+ if (map.empty()) {
+ if (propertyName == "transparent") {
+ map.insert(QString("_kst_widgetType"), QString("QCheckBox"));
+ map.insert(QString("_kst_label"), QString::null);
+ map.insert(QString("text"), i18n("Transparent background"));
+ } else if (propertyName == "backColor") {
+ map.insert(QString("_kst_widgetType"), QString("KColorButton"));
+ map.insert(QString("_kst_label"), i18n("Background color"));
+ }
}
- if (propertyName == "transparent") {
- map.insert(QString("_kst_widgetType"), QString("QCheckBox"));
- map.insert(QString("_kst_label"), QString::null);
- map.insert(QString("text"), i18n("Transparent background"));
- } else if (propertyName == "backColor") {
- map.insert(QString("_kst_widgetType"), QString("KColorButton"));
- map.insert(QString("_kst_label"), i18n("Background color"));
- }
return map;
}
QRegion KstPlotGroup::clipRegion() {
if (transparent()) {
- // make the clipregion just the children
+ KstViewObjectList::iterator i;
QRegion region;
- for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+
+ //
+ // make the clipregion just the children...
+ //
+ for (i = _children.begin(); i != _children.end(); ++i) {
region += (*i)->clipRegion();
}
return region;
--- branches/work/kst/kst1kde4/kst/src/libkstapp/kstplotgroup.h #1106843:1106844
@@ -32,8 +32,8 @@
void save(QTextStream& ts, const QString& indent = QString::null);
bool removeChild(KstViewObjectPtr obj, bool recursive = false);
- bool popupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topLevelParent);
- bool layoutPopupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topParent);
+ bool popupMenu(QMenu *menu, const QPoint& pos, KstViewObjectPtr topLevelParent);
+ bool layoutPopupMenu(QMenu *menu, const QPoint& pos, KstViewObjectPtr topParent);
void setTransparent(bool transparent);
bool transparent() const;
--- branches/work/kst/kst1kde4/kst/src/libkstapp/kstviewobject.cpp #1106843:1106844
@@ -22,6 +22,7 @@
#include <QBitmap>
#include <QMetaObject>
+#include <QMetaProperty>
#include <QTextDocument>
#include "kst.h"
@@ -190,44 +191,62 @@
}
Kst2DPlotMap *pmap = KstApp::inst()->plotHolderWhileOpeningDocument();
if (pmap->count(in_tag) > 0) {
- Kst2DPlotPtr plot = (*pmap)[in_tag];
+ Kst2DPlotPtr plot;
+
+ plot = (*pmap)[in_tag];
if (plot) {
- appendChild(plot.data(), true);
+ appendChild(plot, true);
plot->loadChildren(el);
- pmap->erase(in_tag);
+// xxx pmap->removeAll(in_tag);
}
}
} else if (el.tagName() == "PlotGroup" || el.tagName() == "plotgroup" /* 1.1 support */) {
- KstPlotGroupPtr plotGroup = new KstPlotGroup(el);
- appendChild(plotGroup.data(), true);
+ KstPlotGroupPtr plotGroup;
+
+ plotGroup = new KstPlotGroup(el);
+ appendChild(plotGroup, true);
plotGroup->loadChildren(el);
} else if (el.tagName() == "Box") {
- KstViewBoxPtr box = new KstViewBox(el);
- appendChild(box.data(), true);
+ KstViewBoxPtr box;
+
+ box = new KstViewBox(el);
+ appendChild(box, true);
box->loadChildren(el);
} else if (el.tagName() == "Arrow") {
- KstViewArrowPtr arrow = new KstViewArrow(el);
- appendChild(arrow.data(), true);
+ KstViewArrowPtr arrow;
+
+ arrow = new KstViewArrow(el);
+ appendChild(arrow, true);
arrow->loadChildren(el);
} else if (el.tagName() == "Line") {
- KstViewLinePtr line = new KstViewLine(el);
- appendChild(line.data(), true);
+ KstViewLinePtr line;
+
+ line = new KstViewLine(el);
+ appendChild(line, true);
line->loadChildren(el);
} else if (el.tagName() == "Ellipse") {
- KstViewEllipsePtr ellipse = new KstViewEllipse(el);
- appendChild(ellipse.data(), true);
+ KstViewEllipsePtr ellipse;
+
+ ellipse = new KstViewEllipse(el);
+ appendChild(ellipse, true);
ellipse->loadChildren(el);
} else if (el.tagName() == "Label") {
- KstViewLabelPtr label = new KstViewLabel(el);
- appendChild(label.data(), true);
+ KstViewLabelPtr label;
+
+ label = new KstViewLabel(el);
+ appendChild(label, true);
label->loadChildren(el);
} else if (el.tagName() == "Legend") {
- KstViewLegendPtr legend = new KstViewLegend(el);
- appendChild(legend.data(), true);
+ KstViewLegendPtr legend;
+
+ legend = new KstViewLegend(el);
+ appendChild(legend, true);
legend->loadChildren(el);
} else if (el.tagName() == "Picture") {
- KstViewPicturePtr picture = new KstViewPicture(el);
- appendChild(picture.data(), true);
+ KstViewPicturePtr picture;
+
+ picture = new KstViewPicture(el);
+ appendChild(picture, true);
picture->loadChildren(el);
}
}
@@ -249,21 +268,26 @@
KstObject::UpdateType KstViewObject::updateChildren(int counter) {
KstObject::UpdateType rc = NO_CHANGE;
- for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+ KstViewObjectList::iterator i;
+
+ for (i = _children.begin(); i != _children.end(); ++i) {
if (rc == NO_CHANGE) {
rc = (*i)->update(counter);
} else {
(*i)->update(counter);
}
}
+
return rc;
}
void KstViewObject::save(QTextStream& ts, const QString& indent) {
+ KstViewObjectList::iterator i;
+
saveAttributes(ts, indent);
- for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+ for (i = _children.begin(); i != _children.end(); ++i) {
(*i)->save(ts, indent);
}
}
@@ -281,7 +305,7 @@
if (transparent()) {
ts << indent << "<transparent/>" << endl;
}
- ts << indent << "<tag>" << QStyleSheet::escape(tagName()) << "</tag>" << endl;
+ ts << indent << "<tag>" << Qt::escape(tagName()) << "</tag>" << endl;
ts << indent << "<aspect x=\"" << aspect.x <<
"\" y=\"" << aspect.y <<
"\" w=\"" << aspect.w <<
@@ -290,15 +314,18 @@
ts << indent << "<idealsize w=\"" << _idealSize.width() <<
"\" h=\"" << _idealSize.height() <<"\" />" << endl;
- // save all properties
- for (int i = 0; i < metaObject()->numProperties(true); i++) {
- ts << indent << "<" << metaObject()->property(i, true)->name() << ">";
- if (strcmp(metaObject()->property(i, true)->type(), "QString") == 0) {
- ts << QStyleSheet::escape(property(metaObject()->property(i, true)->name()).toString());
+ //
+ // save all properties...
+ //
+
+ for (int i = 0; i < metaObject()->propertyCount(); i++) {
+ ts << indent << "<" << metaObject()->property(i).name() << ">";
+ if (metaObject()->property(i).type() == QVariant::String) {
+ ts << Qt::escape(property(metaObject()->property(i).name()).toString());
} else {
- ts << property(metaObject()->property(i, true)->name()).toString().latin1();
+ ts << property(metaObject()->property(i).name()).toString().toLatin1();
}
- ts << "</" << metaObject()->property(i, true)->name() << ">" << endl;
+ ts << "</" << metaObject()->property(i).name() << ">" << endl;
}
}
@@ -332,10 +359,14 @@
p.setWindow(geometry());
paintUpdate();
- bool nullBounds = bounds.isNull();
+ KstViewObjectList::iterator i;
+ bool nullBounds = bounds.isEmpty();
- // handle the case where we have maximized plots
- for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+ //
+ // handle the case where we have maximized plots...
+ //
+
+ for (i = _children.begin(); i != _children.end(); ++i) {
if ((*i)->_maximized) {
(*i)->paint(p, bounds);
maximized = true;
@@ -354,21 +385,18 @@
}
if (!_children.isEmpty()) {
- KstViewObjectList::Iterator begin = _children.begin();
- for (KstViewObjectList::Iterator i = _children.fromLast();; --i) {
- const QRegion thisObjectGeometry((*i)->geometry());
+ KstViewObjectList::iterator begin = _children.begin();
+ KstViewObjectList::iterator i = _children.end();
+ QRegion thisObjectGeometry;
+ while (true) {
+ --i;
+
+ thisObjectGeometry = (*i)->geometry();
+
if (nullBounds || !clipRegion.intersect(thisObjectGeometry).isEmpty()) {
-#ifdef BENCHMARK
- QTime t;
- t.start();
-#endif
(*i)->paint(p, clipRegion);
clipRegion -= (*i)->clipRegion();
-#ifdef BENCHMARK
- int x = t.elapsed();
- kstdDebug() << " -> object " << (*i)->tagName() << " took " << x << "ms" << endl;
-#endif
}
if (i == begin) {
@@ -382,7 +410,10 @@
p.restore();
- // Draw any inline UI items
+ //
+ // draw any inline UI items...
+ //
+
if (p.drawInlineUI() && isSelected()) {
if (_parent) {
p.save();
@@ -394,12 +425,12 @@
}
}
- p.flush();
+// xxx p.flush();
}
void KstViewObject::paintSelf(KstPainter& p, const QRegion& bounds) {
- if (!bounds.isNull()) {
+ if (!bounds.isEmpty()) {
p.setClipRegion(bounds);
}
}
@@ -422,7 +453,6 @@
void KstViewObject::drawFocusRect(KstPainter& p) {
- // draw the 8 hotpoints
const QRect geom(geometry());
const QPoint topLeft(geom.topLeft());
const QPoint topRight(geom.topRight());
@@ -432,7 +462,6 @@
const QPoint bottomMiddle(QPoint((bottomLeft.x() + bottomRight.x())/2, bottomLeft.y()));
const QPoint middleLeft(QPoint(topLeft.x(), (topLeft.y() + bottomLeft.y())/2));
const QPoint middleRight(QPoint(topRight.x(), (topRight.y() + bottomRight.y())/2));
-
int dx = KST_RESIZE_BORDER_W/2;
int width = 2*dx + 1;
@@ -445,6 +474,10 @@
p.uiMask() += QRect(middleLeft.x()-dx, middleLeft.y()-dx, width, width);
p.uiMask() += QRect(middleRight.x()-dx, middleRight.y()-dx, width, width);
+ //
+ // draw the eight hotpoints...
+ //
+
p.drawRect(topLeft.x()-dx, topLeft.y()-dx, width, width);
p.drawRect(topRight.x()-dx, topRight.y()-dx, width, width);
p.drawRect(bottomLeft.x()-dx, bottomLeft.y()-dx, width, width);
@@ -500,7 +533,7 @@
bool KstViewObject::removeChild(KstViewObjectPtr obj, bool recursive) {
- bool rc = _children.remove(obj) > 0;
+ bool rc = _children.removeAll(obj) > 0;
if (recursive) {
for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
@@ -515,7 +548,9 @@
void KstViewObject::insertChildAfter(const KstViewObjectPtr after, KstViewObjectPtr obj, bool keepAspect) {
- KstViewObjectList::Iterator i = _children.find(after);
+ KstViewObjectList::iterator i;
+
+ i = _children.find(after);
if (i != _children.end()) {
_children.insert(i, obj);
} else {
@@ -523,7 +558,7 @@
}
obj->_parent = this;
- for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+ for (i = _children.begin(); i != _children.end(); ++i) {
if ((*i)->maximized()) {
(*i)->setMaximized(false);
}
@@ -1204,9 +1239,10 @@
bool KstViewObject::popupMenu(QMenu *menu, const QPoint& pos, KstViewObjectPtr topParent) {
Q_UNUSED(pos)
+
+ QString menuTitle = this->menuTitle();
bool rc = false;
int id;
- QString menuTitle = this->menuTitle();
_topObjectForMenu = topParent;
@@ -1224,13 +1260,6 @@
rc = true;
}
-
-// Copy doesn't do anything yet, so don't put it in the UI...
-// if (_standardActions & Copy) {
-// menu->insertItem(i18n("&Copy"), this, SLOT(copyObject()));
-// rc = true;
-// }
-
if (_layoutActions & Rename) {
menu->insertItem(i18n("Re&name..."), this, SLOT(rename()));
rc = true;
More information about the Kst
mailing list