[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Mon Jul 7 21:32:31 CEST 2008
SVN commit 829183 by fenton:
Add Editor for Legend Item.
M +2 -11 labeltab.cpp
M +0 -3 labeltab.h
M +0 -7 labeltab.ui
M +47 -10 legenditem.cpp
M +20 -2 legenditem.h
A legenditemdialog.cpp [License: GPL (v2+)]
A legenditemdialog.h [License: GPL (v2+)]
A legendtab.cpp [License: GPL (v2+)]
A legendtab.h [License: GPL (v2+)]
A legendtab.ui
M +5 -0 libkstapp.pro
M +10 -17 plotitem.cpp
M +2 -4 plotitem.h
M +0 -4 plotitemdialog.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.cpp #829182:829183
@@ -53,10 +53,11 @@
connect(_rightFamily, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
connect(_showLegend, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
- connect(_matchLegendContents, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
connect(_applyGlobalsButton, SIGNAL(pressed()), this, SLOT(applyGlobals()));
connect(_autoLabel, SIGNAL(pressed()), this, SLOT(autoLabel()));
+
+ connect(_editLegendContents, SIGNAL(pressed()), _plotItem->legend(), SLOT(edit()));
}
@@ -261,16 +262,6 @@
_showLegend->setChecked(show);
}
-
-bool LabelTab::matchLegend() const {
- return _matchLegendContents->isChecked();
}
-
-void LabelTab::setMatchLegend(const bool match) {
- _matchLegendContents->setChecked(match);
-}
-
-}
-
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.h #829182:829183
@@ -65,9 +65,6 @@
bool showLegend() const;
void setShowLegend(const bool show);
- bool matchLegend() const;
- void setMatchLegend(const bool match);
-
public Q_SLOTS:
void update();
void autoLabel();
--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.ui #829182:829183
@@ -377,13 +377,6 @@
</property>
</widget>
</item>
- <item row="0" column="1" >
- <widget class="QCheckBox" name="_matchLegendContents" >
- <property name="text" >
- <string>Match to Contents</string>
- </property>
- </widget>
- </item>
<item row="0" column="2" >
<widget class="QPushButton" name="_editLegendContents" >
<property name="text" >
--- branches/work/kst/portto4/kst/src/libkstapp/legenditem.cpp #829182:829183
@@ -17,6 +17,7 @@
#include "debug.h"
#include "plotitem.h"
+#include "legenditemdialog.h"
#include <QDebug>
#include <QGraphicsItem>
@@ -25,7 +26,7 @@
namespace Kst {
LegendItem::LegendItem(PlotItem *parent)
- : ViewItem(parent->parentView()), _plotItem(parent) {
+ : ViewItem(parent->parentView()), _plotItem(parent), _auto(true), _verticalDisplay(true) {
setName("Legend");
setZValue(LEGEND_ZVALUE);
@@ -47,9 +48,6 @@
void LegendItem::paint(QPainter *painter) {
painter->save();
QRectF box = rect();
- QPen pen = painter->pen();
- pen.setWidth(2);
- painter->setPen(pen);
painter->drawRect(rect());
painter->restore();
}
@@ -64,22 +62,61 @@
void LegendItem::edit() {
- // TODO create edit Dialog.
-// LegendItemDialog editDialog(this);
-// editDialog.exec();
+ LegendItemDialog editDialog(this);
+ editDialog.exec();
}
-void LegendItem::setAutoLegend(const bool autoLegend) {
- _auto = autoLegend;
+void LegendItem::setAutoContents(const bool autoContents) {
+ _auto = autoContents;
}
-bool LegendItem::autoLegend() const {
+bool LegendItem::autoContents() const {
return _auto;
}
+void LegendItem::setVerticalDisplay(const bool vertical) {
+ _verticalDisplay = vertical;
+}
+
+
+bool LegendItem::verticalDisplay() const {
+ return _verticalDisplay;
+}
+
+
+void LegendItem::setTitle(const QString &title) {
+ _title = title;
+}
+
+
+QString LegendItem::title() const {
+ return _title;
+}
+
+
+QFont LegendItem::font() const {
+ return _font;
+}
+
+
+void LegendItem::setFont(const QFont &font) {
+ _font = font;
+}
+
+
+qreal LegendItem::fontScale() const {
+ return _fontScale;
+}
+
+
+void LegendItem::setFontScale(const qreal scale) {
+ _fontScale = scale;
+}
+
+
LegendItemFactory::LegendItemFactory()
: GraphicsFactory() {
registerFactory("legend", this);
--- branches/work/kst/portto4/kst/src/libkstapp/legenditem.h #829182:829183
@@ -32,15 +32,33 @@
virtual void save(QXmlStreamWriter &xml);
virtual void paint(QPainter *painter);
- void setAutoLegend(const bool autoLegend);
- bool autoLegend() const;
+ void setAutoContents(const bool autoContent);
+ bool autoContents() const;
+ void setVerticalDisplay(const bool vertical);
+ bool verticalDisplay() const;
+
+ QFont font() const;
+ void setFont(const QFont &font);
+
+ qreal fontScale() const;
+ void setFontScale(const qreal scale);
+
+ QString title() const;
+ void setTitle(const QString &title);
+
+ PlotItem* plot() { return _plotItem; }
+
public Q_SLOTS:
virtual void edit();
private:
PlotItem *_plotItem;
bool _auto;
+ QString _title;
+ QFont _font;
+ qreal _fontScale;
+ bool _verticalDisplay;
};
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #829182:829183
@@ -76,6 +76,8 @@
layoutboxitem.cpp \
layouttab.cpp \
legenditem.cpp \
+ legenditemdialog.cpp \
+ legendtab.cpp \
lineitem.cpp \
mainwindow.cpp \
markerstab.cpp \
@@ -170,6 +172,8 @@
layoutboxitem.h \
layouttab.h \
legenditem.h \
+ legenditemdialog.h \
+ legendtab.h \
lineitem.h \
mainwindow.h \
markerstab.h \
@@ -239,6 +243,7 @@
labeltab.ui \
labelpropertiestab.ui \
layouttab.ui \
+ legendtab.ui \
markerstab.ui \
matrixeditordialog.ui \
matrixtab.ui \
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #829182:829183
@@ -66,7 +66,6 @@
_topLabelFontScale(0.0),
_rightLabelFontScale(0.0),
_showLegend(false),
- _autoLegend(true),
_legend(0),
_zoomMenu(0)
{
@@ -1621,30 +1620,24 @@
}
+LegendItem* PlotItem::legend() {
+ if (!_legend) {
+ _legend = new LegendItem(this);
+ }
+ return _legend;
+}
+
+
void PlotItem::setShowLegend(const bool show) {
- qDebug() << "setShowLegend";
_showLegend = show;
if (show) {
- if (!_legend) {
- _legend = new LegendItem(this);
- }
- _legend->setVisible(true);
+ legend()->setVisible(true);
} else {
- _legend->setVisible(false);
+ legend()->setVisible(false);
}
}
-bool PlotItem::matchLegend() const {
- return _showLegend;
-}
-
-
-void PlotItem::setMatchLegend(const bool match) {
- _autoLegend = match;
-}
-
-
bool PlotItem::tryShortcut(const QString &keySequence) {
return ViewItem::tryShortcut(keySequence);
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #829182:829183
@@ -152,9 +152,6 @@
bool showLegend() const;
void setShowLegend(const bool show);
- bool matchLegend() const;
- void setMatchLegend(const bool match);
-
qreal mapXToPlot(const qreal &x) const;
qreal mapYToPlot(const qreal &y) const;
QPointF mapToPlot(const QPointF &point) const;
@@ -173,6 +170,8 @@
virtual void addToMenuForContextEvent(QMenu &menu);
virtual bool tryShortcut(const QString &keySequence);
+ LegendItem* legend();
+
Q_SIGNALS:
void marginsChanged();
void updatePlotRect();
@@ -314,7 +313,6 @@
qreal _rightLabelFontScale;
bool _showLegend;
- bool _autoLegend;
LegendItem* _legend;
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #829182:829183
@@ -112,8 +112,6 @@
_labelTab->setRightLabelFontScale(_plotItem->rightLabelFontScale());
_labelTab->setShowLegend(_plotItem->showLegend());
- _labelTab->setMatchLegend(_plotItem->matchLegend());
-
}
@@ -445,8 +443,6 @@
_plotItem->setTopLabelFontScale(_labelTab->topLabelFontScale());
_plotItem->setBottomLabelFontScale(_labelTab->bottomLabelFontScale());
_plotItem->setShowLegend(_labelTab->showLegend());
- _plotItem->setMatchLegend(_labelTab->matchLegend());
-
}
More information about the Kst
mailing list