PDA

View Full Version : example of QPlainTextEdit subclass to handle large text files



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.

DrQuade
17th October 2012, 14:02
Hi i tried to compile your Code but im missing customtextedit.h could you provide the whole project pls ?
Because this sounds exactly of what i need.

nekkro-kvlt
17th October 2012, 14:30
I have merged this into another project, so attaching the other project. It's messy and far from being finished though...
8314