You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

themolecule

Beginner

  • "themolecule" is male
  • "themolecule" started this thread

Posts: 36

Location: New York

Occupation: Special Effects

  • Send private message

1

Friday, October 29th 2004, 6:37am

Trying to modify the contents of a file dialog window...

I'm trying to modify the display of the file dialog window.

I am trying to deal with image sequences (for a video application) and I have directories full of files like:

../ (parent directory)
basename.0001.tif
basename.0002.tif
...
basename.????.tif
..
basename.nnnn.tif
othername.0001.jpg
othername.0002.jpg
...
othername.nnnn.jpg

These directories contain thousands of files.

I want to first filter for image type (*.tif, *.jpg, *.png, etc.) and then when the matching file entries are shown, instead of being hundreds of image file names I want to emulate the Shake "sequence listing" format that would be:

../ (parent directory)
basename.#.tif
othername.#.jpg

or better:

../(parent directory)
basename.1-nnnn#.tif
othername.1-mmm.*.jpg

where nnnn and mmmm are padded frame numbers.

Obviously a regular expression is required, which seems rather simple, but how do you modify the contents of the file dialogue to not acually show the files in a particular directory, and instead show the shorthand of those files?

it seems like it would be an overloading of the display method for that particular object, but what method? It appears to be very similar to the QFilePreview tactic, but I cannot seem to find the function I am looking for.

any help?

thanks,
Chris Healer

hatulflezet

Professional

Posts: 1,301

Location: Munich Germany

Occupation: Programmer

  • Send private message

2

Friday, October 29th 2004, 9:21am

Quoted

it seems like it would be an overloading of the display method for that particular object, but what method? It appears to be very similar to the QFilePreview tactic, but I cannot seem to find the function I am looking for.


Well, you might be right about that, but I think its the filtering method/principle you should overload/change/enhance.
On the other hand, if you change your sequence naming convention to nnnnn_basname.jpg(or similar so that the numbers are at the begining of the name), you could use the filtering as it is, since by defalut the names are sorted a-z and 0-9999...
Wont this (renaming) be easier?
Click here! I dare ya'!! :]
Project Archimedes
----------------------------------------------------------
"Don't panic, and thanks for all the fish!"

themolecule

Beginner

  • "themolecule" is male
  • "themolecule" started this thread

Posts: 36

Location: New York

Occupation: Special Effects

  • Send private message

3

Saturday, October 30th 2004, 3:20pm

Quoted

Originally posted by hatulflezet

Well, you might be right about that, but I think its the filtering method/principle you should overload/change/enhance.
On the other hand, if you change your sequence naming convention to nnnnn_basname.jpg(or similar so that the numbers are at the begining of the name), you could use the filtering as it is, since by defalut the names are sorted a-z and 0-9999...
Wont this (renaming) be easier?


renaming the files like that would destroy the alphabetical sort if there was more than one sequence in a directory!

0001.basename.jpg
0001.othername.tif
0002.basename.jpg
0002.othername.tif

and a filter for image type is obviously necessary, but displaying as "basename.#.tif" is not really a 'filter' on the files, but a display of mutiple files as one file.

it must be an overload...

themolecule

Beginner

  • "themolecule" is male
  • "themolecule" started this thread

Posts: 36

Location: New York

Occupation: Special Effects

  • Send private message

4

Saturday, October 30th 2004, 4:40pm

after more examination, I find this:


friend class QFileDialogQFileListView;
friend class QFileListBox;

QFileDialogPrivate *d;
QFileDialogQFileListView *files;


in the "private" class definition for qfiledialog.h

I guess since QFileDialogQFileListView is not an accessible object (for overloading) and the object itself (*files) is private then I must build my own file dialog from scratch?

Unless someone has a better idea...

themolecule

Beginner

  • "themolecule" is male
  • "themolecule" started this thread

Posts: 36

Location: New York

Occupation: Special Effects

  • Send private message

5

Thursday, November 4th 2004, 6:47pm

For those interested, I've finally got the solution working...

subclass QLocalFs (operationListChildren):

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef SEQUENCE_LISTING_H
#define SEQUENCE_LISTING_H

#include <qlocalfs.h>

class sequenceListing : public QLocalFs
{
    Q_OBJECT

public:
    sequenceListing();
    virtual ~sequenceListing();

protected:
    virtual void operationListChildren( QNetworkOperation *op );
    
private:
    QDir dir;
};

#endif


and then the class itself...

Source code

1
2
3
4
5
6
7
8
9
10
11
sequenceListing :: sequenceListing() : QLocalFs()
{    //nothing...    }

sequenceListing :: ~sequenceListing()
{    //once again... nothing...   }

void sequenceListing::operationListChildren( QNetworkOperation *op )
{
     //insert or modify from qlocalfs.h...
     //be sure to emit() signals like qlocalfs does....
}


and then activate it in main()

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <qapplication.h>
#include <qnetwork.h>

#include "mainform.h"
#include "include/sequenceListing.h"

int main( int argc, char ** argv )
{
    QApplication a( argc, argv );
    
    qInitNetworkProtocols();			//filesequence viewer protocol init
//    QNetworkProtocol::registerNetworkProtocol( "filesequence", new QNetworkProtocolFactory<sequenceListing> );
    QNetworkProtocol::registerNetworkProtocol( "file", new QNetworkProtocolFactory<sequenceListing> );
    
    mainForm w;
    w.show();
    a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    return a.exec();
}


in this case I overrode the default "file://" protocol but if you want to you could uncomment above and use "filesequence://" to keep them separate. In the final implementation I also subclassed QFileDialog so that I could add a button on the top right that would allow a toggle (while "file://" is overidden) so that the user won't see the ugly protocol in the path box.