class DictionarySelectorPanel(QWidget): def __init__(self, config, parent = None): super(DictionarySelectorPanel, self).__init__(parent) self.tablePanel = KTablePanel(config, False, False, self) self.tablePanel.setMaximumWidth(self.tablePanel.sizeHint().width()) # util.setGreenBackground(self.tablePanel) label = QLabel(u'김치') # util.setBackgroundColor(label, QColor.fromRgb(0, 255, 0)) """CONNECTIONS""" self.connect(self.tablePanel, SIGNAL('tableSelected'), self.dictionarySelected) """LAYOUT""" layout = QVBoxLayout() layout.addWidget(self.tablePanel) layout.addStretch() label.setAlignment(Qt.AlignHCenter) # layout.addWidget(label) layout.addStretch() self.setLayout(layout) def dictionarySelected(self, ktable): self.emit(SIGNAL('dictionarySelected'), ktable)
def __init__(self, config, parent = None): super(ConfigDialog, self).__init__(parent) self.setWindowTitle('Manage dictionaries') self.config = copy.deepcopy(config) self.ktablePanel = KTablePanel(self.config) self.kcolumnPanel = KColumnPanel() """ Button box """ buttonBox = QDialogButtonBox(QDialogButtonBox.Apply | QDialogButtonBox.Cancel) """CONNECTIONS""" self.connect(self.ktablePanel, SIGNAL('tableSelected'), self.kcolumnPanel.resetModel) self.connect(buttonBox.button(QDialogButtonBox.Apply), SIGNAL("clicked()"), self, SLOT("accept()")) self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()")) """LAYOUT""" splitter = QSplitter(Qt.Horizontal) self.ktablePanel.setMaximumWidth(self.ktablePanel.minimumSizeHint().width()) splitter.addWidget(self.ktablePanel) splitter.addWidget(self.kcolumnPanel) layout = QVBoxLayout() layout.addWidget(splitter) layout.addWidget(buttonBox) self.setLayout(layout) self.ktablePanel.selectTableAtIndex(0)
class ConfigDialog(QDialog): """Receives application configuration object and returns a new configuration """ def __init__(self, config, parent = None): super(ConfigDialog, self).__init__(parent) self.setWindowTitle('Manage dictionaries') self.config = copy.deepcopy(config) self.ktablePanel = KTablePanel(self.config) self.kcolumnPanel = KColumnPanel() """ Button box """ buttonBox = QDialogButtonBox(QDialogButtonBox.Apply | QDialogButtonBox.Cancel) """CONNECTIONS""" self.connect(self.ktablePanel, SIGNAL('tableSelected'), self.kcolumnPanel.resetModel) self.connect(buttonBox.button(QDialogButtonBox.Apply), SIGNAL("clicked()"), self, SLOT("accept()")) self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()")) """LAYOUT""" splitter = QSplitter(Qt.Horizontal) self.ktablePanel.setMaximumWidth(self.ktablePanel.minimumSizeHint().width()) splitter.addWidget(self.ktablePanel) splitter.addWidget(self.kcolumnPanel) layout = QVBoxLayout() layout.addWidget(splitter) layout.addWidget(buttonBox) self.setLayout(layout) self.ktablePanel.selectTableAtIndex(0) def accept(self): # ktables = self.ktablePanel.ktables # # configDataAccessService = self.configEngine.dataAccessService # # for ktable in ktables: # configDataAccessService.updateKTable(ktable) QDialog.accept(self) def addTable(self): # print "addTable" row = self.ktableModel.rowCount() self.ktableModel.insertRows(row) index = self.ktableModel.index(row, 0) self.ktableView.setFocus() self.ktableView.setCurrentIndex(index) self.ktableView.edit(index) def removeTable(self): # print "removeTable" index = self.ktableView.currentIndex() if not index.isValid(): return row = index.row() self.ktableModel.removeRows(row)