~ubuntu-branches/ubuntu/karmic/digikam/karmic-backports

« back to all changes in this revision

Viewing changes to utilities/cameragui/cameraiconview.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ubuntu Archive Auto-Backport
  • Date: 2009-12-07 19:03:53 UTC
  • mfrom: (54.1.4 lucid)
  • Revision ID: james.westby@ubuntu.com-20091207190353-oara3lenjxymto3i
Tags: 2:1.0.0~rc-1ubuntu1~karmic1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 *
24
24
 * ============================================================ */
25
25
 
26
 
#include "cameraiconview.h"
27
26
#include "cameraiconview.moc"
28
27
 
29
28
// Qt includes
45
44
 
46
45
#include <kaction.h>
47
46
#include <kapplication.h>
48
 
 
49
47
#include <kiconloader.h>
50
48
#include <klocale.h>
51
49
#include <kmenu.h>
102
100
    QPixmap                          pixmapDownloaded;
103
101
    QPixmap                          pixmapDownloadFailed;
104
102
 
105
 
    RenameCustomizer                *renamer;
106
 
 
107
 
    IconGroupItem                   *groupItem;
108
 
 
109
 
    CameraUI                        *cameraUI;
110
 
 
111
 
    CameraIconViewToolTip           *toolTip;
 
103
    RenameCustomizer*                renamer;
 
104
 
 
105
    IconGroupItem*                   groupItem;
 
106
 
 
107
    CameraUI*                        cameraUI;
 
108
 
 
109
    CameraIconViewToolTip*           toolTip;
112
110
};
113
111
 
114
112
CameraIconView::CameraIconView(CameraUI* ui, QWidget* parent)
236
234
    {
237
235
        if (!d->renamer->useDefault())
238
236
        {
239
 
            downloadName = getTemplatedName( &info, d->itemDict.count() );
 
237
            downloadName = getTemplatedName(&info);
240
238
        }
241
239
        else
242
240
        {
339
337
    if (d->renamer)
340
338
    {
341
339
        useDefault = d->renamer->useDefault();
342
 
        startIndex = d->renamer->startIndex() -1;
 
340
        startIndex = d->renamer->startIndex();
343
341
    }
344
342
 
345
343
    bool convertLossLessJpeg = d->cameraUI->convertLosslessJpegFiles();
348
346
    viewport()->setUpdatesEnabled(false);
349
347
 
350
348
    // NOTE: see B.K.O #182352: ordering of item count must be adapted sort of icon view,
351
 
    // since items are ordered from the most rescent to the older one.
 
349
    // since items are ordered from the most recent to the older one.
352
350
    bool revOrder=!d->cameraUI->chronologicOrder();
353
351
    // Camera items selection.
354
352
 
 
353
    // reset the start index
 
354
    d->renamer->setStartIndex(startIndex);
 
355
 
355
356
    for (IconItem* item = (revOrder?lastItem():firstItem()); item; (revOrder?item = item->prevItem():item=item->nextItem()))
356
357
    {
357
358
        QString downloadName;
360
361
        if ( (hasSelection && item->isSelected()) || !hasSelection)
361
362
        {
362
363
            if (!useDefault)
363
 
                downloadName = getTemplatedName( viewItem->itemInfo(), startIndex );
 
364
            {
 
365
                downloadName = getTemplatedName( viewItem->itemInfo());
 
366
            }
364
367
            else
 
368
            {
365
369
                downloadName = getCasedName( d->renamer->changeCase(), viewItem->itemInfo() );
366
 
 
367
 
            ++startIndex;
 
370
            }
368
371
        }
369
372
 
370
373
        if (convertLossLessJpeg && !downloadName.isEmpty())
394
397
    return getCasedName( renamecase, viewItem->itemInfo() );
395
398
}
396
399
 
397
 
QString CameraIconView::getTemplatedName(const GPItemInfo* itemInfo, int position)
 
400
QString CameraIconView::getTemplatedName(const GPItemInfo* itemInfo)
398
401
{
399
 
    QString ext = itemInfo->name;
400
 
    int pos     = ext.lastIndexOf('.');
401
 
    if (pos < 0)
402
 
        ext = "";
403
 
    else
404
 
        ext = ext.right( ext.length() - pos );
405
 
 
406
 
 
407
402
    QFileInfo fi;
408
403
    fi.setFile(QDir(itemInfo->folder), itemInfo->name);
409
404
 
410
 
    return d->renamer->newName(fi.absoluteFilePath(), itemInfo->mtime, position+1, ext);
 
405
    return d->renamer->newName(fi.absoluteFilePath(), itemInfo->mtime);
411
406
}
412
407
 
413
 
QString CameraIconView::getCasedName(const RenameCustomizer::Case ccase,
414
 
                                     const GPItemInfo* itemInfo)
 
408
QString CameraIconView::getCasedName(const RenameCustomizer::Case ccase, const GPItemInfo* itemInfo)
415
409
{
416
410
    QString dname;
417
411