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

« back to all changes in this revision

Viewing changes to digikam/digikam/searchwidgets.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:
60
60
{
61
61
 
62
62
static const int RuleKeyTableCount = 11;
63
 
static const int RuleOpTableCount  = 16;
 
63
static const int RuleOpTableCount  = 18;
64
64
 
65
65
static struct
66
66
{
97
97
    { I18N_NOOP("Does Not Equal"),     "NE",           SearchAdvancedRule::LINEEDIT },
98
98
    { I18N_NOOP("Equals"),             "EQ",           SearchAdvancedRule::ALBUMS   },
99
99
    { I18N_NOOP("Does Not Equal"),     "NE",           SearchAdvancedRule::ALBUMS   },
 
100
    { I18N_NOOP("Contains"),           "LIKE",         SearchAdvancedRule::ALBUMS   },
 
101
    { I18N_NOOP("Does Not Contain"),   "NLIKE",        SearchAdvancedRule::ALBUMS   },
100
102
    { I18N_NOOP("Equals"),             "EQ",           SearchAdvancedRule::TAGS     },
101
103
    { I18N_NOOP("Does Not Equal"),     "NE",           SearchAdvancedRule::TAGS     },
102
104
    { I18N_NOOP("Contains"),           "LIKE",         SearchAdvancedRule::TAGS     },
153
155
        m_key->insertItem( i18n(RuleKeyTable[i].keyText), i );
154
156
 
155
157
    m_operator = new QComboBox( m_hbox );
156
 
    m_operator->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
 
158
    m_operator->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum );
 
159
    // prepopulate the operator widget to get optimal size
 
160
    for (int i=0; i< RuleOpTableCount; i++)
 
161
        m_operator->insertItem( i18n(RuleOpTable[i].keyText), i );
 
162
    m_operator->adjustSize();
157
163
 
158
164
    m_valueBox = new QHBox( m_hbox );
159
165
    m_widgetType = NOWIDGET;
262
268
    QString currentOperator = m_operator->currentText();
263
269
    valueWidgetTypes currentType = m_widgetType;
264
270
 
 
271
    // we need to save the current size of the operator combobox
 
272
    // otherise clear() will shrink it
 
273
    QSize curSize = m_operator->size();
265
274
    m_operator->clear();
266
275
    m_widgetType = RuleKeyTable[id].cat;
267
276
 
275
284
                m_operator->setCurrentText( currentOperator );
276
285
        }
277
286
    }
278
 
    m_operator->adjustSize();
 
287
    m_operator->setFixedSize(curSize);
279
288
    setValueWidget( currentType, m_widgetType );
280
289
}
281
290
 
282
291
void SearchAdvancedRule::setValueWidget(valueWidgetTypes oldType, valueWidgetTypes newType)
283
292
{
 
293
    // this map is used to sort album and tag list combobox
 
294
    typedef QMap<QString, int> SortedList;
 
295
    
284
296
    if (oldType == newType)
285
297
        return;
286
298
 
308
320
    else if (newType == LINEEDIT)
309
321
    {
310
322
        m_lineEdit = new QLineEdit( m_valueBox, "lineedit" );
311
 
        m_lineEdit->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
 
323
        m_lineEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
312
324
        m_lineEdit->show();
313
325
 
314
326
        connect( m_lineEdit, SIGNAL ( textChanged(const QString&) ),
324
336
        AlbumList aList = aManager->allPAlbums();
325
337
 
326
338
        m_itemsIndexIDMap.clear();
327
 
        int index = 0;
 
339
        
 
340
        // First we need to sort the album list.
 
341
        // We create a map with the album url as key, so that it is
 
342
        // automatically sorted.
 
343
        SortedList sAList;
 
344
        
328
345
        for ( AlbumList::Iterator it = aList.begin();
329
346
              it != aList.end(); ++it )
330
347
        {
331
348
            PAlbum *album = (PAlbum*)(*it);
332
349
            if ( !album->isRoot() )
333
350
            {
334
 
                m_valueCombo->insertSqueezedItem( album->url().remove(0,1), index );
335
 
                m_itemsIndexIDMap.insert(index, album->id());
336
 
                index++;
 
351
                sAList.insert(album->url().remove(0,1), album->id());
337
352
            }
338
353
        }
 
354
        
 
355
        // Now we can iterate over the sorted list and fill the combobox
 
356
        int index = 0;
 
357
        for ( SortedList::Iterator it = sAList.begin();
 
358
              it != sAList.end(); ++it )
 
359
        {
 
360
            m_valueCombo->insertSqueezedItem( it.key(), index );
 
361
            m_itemsIndexIDMap.insert(index, it.data());
 
362
            index++;
 
363
            }
339
364
 
340
365
        m_valueCombo->show();
341
366
 
351
376
        AlbumList tList = aManager->allTAlbums();
352
377
 
353
378
        m_itemsIndexIDMap.clear();
354
 
        int index = 0;
 
379
        
 
380
        // First we need to sort the tags.
 
381
        // We create a map with the album tagPath as key, so that it is
 
382
        // automatically sorted.
 
383
        SortedList sTList;
 
384
        
355
385
        for ( AlbumList::Iterator it = tList.begin();
356
386
              it != tList.end(); ++it )
357
387
        {
358
388
            TAlbum *album = (TAlbum*)(*it);
359
389
            if ( !album->isRoot() )
360
390
            {
361
 
                m_valueCombo->insertSqueezedItem( album->tagPath(false), index );
362
 
                m_itemsIndexIDMap.insert( index, album->id() );
363
 
                ++index;
 
391
                sTList.insert(album->tagPath(false), album->id());
364
392
            }
365
393
        }
366
 
 
 
394
        
 
395
        // Now we can iterate over the sorted list and fill the combobox
 
396
        int index = 0;
 
397
        for (SortedList::Iterator it = sTList.begin();
 
398
             it != sTList.end(); ++it)
 
399
        {
 
400
            m_valueCombo->insertSqueezedItem( it.key(), index );
 
401
            m_itemsIndexIDMap.insert( index, it.data() );
 
402
            ++index;
 
403
        }
 
404
        
367
405
        m_valueCombo->show();
368
406
 
369
407
        connect( m_valueCombo, SIGNAL( activated(int) ),