View display saving works! We now have the ability to add and update data in SQL...
authorStas Shtin <antisvin@gmail.com>
Fri, 9 Apr 2010 21:18:50 +0000 (01:18 +0400)
committerStas Shtin <antisvin@gmail.com>
Fri, 9 Apr 2010 21:18:50 +0000 (01:18 +0400)
src/ipypbx/controllers.py

index fa6cbbc..3263273 100644 (file)
@@ -68,7 +68,7 @@ class BaseController(QtCore.QObject):
             # Hide fields not meant for display.
             for i, field in enumerate(self.fields):
                 if field not in self.view_list_fields:
-                    self.view_list.setColumnHidden(i, True)
+                    self.view_list.hideColumn(i)
 
             # Stretch headers to fill all available width.
             self.view_list.setSelectionMode(QtGui.QTableView.SingleSelection)
@@ -132,10 +132,8 @@ class BaseController(QtCore.QObject):
         """
         return (
             (getattr(self.views, self.basename + 'Add'), 'clicked()', self.add),
-            #connect(ui.bookTable->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
-            # mapper, SLOT(setCurrentModelIndex(QModelIndex)));
-            
-            (self.view_list.selectionModel(), 'currentRowChanged(QModelIndex,QModelIndex)',
+            (self.view_list.selectionModel(),
+             'currentRowChanged(QModelIndex,QModelIndex)',
              self.view_display, 'setCurrentModelIndex(QModelIndex)'),
             (getattr(self.views, self.basename + 'Save'), 'clicked()',
              self.save),
@@ -151,7 +149,7 @@ class BaseController(QtCore.QObject):
         self.view_list.selectRow(num_rows)
 
         # Disable adding more than one row.
-        getattr(self.views, self.basename + 'Add').setEnabled(False)
+        self.getFieldWidget('Add').setEnabled(False)
 
         # Focust to the first displayed field.
         self.getFieldWidget(self.getDisplayFields()[0]).setFocus()
@@ -160,28 +158,17 @@ class BaseController(QtCore.QObject):
         for field in self.getDisplayFields():
             self.getFieldWidget(field).clear()
         
-    def select(self, row):
-        """
-        Select an object from the list.
-        """
-        # Fill in form based on selection.
-        
-        
-        #self.parent.ui.connectionName.setText(self.currentConnection.name)
-        #self.parent.ui.connectionLocalIpAddress.setText(
-        #    self.currentConnection.local_ip_address)
-        #self.parent.ui.connectionLocalPort.setText(
-        #    unicode(self.currentConnection.local_port))
-        #self.parent.ui.connectionFreeswitchIpAddress.setText(
-        #    self.currentConnection.freeswitch_ip_address)
-        #self.parent.ui.connectionFreeswitchPort.setText(
-        #    unicode(self.currentConnection.freeswitch_port))
-
     def save(self):
         """
-        TODO: Default implementation.
+        Save currently selected object.
         """
-        return NotImplemented
+        #print self.model.isDirty(self.view_list.currentRow())
+        #print self.view_list.selectedIndexes()[0].row()
+
+        #if self.model.isDirty(self.view_display.currentIndex()), self.model.rowCount()
+        self.view_display.submit()
+        self.getFieldWidget('Add').setEnabled(True)
+        
 
 
 class ConnectionController(BaseController):
@@ -200,7 +187,7 @@ class ConnectionController(BaseController):
         This creates a new connection with bound data copied from another one.
         """
 
-    def save(self):
+    def _save(self):
         """
         Save new or existing connection.
         """