[Kst] extragear/graphics/kst/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Thu Dec 8 06:14:30 CET 2005
Maybe groups should die?
cbn
On December 7, 2005 09:12 pm, George Staikos wrote:
> SVN commit 486524 by staikos:
>
> make plotgroups mostly work again. they're now "non-container" objects
> since they actually abuse the notion of containers. There are lots of bugs
> lurking. They include:
> - clipping of non-plot regions broken in non-transparent mode
> - properties are missing (such as colors, borders)
> - axis alignment doesn't work?
> - conceptual: no way to do graphics in groups (or group contents)
>
>
> M +48 -45 kstplotgroup.cpp
> M +3 -5 kstplotgroup.h
> M +28 -1 ksttoplevelview.cpp
>
>
> --- trunk/extragear/graphics/kst/kst/kstplotgroup.cpp #486523:486524
> @@ -29,42 +29,49 @@
> #include "kstdoc.h"
> #include "kstplotgroup.h"
> #include "ksttimers.h"
> +#include "kstviewobjectfactory.h"
>
> static int pgcount = 0;
>
> -KstPlotGroup::KstPlotGroup() : KstMetaPlot("KstPlotGroup") {
> +KstPlotGroup::KstPlotGroup()
> +: KstMetaPlot("PlotGroup") {
> _standardActions |= Delete | Raise | Zoom | Lower | RaiseToTop |
> LowerToBottom; _layoutActions |= Delete | Copy | Raise | Lower | RaiseToTop
> | LowerToBottom | Rename | MoveTo; setTagName(i18n("Plot Group
> %1").arg(++pgcount));
> - _type = "plotgroup";
> + _type = "PlotGroup";
> setBorderColor(Qt::blue);
> + _container = false; // plot group is a container that doesn't behave
> like one setTransparent(true);
> }
>
>
> -KstPlotGroup::KstPlotGroup(const QDomElement& e) : KstMetaPlot(e) {
> +KstPlotGroup::KstPlotGroup(const QDomElement& e)
> +: KstMetaPlot(e) {
> QDomNode n = e.firstChild();
> while (!n.isNull()) {
> - QDomElement el = n.toElement();
> + QDomElement el = n.toElement();
> if (!el.isNull()) {
> if (metaObject()->findProperty(el.tagName().latin1(), true) > -1) {
> - setProperty(el.tagName().latin1(), QVariant(el.text()));
> - }
> + setProperty(el.tagName().latin1(), QVariant(el.text()));
> + }
> }
> - n = n.nextSibling();
> + n = n.nextSibling();
> }
> -
> +
> // always have these values
> _standardActions |= Delete | Raise | Zoom | Lower | RaiseToTop |
> LowerToBottom; _layoutActions |= Delete | Copy | Raise | Lower | RaiseToTop
> | LowerToBottom | Rename | MoveTo; setTagName(i18n("Plot Group
> %1").arg(++pgcount));
> - _type = "plotgroup";
> + _type = "PlotGroup";
> + _container = false; // plot group is a container that doesn't behave
> like one setBorderColor(Qt::blue);
> }
>
>
> -KstPlotGroup::KstPlotGroup(const KstPlotGroup& plotGroup) :
> KstMetaPlot(plotGroup) { - _type = "plotgroup";
> +KstPlotGroup::KstPlotGroup(const KstPlotGroup& plotGroup)
> +: KstMetaPlot(plotGroup) {
> + _type = "PlotGroup";
> + _container = false; // plot group is a container that doesn't behave
> like one
>
> setTagName(i18n("Plot Group %1").arg(++pgcount));
> }
> @@ -74,17 +81,6 @@
> }
>
>
> -void KstPlotGroup::setHasFocus(bool hasFocus) {
> - _hasFocus = hasFocus;
> - forEachChild<bool>(&KstViewObject::setHasFocus, hasFocus);
> -}
> -
> -
> -void KstPlotGroup::removeFocus(KstPainter& p) {
> - forEachChild<KstPainter&>(&KstViewObject::removeFocus, p);
> -}
> -
> -
> void KstPlotGroup::copyObject() {
> if (_parent) {
> KstApp::inst()->document()->setModified();
> @@ -96,7 +92,7 @@
>
> void KstPlotGroup::copyObjectQuietly(KstViewObject& parent, const QString&
> name) const { Q_UNUSED(name)
> -
> +
> parent.appendChild(new KstPlotGroup(*this), true);
> }
>
> @@ -163,15 +159,7 @@
> p.setClipping(hadClipping);
> }
>
> -#ifdef BENCHMARK
> - QTime t;
> - t.start();
> -#endif
> KstMetaPlot::paint(p, bounds);
> -#ifdef BENCHMARK
> - int x = t.elapsed();
> - kstdDebug() << " -> metaplot parent took " << x << "ms" << endl;
> -#endif
> p.setClipping(false);
> }
>
> @@ -217,30 +205,20 @@
> }
>
>
> -void KstPlotGroup::setTransparent(bool transparent) {
> - KstViewObject::setTransparent(transparent);
> -}
> -
> -
> -bool KstPlotGroup::transparent() const {
> - return KstViewObject::transparent();
> -}
> -
> -
> QMap<QString, QVariant> KstPlotGroup::widgetHints(const QString&
> propertyName) const { // 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;
> + return map;
> }
> -
> +
> if (propertyName == "transparent") {
> map.insert(QString("_kst_widgetType"), QString("QCheckBox"));
> map.insert(QString("_kst_label"), QString::null);
> - map.insert(QString("text"), i18n("Transparent background"));
> + 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"));
> + map.insert(QString("_kst_label"), i18n("Background color"));
> }
> return map;
> }
> @@ -258,5 +236,30 @@
> return KstViewObject::clipRegion();
> }
>
> +
> +void KstPlotGroup::setTransparent(bool transparent) {
> + KstMetaPlot::setTransparent(transparent);
> +}
> +
> +
> +bool KstPlotGroup::transparent() const {
> + return KstMetaPlot::transparent();
> +}
> +
> +
> +namespace {
> +KstViewObject *create_KstPlotGroup() {
> + return new KstPlotGroup;
> +}
> +
> +
> +KstGfxMouseHandler *handler_KstPlotGroup() {
> + return 0L;
> +}
> +
> +KST_REGISTER_VIEW_OBJECT(PlotGroup, create_KstPlotGroup,
> handler_KstPlotGroup) +}
> +
> +
> #include "kstplotgroup.moc"
> // vim: ts=2 sw=2 et
> --- trunk/extragear/graphics/kst/kst/kstplotgroup.h #486523:486524
> @@ -34,14 +34,12 @@
> 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); - void setHasFocus(bool hasFocus);
> - void removeFocus(KstPainter& p);
> -
> +
> void setTransparent(bool transparent);
> bool transparent() const;
> -
> +
> QRegion clipRegion();
> -
> +
> QMap<QString, QVariant> widgetHints(const QString& propertyName)
> const;
>
> void paint(KstPainter& p, const QRegion& bounds);
> --- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #486523:486524
> @@ -228,6 +228,15 @@
>
> KstViewObjectPtr p = findDeepestChild(pos, false);
> if (p) {
> + KstViewObjectPtr p2 = p;
> + while (p2->_parent && p2->_parent->_container) {
> + p2 = p2->_parent;
> + }
> + if (p2->_parent && !p2->_parent->_container) {
> + p = p2->_parent;
> + }
> + }
> + if (p) {
> setCursorFor(pos, p);
> if (p->focused()) {
> _focusOn = true; // just in case - seems to be false on occasion
> @@ -341,7 +350,16 @@
> _pressDirection = -1;
>
> _pressTarget = findDeepestChild(pos, false);
> -
> + if (_pressTarget) {
> + KstViewObjectPtr p = _pressTarget;
> + while (p->_parent && p->_parent->_container) {
> + p = p->_parent;
> + }
> + if (p->_parent && !p->_parent->_container) {
> + _pressTarget = p->_parent;
> + }
> + }
> +
> if (_mode != LayoutMode && !_pressTarget) {
> _pressTarget = 0L;
> return false;
> @@ -1060,6 +1078,15 @@
> bool rc = false;
> // Want to clear focus without repaint
> _pressTarget = findDeepestChild(pos, false);
> + if (_pressTarget) {
> + KstViewObjectPtr p = _pressTarget;
> + while (p->_parent && p->_parent->_container) {
> + p = p->_parent;
> + }
> + if (p->_parent && !p->_parent->_container) {
> + _pressTarget = p->_parent;
> + }
> + }
>
> if (_focusOn) {
> _pressDirection = -1;
> _______________________________________________
> Kst mailing list
> Kst at kde.org
> https://mail.kde.org/mailman/listinfo/kst
More information about the Kst
mailing list