Пример #1
0
    def _loadRootNodeinTree(self, root):
        '''
        Load the search results (formatted into an object of type 'stdm.navigaion.STR') into
        the tree view.
        '''
        strTreeViewModel = STRTreeViewModel(root, view=self.tvSTRResults)
        self.tvSTRResults.setModel(strTreeViewModel)
        # Resize tree columns to fit contents
        self._resizeTreeColumns()

        #Capture selection changes signals when results are returned in the tree view
        resultsSelModel = self.tvSTRResults.selectionModel()
        self.connect(
            resultsSelModel,
            SIGNAL(
                "selectionChanged(const QItemSelection&,const QItemSelection&)"
            ), self.onSelectResults)
Пример #2
0
    def __init__(self, parent=None, State=VIEW):
        QWidget.__init__(self, parent)
        self.setupUi(self)

        self._defaultEditTriggers = self.tvAdminUnits.editTriggers()

        self._state = State
        self._onStateChange()

        self._notifBar = NotificationBar(self.vlNotification)

        #Configure validating line edit controls
        invalidMsg = "{} already exists."
        self.txtUnitName.setModelAttr(AdminSpatialUnitSet, "Name")
        self.txtUnitName.setInvalidMessage(invalidMsg)
        self.txtUnitName.setNotificationBar(self._notifBar)
        self.txtUnitCode.setModelAttr(AdminSpatialUnitSet, "Code")
        self.txtUnitCode.setInvalidMessage(invalidMsg)
        self.txtUnitCode.setNotificationBar(self._notifBar)
        '''
        Initialize formatter for the rendering the admin unit nodes and insert
        the root node into the tree view model.
        '''
        self._adminUnitNodeFormatter = AdminUnitFormatter(
            self.tvAdminUnits, self)
        self._rtNode = self._adminUnitNodeFormatter.rootNode

        self._adminUnitTreeModel = STRTreeViewModel(
            self._adminUnitNodeFormatter.root(), view=self.tvAdminUnits)
        self.tvAdminUnits.setModel(self._adminUnitTreeModel)
        self.tvAdminUnits.hideColumn(2)
        self.tvAdminUnits.setColumnWidth(0, 250)

        #Connects slots
        self.connect(self.btnAdd, SIGNAL("clicked()"), self.onCreateAdminUnit)
        self.connect(self.btnClear, SIGNAL("clicked()"), self.onClearSelection)
        self.connect(self.btnRemove, SIGNAL("clicked()"),
                     self.onDeleteSelection)
        self.connect(
            self._adminUnitTreeModel,
            SIGNAL("dataChanged(const QModelIndex&,const QModelIndex&)"),
            self.onModelDataChanged)