[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kexi/formeditor
From:       Jarosław Staniek <staniek () kde ! org>
Date:       2010-09-09 20:44:53
Message-ID: 20100909204453.26C67AC884 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1173608 by staniek:

Forms
*Widgets Tree: fixed position of context menu



 M  +1 -1      WidgetTreeWidget.cpp  
 M  +1 -1      container.cpp  
 M  +16 -5     form.cpp  
 M  +10 -1     form.h  


--- trunk/koffice/kexi/formeditor/WidgetTreeWidget.cpp #1173607:1173608
@@ -228,7 +228,7 @@
     QWidget *w = item->data()->widget();
     if (!w)
         return;
-    m_form->createContextMenu(w, m_form->activeContainer(), e->pos());
+    m_form->createContextMenu(w, m_form->activeContainer(), e->pos(), \
Form::WidgetTreeContextMenuTarget);  }
 
 void WidgetTreeWidget::contextMenuEvent(QContextMenuEvent* e)
--- trunk/koffice/kexi/formeditor/container.cpp #1173607:1173608
@@ -727,7 +727,7 @@
         m_moving = 0; // clear this otherwise mouse dragging outside
                       // of the popup menu would drag the selected widget(s) \
randomly  //kDebug() << "-----------" << s;
-        d->form->createContextMenu(static_cast<QWidget*>(s), this, \
cme->pos());//false); +        d->form->createContextMenu(static_cast<QWidget*>(s), \
this, cme->pos(), Form::FormContextMenuTarget);  return true;
     }
     case QEvent::Enter:
--- trunk/koffice/kexi/formeditor/form.cpp #1173607:1173608
@@ -2320,7 +2320,7 @@
 }
 
 // moved from FormManager
-void Form::createContextMenu(QWidget *w, Container *container, const QPoint& \
menuPos) //bool popupAtCursor) +void Form::createContextMenu(QWidget *w, Container \
*container, const QPoint& menuPos, ContextMenuTarget target)  {
     if (!widget())
         return;
@@ -2440,7 +2440,7 @@
 
         // We create the signals menu
         KMenu *sigMenu = new KMenu();
-        QList<QMetaMethod> list(
+        const QList<QMetaMethod> list(
             KexiUtils::methodsForMetaObjectWithParents(w->metaObject(), \
QMetaMethod::Signal,  QMetaMethod::Public));
         foreach(const QMetaMethod& m, list) {
@@ -2492,10 +2492,21 @@
 //    QWidgetList *lst = container->form()->selectedWidgets();
 //    QWidget * sel_w = lst ? lst->first() : container->form()->selectedWidget();
 //    QPoint realMenuPos = sel_w ? sel_w->mapToGlobal(QPoint(sel_w->width() / 2, \
                sel_w->height() / 2)) : QCursor::pos();
-    d->insertionPoint = menuPos; //container->widget()->mapToGlobal(menuPos);
+    QPoint pos;
+    switch (target) {
+    case FormContextMenuTarget: {
+        pos = container->widget()->mapToGlobal(w->pos() + menuPos);
+        d->insertionPoint = menuPos;
+        break;
+    }
+    case WidgetTreeContextMenuTarget: {
+        pos = QCursor::pos();
+        d->insertionPoint = container->widget()->mapToGlobal(w->pos() + QPoint(10, \
10)); // user may still want to paste +        break;
+    }
+    }
 
-    QAction *result = menu.exec( container->widget()->mapToGlobal(w->pos() + \
                menuPos) );
-    
+    QAction *result = menu.exec(pos);
     if (!result) {
         // nothing to do
     }
--- trunk/koffice/kexi/formeditor/form.h #1173607:1173608
@@ -314,10 +314,19 @@
      child widgets should ordered by parent tab's order. */
     void autoAssignTabStops();
 
+    //! Specifies target of context menu. Used in createContextMenu().
+    enum ContextMenuTarget
+    {
+        FormContextMenuTarget, //!< Context menu should be displayed on the form
+                               //!< with offset specified by menuPos argument.
+        WidgetTreeContextMenuTarget //!< Context menu should be displayed on the \
widget tree +                                    //!< area with offset specified by \
menuPos argument. +    };
+
     /*! This function creates and displays the context menu corresponding to the \
widget \a w.  The menu item are disabled if necessary, and
         the widget specific part is added (menu from the factory and buddy \
                selection). */
-    void createContextMenu(QWidget *w, Container *container, const QPoint& menuPos); \
//bool popupAtCursor = true); +    void createContextMenu(QWidget *w, Container \
*container, const QPoint& menuPos, ContextMenuTarget target);  
     //! @return true if snapping widgets to grid is enabled.
     bool isSnapWidgetsToGridEnabled() const;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic