PDA

View Full Version : Help w/ Graphical File Selection Screen



dsnuckel
12th April 2010, 01:21
I am working on a project that will use VLC to play files that a user selects from a external hard drive.

I need to create a graphical file selection screen which will display the Alphabet. A user will use left or right arrows to navigate the letters. Whatever letter the user stops in will become enlarged to show selection and the files that stat with that letter will load up and the user can select which one to play.

For example,


t u v w x y z A b c d e f g h
aaa.avi
aab.avi
acc.avi


Can any help me out and tell me where and how to start with this?
Thanks a lot, I appreciate it!

JohannesMunk
12th April 2010, 14:16
You could use a QLabel with HTML links for your letter selector. In its LinkActivated you handle the update of the file list.

some (pseudo)code to get you started:



void MyWidget::MyWidget(..)
{
// Initialization..
connect(label,SIGNAL(linkActivated(QString),this,S LOT(OnLinkActivated(QString));
OnLinkActivated('A');
}

void MyWidget::UpdateLabel(QChar capitalLetter)
{
QString labeltext = "";
through all letters c, where files exist..
{
QChar d = c;
if (d == capitalLetter) d = d.toUpper();
labeltext += "<a href="+c+" style=\"text-decoration:none;\">"+d+"</a>";
}
label.setText(labeltext);
}

void MyWidget::OnLinkActivated(QString letter)
{
UpdateLabel(letter);
// update your file list accordingly..
}


Hope it get's you started..

Good luck,

Johannes

dsnuckel
12th April 2010, 18:11
Thanks a lot with the help.

dsnuckel
28th April 2010, 02:40
Does anybody else have any input on this? I am not very good at programming so I'm having a lot of trouble with this. Any help will be appreciated.
Thanks

Talei
28th April 2010, 07:34
I would go with MVC to do that what You want. Maybe two models, one for a-z and another one for file names. Although using one model for file names is probably not what You want, because lets say user select next z instead of b (i.e. [z]Abc) assuming that a is selected at first by default, so displaying z column content, depending on haw many files is there, would take some time, hence "lag".(You can connect signal to column selection, so that would trigger i.e. populating model). Probably better approach would be QList<QStandardItemModel>. Each model for each character, run in separate thread, to prevent GUI freeze. Custom TableView for characters and ListView for file names, or QGraphicsScene with custom display objects for characters. And what's nice with models, is that there is already i.e. QFileSystemModel that will gave You all file list, Views supports automatic sorting so You don't really need to write that code Yourself. Also some views, i.e. QListView supports layoutMode that allow You view item practically instantly, i.e. you have 2k files in directory, but display displays only 100, so normally You would need to wait for load to complete, with batched mode you can view i.e. first 100 that are already loaded.
You can customize view, maybe with style sheet's (I assume You want some fancy GUI because it's front end for browsing files) or QGraphicsBlurEffect.
That way You can display same data in multiple ways, i.e. here is my project that i work on, what You see is only one model:

4553 4554 4555 4556

And with style sheet's or Effect you could make it look really nice.
As before this is only how I would do that, maybe there is some better way that I don't know about.
Best luck

JohannesMunk
28th April 2010, 11:49
Hi!


Does anybody else have any input on this? I am not very good at programming so I'm having a lot of trouble with this. Any help will be appreciated.
Thanks

Could you be, a bit more specific as to where your problem is? It won't help you on the long run, if we write the program for you.

Do you have a problem with the widget setup? Problem finding files? Handling key events?

What have you got working so far?

Johannes