[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-05-03 14:33:20
Message-ID: 20100503143320.3049BAC8B0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1122306 by staniek:

Forms
*fix inserting group boxes, they now properly act as containers
*avoid loading widgets with the same name more than once



 M  +3 -0      commands.cpp  
 M  +4 -4      container.cpp  
 M  +31 -14    factories/containerfactory.cpp  
 M  +8 -1      formIO.cpp  
 M  +1 -0      objecttree.cpp  


--- trunk/koffice/kexi/formeditor/commands.cpp #1122305:1122306
@@ -875,6 +875,7 @@
 {
     d->form = container.form();
     d->containerName = container.widget()->objectName();
+    kDebug() << "containerName:" << d->containerName;
     d->_class = d->form->selectedClass();
     d->pos = container.selectionOrInsertingBegin();
     d->widgetName = d->form->objectTree()->generateUniqueName(
@@ -892,6 +893,7 @@
 {
     d->form = container.form();
     d->containerName = container.widget()->objectName();
+    kDebug() << "containerName:" << d->containerName;
     d->_class = className;
     d->pos = pos;
     //d->insertRect is null (default)
@@ -1017,6 +1019,7 @@
     // it's already created in Container's constructor
     ObjectTreeItem *item = d->form->objectTree()->lookup(d->widgetName);
     if (!item) { //not yet created...
+        kDebug() << "Creating ObjectTreeItem:";
         item = new ObjectTreeItem(d->form->library()->displayName(d->_class), \
d->widgetName, w, container);  \
d->form->objectTree()->addItem(container->objectTree(), item);  }
--- trunk/koffice/kexi/formeditor/container.cpp #1122305:1122306
@@ -213,6 +213,7 @@
     m_spacing = d->form ? d->form->defaultSpacing() : 0;
 
     if (toplevel) {
+        kDebug() << "Creating ObjectTreeItem:";
         ObjectTreeItem *it = new \
                ObjectTreeItem(d->form->library()->displayName(classname),
                                                 widget()->objectName(), widget(), \
this, this);  setObjectTree(it);
@@ -270,9 +271,8 @@
         d->stopSelectionRectangleOrInserting();
         m_mousePressEventReceived = true;
 
-        kDebug() << "sender object = " << s->objectName()
-            << "of type " << s->metaObject()->className();
-        kDebug() << "this          = " << this->objectName();
+        kDebug() << "sender object =" << s->objectName() << "of type =" << \
s->metaObject()->className() +            << "this =" << this->objectName() << \
metaObject()->className();  
         m_moving = static_cast<QWidget*>(s);
         d->idOfPropertyCommand++; // this will create another PropertyCommand
@@ -485,7 +485,7 @@
         QPainter p(widget());
         p.setRenderHint(QPainter::Antialiasing, false);
 #if 1 // grid
-#define DEBUG_PAINTER
+//#define DEBUG_PAINTER
 #ifdef DEBUG_PAINTER
     kDebug() << "would draw grid" << pe->rect();
     QTime t;
--- trunk/koffice/kexi/formeditor/factories/containerfactory.cpp #1122305:1122306
@@ -808,6 +808,7 @@
                                   CreateWidgetOptions options)
 {
     QWidget *w = 0;
+    bool createContainer = false;
 #if 0 // needed?
     if (c == "QButtonGroup") {
         QString text = container->form()->library()->textForWidgetName(n, c);
@@ -823,6 +824,7 @@
         tab->setTabReorderingEnabled(true);
         connect(tab, SIGNAL(movedTab(int, int)), this, SLOT(reorderTabs(int, int)));
 #endif
+        kDebug() << "Creating ObjectTreeItem:";
         container->form()->objectTree()->addItem(container->objectTree(),
                 new KFormDesigner::ObjectTreeItem(
                     container->form()->library()->displayName(c), n, tab, \
container)); @@ -834,22 +836,26 @@
         }
     } else if (c == "QWidget") {
         w = new ContainerWidget(p);
-        new KFormDesigner::Container(container, w, p);
+        createContainer = true;
+//        new KFormDesigner::Container(container, w, p);
     } else if (c == "QGroupBox") {
         QString text = container->form()->library()->textForWidgetName(n, c);
         w = new GroupBox(text, p);
-        new KFormDesigner::Container(container, w, container);
+        createContainer = true;
+//        new KFormDesigner::Container(container, w, container);
     } else if (c == "QFrame") {
         QFrame *frm = new QFrame(p);
         w = frm;
         frm->setLineWidth(2);
         frm->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
-        new KFormDesigner::Container(container, w, container);
+        createContainer = true;
+//        new KFormDesigner::Container(container, w, container);
     } else if (c == "QStackedWidget" || /* compat */ c == "QWidgetStack") {
         QStackedWidget *stack = new QStackedWidget(p);
         w = stack;
         stack->setLineWidth(2);
         stack->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
+        kDebug() << "Creating ObjectTreeItem:";
         container->form()->objectTree()->addItem(container->objectTree(),
                 new KFormDesigner::ObjectTreeItem(
                     container->form()->library()->displayName(c), n, stack, \
container)); @@ -860,19 +866,24 @@
         }
     } else if (c == "HBox") {
         w = new HBox(p);
-        new KFormDesigner::Container(container, w, container);
+        createContainer = true;
+//        new KFormDesigner::Container(container, w, container);
     } else if (c == "VBox") {
         w = new VBox(p);
-        new KFormDesigner::Container(container, w, container);
+        createContainer = true;
+//        new KFormDesigner::Container(container, w, container);
     } else if (c == "Grid") {
         w = new Grid(p);
-        new KFormDesigner::Container(container, w, container);
+        createContainer = true;
+//        new KFormDesigner::Container(container, w, container);
     } else if (c == "HFlow") {
         w = new HFlow(p);
-        new KFormDesigner::Container(container, w, container);
+        createContainer = true;
+//        new KFormDesigner::Container(container, w, container);
     } else if (c == "VFlow") {
         w = new VFlow(p);
-        new KFormDesigner::Container(container, w, container);
+        createContainer = true;
+//        new KFormDesigner::Container(container, w, container);
 #if 0 //todo
     } else if (c == "SubForm") {
         w = new SubForm(container->form(), p);
@@ -884,16 +895,19 @@
             split->setOrientation(
                 (options & WidgetFactory::VerticalOrientation) ? Qt::Vertical : \
Qt::Horizontal);  }
-        (void)new KFormDesigner::Container(container, split, container);
+        createContainer = true;
+//        (void)new KFormDesigner::Container(container, split, container);
     }
 
     if (w) {
         w->setObjectName(n);
         kDebug() << w << w->objectName() << "created";
+    }
+    if (createContainer) {
+        (void)new KFormDesigner::Container(container, w, container);
+    }
         return w;
     }
-    return 0;
-}
 
 bool
 ContainerFactory::previewWidget(const QByteArray &classname, 
@@ -985,12 +999,15 @@
         return true;
     }
 #endif
-    if (args.classname == "QGroupBox") {
-        QGroupBox *group = static_cast<QGroupBox*>(args.widget);
+//! @todo enable GroupBox inline editing
+#if 0
+    if (args.classname == "GroupBox") {
+        GroupBox *group = dynamic_cast<GroupBox*>(args.widget);
         args.text = group->title();
-        args.geometry = QRect(group->x() + 2, group->y() - 5, group->width() - 10, \
args.widget->fontMetrics().height() + 10); +        args.geometry = QRect(group->x() \
+ 2, group->y(), group->width() - 10, args.widget->fontMetrics().height() + 10);  \
return true;  }
+#endif
     return false;
 }
 
--- trunk/koffice/kexi/formeditor/formIO.cpp #1122305:1122306
@@ -1155,6 +1155,11 @@
             break;
         }
     }
+    ObjectTreeItem *item = container->form()->objectTree()->lookup(wname);
+    if (item) {
+        kWarning() << "Widget" << wname << "already exists! Skipping...";
+        return;
+    }
 
     QByteArray classname, alternate;
     // We translate some name (for compatibility)
@@ -1224,9 +1229,11 @@
     w->show();
 
     // We create and insert the ObjectTreeItem at the good place in the ObjectTree
-    ObjectTreeItem *item = container->form()->objectTree()->lookup(wname);
+    item = container->form()->objectTree()->lookup(wname);
+    kDebug() << wname << item << classname << (parent ? parent->objectName() : 0);
     if (!item)  {
         // not yet created
+        kDebug() << "Creating ObjectTreeItem:";
         item =  new \
ObjectTreeItem(container->form()->library()->displayName(classname),  wname, w, \
container);  if (parent)  {
--- trunk/koffice/kexi/formeditor/objecttree.cpp #1122305:1122306
@@ -40,6 +40,7 @@
                                Container *parentContainer, Container *container)
         : m_enabled(true), m_row(-1), m_col(-1), m_rowspan(-1), m_colspan(-1), \
m_span(false)  {
+    kDebug() << classn << name << widget->objectName() << "parentContainer:" << \
parentContainer << "container:" << container;  m_className = classn;
     m_name = name;
     m_widget = widget;


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

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