Logviewer log search
This commit is contained in:
parent
4883197a6f
commit
a05cbb858c
2 changed files with 25 additions and 2 deletions
|
@ -27,6 +27,7 @@ CHANGELOG
|
|||
* Display (De)OP/Voice messages in memos - Kiooeht [evacipatedBox]
|
||||
* Advanced Mode: Alter IRC user mode - Kiooeht [evacipatedBox]
|
||||
* Logviewer chum search - Kiooeht [evacipatedBox]
|
||||
* Logviewer log search - Kiooeht [evacipatedBox]
|
||||
* Bug fixes
|
||||
* Logviewer updates - Kiooeht [evacipatedBox]
|
||||
* Memo scrollbar thing - Kiooeht [evacipatedBox]
|
||||
|
|
26
logviewer.py
26
logviewer.py
|
@ -15,6 +15,18 @@ class PesterLogSearchInput(QtGui.QLineEdit):
|
|||
QtGui.QLineEdit.keyPressEvent(self, event)
|
||||
self.parent().logSearch(self.text())
|
||||
|
||||
class PesterLogHighlighter(QtGui.QSyntaxHighlighter):
|
||||
def __init__(self, parent):
|
||||
QtGui.QSyntaxHighlighter.__init__(self, parent)
|
||||
self.searchTerm = ""
|
||||
self.hilightstyle = QtGui.QTextCharFormat()
|
||||
self.hilightstyle.setBackground(QtGui.QBrush(QtCore.Qt.green))
|
||||
self.hilightstyle.setForeground(QtGui.QBrush(QtCore.Qt.black))
|
||||
def highlightBlock(self, text):
|
||||
for i in range(0, len(text)-(len(self.searchTerm)-1)):
|
||||
if str(text[i:i+len(self.searchTerm)]).lower() == str(self.searchTerm).lower():
|
||||
self.setFormat(i, len(self.searchTerm), self.hilightstyle)
|
||||
|
||||
class PesterLogUserSelect(QtGui.QDialog):
|
||||
def __init__(self, config, theme, parent):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
|
@ -79,7 +91,6 @@ class PesterLogUserSelect(QtGui.QDialog):
|
|||
|
||||
def logSearch(self, search):
|
||||
found = self.chumsBox.findItems(search, QtCore.Qt.MatchStartsWith)
|
||||
print found
|
||||
if len(found) > 0 and len(found) < self.chumsBox.count():
|
||||
self.chumsBox.setCurrentItem(found[0])
|
||||
|
||||
|
@ -180,8 +191,12 @@ class PesterLogViewer(QtGui.QDialog):
|
|||
child_1.addChild(QtGui.QTreeWidgetItem([self.fileToTime(l)]))
|
||||
last = self.fileToMonthYear(l)
|
||||
|
||||
self.hilight = PesterLogHighlighter(self.textArea)
|
||||
if len(self.logList) > 0: self.loadLog(self.logList[0])
|
||||
|
||||
self.search = PesterLogSearchInput(theme, self)
|
||||
self.search.setFocus()
|
||||
|
||||
self.qdb = QtGui.QPushButton("Pesterchum QDB", self)
|
||||
self.connect(self.qdb, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('openQDB()'))
|
||||
|
@ -197,7 +212,10 @@ class PesterLogViewer(QtGui.QDialog):
|
|||
|
||||
layout_logs = QtGui.QHBoxLayout()
|
||||
layout_logs.addWidget(self.tree)
|
||||
layout_logs.addWidget(self.textArea)
|
||||
layout_right = QtGui.QVBoxLayout()
|
||||
layout_right.addWidget(self.textArea)
|
||||
layout_right.addWidget(self.search)
|
||||
layout_logs.addLayout(layout_right)
|
||||
|
||||
layout_0 = QtGui.QVBoxLayout()
|
||||
layout_0.addWidget(self.instructions)
|
||||
|
@ -227,6 +245,10 @@ class PesterLogViewer(QtGui.QDialog):
|
|||
self.textArea.setTextCursor(textCur)
|
||||
self.instructions.setText("Pesterlog with " +self.chum+ " on " + self.fileToTime(str(fname)))
|
||||
|
||||
def logSearch(self, search):
|
||||
self.hilight.searchTerm = search
|
||||
self.hilight.rehighlight()
|
||||
|
||||
def fileToMonthYear(self, fname):
|
||||
time = strptime(fname[(fname.index(".")+1):fname.index(".txt")], "%Y-%m-%d.%H.%M")
|
||||
return [strftime("%B", time), strftime("%Y", time)]
|
||||
|
|
Loading…
Reference in a new issue