本文整理汇总了Python中PyQt4.QtGui.QStringListModel.index方法的典型用法代码示例。如果您正苦于以下问题:Python QStringListModel.index方法的具体用法?Python QStringListModel.index怎么用?Python QStringListModel.index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QStringListModel
的用法示例。
在下文中一共展示了QStringListModel.index方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PosiviewProperties
# 需要导入模块: from PyQt4.QtGui import QStringListModel [as 别名]
# 或者: from PyQt4.QtGui.QStringListModel import index [as 别名]
class PosiviewProperties(QgsOptionsDialogBase, Ui_PosiviewPropertiesBase):
'''
GUI class classdocs for the Configuration dialog
'''
applyChanges = pyqtSignal(dict)
def __init__(self, project, parent=None):
'''
Setup dialog widgets with the project properties
'''
super(PosiviewProperties, self).__init__("PosiViewProperties", parent)
self.setupUi(self)
self.groupBox_6.hide()
self.initOptionsBase(False)
self.restoreOptionsBaseUi()
self.comboBoxParser.addItems(PARSERS)
self.comboBoxProviderType.addItems(DEVICE_TYPES)
self.project = project
self.projectProperties = project.properties()
self.mToolButtonLoad.setDefaultAction(self.actionLoadConfiguration)
self.mToolButtonSave.setDefaultAction(self.actionSaveConfiguration)
self.mobileModel = QStringListModel()
self.mobileListModel = QStringListModel()
self.mMobileListView.setModel(self.mobileListModel)
self.mobileProviderModel = QStandardItemModel()
self.mobileProviderModel.setHorizontalHeaderLabels(('Provider', 'Filter'))
self.mMobileProviderTableView.setModel(self.mobileProviderModel)
self.providerListModel = QStringListModel()
self.mDataProviderListView.setModel(self.providerListModel)
self.comboBoxProviders.setModel(self.providerListModel)
self.setupModelData(self.projectProperties)
self.setupGeneralData(self.projectProperties)
def setupModelData(self, properties):
self.mobileListModel.setStringList(sorted(properties['Mobiles'].keys()))
self.providerListModel.setStringList(sorted(properties['Provider'].keys()))
def setupGeneralData(self, properties):
self.lineEditCruise.setText(properties['Mission']['cruise'])
self.lineEditDive.setText(properties['Mission']['dive'])
self.lineEditStation.setText(properties['Mission']['station'])
self.lineEditRecorderPath.setText(properties['RecorderPath'])
self.checkBoxAutoRecording.setChecked(properties['AutoRecord'])
self.spinBoxNotifyDuration.setValue(properties['NotifyDuration'])
self.checkBoxUtcClock.setChecked((properties['ShowUtcClock']))
def updateGeneralData(self):
self.projectProperties['Mission']['cruise'] = self.lineEditCruise.text()
self.projectProperties['Mission']['dive'] = self.lineEditDive.text()
self.projectProperties['Mission']['station'] = self.lineEditStation.text()
self.projectProperties['RecorderPath'] = self.lineEditRecorderPath.text()
self.projectProperties['AutoRecord'] = self.checkBoxAutoRecording.isChecked()
self.projectProperties['NotifyDuration'] = self.spinBoxNotifyDuration.value()
self.projectProperties['ShowUtcClock'] = self.checkBoxUtcClock.isChecked()
def getColor(self, value):
try:
return QColor.fromRgba(int(value))
except ValueError:
return QColor(value)
@pyqtSlot(QAbstractButton, name='on_buttonBox_clicked')
def onButtonBoxClicked(self, button):
role = self.buttonBox.buttonRole(button)
if role == QDialogButtonBox.ApplyRole or role == QDialogButtonBox.AcceptRole:
self.updateGeneralData()
self.applyChanges.emit(self.projectProperties)
@pyqtSlot(name='on_actionSaveConfiguration_triggered')
def onActionSaveConfigurationTriggered(self):
''' Save the current configuration
'''
fn = QFileDialog.getSaveFileName(None, 'Save PosiView configuration', '', 'Configuration (*.ini *.conf)')
self.project.store(fn)
@pyqtSlot(name='on_actionLoadConfiguration_triggered')
def onActionLoadConfigurationTriggered(self):
''' Load configuration from file
'''
fn = QFileDialog.getOpenFileName(None, 'Save PosiView configuration', '', 'Configuration (*.ini *.conf)')
self.projectProperties = self.project.read(fn)
self.setupModelData(self.projectProperties)
self.setupGeneralData(self.projectProperties)
@pyqtSlot(QModelIndex, name='on_mMobileListView_clicked')
def editMobile(self, index):
''' Populate the widgets with the selected mobiles properties
'''
if index.isValid():
self.populateMobileWidgets(index)
@pyqtSlot(str, name='on_comboBoxMobileType_currentIndexChanged')
def mobileTypeChanged(self, mType):
if mType == 'SHAPE':
# self.lineEditMobileShape.setText(str(mobile['shape']))
self.lineEditMobileShape.setEnabled(True)
else:
self.lineEditMobileShape.setEnabled(False)
#.........这里部分代码省略.........