Пример #1
0
 def init(self, app, dataManager):
     super().init(app, dataManager)
     self.app = app
     self.DataManager = dataManager
     self.selectedWorkshop = None
     self.workshopModel = WorkshopTableModel(self.Widgets.workshopList)
     self.sortModel = SortProxyModel(app.settings, 'workshopsbrowser')
     self.sortModel.setSourceModel(self.workshopModel)
     self.Widgets.workshopList.setModel(self.sortModel) # we need to call setModel() before selectionModel() (and never afterwards)
     self.Widgets.workshopList.selectionModel().currentChanged.connect(self.WorkshopListCurrentChanged)
     self.Widgets.workshopList.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
     self.Widgets.workshopList.customContextMenuRequested.connect(self.workshopListMenuRequested)
     # Init Splitter
     settings.setSplitterState(self.Widgets.splitter, self.app.settings.value('workshopsbrowser/splitterState', None))
     self.Widgets.splitter.splitterMoved.connect(self._slotSplitterMoved)
     # Init table header
     self.tableHeader = self.Widgets.workshopList.horizontalHeader()
     self.tableHeader.setSectionsMovable(True)
     self.tableHeader.setStretchLastSection(True)
     settings.setHeaderSectionSizes(self.tableHeader, self.app.settings.value('workshopsbrowser/HeaderSectionSizes', []))
     settings.setHeaderSectionVisualIndices(self.tableHeader, self.app.settings.value('workshopsbrowser/HeaderSectionVisualIndices', []))
     if self.sortModel.sortReversed:
         self.Widgets.workshopList.sortByColumn(self.sortModel.sortColumn, QtCore.Qt.DescendingOrder)
     else:
         self.Widgets.workshopList.sortByColumn(self.sortModel.sortColumn, QtCore.Qt.AscendingOrder)
     self.tableHeader.sectionResized.connect(self._slotTableSectionResized)
     self.tableHeader.sectionMoved.connect(self._slotTableSectionMoved)
     self.DataManager.registerRootObjectListener(self.DataManagerUpdated)
Пример #2
0
 def init(self, app, datamanager):
     super().init(app, datamanager)
     self.app = app
     for cat in [ ('All', CatAllModel, SortProxyModel),
                  ('Weapons', CatWeaponsModel, WeaponSortProxyModel),
                  ('Apparel', CatApparelModel, ApparelSortProxyModel),
                  ('Aid', CatAidModel, SortProxyModel),
                  ('Misc', CatMiscModel, SortProxyModel),
                  ('Junk', CatJunkModel, SortProxyModel),
                  ('Mods', CatModsModel, SortProxyModel),
                  ('Ammo', CatAmmoModel, SortProxyModel),
                  ('Books', CatBooksModel, SortProxyModel),
                  ('Holotapes', CatHolotapeModel, SortProxyModel),
                  ('Keys', CatKeysModel, SortProxyModel),
                  ('Components', ComponentsTableModel, SortProxyModel)  ]:
         tab = self._addTab(cat[0], cat[1], cat[2])
         self.tabs.append(tab)
         self.models.append(tab.tableView.model().sourceModel())
     self.widget.tabWidget.currentChanged.connect(self._slotCatTabChanged)
     activeTab = int(self.app.settings.value('inventorybrowser/activeTab', 0))
     self.widget.tabWidget.setCurrentIndex(activeTab)
     settings.setSplitterState(self.widget.splitter1, self.app.settings.value('inventorybrowser/splitter1State', None))
     self.widget.splitter1.splitterMoved.connect(self._slotSplitter1Moved)
     settings.setSplitterState(self.widget.splitter2, self.app.settings.value('inventorybrowser/splitter2State', None))
     self.widget.splitter2.splitterMoved.connect(self._slotSplitter2Moved)
     self.propertyTreeHeader = self.widget.propertyTree.header()
     settings.setHeaderSectionSizes(self.propertyTreeHeader, self.app.settings.value('inventorybrowser/PropertyHeaderSectionSizes', []))
     self.propertyTreeHeader.sectionResized.connect(self._slotPropertyTreeSectionResized)
     self.widget.filterEdit.textChanged.connect(self._slotFilterTextChanged)
     self.dataManager = datamanager
     self.dataManager.registerRootObjectListener(self._onPipRootObjectEvent)
Пример #3
0
 def init(self, app, datamanager):
     super().init(app, datamanager)
     self.app = app
     self.effectsViewModel = EffectsTableModel(self.app.settings)
     self.sortProxyModel = SortProxyModel(self.app.settings)
     self.sortProxyModel.setSourceModel(self.effectsViewModel)
     self.widget.effectsView.setModel(self.sortProxyModel)
     self.tableHeader = self.widget.effectsView.horizontalHeader()
     self.tableHeader.setSectionsMovable(True)
     self.tableHeader.setStretchLastSection(True)
     settings.setHeaderSectionSizes(self.tableHeader, self.app.settings.value('effectswidget/HeaderSectionSizes', []))
     settings.setHeaderSectionVisualIndices(self.tableHeader, self.app.settings.value('effectswidget/headerSectionVisualIndices', []))
     self.tableHeader.sectionResized.connect(self._slotTableSectionResized)
     self.tableHeader.sectionMoved.connect(self._slotTableSectionMoved)
     settings.setSplitterState(self.widget.splitter, self.app.settings.value('effectswidget/splitterState', None))
     self.widget.splitter.splitterMoved.connect(self._slotSplitterMoved)
     self.widget.showPermanentCheckBox.setChecked(bool(int(self.app.settings.value('effectswidget/showPermanent', 0))))
     self.widget.showEmptySourcesCheckBox.setChecked(bool(int(self.app.settings.value('effectswidget/showEmptySources', 0))))
     self.widget.showInactiveCheckBox.setChecked(bool(int(self.app.settings.value('effectswidget/showInactive', 0))))
     self.widget.showPermanentCheckBox.stateChanged.connect(self.effectsViewModel.setShowPermanent)
     self.widget.showEmptySourcesCheckBox.stateChanged.connect(self.effectsViewModel.setShowEmptySources)
     self.widget.showInactiveCheckBox.stateChanged.connect(self.effectsViewModel.setShowInactive)
     if self.sortProxyModel.sortReversed:
         self.widget.effectsView.sortByColumn(self.sortProxyModel.sortColumn, QtCore.Qt.DescendingOrder)
     else:
         self.widget.effectsView.sortByColumn(self.sortProxyModel.sortColumn, QtCore.Qt.AscendingOrder)
     self.dataManager = datamanager
     self.dataManager.registerRootObjectListener(self._onPipRootObjectEvent)
Пример #4
0
 def init(self, app, datamanager):
     super().init(app, datamanager)
     self.app = app
     self.radioViewModel = RadioTableModel(self.app.settings)
     self.sortProxyModel = SortProxyModel(self.app.settings)
     self.sortProxyModel.setSourceModel(self.radioViewModel)
     self.widget.radioView.setModel(self.sortProxyModel)
     self.widget.radioView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
     self.widget.radioView.customContextMenuRequested.connect(
         self._slotTableContextMenu)
     self.widget.radioView.doubleClicked.connect(
         self._slotTableDoubleClicked)
     self.tableHeader = self.widget.radioView.horizontalHeader()
     self.tableHeader.setSectionsMovable(True)
     self.tableHeader.setStretchLastSection(True)
     settings.setHeaderSectionSizes(
         self.tableHeader,
         self.app.settings.value('radiowidget/HeaderSectionSizes', []))
     settings.setHeaderSectionVisualIndices(
         self.tableHeader,
         self.app.settings.value('radiowidget/headerSectionVisualIndices',
                                 []))
     if self.sortProxyModel.sortReversed:
         self.widget.radioView.sortByColumn(self.sortProxyModel.sortColumn,
                                            QtCore.Qt.DescendingOrder)
     else:
         self.widget.radioView.sortByColumn(self.sortProxyModel.sortColumn,
                                            QtCore.Qt.AscendingOrder)
     self.tableHeader.sectionResized.connect(self._slotTableSectionResized)
     self.tableHeader.sectionMoved.connect(self._slotTableSectionMoved)
     self.dataManager = datamanager
     self.dataManager.registerRootObjectListener(self._onPipRootObjectEvent)
Пример #5
0
 def _addTab(self, title, modelClass, proxyClass):
     skeySizes = 'inventorybrowser/' + title + '/headerSectionSizes'
     skeyMoved = 'inventorybrowser/' + title + '/headerSectionVisualIndices'
     tab = uic.loadUi(self.invTabUiPath)
     self.widget.tabWidget.addTab(tab, title)
     model = modelClass(tab)
     proxyModel = proxyClass(self.app.settings, 'inventorybrowser/' + title)
     proxyModel.setSourceModel(model)
     tab.tableView.setModel(proxyModel)
     tableHeader = tab.tableView.horizontalHeader()
     tableHeader.setSectionsMovable(True)
     settings.setHeaderSectionSizes(tableHeader, self.app.settings.value(skeySizes, []))
     settings.setHeaderSectionVisualIndices(tableHeader, self.app.settings.value(skeyMoved, []))
     if proxyModel.sortReversed:
         tab.tableView.sortByColumn(proxyModel.sortColumn, QtCore.Qt.DescendingOrder)
     else:
         tab.tableView.sortByColumn(proxyModel.sortColumn, QtCore.Qt.AscendingOrder)
     @QtCore.pyqtSlot(int, int, int)
     def _slotSectionResized(logicalIndex, oldSize, newSize):
         self.app.settings.setValue(skeySizes, settings.getHeaderSectionSizes(tableHeader))
     tableHeader.sectionResized.connect(_slotSectionResized)
     @QtCore.pyqtSlot(int, int, int)
     def _slotSectionMoved(logicalIndex, oldVisualIndex, newVisualIndex):
         self.app.settings.setValue(skeyMoved, settings.getHeaderSectionVisualIndices(tableHeader))
     tableHeader.sectionMoved.connect(_slotSectionMoved)
     @QtCore.pyqtSlot(QtCore.QModelIndex, QtCore.QModelIndex)
     def _slotItemSelected(index, previous):
         rindex = proxyModel.mapToSource(index)
         item = model.getPipValue(rindex.row())
         if item:
             self.showItemProperties(item)
     tab.tableView.selectionModel().currentChanged.connect(_slotItemSelected)
     @QtCore.pyqtSlot(QtCore.QPoint)
     def _slotItemContextMenu(pos):
         currentIndex = tab.tableView.selectionModel().currentIndex()
         if currentIndex.isValid():
             current = model.getPipValue(proxyModel.mapToSource(currentIndex).row())
         else:
             current = None
         selected = []
         for rowIndex in tab.tableView.selectionModel().selectedRows():
             item = model.getPipValue(proxyModel.mapToSource(rowIndex).row())
             if item:
                 selected.append(item)
         if current:
             model.showItemContextMenu(self.dataManager, current, selected, pos, tab.tableView)
     tab.tableView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
     tab.tableView.customContextMenuRequested.connect(_slotItemContextMenu)
     @QtCore.pyqtSlot(QtCore.QModelIndex)
     def _slotItemDoubleClicked(index):
         index = tab.tableView.selectionModel().currentIndex()
         if index.isValid():
             value = model.getPipValue(proxyModel.mapToSource(index).row())
             if value:
                 model.itemDoubleClicked(self.dataManager, value, tab.tableView)
     tab.tableView.doubleClicked.connect(_slotItemDoubleClicked)
     return tab
Пример #6
0
 def init(self, app, datamanager):
     super().init(app, datamanager)
     self.dataManager = datamanager
     self.app = app
     self.treeModel = DataBrowserTreeModel(self.widget.treeView, self.dataManager)
     self.widget.treeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
     self.widget.treeView.customContextMenuRequested.connect(self._slotShowTreeCustomContextMenu)
     self.treeHeader = self.widget.treeView.header()
     self.treeHeader.setSectionsMovable(True)
     self.treeHeader.setStretchLastSection(True)
     settings.setHeaderSectionSizes(self.treeHeader, self.app.settings.value('databrowserwidget/HeaderSectionSizes', []))
     settings.setHeaderSectionVisualIndices(self.treeHeader, self.app.settings.value('databrowserwidget/headerSectionVisualIndices', []))
     self.treeHeader.sectionResized.connect(self._slotTreeSectionResized)
     self.treeHeader.sectionMoved.connect(self._slotTreeSectionMoved)
Пример #7
0
 def init(self, app, datamanager):
     super().init(app, datamanager)
     self.app = app
     self.effectsViewModel = EffectsTableModel(self.app.settings)
     self.sortProxyModel = SortProxyModel(self.app.settings)
     self.sortProxyModel.setSourceModel(self.effectsViewModel)
     self.widget.effectsView.setModel(self.sortProxyModel)
     self.tableHeader = self.widget.effectsView.horizontalHeader()
     self.tableHeader.setSectionsMovable(True)
     self.tableHeader.setStretchLastSection(True)
     settings.setHeaderSectionSizes(
         self.tableHeader,
         self.app.settings.value('effectswidget/HeaderSectionSizes', []))
     settings.setHeaderSectionVisualIndices(
         self.tableHeader,
         self.app.settings.value('effectswidget/headerSectionVisualIndices',
                                 []))
     self.tableHeader.sectionResized.connect(self._slotTableSectionResized)
     self.tableHeader.sectionMoved.connect(self._slotTableSectionMoved)
     settings.setSplitterState(
         self.widget.splitter,
         self.app.settings.value('effectswidget/splitterState', None))
     self.widget.splitter.splitterMoved.connect(self._slotSplitterMoved)
     self.widget.showPermanentCheckBox.setChecked(
         bool(int(self.app.settings.value('effectswidget/showPermanent',
                                          0))))
     self.widget.showEmptySourcesCheckBox.setChecked(
         bool(
             int(
                 self.app.settings.value('effectswidget/showEmptySources',
                                         0))))
     self.widget.showInactiveCheckBox.setChecked(
         bool(int(self.app.settings.value('effectswidget/showInactive',
                                          0))))
     self.widget.showPermanentCheckBox.stateChanged.connect(
         self.effectsViewModel.setShowPermanent)
     self.widget.showEmptySourcesCheckBox.stateChanged.connect(
         self.effectsViewModel.setShowEmptySources)
     self.widget.showInactiveCheckBox.stateChanged.connect(
         self.effectsViewModel.setShowInactive)
     if self.sortProxyModel.sortReversed:
         self.widget.effectsView.sortByColumn(
             self.sortProxyModel.sortColumn, QtCore.Qt.DescendingOrder)
     else:
         self.widget.effectsView.sortByColumn(
             self.sortProxyModel.sortColumn, QtCore.Qt.AscendingOrder)
     self.dataManager = datamanager
     self.dataManager.registerRootObjectListener(self._onPipRootObjectEvent)
Пример #8
0
 def init(self, app, dataManager):
     super().init(app, dataManager)
     self.app = app
     self.DataManager = dataManager
     self.selectedWorkshop = None
     self.workshopModel = WorkshopTableModel(self.Widgets.workshopList)
     self.sortModel = SortProxyModel(app.settings, 'workshopsbrowser')
     self.sortModel.setSourceModel(self.workshopModel)
     self.Widgets.workshopList.setModel(
         self.sortModel
     )  # we need to call setModel() before selectionModel() (and never afterwards)
     self.Widgets.workshopList.selectionModel().currentChanged.connect(
         self.WorkshopListCurrentChanged)
     self.Widgets.workshopList.setContextMenuPolicy(
         QtCore.Qt.CustomContextMenu)
     self.Widgets.workshopList.customContextMenuRequested.connect(
         self.workshopListMenuRequested)
     # Init Splitter
     settings.setSplitterState(
         self.Widgets.splitter,
         self.app.settings.value('workshopsbrowser/splitterState', None))
     self.Widgets.splitter.splitterMoved.connect(self._slotSplitterMoved)
     # Init table header
     self.tableHeader = self.Widgets.workshopList.horizontalHeader()
     self.tableHeader.setSectionsMovable(True)
     self.tableHeader.setStretchLastSection(True)
     settings.setHeaderSectionSizes(
         self.tableHeader,
         self.app.settings.value('workshopsbrowser/HeaderSectionSizes', []))
     settings.setHeaderSectionVisualIndices(
         self.tableHeader,
         self.app.settings.value(
             'workshopsbrowser/HeaderSectionVisualIndices', []))
     if self.sortModel.sortReversed:
         self.Widgets.workshopList.sortByColumn(self.sortModel.sortColumn,
                                                QtCore.Qt.DescendingOrder)
     else:
         self.Widgets.workshopList.sortByColumn(self.sortModel.sortColumn,
                                                QtCore.Qt.AscendingOrder)
     self.tableHeader.sectionResized.connect(self._slotTableSectionResized)
     self.tableHeader.sectionMoved.connect(self._slotTableSectionMoved)
     self.DataManager.registerRootObjectListener(self.DataManagerUpdated)
Пример #9
0
 def init(self, app, datamanager):
     super().init(app, datamanager)
     self.app = app
     for cat in [('All', CatAllModel, SortProxyModel),
                 ('Weapons', CatWeaponsModel, WeaponSortProxyModel),
                 ('Apparel', CatApparelModel, ApparelSortProxyModel),
                 ('Aid', CatAidModel, SortProxyModel),
                 ('Misc', CatMiscModel, SortProxyModel),
                 ('Junk', CatJunkModel, SortProxyModel),
                 ('Mods', CatModsModel, SortProxyModel),
                 ('Ammo', CatAmmoModel, SortProxyModel),
                 ('Books', CatBooksModel, SortProxyModel),
                 ('Holotapes', CatHolotapeModel, SortProxyModel),
                 ('Keys', CatKeysModel, SortProxyModel),
                 ('Components', ComponentsTableModel, SortProxyModel)]:
         tab = self._addTab(cat[0], cat[1], cat[2])
         self.tabs.append(tab)
         self.models.append(tab.tableView.model().sourceModel())
     self.widget.tabWidget.currentChanged.connect(self._slotCatTabChanged)
     activeTab = int(
         self.app.settings.value('inventorybrowser/activeTab', 0))
     self.widget.tabWidget.setCurrentIndex(activeTab)
     settings.setSplitterState(
         self.widget.splitter1,
         self.app.settings.value('inventorybrowser/splitter1State', None))
     self.widget.splitter1.splitterMoved.connect(self._slotSplitter1Moved)
     settings.setSplitterState(
         self.widget.splitter2,
         self.app.settings.value('inventorybrowser/splitter2State', None))
     self.widget.splitter2.splitterMoved.connect(self._slotSplitter2Moved)
     self.propertyTreeHeader = self.widget.propertyTree.header()
     settings.setHeaderSectionSizes(
         self.propertyTreeHeader,
         self.app.settings.value(
             'inventorybrowser/PropertyHeaderSectionSizes', []))
     self.propertyTreeHeader.sectionResized.connect(
         self._slotPropertyTreeSectionResized)
     self.widget.filterEdit.textChanged.connect(self._slotFilterTextChanged)
     self.dataManager = datamanager
     self.dataManager.registerRootObjectListener(self._onPipRootObjectEvent)
Пример #10
0
 def init(self, app, datamanager):
     super().init(app, datamanager)
     self.app = app
     self.globalMap = app.iwcGetEndpoint('globalmapwidget')
     self.pipMapObject = None
     self.pipMapWorldObject = None
     self.pipWorldLocations = None
     self.locationViewModel = LocationTableModel(self.app.settings)
     self.sortProxyModel = SortProxyModel(self.app.settings)
     self.sortProxyModel.setSourceModel(self.locationViewModel)
     self.widget.locationView.setModel(self.sortProxyModel)
     self.widget.locationView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
     self.widget.locationView.customContextMenuRequested.connect(self._slotLocationTableContextMenu)
     self.widget.locationView.selectionModel().currentChanged.connect(self._slotLocationItemSelected)
     self.widget.locationView.doubleClicked.connect(self._slotLocationItemDoubleClicked)
     self.locationTableHeader = self.widget.locationView.horizontalHeader()
     self.locationTableHeader.setSectionsMovable(True)
     self.locationTableHeader.setStretchLastSection(True)
     self.propertyTableHeader = self.widget.propertyTable.horizontalHeader()
     settings.setHeaderSectionSizes(self.locationTableHeader, self.app.settings.value('locationbrowserwidget/LocationHeaderSectionSizes', []))
     settings.setHeaderSectionVisualIndices(self.locationTableHeader, self.app.settings.value('locationbrowserwidget/LocationHeaderSectionVisualIndices', []))
     if self.sortProxyModel.sortReversed:
         self.widget.locationView.sortByColumn(self.sortProxyModel.sortColumn, QtCore.Qt.DescendingOrder)
     else:
         self.widget.locationView.sortByColumn(self.sortProxyModel.sortColumn, QtCore.Qt.AscendingOrder)
     self.locationTableHeader.sectionResized.connect(self._slotLocationTableSectionResized)
     self.locationTableHeader.sectionMoved.connect(self._slotLocationTableSectionMoved)
     self.propertyTableHeader = self.widget.propertyTable.horizontalHeader()
     settings.setHeaderSectionSizes(self.propertyTableHeader, self.app.settings.value('locationbrowserwidget/PropertyHeaderSectionSizes', []))
     self.propertyTableHeader.sectionResized.connect(self._slotPropertyTableSectionResized)
     settings.setSplitterState(self.widget.splitter1, self.app.settings.value('locationbrowserwidget/splitter1State', None))
     self.widget.splitter1.splitterMoved.connect(self._slotSplitter1Moved)
     settings.setSplitterState(self.widget.splitter2, self.app.settings.value('locationbrowserwidget/splitter2State', None))
     self.widget.splitter2.splitterMoved.connect(self._slotSplitter2Moved)
     self.widget.showUnknownCheckBox.setChecked(self.sortProxyModel.showUnknown)
     self.widget.showUnknownCheckBox.stateChanged.connect(self.sortProxyModel.showUnknownLocations)
     self.widget.filterNameLineEdit.textEdited.connect(self.sortProxyModel.setNameFilterString)
     self.dataManager = datamanager
     self.dataManager.registerRootObjectListener(self._onPipRootObjectEvent)
Пример #11
0
 def init(self, app, datamanager):
     super().init(app, datamanager)
     self.dataManager = datamanager
     self.app = app
     self.treeModel = DataBrowserTreeModel(self.widget.treeView,
                                           self.dataManager)
     self.widget.treeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
     self.widget.treeView.customContextMenuRequested.connect(
         self._slotShowTreeCustomContextMenu)
     self.treeHeader = self.widget.treeView.header()
     self.treeHeader.setSectionsMovable(True)
     self.treeHeader.setStretchLastSection(True)
     settings.setHeaderSectionSizes(
         self.treeHeader,
         self.app.settings.value('databrowserwidget/HeaderSectionSizes',
                                 []))
     settings.setHeaderSectionVisualIndices(
         self.treeHeader,
         self.app.settings.value(
             'databrowserwidget/headerSectionVisualIndices', []))
     self.treeHeader.sectionResized.connect(self._slotTreeSectionResized)
     self.treeHeader.sectionMoved.connect(self._slotTreeSectionMoved)
Пример #12
0
 def init(self, app, datamanager):
     super().init(app, datamanager)
     self.app = app
     self.radioViewModel = RadioTableModel(self.app.settings)
     self.sortProxyModel = SortProxyModel(self.app.settings)
     self.sortProxyModel.setSourceModel(self.radioViewModel)
     self.widget.radioView.setModel(self.sortProxyModel)
     self.widget.radioView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
     self.widget.radioView.customContextMenuRequested.connect(self._slotTableContextMenu)
     self.widget.radioView.doubleClicked.connect(self._slotTableDoubleClicked)
     self.tableHeader = self.widget.radioView.horizontalHeader()
     self.tableHeader.setSectionsMovable(True)
     self.tableHeader.setStretchLastSection(True)
     settings.setHeaderSectionSizes(self.tableHeader, self.app.settings.value('radiowidget/HeaderSectionSizes', []))
     settings.setHeaderSectionVisualIndices(self.tableHeader, self.app.settings.value('radiowidget/headerSectionVisualIndices', []))
     if self.sortProxyModel.sortReversed:
         self.widget.radioView.sortByColumn(self.sortProxyModel.sortColumn, QtCore.Qt.DescendingOrder)
     else:
         self.widget.radioView.sortByColumn(self.sortProxyModel.sortColumn, QtCore.Qt.AscendingOrder)
     self.tableHeader.sectionResized.connect(self._slotTableSectionResized)
     self.tableHeader.sectionMoved.connect(self._slotTableSectionMoved)
     self.dataManager = datamanager
     self.dataManager.registerRootObjectListener(self._onPipRootObjectEvent)
Пример #13
0
    def _addTab(self, title, modelClass, proxyClass):
        skeySizes = 'inventorybrowser/' + title + '/headerSectionSizes'
        skeyMoved = 'inventorybrowser/' + title + '/headerSectionVisualIndices'
        tab = uic.loadUi(self.invTabUiPath)
        self.widget.tabWidget.addTab(tab, title)
        model = modelClass(tab)
        proxyModel = proxyClass(self.app.settings, 'inventorybrowser/' + title)
        proxyModel.setSourceModel(model)
        tab.tableView.setModel(proxyModel)
        tableHeader = tab.tableView.horizontalHeader()
        tableHeader.setSectionsMovable(True)
        settings.setHeaderSectionSizes(tableHeader,
                                       self.app.settings.value(skeySizes, []))
        settings.setHeaderSectionVisualIndices(
            tableHeader, self.app.settings.value(skeyMoved, []))
        if proxyModel.sortReversed:
            tab.tableView.sortByColumn(proxyModel.sortColumn,
                                       QtCore.Qt.DescendingOrder)
        else:
            tab.tableView.sortByColumn(proxyModel.sortColumn,
                                       QtCore.Qt.AscendingOrder)

        @QtCore.pyqtSlot(int, int, int)
        def _slotSectionResized(logicalIndex, oldSize, newSize):
            self.app.settings.setValue(
                skeySizes, settings.getHeaderSectionSizes(tableHeader))

        tableHeader.sectionResized.connect(_slotSectionResized)

        @QtCore.pyqtSlot(int, int, int)
        def _slotSectionMoved(logicalIndex, oldVisualIndex, newVisualIndex):
            self.app.settings.setValue(
                skeyMoved, settings.getHeaderSectionVisualIndices(tableHeader))

        tableHeader.sectionMoved.connect(_slotSectionMoved)

        @QtCore.pyqtSlot(QtCore.QModelIndex, QtCore.QModelIndex)
        def _slotItemSelected(index, previous):
            rindex = proxyModel.mapToSource(index)
            item = model.getPipValue(rindex.row())
            if item:
                self.showItemProperties(item)

        tab.tableView.selectionModel().currentChanged.connect(
            _slotItemSelected)

        @QtCore.pyqtSlot(QtCore.QPoint)
        def _slotItemContextMenu(pos):
            currentIndex = tab.tableView.selectionModel().currentIndex()
            if currentIndex.isValid():
                current = model.getPipValue(
                    proxyModel.mapToSource(currentIndex).row())
            else:
                current = None
            selected = []
            for rowIndex in tab.tableView.selectionModel().selectedRows():
                item = model.getPipValue(
                    proxyModel.mapToSource(rowIndex).row())
                if item:
                    selected.append(item)
            if current:
                model.showItemContextMenu(self.dataManager, current, selected,
                                          pos, tab.tableView)

        tab.tableView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        tab.tableView.customContextMenuRequested.connect(_slotItemContextMenu)

        @QtCore.pyqtSlot(QtCore.QModelIndex)
        def _slotItemDoubleClicked(index):
            index = tab.tableView.selectionModel().currentIndex()
            if index.isValid():
                value = model.getPipValue(proxyModel.mapToSource(index).row())
                if value:
                    model.itemDoubleClicked(self.dataManager, value,
                                            tab.tableView)

        tab.tableView.doubleClicked.connect(_slotItemDoubleClicked)
        return tab
Пример #14
0
 def init(self, app, datamanager):
     super().init(app, datamanager)
     self.app = app
     self.globalMap = app.iwcGetEndpoint('globalmapwidget')
     self.pipMapObject = None
     self.pipMapWorldObject = None
     self.pipWorldLocations = None
     self.locationViewModel = LocationTableModel(self.app.settings)
     self.sortProxyModel = SortProxyModel(self.app.settings)
     self.sortProxyModel.setSourceModel(self.locationViewModel)
     self.widget.locationView.setModel(self.sortProxyModel)
     self.widget.locationView.setContextMenuPolicy(
         QtCore.Qt.CustomContextMenu)
     self.widget.locationView.customContextMenuRequested.connect(
         self._slotLocationTableContextMenu)
     self.widget.locationView.selectionModel().currentChanged.connect(
         self._slotLocationItemSelected)
     self.widget.locationView.doubleClicked.connect(
         self._slotLocationItemDoubleClicked)
     self.locationTableHeader = self.widget.locationView.horizontalHeader()
     self.locationTableHeader.setSectionsMovable(True)
     self.locationTableHeader.setStretchLastSection(True)
     self.propertyTableHeader = self.widget.propertyTable.horizontalHeader()
     settings.setHeaderSectionSizes(
         self.locationTableHeader,
         self.app.settings.value(
             'locationbrowserwidget/LocationHeaderSectionSizes', []))
     settings.setHeaderSectionVisualIndices(
         self.locationTableHeader,
         self.app.settings.value(
             'locationbrowserwidget/LocationHeaderSectionVisualIndices',
             []))
     if self.sortProxyModel.sortReversed:
         self.widget.locationView.sortByColumn(
             self.sortProxyModel.sortColumn, QtCore.Qt.DescendingOrder)
     else:
         self.widget.locationView.sortByColumn(
             self.sortProxyModel.sortColumn, QtCore.Qt.AscendingOrder)
     self.locationTableHeader.sectionResized.connect(
         self._slotLocationTableSectionResized)
     self.locationTableHeader.sectionMoved.connect(
         self._slotLocationTableSectionMoved)
     self.propertyTableHeader = self.widget.propertyTable.horizontalHeader()
     settings.setHeaderSectionSizes(
         self.propertyTableHeader,
         self.app.settings.value(
             'locationbrowserwidget/PropertyHeaderSectionSizes', []))
     self.propertyTableHeader.sectionResized.connect(
         self._slotPropertyTableSectionResized)
     settings.setSplitterState(
         self.widget.splitter1,
         self.app.settings.value('locationbrowserwidget/splitter1State',
                                 None))
     self.widget.splitter1.splitterMoved.connect(self._slotSplitter1Moved)
     settings.setSplitterState(
         self.widget.splitter2,
         self.app.settings.value('locationbrowserwidget/splitter2State',
                                 None))
     self.widget.splitter2.splitterMoved.connect(self._slotSplitter2Moved)
     self.widget.showUnknownCheckBox.setChecked(
         self.sortProxyModel.showUnknown)
     self.widget.showUnknownCheckBox.stateChanged.connect(
         self.sortProxyModel.showUnknownLocations)
     self.widget.filterNameLineEdit.textEdited.connect(
         self.sortProxyModel.setNameFilterString)
     self.dataManager = datamanager
     self.dataManager.registerRootObjectListener(self._onPipRootObjectEvent)