nekkro-kvlt
19th September 2012, 18:08
Hi all,
I'm working on a log parser, and I wanted to be able to open multiples text files of 50Mo or more.
I've made a text component based on QPlainTextEdit with threads to address this. It's probably ugly and undocummented, but it seems to work at least. I don't have that much time to spend on this, so I provide it as-is in case it is useful to anyone.
The principe is the following:
-When you load a file, a thread is started to index the file, meaning it will note the offest in the file every X lines (configurable in options.h) to allow fast seeking
-When you scroll (custom scrollbar), if you scroll to a position that is not in memory, another thread is used to get the text and update the text. If you continue scrolling before the thread is complete, the current reading task will abort and the thread will start to read the new position.
I have also added a side panel with the line numbers from an example i've seen around.
Feel free to ask me if you have any question, but I don't guarantee i'll answer.
I'm working on a log parser, and I wanted to be able to open multiples text files of 50Mo or more.
I've made a text component based on QPlainTextEdit with threads to address this. It's probably ugly and undocummented, but it seems to work at least. I don't have that much time to spend on this, so I provide it as-is in case it is useful to anyone.
The principe is the following:
-When you load a file, a thread is started to index the file, meaning it will note the offest in the file every X lines (configurable in options.h) to allow fast seeking
-When you scroll (custom scrollbar), if you scroll to a position that is not in memory, another thread is used to get the text and update the text. If you continue scrolling before the thread is complete, the current reading task will abort and the thread will start to read the new position.
I have also added a side panel with the line numbers from an example i've seen around.
Feel free to ask me if you have any question, but I don't guarantee i'll answer.