More work on config generation. Added a workaround for QTBUG-8217
[ipypbx] / src / ipypbx / controllers.py
index c4e962e..19680d3 100644 (file)
@@ -285,13 +285,21 @@ class ConnectionChangeListenerController(BaseController):
             connection_id, _ok = index.model().data(
                 index.sibling(index.row(), 0)).toInt()
             self.connection_id = connection_id
-            self.model.setFilter(
-                'ipypbxweb_%s.connection_id = %i' %
-                (self.basename, connection_id))
+
+            # Filter is customizable in order to allow ugly hacks :-)
+            self.model.setFilter(self.getFilter(connection_id))
+
+            # Select first row.
             self.view_list.selectRow(0)
+
+            # Create a new object if none exist.
             if not self.model.rowCount():
                 self.add()
 
+    def getFilter(self, connection_id):
+        return 'ipypbxweb_%s.connection_id = %i' % (
+            self.basename, connection_id)        
+
     def objectAdded(self, row, record):
         """
         Set connection_id from currently selected connection.
@@ -392,3 +400,9 @@ class ExtensionController(ConnectionChangeListenerController):
             'xml_dialplan', '<action application="echo" data=""/>')
         super(ExtensionController, self).objectAdded(row, record)
         
+    def getFilter(self, connection_id):
+        # Workaround for Qt bug:
+        # http://bugreports.qt.nokia.com/browse/QTBUG-8217 . Apparently they
+        # don't hurry to fix it.
+        return '1 = 1) or (ipypbxweb_%s.connection_id = %i' % (
+            self.basename, connection_id)