[Kst] branches/work/kst/kst1kde4/kst/src/libkstapp

Andrew Walker arwalker at sumusltd.com
Tue Mar 23 23:34:26 CET 2010


SVN commit 1106776 by arwalker:

continue kst1kde4

 M  +7 -14     kstviewobject.cpp  
 M  +3 -3      kstviewobject.h  
 M  +1 -5      kstviewobjectfactory.cpp  
 M  +71 -53    kstviewwidget.cpp  
 M  +2 -1      kstviewwidget.h  


--- branches/work/kst/kst1kde4/kst/src/libkstapp/kstviewobject.cpp #1106775:1106776
@@ -20,22 +20,15 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-// include files for Qt
-#include <qbitmap.h>
-#include <qdeepcopy.h>
-#include <qmetaobject.h>
-#include <qstylesheet.h>
+#include <QBitmap>
+#include <QMetaObject>
+#include <QTextDocument>
 
-// include files for KDE
-#include <kdatastream.h>
-#include "ksdebug.h"
-
-// application specific includes
 #include "kst.h"
-#include "kst2dplot.h" // Yuck, fix this
+#include "kst2dplot.h"
 #include "kstaccessibility.h"
 #include "kstdoc.h"
-#include "ksteditviewobjectdialog_i.h"
+#include "ksteditviewobjectdialog.h"
 #include "kstmath.h"
 #include "kstobject.h"
 #include "kstplotgroup.h"
@@ -1209,7 +1202,7 @@
 }
 
 
-bool KstViewObject::popupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topParent) {
+bool KstViewObject::popupMenu(QMenu *menu, const QPoint& pos, KstViewObjectPtr topParent) {
   Q_UNUSED(pos)
   bool rc = false;
   int id;
@@ -1264,7 +1257,7 @@
 }
 
 
-bool KstViewObject::layoutPopupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topParent) {
+bool KstViewObject::layoutPopupMenu(QMenu *menu, const QPoint& pos, KstViewObjectPtr topParent) {
   Q_UNUSED(pos)
 
   _topObjectForMenu = topParent;
--- branches/work/kst/kst1kde4/kst/src/libkstapp/kstviewobject.h #1106775:1106776
@@ -21,6 +21,7 @@
 #include <QColor>
 #include <QDomElement>
 #include <QExplicitlySharedDataPointer>
+#include <QMenu>
 #include <QMouseEvent>
 #include <QPointer>
 
@@ -32,7 +33,6 @@
 #include "kstpainter.h"
 #include "kst_export.h"
 
-class KPopupMenu;
 class KstGfxMouseHandler;
 class KstViewObject;
 class KstViewWidget;
@@ -180,8 +180,8 @@
     // note also: self=false
     template<class U> void forEachChild2(void (U::*)());
 
-    virtual bool popupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topParent);
-    virtual bool layoutPopupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topParent);
+    virtual bool popupMenu(QMenu *menu, const QPoint& pos, KstViewObjectPtr topParent);
+    virtual bool layoutPopupMenu(QMenu *menu, const QPoint& pos, KstViewObjectPtr topParent);
 
     enum StandardActions { Delete =          0x1,
                            Copy =            0x2,
--- branches/work/kst/kst1kde4/kst/src/libkstapp/kstviewobjectfactory.cpp #1106775:1106776
@@ -18,12 +18,8 @@
 #include "kstviewobjectfactory.h"
 #include "kstgfxmousehandler.h"
 
-static KStaticDeleter<KstViewObjectFactory> sdViewObjectFactory;
-
 KstViewObjectFactory *KstViewObjectFactory::self() {
-  if (!_self) {
-    sdViewObjectFactory.setObject(_self, new KstViewObjectFactory);
-  }
+  _self = new KstViewObjectFactory;
 
   return _self;
 }
--- branches/work/kst/kst1kde4/kst/src/libkstapp/kstviewwidget.cpp #1106775:1106776
@@ -17,9 +17,6 @@
 
 #include <assert.h>
 
-#include "ksdebug.h"
-#include <kmultipledrag.h>
-
 #include "kst.h"
 #include "kstviewobjectimagedrag.h"
 #include "ksttimers.h"
@@ -27,13 +24,13 @@
 #include "kstviewwindow.h"
 #include "plotmimesource.h"
 
-KstViewWidget::KstViewWidget(KstTopLevelViewPtr view, QWidget *parent, const char *name, Qt::WFlags w)
-: QWidget(parent, name, WStyle_Customize | WRepaintNoErase | w), _view(view) {
+KstViewWidget::KstViewWidget(KstTopLevelViewPtr view, QWidget *parent, const char *name, Qt::WindowFlags w)
+: QWidget(parent, w), _view(view) {
   setDragEnabled(true);
   setDropEnabled(true);
   setMouseTracking(true);
-  setFocusPolicy(QWidget::StrongFocus);
-  setBackgroundMode(Qt::NoBackground);
+// xxx  setFocusPolicy(QWidget::StrongFocus);
+// xxx  setBackgroundMode(Qt::NoBackground);
   setMinimumSize(40, 25);
   _vo_datamode = 0L;
   _lastViewMode = KstTopLevelView::LayoutMode;
@@ -46,7 +43,7 @@
   }
 }
 
-
+/* xxx
 QDragObject *KstViewWidget::dragObject() {
   KMultipleDrag *drag = new KMultipleDrag(this);
   QStringList plots;
@@ -77,8 +74,8 @@
 
   return drag;
 }
+*/
 
-
 void KstViewWidget::enterEvent(QEvent *e) {
   if (_view->viewMode() != KstTopLevelView::DisplayMode) {
     if (!_menu && !_view->tracking()) {
@@ -108,6 +105,7 @@
       _view->clearFocus();
     } else {
       if (_view->trackingIsMove() && _dragEnabled) {
+/* xxx
         QDragObject *d = dragObject();
         if (d) {
           // First cancel any operations
@@ -115,6 +113,7 @@
           _view->paint(KstPainter::P_PAINT);
           d->drag();
         }
+*/
       }
     }
   }
@@ -123,8 +122,9 @@
 
 KstViewObjectPtr KstViewWidget::findChildFor(const QPoint& pos) {
   KstViewObjectPtr rc;
-  KstViewObjectPtr search = _view.data();
+  KstViewObjectPtr search;
 
+  search = _view.data();
   while (search) {
     search = search->findChild(pos);
     if (search && search->mouseHandler()) {
@@ -167,10 +167,10 @@
       setCursor(QCursor(Qt::ArrowCursor));
     }
   } else {
-    if ((e->state() & Qt::MouseButtonMask) == 0) {
+    if ((e->modifiers() & Qt::MouseButtonMask) == 0) {
       switch (_view->viewMode()) {
         case KstTopLevelView::LabelMode:
-          setCursor(QCursor(Qt::IbeamCursor));
+          setCursor(QCursor(Qt::IBeamCursor));
           break;
         case KstTopLevelView::CreateMode:
           setCursor(QCursor(Qt::ArrowCursor));
@@ -180,8 +180,8 @@
       }
       _view->updateFocus(e->pos());
       e->accept();
-    } else if (e->state() & Qt::LeftButton) {
-      _view->pressMove(e->pos(), e->state() & Qt::ShiftButton, e->state() & Qt::AltButton);
+    } else if (e->modifiers() & Qt::LeftButton) {
+      _view->pressMove(e->pos(), e->modifiers() & Qt::ShiftModifier, e->modifiers() & Qt::AltModifier);
       e->accept();
     }
   }
@@ -209,10 +209,13 @@
     return;
   }
 
-  // Layout/graphics mode
+  //
+  // layout/graphics mode...
+  //
+
   if (e->button() & Qt::LeftButton) {
     setCursor(QCursor(Qt::ArrowCursor));
-    if (_view->handlePress(e->pos(), e->state() & Qt::ShiftButton)) {
+    if (_view->handlePress(e->pos(), e->modifiers() & Qt::ShiftModifier)) {
       e->accept();
 
       return;
@@ -242,11 +245,18 @@
     return;
   }
 
-  // layout/graphics mode
+  //
+  // layout/graphics mode...
+  //
+
   if (e->button() & Qt::LeftButton) {
-    // let the toplevel view handle it
-    if (_view->handleDoubleClick(e->pos(), e->state() & Qt::ShiftButton)) {
+    //
+    // let the toplevel view handle it...
+    //
+
+    if (_view->handleDoubleClick(e->pos(), e->modifiers() & Qt::ShiftModifier)) {
       e->accept();
+
       return;
     }
   }
@@ -258,6 +268,7 @@
 void KstViewWidget::wheelEvent(QWheelEvent *e) {
   if (_view->viewMode() == KstTopLevelView::DisplayMode) {
     KstViewObjectPtr vo;
+
     if (_view->mouseGrabbed()) {
       vo = _view->mouseGrabber();
     } else {
@@ -266,6 +277,7 @@
     if (vo) {
       vo->wheelEvent(this, e);
     }
+
     return;
   }
 }
@@ -274,6 +286,7 @@
 void KstViewWidget::mouseReleaseEvent(QMouseEvent *e) {
   if (_view->viewMode() == KstTopLevelView::DisplayMode) {
     KstViewObjectPtr vo;
+
     if (_view->mouseGrabbed()) {
       vo = _view->mouseGrabber();
     } else {
@@ -282,16 +295,17 @@
     if (vo) {
       vo->mouseReleaseEvent(this, e);
     }
+
     return;
   }
 
-  if ((e->state() & Qt::ShiftButton) && (e->button() & Qt::LeftButton) && !_view->tracking()) {
+  if ((e->modifiers() & Qt::ShiftModifier) && (e->button() & Qt::LeftButton) && !_view->tracking()) {
     _view->releasePress(e->pos(), true);
   } else if (e->button() & Qt::LeftButton) {
-    _view->releasePress(e->pos(), e->state() & Qt::ShiftButton);
+    _view->releasePress(e->pos(), e->modifiers() & Qt::ShiftModifier);
     e->accept();
   } else {
-    if (e->state() & Qt::LeftButton && _view->tracking()) {
+    if (e->modifiers() & Qt::LeftButton && _view->tracking()) {
       e->accept();
 
       return;
@@ -303,7 +317,7 @@
 
 
 void KstViewWidget::contextMenuEvent(QContextMenuEvent *e) {
-  if (e->state() & Qt::LeftButton || _view->tracking()) {
+  if (e->modifiers() & Qt::LeftButton || _view->tracking()) {
     e->ignore();
 
     return;
@@ -321,7 +335,8 @@
     return;
   }
 
-  _menu = new KPopupMenu(this);
+  _menu = new QMenu(this);
+/* xxx
   bool rc = _view->popupMenu(_menu, e->pos());
   if (rc && _menu->count() > 0) {
     _menu->popup(mapToGlobal(e->pos()));
@@ -329,12 +344,14 @@
   } else {
     delete _menu;
   }
+*/
   e->accept();
 }
 
 
 void KstViewWidget::paint(const QRegion& region) {
   QPaintEvent e(region);
+
   paintEvent(&e);
 }
 
@@ -346,11 +363,6 @@
 
 // Note: e can be null
 void KstViewWidget::paintEvent(QPaintEvent *e) {
-#ifdef BENCHMARK
-  QTime t;
-  t.start();
-#endif
-
   if (e) {  // Resize/expose/etc triggered by X11
     QRegion r = e->region();
     if (r.isEmpty()) {
@@ -358,18 +370,8 @@
     } else {
       _view->paint(KstPainter::P_PAINT, e->region());
     }
-
-#ifdef BENCHMARK
-    int x = t.elapsed();
-    kstdDebug() << "Paint event: X11 triggered - " << x << "ms" << endl;
-#endif
   } else { // explicitly forced paint in the code
     _view->paint(KstPainter::P_ZOOM);
-
-#ifdef BENCHMARK
-    int x = t.elapsed();
-    kstdDebug() << "Paint event: Forced (zoom) - " << x << "ms" << endl;
-#endif
   }
 }
 
@@ -378,32 +380,36 @@
   if (e->provides(PlotMimeSource::mimeType())) {
     if (e->source() == this) {
       QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Escape, 0, 0);
-      QApplication::sendEvent(this, &keyEvent);
+
+// xxx      QApplication::sendEvent(this, &keyEvent);
       _view->restartMove();
     } else {
-      e->acceptAction(true);
+// xxx      e->acceptAction(true);
     }
   } else if (_view->viewMode() != KstTopLevelView::LayoutMode) {
-    KstViewObjectPtr vo = findChildFor(e->pos());
+    KstViewObjectPtr vo;
+
+    vo = findChildFor(e->pos());
     if (vo) {
       vo->dragEnterEvent(this, e);
     } else {
-      e->accept(false);
+// xxx      e->accept(false);
     }
   }
+
   QWidget::dragEnterEvent(e);
 }
 
 
 void KstViewWidget::dragMoveEvent(QDragMoveEvent *e) {
   if (_dragEnabled && e->provides(PlotMimeSource::mimeType())) {
-    e->accept(true);
+// xxx    e->accept(true);
   } else if (_view->viewMode() != KstTopLevelView::LayoutMode) {
     KstViewObjectPtr vo = findChildFor(e->pos());
     if (vo) {
       vo->dragMoveEvent(this, e);
     } else {
-      e->accept(false);
+// xxx      e->accept(false);
     }
   }
   QWidget::dragMoveEvent(e);
@@ -419,22 +425,30 @@
 void KstViewWidget::dropEvent(QDropEvent *e) {
   if (e->source() != this && e->provides(PlotMimeSource::mimeType())) {
     // FIXME: support both copy and move
-    KstViewObjectPtr vo = findChildFor(e->pos());
+    KstViewObjectPtr vo;
+
+    vo = findChildFor(e->pos());
     if (vo) {
+/* xxx
       if (vo->paste(e)) {
         e->acceptAction(true);
         KstApp::inst()->updateViewManager(true);
         _view->paint(KstPainter::P_PAINT);
       }
+*/
     } else {
+/* xxx
       if (viewObject()->paste(e)) {
         e->acceptAction(true);
         KstApp::inst()->updateViewManager(true);
         _view->paint(KstPainter::P_PAINT);
       }
+*/
     }
   } else if (_view->viewMode() != KstTopLevelView::LayoutMode) {
-    KstViewObjectPtr vo = findChildFor(e->pos());
+    KstViewObjectPtr vo;
+
+    vo = findChildFor(e->pos());
     if (vo) {
       vo->dropEvent(this, e);
       return;
@@ -453,7 +467,7 @@
 void KstViewWidget::keyPressEvent(QKeyEvent *e) {
   if (_view->viewMode() == KstTopLevelView::DisplayMode) {
     KstViewObjectPtr vo;
-    // Note: should mouse grabbers get keyboard input?
+
     if (_view->mouseGrabbed()) {
       vo = _view->mouseGrabber();
     } else {
@@ -464,12 +478,13 @@
     }
     return;
   } else if (_view->viewMode() == KstTopLevelView::LayoutMode) {
-    ButtonState s = e->stateAfter();
+    Qt::KeyboardModifiers s = e->modifiers();
+
     if (e->key() == Qt::Key_Escape) {
       _view->cancelMouseOperations();
       return;
-    } else if (e->key() == Qt::Key_A && (s & Qt::ControlButton) && _view->viewMode() == KstTopLevelView::LayoutMode) {
-      if (s & Qt::ShiftButton) {
+    } else if (e->key() == Qt::Key_A && (s & Qt::ControlModifier) && _view->viewMode() == KstTopLevelView::LayoutMode) {
+      if (s & Qt::ShiftModifier) {
         _view->unselectAll();
       } else {
         _view->selectAll();
@@ -493,6 +508,7 @@
 void KstViewWidget::keyReleaseEvent(QKeyEvent *e) {
   if (_view->viewMode() == KstTopLevelView::DisplayMode) {
     KstViewObjectPtr vo;
+
     // Note: should mouse grabbers get keyboard input?
     if (_view->mouseGrabbed()) {
       vo = _view->mouseGrabber();
@@ -535,7 +551,10 @@
     _view->updateFocus(mapFromGlobal(QCursor::pos()));
   }
 
-  // for convenience, let's update the dialogs
+  //
+  // for convenience, let's update the dialogs...
+  //
+
   QTimer::singleShot(0, KstApp::inst(), SLOT(updateVisibleDialogs()));
 }
 
@@ -546,4 +565,3 @@
 
 
 #include "kstviewwidget.moc"
-
--- branches/work/kst/kst1kde4/kst/src/libkstapp/kstviewwidget.h #1106775:1106776
@@ -19,6 +19,7 @@
 #define KSTVIEWWIDGET_H
 
 // xxx#include <qdragobject.h>
+#include <QMenu>
 #include <QPointer>
 #include <QWidget>
 
@@ -74,7 +75,7 @@
     KstTopLevelViewPtr _view;
     KstTopLevelView::ViewMode _lastViewMode;
     QPointer<KstViewObject> _vo_datamode;
-    QPointer<KPopupMenu> _menu;
+    QPointer<QMenu> _menu;
 // xxx    QDragObject *_drag;
     bool _dropEnabled : 1;
     bool _dragEnabled : 1;


More information about the Kst mailing list