commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r8880 - trunk/gnue-forms/src/uidrivers/qt3/widgets


From: johannes
Subject: [gnue] r8880 - trunk/gnue-forms/src/uidrivers/qt3/widgets
Date: Fri, 20 Oct 2006 02:30:29 -0500 (CDT)

Author: johannes
Date: 2006-10-20 02:30:29 -0500 (Fri, 20 Oct 2006)
New Revision: 8880

Modified:
   trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py
   trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
Log:
Getting the grids up and running ...


Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py 2006-10-20 07:20:14 UTC 
(rev 8879)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py 2006-10-20 07:30:29 UTC 
(rev 8880)
@@ -62,17 +62,31 @@
 
     # -------------------------------------------------------------------------
 
-    def _ui_focus_out_(self, index):
+    def _ui_focus_in_(self, index):
 
-        pass
+        widget = self.widgets[index]
+        if self.in_grid and widget._gnue_label_:
+            label = widget._gnue_label_
+            widget.show()
+            label.hide()
+            widget.updateGeometry()
+            widget.parent().layout().activate()
 
+
     # -------------------------------------------------------------------------
 
     def _ui_focus_out_(self, index):
 
-        pass
+        widget = self.widgets[index]
+        if self.in_grid and widget._gnue_label_:
+            label = widget._gnue_label_
+            label.show()
+            widget.hide()
+            label.updateGeometry()
+            label.parent().layout().activate()
 
 
+
 # =============================================================================
 # Base class for H/V-Boxes in a managed layout
 # =============================================================================

Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-20 07:20:14 UTC 
(rev 8879)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-20 07:30:29 UTC 
(rev 8880)
@@ -124,7 +124,7 @@
     def __add_entry_label(self, parent):
 
         if self.in_grid:
-            result = qt.QLabel(parent)
+            result = GridLabel(parent, self)
 
         elif self._gfObject.label:
             result = qt.QLabel(self._gfObject.label, parent)
@@ -161,6 +161,10 @@
             if method:
                 method(value)
         finally:
+            if self.in_grid and widget._gnue_label_:
+                if isinstance(widget._gnue_label_, qt.QLabel):
+                    widget._gnue_label_.setText(value)
+
             self._block_change_ = False
 
     # -------------------------------------------------------------------------
@@ -195,19 +199,6 @@
             method(selection1, selection2)
 
     # -------------------------------------------------------------------------
-
-    def _ui_set_focus_(self, index):
-
-        widget = self.widgets[index]
-        if self.in_grid and widget._gnue_label_:
-            label = widget._gnue_label_
-            widget.show()
-            label.hide()
-
-        UIHelper._ui_set_focus_(self, index)
-
-
-    # -------------------------------------------------------------------------
     # Clipboard and selection
     # -------------------------------------------------------------------------
 
@@ -376,7 +367,44 @@
 
         self.setText(value)
 
+# =============================================================================
+# GridLabel
+# =============================================================================
 
+class GridLabel(qt.QLabel):
+    """
+    Implements a Label widget used within grid controls which is capable of
+    activating the corresponding entry widget on a mouse click.
+    """
+
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
+
+    def __init__(self, parent, ui_widget):
+
+        self.ui_widget = ui_widget
+        qt.QLabel.__init__(self, parent)
+
+
+    # -------------------------------------------------------------------------
+    # Event-handler
+    # -------------------------------------------------------------------------
+
+    def mousePressEvent(self, event):
+
+        # Find the widget this label belongs to
+        for (index, item) in enumerate(self.ui_widget.widgets):
+            if item._gnue_label_ == self:
+                if item.isEnabled():
+                    # This replaces the label with the actual entry and sets
+                    # the focus on the entry
+                    self.ui_widget._ui_focus_in_(index)
+                    self.ui_widget._ui_set_focus_(index)
+
+                break
+
+
 # =============================================================================
 # LineEdit widgets
 # =============================================================================





reply via email to

[Prev in Thread] Current Thread [Next in Thread]