prepare filtering
This commit is contained in:
11
bigtext.py
11
bigtext.py
@@ -21,7 +21,7 @@ from settings import Settings
|
||||
|
||||
|
||||
class BigText(QWidget):
|
||||
def __init__(self, model: LogFileModel, settings: Settings):
|
||||
def __init__(self, model: LogFileModel):
|
||||
super(BigText, self).__init__()
|
||||
|
||||
self.model = model
|
||||
@@ -31,7 +31,7 @@ class BigText(QWidget):
|
||||
self.grid.setVerticalSpacing(0)
|
||||
self.setLayout(self.grid)
|
||||
|
||||
big_text = InnerBigText(self, model, settings)
|
||||
big_text = InnerBigText(self, model)
|
||||
big_text.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding))
|
||||
|
||||
self.h_scroll_bar = QScrollBar(Qt.Orientation.Horizontal)
|
||||
@@ -59,10 +59,9 @@ class InnerBigText(QWidget):
|
||||
|
||||
highlights: [Highlight] = []
|
||||
|
||||
def __init__(self, parent: BigText, model: LogFileModel, settings: Settings):
|
||||
def __init__(self, parent: BigText, model: LogFileModel):
|
||||
super(InnerBigText, self).__init__()
|
||||
self.model = model
|
||||
self.settings = settings
|
||||
self.parent = parent
|
||||
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
self.setFocusPolicy(Qt.FocusPolicy.WheelFocus)
|
||||
@@ -80,7 +79,7 @@ class InnerBigText(QWidget):
|
||||
|
||||
def keyPressEvent(self, e: QKeyEvent) -> None:
|
||||
|
||||
print("%s + %s" % (e.keyCombination().keyboardModifiers(), e.key()))
|
||||
#print("%s + %s" % (e.keyCombination().keyboardModifiers(), e.key()))
|
||||
if e.modifiers() == Qt.KeyboardModifier.NoModifier:
|
||||
lines_to_scroll = math.floor(self.lines_shown()) - 1
|
||||
if e.key() == Qt.Key.Key_PageUp:
|
||||
@@ -185,7 +184,7 @@ class InnerBigText(QWidget):
|
||||
|
||||
def paintEvent(self, event: QPaintEvent) -> None:
|
||||
painter = QPainter(self)
|
||||
painter.setFont(self.settings.font())
|
||||
painter.setFont(self.model.settings.font())
|
||||
painter.setPen(QColor(0, 0, 0))
|
||||
self.update_font_metrics(painter)
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
|
||||
...............................|
|
||||
|
|
||||
ääääääääääääää|ääääääääääääääää|
|
||||
ääääääääääääää♥ääääääääääääääää|
|
||||
2019-08-07 00:00:10,391 [catalina-exec-40] INFO c.r.c.u.l.PerformancePointcut - Executed HealthCheckController.checkOperativeness in 1 ms successful. [jv3fw7r2.m1u5]
|
||||
2019-08-07 00:00:16,377 [catalina-exec-56] INFO c.r.c.u.l.PerformancePointcut - Executed HealthCheckController.checkOperativeness in 1 ms successful. [jv3fw7r2.m1u6]
|
||||
2019-08-07 00:00:40,403 [catalina-exec-26] INFO c.r.c.u.l.PerformancePointcut - Executed HealthCheckController.checkOperativeness in 1 ms successful. [jv3fw7r2.m1ud]
|
||||
2019-08-07 00:00:40,403 [catalina-exec-26] ERROR c.r.c.u.l.PerformancePointcut - Executed HealthCheckController.checkOperativeness in 1 ms successful. [jv3fw7r2.m1ud]
|
||||
2019-08-07 00:02:10,598 [catalina-exec-16] INFO c.r.c.u.l.PerformancePointcut - Executed SecurityController.loginIndex in 0 ms successful. [jv3fw7r2.m1uf]
|
||||
2019-08-07 00:02:16,467 [catalina-exec-36] INFO c.r.c.u.l.PerformancePointcut - Executed HealthCheckController.checkOperativeness in 1 ms successful. [jv3fw7r2.m1ug]
|
||||
2019-08-07 00:02:23,519 [catalina-exec-53] INFO c.r.c.u.l.PerformancePointcut - Executed AuthenticationProvider.authenticate in 224 ms successful. [jv3fw7r2.m1uh]
|
||||
2019-08-07 00:02:23,519 [catalina-exec-53] ERROR c.r.c.u.l.PerformancePointcut - Executed AuthenticationProvider.authenticate in 224 ms successful. [jv3fw7r2.m1uh]
|
||||
2019-08-07 00:02:24,195 [catalina-exec-43] INFO c.r.c.u.l.PerformancePointcut - Executed SecurityController.accessDenied in 0 ms successful. [jv3fw7r2.m1uj]
|
||||
2019-08-07 00:02:24,937 [catalina-exec-74] INFO c.r.c.u.l.PerformancePointcut - Executed RedirectController.redirect in 1159 ms successful. [jv3fw7r2.m1ui]
|
||||
2019-08-07 00:02:25,674 [catalina-exec-29] INFO c.r.c.u.l.PerformancePointcut - Executed AssignmentsController.index in 683 ms successful. [jv3fw7r2.m1uk]
|
||||
|
||||
37
filterwidget.py
Normal file
37
filterwidget.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLineEdit, QCheckBox
|
||||
|
||||
from bigtext import BigText
|
||||
from logFileModel import LogFileModel
|
||||
|
||||
|
||||
class FilterWidget(QWidget):
|
||||
def __init__(self, model: LogFileModel):
|
||||
super(FilterWidget, self).__init__()
|
||||
self.model = model
|
||||
|
||||
self.layout = QVBoxLayout(self)
|
||||
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
query_field = QLineEdit()
|
||||
query_field.textChanged.connect(self.query_changed)
|
||||
|
||||
ignore_case = QCheckBox(self.tr("ignore case"))
|
||||
ignore_case.setChecked(True)
|
||||
|
||||
is_regex = QCheckBox(self.tr("regex"))
|
||||
is_regex.setChecked(True)
|
||||
|
||||
filter_bar = QWidget()
|
||||
filter_bar.layout = QHBoxLayout(filter_bar)
|
||||
filter_bar.layout.setContentsMargins(0,0,0,0)
|
||||
filter_bar.layout.addWidget(query_field)
|
||||
filter_bar.layout.addWidget(ignore_case)
|
||||
filter_bar.layout.addWidget(is_regex)
|
||||
|
||||
self.hits_view = BigText(model)
|
||||
|
||||
self.layout.addWidget(filter_bar)
|
||||
self.layout.addWidget(self.hits_view)
|
||||
|
||||
def query_changed(self, query: str):
|
||||
print(query)
|
||||
30
fulltabwidget.py
Normal file
30
fulltabwidget.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from PyQt6.QtWidgets import *
|
||||
from PyQt6.QtCore import *
|
||||
|
||||
from bigtext import BigText
|
||||
from filterwidget import FilterWidget
|
||||
from logFileModel import LogFileModel
|
||||
|
||||
|
||||
class FullTabWidget(QWidget):
|
||||
|
||||
def __init__(self, model: LogFileModel):
|
||||
super(FullTabWidget, self).__init__()
|
||||
self._model = model
|
||||
self._file_view = BigText(model)
|
||||
self._filter_hit_view = FilterWidget(self._model)
|
||||
|
||||
self.layout = QVBoxLayout(self)
|
||||
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
splitter = QSplitter()
|
||||
splitter.setOrientation(Qt.Orientation.Vertical)
|
||||
splitter.setHandleWidth(5)
|
||||
#splitter.setStyleSheet("QSplitter::handle{background: #cccccc;}")
|
||||
splitter.addWidget(self._file_view)
|
||||
splitter.addWidget(self._filter_hit_view)
|
||||
|
||||
self.layout.addWidget(splitter)
|
||||
|
||||
def file_view(self):
|
||||
return self._file_view
|
||||
@@ -29,6 +29,7 @@ class HighlightSelection(Highlight):
|
||||
start_byte_in_line = begin - line.byte_offset()
|
||||
else:
|
||||
start_byte_in_line = 0
|
||||
|
||||
start_char = line.byte_index_to_char_index(start_byte_in_line)
|
||||
|
||||
if line.includes_byte(end):
|
||||
|
||||
@@ -9,7 +9,8 @@ from settings import Settings
|
||||
class LogFileModel:
|
||||
_lock = threading.RLock()
|
||||
|
||||
def __init__(self, file):
|
||||
def __init__(self, file:str, settings: Settings):
|
||||
self.settings = settings
|
||||
self._file = os.path.realpath(file)
|
||||
|
||||
def get_file(self):
|
||||
@@ -43,7 +44,7 @@ class LogFileModel:
|
||||
# TODO handle lines longer than 4096 bytes
|
||||
with open(self._file, 'rb') as f:
|
||||
offset = min(byte_offset, self.byte_count())
|
||||
offset = max(0, offset - Settings.max_line_length())
|
||||
offset = max(0, offset - self.settings.max_line_length())
|
||||
|
||||
#print("offset: %s" % (offset))
|
||||
|
||||
|
||||
1
main.py
1
main.py
@@ -26,6 +26,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.tabs = Tabs(self.settings)
|
||||
self.tabs.create_tab("/home/andi/ws/performanceDb/data/production/logs_2018-09-06_2018-09-06.csv")
|
||||
#self.tabs.create_tab("/home/andi/ws/performanceDb/data/production/vapbdcom.csv")
|
||||
self.tabs.create_tab("/home/andi/ws/ravenlog/example.log")
|
||||
|
||||
|
||||
|
||||
19
tabs.py
19
tabs.py
@@ -6,6 +6,7 @@ from PyQt6.QtCore import *
|
||||
from PyQt6.QtGui import *
|
||||
|
||||
from bigtext import BigText
|
||||
from fulltabwidget import FullTabWidget
|
||||
from logFileModel import LogFileModel
|
||||
from settings import Settings
|
||||
|
||||
@@ -36,23 +37,23 @@ class Tabs(QWidget):
|
||||
message.exec()
|
||||
return
|
||||
|
||||
model = LogFileModel(file)
|
||||
big_text = BigText(model, self.settings)
|
||||
model = LogFileModel(file, self.settings)
|
||||
full_tab = FullTabWidget(model)
|
||||
|
||||
if big_text.get_file() in self.tabs_by_filename:
|
||||
if model.get_file() in self.tabs_by_filename:
|
||||
for tab_index in range(0, self.tabs.count()):
|
||||
widget : BigText = self.tabs.widget(tab_index)
|
||||
if widget.get_file() == big_text.get_file():
|
||||
widget : FullTabWidget = self.tabs.widget(tab_index)
|
||||
if widget.get_file() == model.get_file():
|
||||
self.tabs.setCurrentIndex(tab_index)
|
||||
break
|
||||
else:
|
||||
tab_index = self.tabs.addTab(big_text, model.get_tab_name())
|
||||
self.tabs_by_filename[big_text.get_file()] = big_text
|
||||
tab_index = self.tabs.addTab(full_tab, model.get_tab_name())
|
||||
self.tabs_by_filename[model.get_file()] = full_tab
|
||||
self.tabs.setCurrentIndex(tab_index)
|
||||
|
||||
def _close_tab(self, tab_index: int):
|
||||
big_text: BigText = self.tabs.widget(tab_index)
|
||||
del self.tabs_by_filename[big_text.get_file()]
|
||||
full_tab: FullTabWidget = self.tabs.widget(tab_index)
|
||||
del self.tabs_by_filename[full_tab.file_view.get_file()]
|
||||
self.tabs.removeTab(tab_index)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user