[Kst] branches/work/kst/portto4/kst/src/libkstapp
Peter Kümmel
syntheticpp at gmx.net
Thu May 27 19:33:41 CEST 2010
SVN commit 1131224 by kuemmel:
create actions with shortcuts on item creation,
doing this in the context menu event is too late for the shortcuts
because they could be used before a context menu event.
BUG: 236679
M +18 -19 plotitem.cpp
M +5 -0 plotitem.h
M +6 -8 sharedaxisboxitem.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1131223:1131224
@@ -514,8 +514,23 @@
registerShortcut(_plotMaximize);
connect(_plotMaximize, SIGNAL(triggered()), this, SLOT(plotMaximize()));
- _shareBoxShareX = 0;
- _shareBoxShareY = 0;
+
+ _shareBoxShareX = new QAction(tr("Share Plots on X-Axis"), this);
+ _shareBoxShareX->setShortcut(Qt::Key_X);
+ _shareBoxShareX->setCheckable(true);
+ registerShortcut(_shareBoxShareX);
+ connect(_shareBoxShareX, SIGNAL(triggered()), this, SIGNAL(shareXAxisTriggered()));
+
+ _shareBoxShareY = new QAction(tr("Share Plots on Y-Axis"), this);
+ _shareBoxShareY->setShortcut(Qt::Key_Y);
+ _shareBoxShareY->setCheckable(true);
+ registerShortcut(_shareBoxShareY);
+ connect(_shareBoxShareY, SIGNAL(triggered()), this, SIGNAL(shareYAxisTriggered()));
+
+ _breakSharedBox = new QAction(tr("Break Shared Axis Box"), this);
+ _breakSharedBox->setShortcut(Qt::Key_B);
+ registerShortcut(_breakSharedBox);
+ connect(_breakSharedBox, SIGNAL(triggered()), this, SIGNAL(breakShareTriggered()));
}
@@ -608,24 +623,11 @@
void PlotItem::createSharedAxisBoxMenu() {
if (_sharedAxisBoxMenu) {
delete _shareBoxShareX;
- delete _shareBoxShareY;
- delete _sharedAxisBoxMenu;
}
_sharedAxisBoxMenu = new QMenu;
_sharedAxisBoxMenu->setTitle(tr("Shared Axis Box Settings"));
- _shareBoxShareX = new QAction(tr("Share Plots on X-Axis"), this);
- _shareBoxShareX->setShortcut(Qt::Key_X);
- connect(_shareBoxShareX, SIGNAL(triggered()), _sharedBox, SLOT(shareXAxis()));
- _shareBoxShareX->setCheckable(true);
- registerShortcut(_shareBoxShareX);
_sharedAxisBoxMenu->addAction(_shareBoxShareX);
-
- _shareBoxShareY = new QAction(tr("Share Plots on Y-Axis"), this);
- _shareBoxShareY->setShortcut(Qt::Key_Y);
- connect(_shareBoxShareY, SIGNAL(triggered()), _sharedBox, SLOT(shareYAxis()));
- _shareBoxShareY->setCheckable(true);
- registerShortcut(_shareBoxShareY);
_sharedAxisBoxMenu->addAction(_shareBoxShareY);
}
@@ -638,10 +640,7 @@
menu.addMenu(_sharedAxisBoxMenu);
- QAction *breakSharedBox = new QAction(tr("Break Shared Axis Box"), this);
- breakSharedBox->setShortcut(Qt::Key_B);
- connect(breakSharedBox, SIGNAL(triggered()), _sharedBox, SLOT(breakShare()));
- menu.addAction(breakSharedBox);
+ menu.addAction(_breakSharedBox);
_shareBoxShareX->setChecked(_sharedBox->isXAxisShared());
_shareBoxShareY->setChecked(_sharedBox->isYAxisShared());
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #1131223:1131224
@@ -264,6 +264,10 @@
void updateAxes();
void triggerRedraw();
+ void breakShareTriggered();
+ void shareXAxisTriggered();
+ void shareYAxisTriggered();
+
public Q_SLOTS:
void zoomFixedExpression(const QRectF &projection, bool force = false);
void zoomXRange(const QRectF &projection, bool force = false);
@@ -495,6 +499,7 @@
QMenu *_sharedAxisBoxMenu;
QAction *_shareBoxShareX;
QAction *_shareBoxShareY;
+ QAction *_breakSharedBox;
SharedAxisBoxItem * _sharedBox;
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.cpp #1131223:1131224
@@ -169,6 +169,10 @@
plotItem->setSharedAxisBox(this);
_sharedPlots << plotItem;
+ connect(plotItem, SIGNAL(breakShareTriggered()), this, SLOT(breakShare()));
+ connect(plotItem, SIGNAL(shareXAxisTriggered()), this, SLOT(shareXAxis()));
+ connect(plotItem, SIGNAL(shareYAxisTriggered()), this, SLOT(shareYAxis()));
+
child = plotItem;
if (!maxSize.contains(plotItem->mapToParent(plotItem->viewRect().topLeft()))) {
maxSize.setTop(qMin(plotItem->mapToParent(plotItem->viewRect().topLeft()).y(), maxSize.top()));
@@ -198,13 +202,8 @@
void SharedAxisBoxItem::breakShare() {
_loaded = false;
- QList<QGraphicsItem*> list = QGraphicsItem::children();
- foreach (QGraphicsItem *item, list) {
- ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
- if (!viewItem)
- continue;
-
- if (PlotItem *plotItem = qobject_cast<PlotItem*>(viewItem)) {
+ QList<PlotItem*> list = getSharedPlots();
+ foreach (PlotItem *plotItem, list) {
plotItem->setPos(mapToParent(plotItem->pos()));
plotItem->setSharedAxisBox(0);
plotItem->setLabelsVisible(true);
@@ -212,7 +211,6 @@
plotItem->yAxis()->setAxisZoomMode(yAxisZoomMode());
plotItem->update();
}
- }
if (_layout) {
_layout->reset();
}
More information about the Kst
mailing list