10 changes: 5 additions & 5 deletions python/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ MACRO (PLUGIN_INSTALL plugin subdir )
ENDFOREACH(file)
ADD_DEPENDENCIES(staged-plugins ${plugin}-${subdir_sane}-stageinstall)

IF(TARGET staged_${plugin})
ADD_DEPENDENCIES(staged_${plugin} ${plugin}-${subdir_sane}-stageinstall)
ELSE(TARGET staged_${plugin})
ADD_CUSTOM_TARGET(staged_${plugin} DEPENDS ${plugin}-${subdir_sane}-stageinstall)
IF(TARGET staged-${plugin})
ADD_DEPENDENCIES(staged-${plugin} ${plugin}-${subdir_sane}-stageinstall)
ELSE(TARGET staged-${plugin})
ADD_CUSTOM_TARGET(staged-${plugin} DEPENDS ${plugin}-${subdir_sane}-stageinstall)
ADD_CUSTOM_TARGET(clean-staged-${plugin}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}
)
ENDIF(TARGET staged_${plugin})
ENDIF(TARGET staged-${plugin})

ENDMACRO (PLUGIN_INSTALL)

Expand Down
9 changes: 8 additions & 1 deletion python/plugins/db_manager/db_plugins/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ def headerData(self, section, orientation, role):
return section+1
return SimpleTableModel.headerData(self, section, orientation, role)

def flags(self, index):
flags = SimpleTableModel.flags(self, index)
if index.column() == 2: # set Null column as checkable
flags &= ~Qt.ItemIsEditable
flags |= Qt.ItemIsUserCheckable
return flags

def append(self, fld):
data = [fld.name, fld.type2String(), not fld.notNull, fld.default2String()]
self.appendRow( self.rowFromData(data) )
Expand All @@ -230,7 +237,7 @@ def getObject(self, row):
fld.modifier = None
fld.dataType = typestr

fld.notNull = self.data(self.index(row, 2)) != "true"
fld.notNull = self.data(self.index(row, 2), Qt.CheckStateRole) == Qt.Unchecked
fld.primaryKey = self.data(self.index(row, 1), Qt.UserRole)
return fld

Expand Down
5 changes: 3 additions & 2 deletions python/plugins/db_manager/db_plugins/postgis/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from PyQt4.QtCore import *
from PyQt4.QtGui import *

from ..plugin import ConnectionError, DBPlugin, Database, Schema, Table, VectorTable, RasterTable, TableField, TableConstraint, TableIndex, TableTrigger, TableRule
from ..plugin import ConnectionError, InvalidDataException, DBPlugin, Database, Schema, Table, VectorTable, RasterTable, TableField, TableConstraint, TableIndex, TableTrigger, TableRule

try:
from . import resources_rc
except ImportError:
Expand Down Expand Up @@ -77,7 +78,7 @@ def connect(self, parent=None):
uri = QgsDataSourceURI()

settingsList = ["service", "host", "port", "database", "username", "password"]
service, host, port, database, username, password = map(lambda x: settings.value(x), settingsList)
service, host, port, database, username, password = map(lambda x: settings.value(x, "", type=str), settingsList)

# qgis1.5 use 'savePassword' instead of 'save' setting
savedPassword = settings.value("save", False, type=bool) or settings.value("savePassword", False, type=bool)
Expand Down
10 changes: 2 additions & 8 deletions python/plugins/db_manager/dlg_create_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ def createEditor(self, parent, option, index):
for item in self.fieldTypes:
cbo.addItem(item)
return cbo
elif index.column() == 2:
return QCheckBox(parent)
return QItemDelegate.createEditor(self, parent, option, index)

def setEditorData(self, editor, index):
Expand All @@ -59,9 +57,6 @@ def setEditorData(self, editor, index):
if index.column() == 1:
txt = m.data(index, Qt.DisplayRole)
editor.setEditText(txt)
elif index.column() == 2:
checked = m.data(index, Qt.DisplayRole) == "true"
editor.setChecked( checked )
else:
# use default
QItemDelegate.setEditorData(self, editor, index)
Expand All @@ -70,8 +65,6 @@ def setModelData(self, editor, model, index):
""" save data from editor back to model """
if index.column() == 1:
model.setData(index, editor.currentText())
elif index.column() == 1:
model.setData(index, editor.isChecked())
else:
# use default
QItemDelegate.setModelData(self, editor, model, index)
Expand Down Expand Up @@ -191,7 +184,8 @@ def addField(self):
if "serial" in self.fieldTypes: # PostgreSQL
colType = "serial"
m.setData(indexType, colType)
m.setData(indexNull, False)
m.setData(indexNull, None, Qt.DisplayRole)
m.setData(indexNull, Qt.Unchecked, Qt.CheckStateRole)

# selects the new row
sel = self.fields.selectionModel()
Expand Down
3 changes: 3 additions & 0 deletions python/plugins/db_manager/ui/DlgCreateTable.ui
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
</item>
<item row="1" column="0">
<widget class="QTableView" name="fields">
<property name="editTriggers">
<set>QAbstractItemView::AllEditTriggers</set>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
Expand Down