PDA

View Full Version : Server/client file manager, QFileSystemModel serialization



Anslem
22nd April 2014, 13:47
Hi guys, as you might have guessed i'm new to QT.

I need to write a Server/client file manager, basically a file explorer as it is in Windows but for client/server.

From my limited knowledge in QT i decided to use QFileSystemModel class on the server.
With this in mind, i'll have to 1)send files hierarchy to a client 2)if client wants to exapand some directory all i have to do is to send QModelIndex to the server and it will reply with a new hierarchy.

Question is, how do i send QFileSystemModel to the client? Serialization, maybe? As i understand it i can't directly serialize a QFileSystemModel object. But i can get a list of it's child objects and serialize it. Can i deserialize it on the client side and create new QFileSystemModel object using this list?

Or maybe you could suggest a better way to write this class, or use other classes?

Thank you in advance.

anda_skoa
22nd April 2014, 15:53
I don't think QFileSystemModel is going to help you there, direct usage of QDir and QFileInfo might be better.

The best approach is to first determine what kind of data you need for each directory entry and then come up with a protocol to transport that data.
Since you are writing both sides you could use a simple protocol based on QDataStream.

Once you can transmit data you can always build a model on the client side to use instead of a QFileSystemModel

Cheers,
_