[Kst] branches/work/kst/portto4/kst/src
Adam Treat
treat at kde.org
Fri Sep 7 21:23:23 CEST 2007
SVN commit 709544 by treat:
* Rename KstApplication to use namespace.
* No need for singleton ViewItemDialog.
* Add ability for ViewItem subclasses to customize
the ViewItemDialog by adding pages.
M +2 -2 kst/main.cpp
A libkstapp/application.cpp libkstapp/kstapplication.cpp#706444 [License: GPL (v2+)]
A libkstapp/application.h libkstapp/kstapplication.h#706444 [License: GPL (v2+)]
D libkstapp/kstapplication.cpp
D libkstapp/kstapplication.h
M +2 -2 libkstapp/libkstapp.pro
M +1 -1 libkstapp/mainwindow.cpp
M +1 -1 libkstapp/view.cpp
M +1 -1 libkstapp/viewcommand.cpp
M +3 -2 libkstapp/viewitem.cpp
M +3 -0 libkstapp/viewitem.h
M +10 -42 libkstapp/viewitemdialog.cpp
M +13 -20 libkstapp/viewitemdialog.h
--- branches/work/kst/portto4/kst/src/kst/main.cpp #709543:709544
@@ -9,13 +9,13 @@
* *
***************************************************************************/
-#include "kstapplication.h"
+#include <application.h>
#include <builtingraphics.h>
#include <builtinobjects.h>
int main(int argc, char *argv[])
{
- KstApplication app(argc, argv);
+ Kst::Application app(argc, argv);
Kst::Builtins::initObjects();
Kst::Builtins::initGraphics();
return app.exec();
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #709543:709544
@@ -19,6 +19,7 @@
LIBS += -lkst -lkstmath -lkstwidgets
SOURCES += \
+ application.cpp \
applicationsettings.cpp \
axis.cpp \
boxitem.cpp \
@@ -34,7 +35,6 @@
exportgraphicsdialog.cpp \
filltab.cpp \
graphicsfactory.cpp \
- kstapplication.cpp \
labelitem.cpp \
labelrenderer.cpp \
lineitem.cpp \
@@ -61,6 +61,7 @@
viewmanager.cpp
HEADERS += \
+ application.h \
applicationsettings.h \
axis.h \
boxitem.h \
@@ -77,7 +78,6 @@
exportgraphicsdialog.h \
filltab.h \
graphicsfactory.h \
- kstapplication.h \
labelitem.h \
labelrenderer.h \
lineitem.h \
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #709543:709544
@@ -17,7 +17,7 @@
#include "document.h"
#include "ellipseitem.h"
#include "exportgraphicsdialog.h"
-#include "kstapplication.h"
+#include "application.h"
#include "kstdebug.h"
#include "labelitem.h"
#include "lineitem.h"
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #709543:709544
@@ -12,7 +12,7 @@
#include "view.h"
#include "viewitem.h"
#include "mainwindow.h"
-#include "kstapplication.h"
+#include "application.h"
#include "applicationsettings.h"
#include <math.h>
--- branches/work/kst/portto4/kst/src/libkstapp/viewcommand.cpp #709543:709544
@@ -10,7 +10,7 @@
***************************************************************************/
#include "viewcommand.h"
-#include "kstapplication.h"
+#include "application.h"
#include "tabwidget.h"
#include "view.h"
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #709543:709544
@@ -10,7 +10,7 @@
***************************************************************************/
#include "viewitem.h"
-#include "kstapplication.h"
+#include "application.h"
#include "tabwidget.h"
#include "viewitemdialog.h"
#include "viewgridlayout.h"
@@ -372,7 +372,8 @@
void ViewItem::edit() {
- ViewItemDialog::self()->show(this);
+ ViewItemDialog editDialog(this);
+ editDialog.exec();
}
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #709543:709544
@@ -24,6 +24,7 @@
namespace Kst {
+class DialogPage;
class ViewGridLayout;
class KST_EXPORT ViewItem : public QObject, public QGraphicsRectItem
@@ -86,6 +87,8 @@
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual void paint(QPainter *painter);
+ virtual QList<DialogPage*> dialogPages() const { return QList<DialogPage*>(); }
+
Q_SIGNALS:
void geometryChanged();
void creationComplete();
--- branches/work/kst/portto4/kst/src/libkstapp/viewitemdialog.cpp #709543:709544
@@ -12,11 +12,9 @@
#include "viewitemdialog.h"
#include "viewitem.h"
-
-#include "dialogpage.h"
-
#include "filltab.h"
#include "stroketab.h"
+#include "dialogpage.h"
#include <QPen>
#include <QBrush>
@@ -24,29 +22,11 @@
namespace Kst {
-static ViewItemDialog *_self = 0;
-void ViewItemDialog::cleanup() {
- delete _self;
- _self = 0;
-}
+ViewItemDialog::ViewItemDialog(ViewItem *item, QWidget *parent)
+ : Dialog(parent), _item(item) {
-
-ViewItemDialog *ViewItemDialog::self() {
- if (!_self) {
- _self = new ViewItemDialog;
- qAddPostRoutine(cleanup);
- }
- return _self;
-}
-
-
-ViewItemDialog::ViewItemDialog(QWidget *parent)
- : Dialog(parent) {
-
setWindowTitle(tr("Edit View Item"));
- setModal(true);
-
_fillTab = new FillTab(this);
_strokeTab = new StrokeTab(this);
connect(_fillTab, SIGNAL(apply()), this, SLOT(fillChanged()));
@@ -57,23 +37,20 @@
page->addDialogTab(_fillTab);
page->addDialogTab(_strokeTab);
addDialogPage(page);
-}
+ QList<DialogPage*> dialogPages = _item->dialogPages();
+ foreach (DialogPage *dialogPage, dialogPages)
+ addDialogPage(dialogPage);
-ViewItemDialog::~ViewItemDialog() {
-}
-
-void ViewItemDialog::show(ViewItem *item) {
- _item = item;
-
setupFill();
setupStroke();
+}
- Dialog::show();
- Dialog::raise();
- Dialog::activateWindow();
+
+ViewItemDialog::~ViewItemDialog() {
}
+
void ViewItemDialog::setupFill() {
Q_ASSERT(_item);
QBrush b = _item->brush();
@@ -142,15 +119,6 @@
_item->setPen(p);
}
-
-void ViewItemDialog::setVisible(bool visible) {
- if (visible && !_item)
- return; //nothing to show...
-
- Dialog::setVisible(visible);
}
-
-}
-
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/viewitemdialog.h #709543:709544
@@ -27,29 +27,22 @@
class KST_EXPORT ViewItemDialog : public Dialog
{
Q_OBJECT
-public:
- static ViewItemDialog *self();
+ public:
+ ViewItemDialog(ViewItem *item, QWidget *parent = 0);
+ virtual ~ViewItemDialog();
- void show(ViewItem *item);
+ private Q_SLOTS:
+ void fillChanged();
+ void strokeChanged();
-private:
- ViewItemDialog(QWidget *parent = 0);
- virtual ~ViewItemDialog();
- void setupFill();
- void setupStroke();
- static void cleanup();
+ private:
+ void setupFill();
+ void setupStroke();
-private Q_SLOTS:
- void fillChanged();
- void strokeChanged();
-
-protected:
- void setVisible(bool visible);
-
-private:
- QPointer<ViewItem> _item;
- FillTab *_fillTab;
- StrokeTab *_strokeTab;
+ private:
+ QPointer<ViewItem> _item;
+ FillTab *_fillTab;
+ StrokeTab *_strokeTab;
};
}
More information about the Kst
mailing list