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

« back to all changes in this revision

Viewing changes to digikam/digikam/searchfolderview.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 : Searches folder view 
8
8
 * 
9
9
 * Copyright (C) 2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
10
 
 * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
11
 *
12
12
 * This program is free software; you can redistribute it
13
13
 * and/or modify it under the terms of the GNU General
60
60
 
61
61
class SearchFolderItem : public FolderItem
62
62
{
63
 
    
 
63
 
64
64
public:
65
65
 
66
66
    SearchFolderItem(QListView* parent, SAlbum* album)
79
79
    {
80
80
        if (!i)
81
81
            return 0;
82
 
        
 
82
 
83
83
        if (text(0) == i18n("Last Search"))
84
84
            return -1;
85
85
 
86
86
        return text(0).localeAwareCompare(i->text(0));
87
87
    }
88
 
    
 
88
 
89
89
    int id() const
90
90
    {
91
91
        return m_album ? m_album->id() : 0;
92
92
    }
93
 
    
94
 
    SAlbum* m_album;
 
93
 
 
94
    SAlbum* album() const
 
95
    {
 
96
        return m_album;
 
97
    }
 
98
 
 
99
private:
 
100
 
 
101
    SAlbum *m_album;
95
102
};
96
103
 
97
104
SearchFolderView::SearchFolderView(QWidget* parent)
123
130
}
124
131
 
125
132
SearchFolderView::~SearchFolderView()
126
 
{    
 
133
{
127
134
}
128
135
 
129
 
void SearchFolderView::slotSearchFilterChanged(const QString& filter)
 
136
void SearchFolderView::slotTextSearchFilterChanged(const QString& filter)
130
137
{
131
138
    QString search = filter.lower();
132
139
 
138
145
        SAlbum* salbum             = (SAlbum*)(*it);
139
146
        SearchFolderItem* viewItem = (SearchFolderItem*) salbum->extraData(this);
140
147
 
141
 
        bool match = salbum->title().lower().contains(search);
142
 
        if (match)
 
148
        // Check if a special url query exist to identify a SAlbum dedicaced to Date Search
 
149
        // used with TimeLine.
 
150
        KURL url     = salbum->kurl();
 
151
        QString type = url.queryItem("type");
 
152
 
 
153
        if (salbum->title().lower().contains(search) &&
 
154
            type != QString("datesearch"))
143
155
        {
144
156
            atleastOneMatch = true;
145
157
 
155
167
        }
156
168
    }
157
169
 
158
 
    emit signalSearchFilterMatch(atleastOneMatch);
 
170
    emit signalTextSearchFilterMatch(atleastOneMatch);
159
171
}
160
172
 
161
173
void SearchFolderView::quickSearchNew()
232
244
                                                  albumTitle, ok, this );
233
245
#endif
234
246
        if (!ok)
235
 
            return( false );
 
247
            return false;
236
248
 
237
249
        albumTitle=newTitle;
238
250
        checked = checkAlbum( albumTitle );
240
252
 
241
253
    url.removeQueryItem( "name" );
242
254
    url.addQueryItem( "name", albumTitle );
243
 
    return( true );
 
255
    return true;
244
256
}
245
257
 
246
258
bool SearchFolderView::checkAlbum( const QString& name ) const
254
266
    {
255
267
        SAlbum *album = (SAlbum*)(*it);
256
268
        if ( album->title() == name )
257
 
        {
258
 
            return( false );
259
 
        }
 
269
            return false;
260
270
    }
261
 
    return( true );
 
271
    return true;
262
272
}
263
273
 
264
274
void SearchFolderView::quickSearchEdit(SAlbum* album)
326
336
 
327
337
    SAlbum* album = (SAlbum*)a;
328
338
 
 
339
    // Check if a special url query exist to identify a SAlbum dedicaced to Date Search
 
340
    // used with TimeLine. In this case, SAlbum is not displayed here, but in TimeLineFolderView.
 
341
    KURL url     = album->kurl();
 
342
    QString type = url.queryItem("type");
 
343
    if (type == QString("datesearch")) return;
 
344
 
329
345
    SearchFolderItem* item = new SearchFolderItem(this, album);
330
346
    item->setPixmap(0, SmallIcon("find", AlbumSettings::instance()->getDefaultTreeIconSize()));
331
347
    m_lastAddedItem = item;
340
356
 
341
357
    SearchFolderItem* item = (SearchFolderItem*) album->extraData(this);
342
358
    if (item)
343
 
    {
344
359
        delete item;
345
 
    }
346
360
}
347
361
 
348
362
void SearchFolderView::slotSelectionChanged()
351
365
        return;
352
366
 
353
367
    QListViewItem* selItem = 0;
354
 
    
 
368
 
355
369
    QListViewItemIterator it( this );
356
370
    while (it.current())
357
371
    {
370
384
    }
371
385
 
372
386
    SearchFolderItem* searchItem = dynamic_cast<SearchFolderItem*>(selItem);
373
 
    
374
 
    if (!searchItem || !searchItem->m_album)
375
 
    {
 
387
 
 
388
    if (!searchItem || !searchItem->album())
376
389
        AlbumManager::instance()->setCurrentAlbum(0);
377
 
    }
378
390
    else
379
 
    {
380
 
        AlbumManager::instance()->setCurrentAlbum(searchItem->m_album);
381
 
    }
 
391
        AlbumManager::instance()->setCurrentAlbum(searchItem->album());
382
392
}
383
393
 
384
394
void SearchFolderView::slotContextMenu(QListViewItem* item, const QPoint&, int)
414
424
        popmenu.insertTitle(SmallIcon("digikam"), i18n("My Searches"));
415
425
        popmenu.insertItem(SmallIcon("filefind"), i18n("Edit Search..."), 10);
416
426
 
417
 
        if ( sItem->m_album->isSimple() )
 
427
        if ( sItem->album()->isSimple() )
418
428
            popmenu.insertItem(SmallIcon("find"), i18n("Edit as Advanced Search..."), 11);
419
 
        
 
429
 
420
430
        popmenu.insertSeparator(-1);
421
431
        popmenu.insertItem(SmallIcon("editdelete"), i18n("Delete Search"), 12);
422
432
 
424
434
        {
425
435
            case 10:
426
436
            {
427
 
                if (sItem->m_album->isSimple())
428
 
                    quickSearchEdit(sItem->m_album);
 
437
                if (sItem->album()->isSimple())
 
438
                    quickSearchEdit(sItem->album());
429
439
                else
430
 
                    extendedSearchEdit(sItem->m_album);
 
440
                    extendedSearchEdit(sItem->album());
431
441
                break;
432
442
            }
433
443
            case 11:
434
444
            {
435
 
                extendedSearchEdit(sItem->m_album);
 
445
                extendedSearchEdit(sItem->album());
436
446
                break;
437
447
            }
438
448
            case 12:
439
449
            {
440
 
                searchDelete(sItem->m_album);
 
450
                searchDelete(sItem->album());
441
451
                break;
442
452
            }
443
453
            default:
450
460
{
451
461
    if (!item)
452
462
        return;
453
 
    
 
463
 
454
464
    SearchFolderItem* sItem = dynamic_cast<SearchFolderItem*>(item);
455
 
    
456
 
    if (sItem->m_album->isSimple())
457
 
        quickSearchEdit(sItem->m_album);
 
465
 
 
466
    if (sItem->album()->isSimple())
 
467
        quickSearchEdit(sItem->album());
458
468
    else
459
 
        extendedSearchEdit(sItem->m_album);
 
469
        extendedSearchEdit(sItem->album());
460
470
}
461
471
 
462
472
void SearchFolderView::selectItem(int id)
474
484
}
475
485
 
476
486
}  // namespace Digikam
477