commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8844 - in trunk/gnue-forms/src/uidrivers/qt3: . widgets


From: johannes
Subject: [gnue] r8844 - in trunk/gnue-forms/src/uidrivers/qt3: . widgets
Date: Wed, 18 Oct 2006 08:25:55 -0500 (CDT)

Author: johannes
Date: 2006-10-18 08:25:54 -0500 (Wed, 18 Oct 2006)
New Revision: 8844

Modified:
   trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py
   trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
Log:
Changed clipboard handling


Modified: trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py      2006-10-18 13:10:08 UTC 
(rev 8843)
+++ trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py      2006-10-18 13:25:54 UTC 
(rev 8844)
@@ -146,20 +146,6 @@
 
 
     # -------------------------------------------------------------------------
-    # Clipbard routines
-    # TODO: only kept for reference, can be deleted, not used any more
-    # -------------------------------------------------------------------------
-
-    def getClipboardContents(self, event):
-        event.__result__ = str(self._qtapp.clipboard().text())
-
-    # -------------------------------------------------------------------------
-
-    def setClipboardContents(self, event):
-        self._qtapp.clipboard().setText(event.text)
-
-
-    # -------------------------------------------------------------------------
     # Show a simple error message
     # -------------------------------------------------------------------------
 

Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-18 13:10:08 UTC 
(rev 8843)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-18 13:25:54 UTC 
(rev 8844)
@@ -125,7 +125,6 @@
         return result
 
 
-
     # -------------------------------------------------------------------------
     # Enable/disable this entry
     # -------------------------------------------------------------------------
@@ -147,9 +146,13 @@
 
         widget = self.widgets[index]
 
-        method = getattr(widget, '_ui_set_value_', None)
-        if method:
-            method(value)
+        self._block_change_ = True
+        try:
+            method = getattr(widget, '_ui_set_value_', None)
+            if method:
+                method(value)
+        finally:
+            self._block_change_ = False
 
     # -------------------------------------------------------------------------
 
@@ -189,29 +192,33 @@
 
     def _ui_cut_(self, index):
 
-        # TODO
-        pass
+        widget = self.widgets[index]
+        if hasattr(widget, '_ui_cut_'):
+            widget._ui_cut_()
 
     # -------------------------------------------------------------------------
 
     def _ui_copy_(self, index):
 
-        # TODO
-        pass
+        widget = self.widgets[index]
+        if hasattr(widget, '_ui_copy_'):
+            widget._ui_copy_()
 
     # -------------------------------------------------------------------------
 
     def _ui_paste_(self, index):
 
-        # TODO
-        pass
+        widget = self.widgets[index]
+        if hasattr(widget, '_ui_paste_'):
+            widget._ui_paste_()
 
     # -------------------------------------------------------------------------
 
     def _ui_select_all_(self, index):
 
-        # TODO
-        pass
+        widget = self.widgets[index]
+        if hasattr(widget, '_ui_select_all_'):
+            widget._ui_select_all_()
 
 
 # =============================================================================
@@ -228,6 +235,7 @@
         self.ui_widget = ui_widget
         self.qt_class = qt_class
         self.lookup = self
+        self._keypress_ = False
 
 
     # -------------------------------------------------------------------------
@@ -246,8 +254,36 @@
         if hasattr(self, 'setSelection'):
             self.setSelection(selection1, selection2-selection1)
 
+    # -------------------------------------------------------------------------
 
+    def _ui_cut_(self):
+
+        if hasattr(self, 'cut'):
+            self.cut()
+
     # -------------------------------------------------------------------------
+
+    def _ui_copy_(self):
+
+        if hasattr(self, 'copy'):
+            self.copy()
+
+    # -------------------------------------------------------------------------
+
+    def _ui_paste_(self):
+
+        if hasattr(self, 'paste'):
+            self.paste()
+
+    # -------------------------------------------------------------------------
+
+    def _ui_select_all_(self):
+
+        if hasattr(self, 'selectAll'):
+            self.selectAll()
+
+
+    # -------------------------------------------------------------------------
     # Event-Handler
     # -------------------------------------------------------------------------
 
@@ -271,11 +307,9 @@
             else:
                 self.ui_widget._request(command, triggerName = args)
 
-        elif len(event.text()):
-            self.ui_widget._keypress(unicode(event.text()))
         else:
-            # TODO: is there another way to find the qt widget class which is
-            # implemented by the class of this Mixin ?
+            # TODO: is there another way to find the qt widget class which
+            # is implemented by the class of this Mixin ?
             self.qt_class.keyPressEvent(self, event)
 
 
@@ -316,6 +350,7 @@
         if adjust:
             self.ui_widget._request('JUMPRECORD', data=adjust)
 
+
 # =============================================================================
 # Label widgets
 # =============================================================================
@@ -342,8 +377,6 @@
         self.setText(value)
 
 
-
-
 # =============================================================================
 # LineEdit widgets
 # =============================================================================
@@ -361,11 +394,31 @@
         qt.QLineEdit.__init__(self, parent)
         BaseEntry.__init__(self, ui_widget, qt.QLineEdit)
 
+        self.connect(self, qt.SIGNAL('textChanged(const QString &)'),
+                self.__on_text_changed)
+        self.connect(self, qt.SIGNAL('selectionChanged()'),
+            self.__on_selection_changed)
+
         if password:
             self.setEchoMode(qt.QLineEdit.Password)
 
 
     # -------------------------------------------------------------------------
+    # Qt-Signals
+    # -------------------------------------------------------------------------
+
+    def __on_text_changed(self, value):
+
+        if not self.ui_widget._block_change_:
+            self.ui_widget._request('KEYPRESS', text=unicode(value))
+
+    # -------------------------------------------------------------------------
+
+    def __on_selection_changed(self):
+        pass
+
+
+    # -------------------------------------------------------------------------
     # Release of a mouse button
     # -------------------------------------------------------------------------
 
@@ -396,6 +449,7 @@
         self.setText(value)
 
 
+
 # =============================================================================
 # Multiline text entry widget
 # =============================================================================
@@ -638,7 +692,31 @@
 
         self.lineEdit().setSelection(position1, position2-position1)
 
+    # -------------------------------------------------------------------------
 
+    def _ui_cut_(self):
+
+        self.lineEdit().cut()
+
+    # -------------------------------------------------------------------------
+
+    def _ui_copy_(self):
+
+        self.lineEdit().copy()
+
+    # -------------------------------------------------------------------------
+
+    def _ui_paste_(self):
+
+        self.lineEdit().paste()
+
+    # -------------------------------------------------------------------------
+
+    def _ui_select_all_(self):
+
+        self.lineEdit().selectAll()
+
+
 # =============================================================================
 # Listbox widgets
 # =============================================================================
@@ -696,6 +774,8 @@
 # =============================================================================
 
 qtKeyTranslations = {
+    vk.A      : qt.Qt.Key_A,         vk.C         : qt.Qt.Key_C,
+    vk.V      : qt.Qt.Key_V,         vk.X         : qt.Qt.Key_X,
     vk.F1     : qt.Qt.Key_F1,        vk.F2        : qt.Qt.Key_F2,
     vk.F3     : qt.Qt.Key_F3,        vk.F4        : qt.Qt.Key_F4,
     vk.F5     : qt.Qt.Key_F5,        vk.F6        : qt.Qt.Key_F6,





reply via email to

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