Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, November 2006
Howto restrict QDir::entryInfoList to all dirs and files matching pattern?


Message 1 in thread

How can I get QDir to still list directories when I set a value for
nameFilters to match the extension of the file type I want to list?

cheers

-- 
 [ signature omitted ] 

Message 2 in thread

Patrick Stinson wrote:
> How can I get QDir to still list directories when I set a value for
> nameFilters to match the extension of the file type I want to list?
>
> cheers
>
The following works for me (rename FileSysModel to QDirModel):

  // setup the list view:
  QStringList filters;
  get_image_filters(filters, false);
 
  filesys_ = new FileSysModel();
  filesys_->setFilter(QDir::Drives |
              QDir::AllDirs |
              QDir::Files |
              QDir::Hidden |
              QDir::CaseSensitive |
              QDir::NoDotAndDotDot);
  filesys_->setNameFilters(filters);
  QDir::SortFlags sort = QDir::SortFlags(QDir::Name |
                     QDir::LocaleAware |
                     QDir::IgnoreCase |
                     QDir::DirsFirst);

    Paul.

--
 [ signature omitted ] 

Message 3 in thread

do you do anything with the SortFlags that  you created, or was that
merely for readability?

On 11/6/06, Paul Koshevoy <paul@xxxxxxxxxx> wrote:
> Patrick Stinson wrote:
> > How can I get QDir to still list directories when I set a value for
> > nameFilters to match the extension of the file type I want to list?
> >
> > cheers
> >
> The following works for me (rename FileSysModel to QDirModel):
>
>   // setup the list view:
>   QStringList filters;
>   get_image_filters(filters, false);
>
>   filesys_ = new FileSysModel();
>   filesys_->setFilter(QDir::Drives |
>               QDir::AllDirs |
>               QDir::Files |
>               QDir::Hidden |
>               QDir::CaseSensitive |
>               QDir::NoDotAndDotDot);
>   filesys_->setNameFilters(filters);
>   QDir::SortFlags sort = QDir::SortFlags(QDir::Name |
>                      QDir::LocaleAware |
>                      QDir::IgnoreCase |
>                      QDir::DirsFirst);
>
>     Paul.
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>


-- 
 [ signature omitted ] 

Message 4 in thread

Patrick Stinson wrote:
> do you do anything with the SortFlags that  you created, or was that
> merely for readability?
>
It's not important, I just cut and pasted a chunk of the relevant code.
The sorting is up to you.

If you care, the rest of the code look like this:

  QDir::SortFlags sort = QDir::SortFlags(QDir::Name |
                     QDir::LocaleAware |
                     QDir::IgnoreCase |
                     QDir::DirsFirst);
  filesys_->setSorting(sort);
  filesys_->setReadOnly(true);
  filesys_->setLazyChildCount(true);
 
  ThumbnailProvider * provider = new ThumbnailProvider();
  connect(&THUMBNAIL_THREAD,
      SIGNAL(transactionFinished(ImageProcessingTransaction *)),
      this, SLOT(thumbnailReady(ImageProcessingTransaction *)));
 
  filesys_->setIconProvider(provider);
  // iconList->setResizeMode(QListView::Adjust);
  iconList->setModel(filesys_);
  iconList->setDragEnabled(true);


> On 11/6/06, Paul Koshevoy <paul@xxxxxxxxxx> wrote:
>> Patrick Stinson wrote:
>> > How can I get QDir to still list directories when I set a value for
>> > nameFilters to match the extension of the file type I want to list?
>> >
>> > cheers
>> >
>> The following works for me (rename FileSysModel to QDirModel):
>>
>>   // setup the list view:
>>   QStringList filters;
>>   get_image_filters(filters, false);
>>
>>   filesys_ = new FileSysModel();
>>   filesys_->setFilter(QDir::Drives |
>>               QDir::AllDirs |
>>               QDir::Files |
>>               QDir::Hidden |
>>               QDir::CaseSensitive |
>>               QDir::NoDotAndDotDot);
>>   filesys_->setNameFilters(filters);
>>   QDir::SortFlags sort = QDir::SortFlags(QDir::Name |
>>                      QDir::LocaleAware |
>>                      QDir::IgnoreCase |
>>                      QDir::DirsFirst);
>>
>>     Paul.
>>
>> -- 
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
>> with "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>>
>>
>
>

--
 [ signature omitted ] 

Message 5 in thread

cool! thanks

On 11/6/06, Paul Koshevoy <paul@xxxxxxxxxx> wrote:
> Patrick Stinson wrote:
> > do you do anything with the SortFlags that  you created, or was that
> > merely for readability?
> >
> It's not important, I just cut and pasted a chunk of the relevant code.
> The sorting is up to you.
>
> If you care, the rest of the code look like this:
>
>   QDir::SortFlags sort = QDir::SortFlags(QDir::Name |
>                      QDir::LocaleAware |
>                      QDir::IgnoreCase |
>                      QDir::DirsFirst);
>   filesys_->setSorting(sort);
>   filesys_->setReadOnly(true);
>   filesys_->setLazyChildCount(true);
>
>   ThumbnailProvider * provider = new ThumbnailProvider();
>   connect(&THUMBNAIL_THREAD,
>       SIGNAL(transactionFinished(ImageProcessingTransaction *)),
>       this, SLOT(thumbnailReady(ImageProcessingTransaction *)));
>
>   filesys_->setIconProvider(provider);
>   // iconList->setResizeMode(QListView::Adjust);
>   iconList->setModel(filesys_);
>   iconList->setDragEnabled(true);
>
>
> > On 11/6/06, Paul Koshevoy <paul@xxxxxxxxxx> wrote:
> >> Patrick Stinson wrote:
> >> > How can I get QDir to still list directories when I set a value for
> >> > nameFilters to match the extension of the file type I want to list?
> >> >
> >> > cheers
> >> >
> >> The following works for me (rename FileSysModel to QDirModel):
> >>
> >>   // setup the list view:
> >>   QStringList filters;
> >>   get_image_filters(filters, false);
> >>
> >>   filesys_ = new FileSysModel();
> >>   filesys_->setFilter(QDir::Drives |
> >>               QDir::AllDirs |
> >>               QDir::Files |
> >>               QDir::Hidden |
> >>               QDir::CaseSensitive |
> >>               QDir::NoDotAndDotDot);
> >>   filesys_->setNameFilters(filters);
> >>   QDir::SortFlags sort = QDir::SortFlags(QDir::Name |
> >>                      QDir::LocaleAware |
> >>                      QDir::IgnoreCase |
> >>                      QDir::DirsFirst);
> >>
> >>     Paul.
> >>
> >> --
> >> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
> >> with "unsubscribe" in the subject or the body.
> >> List archive and information: http://lists.trolltech.com/qt-interest/
> >>
> >>
> >
> >
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>


-- 
 [ signature omitted ]