def search(self): s, ok = QInputDialog.getText(None, "Search all files", "Search (Case Insensitive)") if not ok or not s: return s = str(s).lower() hits = [] version = config.project["versioninfo"] for i, f in enumerate(self.narc.gmif.files): if pokeversion.gens[version[0]] == 4: texts = txt.gen4get(f) else: texts = txt.gen5get(f) for entry in texts: if s in entry[1].lower(): hits.append((i, entry[0], entry[1])) if not hits: QMessageBox.information(None, "Search results", "None found") return dlg = QMainWindow(config.mw) dlg.setWindowTitle("Search Results") dlg.resize(600, 400) wdgt = QWidget(dlg) scroller = QScrollArea(wdgt) scroller.setGeometry(QRect(0, 0, 600, 400)) container = QWidget(scroller) y = 10 for result in hits: label = QLabel(container) label.setText("[%s] %s: %s"%result) label.setGeometry(QRect(0, y, 580, 20)) y += 20 container.setGeometry(QRect(0, 0, 600, y)) scroller.setWidget(container) dlg.setCentralWidget(wdgt) dlg.show()
def getTextEntry(self, entry): version = config.project["versioninfo"] entrynum = pokeversion.textentries[version[0]][pokeversion.langs[ version[1]]][entry] if pokeversion.gens[version[0]] == 4: text = txt.gen4get(self.textnarc.gmif.files[entrynum]) elif pokeversion.gens[version[0]] == 5: text = txt.gen5get(self.textnarc.gmif.files[entrynum]) else: raise ValueError ret = [] for t in text: ret.append(t[1]) return ret
def openText(self, i): if not self.checkClean(False): return self.currentfile = i self.textedit.setEnabled(True) version = config.project["versioninfo"] if pokeversion.gens[version[0]] == 4: text = txt.gen4get(self.narc.gmif.files[self.currentfile]) elif pokeversion.gens[version[0]] == 5: text = txt.gen5get(self.narc.gmif.files[self.currentfile]) buff = "" for entry in text: buff += entry[0]+": "+entry[1]+"\n\n" self.textedit.setText(buff.strip("\n")) self.dirty = False self.updateCurrentFileLabel()
def openText(self, i): if not self.checkClean(False): return self.currentfile = i self.textedit.setEnabled(True) version = config.project["versioninfo"] if pokeversion.gens[version[0]] == 4: text = txt.gen4get(self.narc.gmif.files[self.currentfile]) elif pokeversion.gens[version[0]] == 5: text = txt.gen5get(self.narc.gmif.files[self.currentfile]) buff = "" for entry in text: buff += entry[0] + ": " + entry[1] + "\n\n" self.textedit.setText(buff.strip("\n")) self.dirty = False self.updateCurrentFileLabel()
def search(self): s, ok = QInputDialog.getText(None, "Search all files", "Search (Case Insensitive)") if not ok or not s: return s = str(s).lower() hits = [] version = config.project["versioninfo"] for i, f in enumerate(self.narc.gmif.files): if pokeversion.gens[version[0]] == 4: texts = txt.gen4get(f) else: texts = txt.gen5get(f) for entry in texts: if s in entry[1].lower(): hits.append((i, entry[0], entry[1])) if not hits: QMessageBox.information(None, "Search results", "None found") return dlg = QMainWindow(config.mw) dlg.setWindowTitle("Search Results") dlg.resize(600, 400) wdgt = QWidget(dlg) scroller = QScrollArea(wdgt) scroller.setGeometry(QRect(0, 0, 600, 400)) container = QWidget(scroller) y = 10 for result in hits: label = QLabel(container) label.setText("[%s] %s: %s" % result) label.setGeometry(QRect(0, y, 580, 20)) y += 20 container.setGeometry(QRect(0, 0, 600, y)) scroller.setWidget(container) dlg.setCentralWidget(wdgt) dlg.show()