[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Thu May 24 22:51:02 CEST 2007
SVN commit 668031 by treat:
* Begin label command test design
M +14 -0 kstmainwindow.cpp
M +4 -0 kstmainwindow.h
M +30 -0 kstplotcommands.cpp
M +11 -0 kstplotcommands.h
M +5 -0 kstplotview.cpp
M +2 -0 kstplotview.h
--- branches/work/kst/portto4/kst/src/libkstapp/kstmainwindow.cpp #668030:668031
@@ -13,6 +13,8 @@
#include "kstapplication.h"
#include "kstplotview.h"
+#include "kstplotcommands.h"
+
#include <QtGui>
KstMainWindow::KstMainWindow() {
@@ -86,7 +88,16 @@
}
+void KstMainWindow::createLabel() {
+ new CreateLabelCommand;
+}
+
+
void KstMainWindow::createActions() {
+ _createLabelAct = new QAction(tr("&Create label"), this);
+ _createLabelAct->setStatusTip(tr("Create a label for the current plot"));
+ connect(_createLabelAct, SIGNAL(triggered()), this, SLOT(createLabel()));
+
_exitAct = new QAction(tr("E&xit"), this);
_exitAct->setShortcut(tr("Ctrl+Q"));
_exitAct->setStatusTip(tr("Exit the application"));
@@ -108,6 +119,9 @@
_editMenu = menuBar()->addMenu(tr("&Edit"));
+ _plotMenu = menuBar()->addMenu(tr("&Plot"));
+ _plotMenu->addAction(_createLabelAct);
+
_settingsMenu = menuBar()->addMenu(tr("&Settings"));
menuBar()->addSeparator();
--- branches/work/kst/portto4/kst/src/libkstapp/kstmainwindow.h #668030:668031
@@ -38,6 +38,7 @@
void aboutToQuit();
void about();
void plotViewDestroyed(QObject *object);
+ void createLabel();
private:
void createActions();
@@ -54,12 +55,15 @@
QMenu *_fileMenu;
QMenu *_editMenu;
+ QMenu *_plotMenu;
QMenu *_settingsMenu;
QMenu *_helpMenu;
QToolBar *_fileToolBar;
QToolBar *_editToolBar;
+ QAction *_createLabelAct;
+
QAction *_exitAct;
QAction *_aboutAct;
QAction *_aboutQtAct;
--- branches/work/kst/portto4/kst/src/libkstapp/kstplotcommands.cpp #668030:668031
@@ -13,13 +13,18 @@
#include "kstapplication.h"
#include "kstplotview.h"
+#include <QObject>
+#include <QInputDialog>
+
KstPlotViewCommand::KstPlotViewCommand(const QString &text, QUndoCommand *parent)
: QUndoCommand(text, parent), _view(kstApp->mainWindow()->currentPlotView()) {
+ _view->undoStack()->push(this);
}
KstPlotViewCommand::KstPlotViewCommand(KstPlotView *view, const QString &text, QUndoCommand *parent)
: QUndoCommand(text, parent), _view(view) {
+ _view->undoStack()->push(this);
}
@@ -29,15 +34,40 @@
KstPlotItemCommand::KstPlotItemCommand(const QString &text, QUndoCommand *parent)
: QUndoCommand(text, parent), _item(kstApp->mainWindow()->currentPlotView()->currentPlotItem()) {
+ _item->parentView()->undoStack()->push(this);
}
KstPlotItemCommand::KstPlotItemCommand(KstPlotItem *item, const QString &text, QUndoCommand *parent)
: QUndoCommand(text, parent), _item(item) {
+ _item->parentView()->undoStack()->push(this);
}
KstPlotItemCommand::~KstPlotItemCommand() {
}
+
+CreateLabelCommand::CreateLabelCommand()
+ : KstPlotViewCommand(QObject::tr("Create Label")) {
+
+ bool ok;
+ QString text = QInputDialog::getText(_view, QObject::tr("label"),
+ QObject::tr("label:"), QLineEdit::Normal,
+ QString::null, &ok);
+ if (ok && !text.isEmpty()) {
+ //Create the item!!
+ }
+}
+
+
+CreateLabelCommand::CreateLabelCommand(KstPlotView *view)
+ : KstPlotViewCommand(view, QObject::tr("Create Label")) {
+}
+
+
+CreateLabelCommand::~CreateLabelCommand() {
+}
+
+
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/kstplotcommands.h #668030:668031
@@ -42,6 +42,17 @@
QPointer<KstPlotItem> _item;
};
+class KST_EXPORT CreateLabelCommand : public KstPlotViewCommand
+{
+public:
+ CreateLabelCommand();
+ CreateLabelCommand(KstPlotView *view);
+ virtual ~CreateLabelCommand();
+
+protected:
+ QPointer<KstPlotItem> _item;
+};
+
/*
LABEL
BOX
--- branches/work/kst/portto4/kst/src/libkstapp/kstplotview.cpp #668030:668031
@@ -27,6 +27,11 @@
}
+KstPlotView *KstPlotItem::parentView() const {
+ return qobject_cast<KstPlotView*>(parent());
+}
+
+
KstPlotView::KstPlotView()
: QGraphicsView(kstApp->mainWindow()), _currentPlotItem(0) {
--- branches/work/kst/portto4/kst/src/libkstapp/kstplotview.h #668030:668031
@@ -27,6 +27,8 @@
KstPlotItem(KstPlotView *parent);
virtual ~KstPlotItem();
+ KstPlotView *parentView() const;
+
virtual QGraphicsItem *graphicsItem() const = 0;
};
More information about the Kst
mailing list