~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/digikam/albumlister.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.2.15 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080717202539-6n7dtirbkoo7qvhd
Tags: 2:0.9.4-1
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * Description : Albums lister.
8
8
 *
9
9
 * Copyright (C) 2004-2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
10
 
 * Copyright (C) 2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 * Copyright (C) 2007-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
11
 * Copyright (C) 2007 by Arnd Baecker <arnd dot baecker at web dot de>
12
12
 *
13
13
 * This program is free software; you can redistribute it
96
96
    QString                         textFilter;
97
97
 
98
98
    QMap<Q_LLONG, ImageInfo*>       itemMap;
99
 
    QMap<int,int>                   invalidatedItems;
100
 
    QMap<int,bool>                  dayFilter;
 
99
    QMap<int, int>                  invalidatedItems;
 
100
    QMap<QDateTime, bool>           dayFilter;
101
101
 
102
102
    QValueList<int>                 tagFilter;
103
103
 
221
221
            this, SLOT(slotData(KIO::Job*, const QByteArray&)));
222
222
}
223
223
 
224
 
void AlbumLister::setDayFilter(const QValueList<int>& days)
 
224
void AlbumLister::setDayFilter(const QValueList<QDateTime>& days)
225
225
{
226
226
    d->dayFilter.clear();
227
227
 
228
 
    for (QValueList<int>::const_iterator it = days.begin(); it != days.end(); ++it)
 
228
    for (QValueList<QDateTime>::const_iterator it = days.begin(); it != days.end(); ++it)
229
229
        d->dayFilter.insert(*it, true);
230
230
 
231
231
    d->filterTimer->start(100, true);
232
232
}
233
233
 
 
234
bool AlbumLister::tagFiltersIsActive()
 
235
{
 
236
    if (!d->tagFilter.isEmpty() || d->untaggedFilter)
 
237
        return true;
 
238
 
 
239
    return false;
 
240
}
 
241
 
234
242
void AlbumLister::setTagFilter(const QValueList<int>& tags, const MatchingCondition& matchingCond,
235
243
                               bool showUnTagged)
236
244
{
322
330
 
323
331
    if (!d->dayFilter.isEmpty())
324
332
    {
325
 
        match &= d->dayFilter.contains(info->dateTime().date().day());
 
333
        match &= d->dayFilter.contains(QDateTime(info->dateTime().date(), QTime()));
326
334
    }
327
335
 
328
336
    //-- Filter by rating ---------------------------------------------------------
423
431
        if (settings->getIconShowName())
424
432
        {
425
433
            if (info->name().lower().contains(d->textFilter.lower()))
 
434
            {
426
435
                foundText = true;
 
436
            }
427
437
        }
428
438
        if (settings->getIconShowComments())
429
439
        {
439
449
                    foundText = true;
440
450
            }
441
451
        }
 
452
        // check for folder names
 
453
        if (info->album()->title().lower().contains(d->textFilter.lower()))
 
454
        {
 
455
            foundText = true;
 
456
        }
442
457
        match &= foundText;
443
458
    }
444
459
 
471
486
    d->invalidatedItems.insert(item->id(), item->id());
472
487
}
473
488
 
474
 
void AlbumLister::slotClear()
475
 
{
476
 
    emit signalClear();
477
 
}
478
 
 
479
489
void AlbumLister::slotFilterItems()
480
490
{
481
491
    if (d->job)
486
496
 
487
497
    QPtrList<ImageInfo> newFilteredItemsList;
488
498
    QPtrList<ImageInfo> deleteFilteredItemsList;
489
 
    ImageInfo *item      = 0;
490
 
    bool atleastOneMatch = false;
 
499
    ImageInfo *item   = 0;
 
500
    bool matchForText = false;
 
501
    bool match        = false;
491
502
 
492
503
    for (ImageInfoListIterator it(d->itemList);
493
504
         (item = it.current()); ++it)
495
506
        bool foundText = false;
496
507
        if (matchesFilter(item, foundText))
497
508
        {
 
509
            match = true;
498
510
            if (!item->getViewItem())
499
511
                newFilteredItemsList.append(item);
500
512
        }
505
517
        }
506
518
 
507
519
        if (foundText)
508
 
            atleastOneMatch = true;
 
520
            matchForText = true;
509
521
    }
510
522
 
511
523
    // This takes linear time - and deleting seems to take longer. Set wait cursor for large numbers.
513
525
    if (setCursor)
514
526
        kapp->setOverrideCursor(KCursor::waitCursor());
515
527
 
516
 
    emit signalItemsTextFilterMatch(atleastOneMatch);
 
528
    emit signalItemsTextFilterMatch(matchForText);
 
529
    emit signalItemsFilterMatch(match);
517
530
 
518
531
    if (!deleteFilteredItemsList.isEmpty())
519
532
    {
562
575
    if (data.isEmpty())
563
576
        return;
564
577
 
565
 
    bool    foundText = false;
566
578
    Q_LLONG imageID;
567
579
    int     albumID;
568
580
    QString name;
577
589
 
578
590
    while (!ds.atEnd())
579
591
    {
 
592
        bool foundText = false;
 
593
 
580
594
        ds >> imageID;
581
595
        ds >> albumID;
582
596
        ds >> name;
621
635
 
622
636
    if (!newItemsList.isEmpty())
623
637
        emit signalNewItems(newItemsList);
 
638
    
 
639
    slotFilterItems();
624
640
}
625
641
 
626
642
}  // namespace Digikam