~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to utilities/cameragui/cameraui.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 /* ============================================================
2
 
 *
3
 
 * This file is a part of digiKam project
4
 
 * http://www.digikam.org
5
 
 *
6
 
 * Date        : 2004-09-16
7
 
 * Description : Camera interface
8
 
 *
9
 
 * Copyright (C) 2004-2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
10
 
 * Copyright (C) 2006-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
 
 * Copyright (C) 2006-2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
12
 
 *
13
 
 * This program is free software; you can redistribute it
14
 
 * and/or modify it under the terms of the GNU General
15
 
 * Public License as published by the Free Software Foundation;
16
 
 * either version 2, or (at your option)
17
 
 * any later version.
18
 
 *
19
 
 * This program is distributed in the hope that it will be useful,
20
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 
 * GNU General Public License for more details.
23
 
 *
24
 
 * ============================================================ */
 
1
/* ============================================================
 
2
*
 
3
* This file is a part of digiKam project
 
4
* http://www.digikam.org
 
5
*
 
6
* Date        : 2004-09-16
 
7
* Description : Camera interface
 
8
*
 
9
* Copyright (C) 2004-2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
 
10
* Copyright (C) 2006-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
11
* Copyright (C) 2006-2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 
12
*
 
13
* This program is free software; you can redistribute it
 
14
* and/or modify it under the terms of the GNU General
 
15
* Public License as published by the Free Software Foundation;
 
16
* either version 2, or (at your option)
 
17
* any later version.
 
18
*
 
19
* This program is distributed in the hope that it will be useful,
 
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
22
* GNU General Public License for more details.
 
23
*
 
24
* ============================================================ */
25
25
 
26
26
#include "cameraui.moc"
27
27
#include "cameraui_p.h"
135
135
CameraUI::CameraUI(QWidget* const parent, const QString& cameraTitle,
136
136
                   const QString& model, const QString& port,
137
137
                   const QString& path, int startIndex)
138
 
        : KXmlGuiWindow(parent), d(new CameraUIPriv)
 
138
    : KXmlGuiWindow(parent), d(new CameraUIPriv)
139
139
 
140
140
{
141
141
    setXMLFile("cameraui.rc");
143
143
    // --------------------------------------------------------
144
144
 
145
145
    UiFileValidator validator(localXMLFile());
 
146
 
146
147
    if (!validator.isValid())
147
148
    {
148
149
        validator.fixConfigFile();
247
248
    QVBoxLayout* albumVlay = new QVBoxLayout(albumBox);
248
249
    d->autoAlbumExtCheck   = new QCheckBox(i18n("Extension-based sub-albums"), albumBox);
249
250
    d->autoAlbumDateCheck  = new QCheckBox(i18n("Date-based sub-albums"), albumBox);
250
 
    KHBox *hbox1           = new KHBox(albumBox);
 
251
    KHBox* hbox1           = new KHBox(albumBox);
251
252
    d->folderDateLabel     = new QLabel(i18n("Date format:"), hbox1);
252
253
    d->folderDateFormat    = new KComboBox(hbox1);
253
254
    d->folderDateFormat->insertItem(CameraUIPriv::IsoDateFormat,   i18n("ISO"));
263
264
 
264
265
    albumBox->setWhatsThis( i18n("Set how digiKam creates albums automatically when downloading."));
265
266
    d->autoAlbumExtCheck->setWhatsThis( i18n("Enable this option if you want to download your "
266
 
                     "pictures into automatically created file extension-based sub-albums of the destination "
267
 
                     "album. This way, you can separate JPEG and RAW files as they are downloaded from your camera."));
 
267
                                        "pictures into automatically created file extension-based sub-albums of the destination "
 
268
                                        "album. This way, you can separate JPEG and RAW files as they are downloaded from your camera."));
268
269
    d->autoAlbumDateCheck->setWhatsThis( i18n("Enable this option if you want to "
269
 
                     "download your pictures into automatically created file date-based sub-albums "
270
 
                     "of the destination album."));
 
270
                                         "download your pictures into automatically created file date-based sub-albums "
 
271
                                         "of the destination album."));
271
272
    d->folderDateFormat->setWhatsThis( i18n("<p>Select your preferred date format used to "
272
 
                     "create new albums. The options available are:</p>"
273
 
                     "<p><b>ISO</b>: the date format is in accordance with ISO 8601 "
274
 
                     "(YYYY-MM-DD). E.g.: <i>2006-08-24</i></p>"
275
 
                     "<p><b>Full Text</b>: the date format is in a user-readable string. "
276
 
                     "E.g.: <i>Thu Aug 24 2006</i></p>"
277
 
                     "<p><b>Local Settings</b>: the date format depending on KDE control panel settings.</p>"));
 
273
                                            "create new albums. The options available are:</p>"
 
274
                                            "<p><b>ISO</b>: the date format is in accordance with ISO 8601 "
 
275
                                            "(YYYY-MM-DD). E.g.: <i>2006-08-24</i></p>"
 
276
                                            "<p><b>Full Text</b>: the date format is in a user-readable string. "
 
277
                                            "E.g.: <i>Thu Aug 24 2006</i></p>"
 
278
                                            "<p><b>Local Settings</b>: the date format depending on KDE control panel settings.</p>"));
278
279
 
279
280
    d->advBox->addItem(albumBox, SmallIcon("folder-new"), i18n("Auto-creation of Albums"),
280
281
                       QString("AlbumBox"), false);
288
289
    d->dateTimeEdit        = new KDateTimeEdit(onFlyBox, "datepicker");
289
290
    d->autoRotateCheck     = new QCheckBox(i18n("Auto-rotate/flip image"), onFlyBox);
290
291
    d->convertJpegCheck    = new QCheckBox(i18n("Convert to lossless file format"), onFlyBox);
291
 
    KHBox *hbox2           = new KHBox(onFlyBox);
 
292
    KHBox* hbox2           = new KHBox(onFlyBox);
292
293
    d->formatLabel         = new QLabel(i18n("New image format:"), hbox2);
293
294
    d->losslessFormat      = new KComboBox(hbox2);
294
295
    d->losslessFormat->insertItem(0, "PNG");
307
308
    onFlyVlay->setSpacing(KDialog::spacingHint());
308
309
 
309
310
    onFlyBox->setWhatsThis( i18n("Set here all options to fix/transform JPEG files automatically "
310
 
                     "as they are downloaded."));
 
311
                                 "as they are downloaded."));
311
312
    d->autoRotateCheck->setWhatsThis( i18n("Enable this option if you want images automatically "
312
 
                     "rotated or flipped using EXIF information provided by the camera."));
 
313
                                           "rotated or flipped using EXIF information provided by the camera."));
313
314
    d->templateSelector->setWhatsThis( i18n("Select here which metadata template you want to apply "
314
 
                     "to images."));
 
315
                                            "to images."));
315
316
    d->fixDateTimeCheck->setWhatsThis( i18n("Enable this option to set date and time metadata "
316
 
                     "tags to the right values if your camera does not set "
317
 
                     "these tags correctly when pictures are taken. The values will "
318
 
                     "be saved in the DateTimeDigitized and DateTimeCreated EXIF, XMP, and IPTC tags."));
 
317
                                            "tags to the right values if your camera does not set "
 
318
                                            "these tags correctly when pictures are taken. The values will "
 
319
                                            "be saved in the DateTimeDigitized and DateTimeCreated EXIF, XMP, and IPTC tags."));
319
320
    d->convertJpegCheck->setWhatsThis( i18n("Enable this option to automatically convert "
320
 
                     "all JPEG files to a lossless image format. <b>Note:</b> Image conversion can take a "
321
 
                     "while on a slow computer."));
 
321
                                            "all JPEG files to a lossless image format. <b>Note:</b> Image conversion can take a "
 
322
                                            "while on a slow computer."));
322
323
    d->losslessFormat->setWhatsThis( i18n("Select your preferred lossless image file format to "
323
 
                     "convert to. <b>Note:</b> All metadata will be preserved during the conversion."));
 
324
                                          "convert to. <b>Note:</b> All metadata will be preserved during the conversion."));
324
325
 
325
326
    d->advBox->addItem(onFlyBox, SmallIcon("system-run"), i18n("On the Fly Operations (JPEG only)"),
326
327
                       QString("OnFlyBox"), true);
537
538
 
538
539
    // -- Keyboard-only actions added to <MainWindow> ------------------------------
539
540
 
540
 
    KAction *altBackwardAction = new KAction(i18n("Previous Image"), this);
 
541
    KAction* altBackwardAction = new KAction(i18n("Previous Image"), this);
541
542
    actionCollection()->addAction("cameraui_backward_shift_space", altBackwardAction);
542
543
    altBackwardAction->setShortcut( KShortcut(Qt::SHIFT+Qt::Key_Space) );
543
544
    connect(altBackwardAction, SIGNAL(triggered()), this, SLOT(slotPrevItem()));
630
631
    // -------------------------------------------------------------------------
631
632
 
632
633
    connect(d->zoomBar, SIGNAL(signalZoomSliderChanged(int)),
633
 
           this, SLOT(slotZoomSliderChanged(int)));
 
634
            this, SLOT(slotZoomSliderChanged(int)));
634
635
 
635
636
    connect(this, SIGNAL(signalWindowHasMoved()),
636
637
            d->zoomBar, SLOT(slotUpdateTrackerPos()));
637
638
 
638
639
    // -------------------------------------------------------------------------
639
640
 
640
 
    connect(CollectionManager::instance(), SIGNAL(locationStatusChanged(const CollectionLocation &, int)),
641
 
            this, SLOT(slotCollectionLocationStatusChanged(const CollectionLocation &, int)));
 
641
    connect(CollectionManager::instance(), SIGNAL(locationStatusChanged(const CollectionLocation&, int)),
 
642
            this, SLOT(slotCollectionLocationStatusChanged(const CollectionLocation&, int)));
642
643
 
643
644
    connect(AlbumSettings::instance(), SIGNAL(setupChanged()),
644
645
            this, SLOT(slotSidebarTabTitleStyleChanged()));
843
844
void CameraUI::refreshFreeSpace()
844
845
{
845
846
    if (d->controller->cameraDriverType() == DKCamera::GPhotoDriver)
 
847
    {
846
848
        d->controller->getFreeSpace();
 
849
    }
847
850
    else
 
851
    {
848
852
        d->cameraFreeSpace->refresh();
 
853
    }
849
854
}
850
855
 
851
856
void CameraUI::closeEvent(QCloseEvent* e)
852
857
{
853
858
    if (dialogClosed())
 
859
    {
854
860
        e->accept();
 
861
    }
855
862
    else
 
863
    {
856
864
        e->ignore();
 
865
    }
857
866
}
858
867
 
859
 
void CameraUI::moveEvent(QMoveEvent *e)
 
868
void CameraUI::moveEvent(QMoveEvent* e)
860
869
{
861
870
    Q_UNUSED(e)
862
871
    emit signalWindowHasMoved();
864
873
 
865
874
void CameraUI::slotClose()
866
875
{
867
 
/*FIXME
868
 
    if (dialogClosed())
869
 
        reject();
870
 
*/
 
876
    /*FIXME
 
877
        if (dialogClosed())
 
878
            reject();
 
879
    */
871
880
}
872
881
 
873
882
bool CameraUI::dialogClosed()
874
883
{
875
884
    if (d->closed)
 
885
    {
876
886
        return true;
 
887
    }
877
888
 
878
889
    if (isBusy())
879
890
    {
881
892
                                       i18n("Do you want to close the dialog "
882
893
                                            "and cancel the current operation?"))
883
894
            == KMessageBox::No)
 
895
        {
884
896
            return false;
 
897
        }
885
898
    }
886
899
 
887
900
    d->statusProgressBar->progressBarMode(StatusProgressBar::TextMode,
911
924
    if (d->view->itemsDownloaded() > 0)
912
925
    {
913
926
        CameraList* clist = CameraList::defaultList();
 
927
 
914
928
        if (clist)
915
929
        {
916
930
            clist->changeCameraStartIndex(d->cameraTitle, d->renameCustomizer->startIndex());
933
947
    deleteLater();
934
948
 
935
949
    if (!d->lastDestURL.isEmpty())
 
950
    {
936
951
        emit signalLastDestination(d->lastDestURL);
 
952
    }
937
953
 
938
954
    saveSettings();
939
955
}
943
959
    if (!val)   // Camera is available for actions.
944
960
    {
945
961
        if (!d->busy)
 
962
        {
946
963
            return;
 
964
        }
947
965
 
948
966
        d->busy = false;
949
967
        d->cameraCancelAction->setEnabled(false);
982
1000
    else    // Camera is busy.
983
1001
    {
984
1002
        if (d->busy)
 
1003
        {
985
1004
            return;
 
1005
        }
986
1006
 
987
1007
        if (!d->anim->running())
 
1008
        {
988
1009
            d->anim->start();
 
1010
        }
989
1011
 
990
1012
        d->busy = true;
991
1013
 
1045
1067
    d->decreaseThumbsAction->setEnabled(true);
1046
1068
 
1047
1069
    if (d->view->thumbnailSize() == ThumbnailSize::Small)
 
1070
    {
1048
1071
        d->decreaseThumbsAction->setEnabled(false);
 
1072
    }
1049
1073
 
1050
1074
    if (d->view->thumbnailSize() == ThumbnailSize::Huge)
 
1075
    {
1051
1076
        d->increaseThumbsAction->setEnabled(false);
 
1077
    }
1052
1078
}
1053
1079
 
1054
1080
void CameraUI::slotConnected(bool val)
1055
1081
{
1056
1082
    if (!val)
1057
1083
    {
1058
 
      if (KMessageBox::warningYesNo(this,
1059
 
                                    i18n("Failed to connect to the camera. "
1060
 
                                         "Please make sure it is connected "
1061
 
                                         "properly and turned on. "
1062
 
                                         "Would you like to try again?"),
1063
 
                                    i18n("Connection Failed"),
1064
 
                                    KGuiItem(i18n("Retry")),
1065
 
                                    KGuiItem(i18n("Abort")))
1066
 
          == KMessageBox::Yes)
1067
 
          QTimer::singleShot(0, d->controller, SLOT(slotConnect()));
1068
 
      else
1069
 
          close();
 
1084
        if (KMessageBox::warningYesNo(this,
 
1085
                                      i18n("Failed to connect to the camera. "
 
1086
                                           "Please make sure it is connected "
 
1087
                                           "properly and turned on. "
 
1088
                                           "Would you like to try again?"),
 
1089
                                      i18n("Connection Failed"),
 
1090
                                      KGuiItem(i18n("Retry")),
 
1091
                                      KGuiItem(i18n("Abort")))
 
1092
            == KMessageBox::Yes)
 
1093
        {
 
1094
            QTimer::singleShot(0, d->controller, SLOT(slotConnect()));
 
1095
        }
 
1096
        else
 
1097
        {
 
1098
            close();
 
1099
        }
1070
1100
    }
1071
1101
    else
1072
1102
    {
1078
1108
void CameraUI::slotFolderList(const QStringList& folderList)
1079
1109
{
1080
1110
    if (d->closed)
 
1111
    {
1081
1112
        return;
 
1113
    }
1082
1114
 
1083
1115
    d->statusProgressBar->setProgressValue(0);
1084
1116
    d->statusProgressBar->setProgressTotalSteps(0);
1085
1117
 
1086
1118
    d->cameraFolderList = folderList;
 
1119
 
1087
1120
    for (QStringList::const_iterator it = folderList.constBegin();
1088
1121
         it != folderList.constEnd(); ++it)
1089
1122
    {
1094
1127
void CameraUI::slotFileList(const GPItemInfoList& fileList)
1095
1128
{
1096
1129
    if (d->closed)
 
1130
    {
1097
1131
        return;
 
1132
    }
1098
1133
 
1099
1134
    if (fileList.empty())
 
1135
    {
1100
1136
        return;
 
1137
    }
1101
1138
 
1102
1139
    d->filesToBeAdded << fileList;
1103
1140
    d->refreshIconViewTimer->start();
1112
1149
    }
1113
1150
 
1114
1151
    if (d->filesToBeAdded.isEmpty())
 
1152
    {
1115
1153
        return;
 
1154
    }
1116
1155
 
1117
1156
    AlbumSettings* settings = AlbumSettings::instance();
1118
 
    if (!settings) return;
 
1157
 
 
1158
    if (!settings)
 
1159
    {
 
1160
        return;
 
1161
    }
1119
1162
 
1120
1163
    // We sort the map by time stamp
1121
1164
    // and we remove internal camera files which are not image/video/sounds.
1136
1179
    QStringList list = settings->getAllFileFilter().toLower().split(' ');
1137
1180
 
1138
1181
    QMultiMap<QDateTime, GPItemInfo> map;
1139
 
    CameraIconItem *citem = static_cast<CameraIconItem*>(d->view->firstItem());
1140
 
    while(citem)
 
1182
    CameraIconItem* citem = static_cast<CameraIconItem*>(d->view->firstItem());
 
1183
 
 
1184
    while (citem)
1141
1185
    {
1142
1186
        info.setFile(citem->itemInfo()->name);
1143
1187
        map.insertMulti(citem->itemInfo()->mtime, *citem->itemInfo());
1145
1189
    }
1146
1190
 
1147
1191
    GPItemInfoList::iterator it = d->filesToBeAdded.begin();
 
1192
 
1148
1193
    while (it != d->filesToBeAdded.end())
1149
1194
    {
1150
1195
        info.setFile((*it).name);
 
1196
 
1151
1197
        if (!fileNames.contains(info.fileName().toLower()) &&
1152
1198
            !fileExts.contains(info.suffix().toLower())    &&
1153
1199
            list.contains(QString("*.%1").arg(info.suffix().toLower())))
1154
1200
        {
1155
1201
            map.insertMulti((*it).mtime, *it);
1156
1202
        }
 
1203
 
1157
1204
        it = d->filesToBeAdded.erase(it);
1158
1205
    }
1159
1206
 
1160
1207
    citem = static_cast<CameraIconItem*>(d->view->firstItem());
1161
 
    while(citem)
 
1208
 
 
1209
    while (citem)
1162
1210
    {
1163
 
        CameraIconItem *tempItem = citem;
 
1211
        CameraIconItem* tempItem = citem;
1164
1212
        citem = static_cast<CameraIconItem*>(tempItem->nextItem());
1165
1213
        d->view->removeItem(tempItem->itemInfo()->folder,tempItem->itemInfo()->name);
1166
1214
    }
1171
1219
void CameraUI::slotRefreshIconView(const CHUpdateItemMap& map)
1172
1220
{
1173
1221
    if (map.empty())
 
1222
    {
1174
1223
        return;
 
1224
    }
1175
1225
 
1176
1226
    CHUpdateItemMap _map = map;
1177
1227
 
1187
1237
 
1188
1238
    do
1189
1239
    {
1190
 
        if (lastPhotoFirst) --it;
 
1240
        if (lastPhotoFirst)
 
1241
        {
 
1242
            --it;
 
1243
        }
1191
1244
 
1192
1245
        item = *it;
1193
1246
        d->view->addItem(item);
1194
1247
        itemsList.append(QStringList() << item.folder << item.name);
1195
1248
 
1196
 
        if (!lastPhotoFirst) it++;
 
1249
        if (!lastPhotoFirst)
 
1250
        {
 
1251
            it++;
 
1252
        }
1197
1253
    }
1198
 
    while((lastPhotoFirst ? it != _map.begin() : it != _map.end()));
 
1254
    while ((lastPhotoFirst ? it != _map.begin() : it != _map.end()));
1199
1255
 
1200
1256
    d->controller->getThumbnails(itemsList);
1201
1257
}
1205
1261
    saveSettings();
1206
1262
 
1207
1263
    QMultiMap<QDateTime, GPItemInfo> map;
1208
 
    CameraIconItem *item = dynamic_cast<CameraIconItem*>(d->view->firstItem());
 
1264
    CameraIconItem* item = dynamic_cast<CameraIconItem*>(d->view->firstItem());
1209
1265
    QFileInfo info;
1210
 
    while(item)
 
1266
 
 
1267
    while (item)
1211
1268
    {
1212
1269
        info.setFile(item->itemInfo()->name);
1213
1270
        map.insertMulti(item->itemInfo()->mtime, *item->itemInfo());
1215
1272
    }
1216
1273
 
1217
1274
    item = dynamic_cast<CameraIconItem*>(d->view->firstItem());
1218
 
    while(item)
 
1275
 
 
1276
    while (item)
1219
1277
    {
1220
1278
        d->view->removeItem(item->itemInfo()->folder,item->itemInfo()->name);
1221
1279
        item = dynamic_cast<CameraIconItem*>(item->nextItem());
1264
1322
void CameraUI::startKdePreviewJob()
1265
1323
{
1266
1324
    if (d->kdeJob || d->kdeTodo.isEmpty())
 
1325
    {
1267
1326
        return;
 
1327
    }
1268
1328
 
1269
1329
    KUrl::List list = d->kdeTodo;
1270
1330
    d->kdeTodo.clear();
1285
1345
    QString file   = item.url().fileName();
1286
1346
    QString folder = item.url().toLocalFile().remove(QString("/") + file);
1287
1347
    QImage thumb   = pix.toImage();
 
1348
 
1288
1349
    if (thumb.isNull())
1289
1350
    {
1290
1351
        // This call must be run outside Camera Controller thread.
1291
1352
        thumb = d->controller->mimeTypeThumbnail(file).toImage();
1292
1353
    }
 
1354
 
1293
1355
    d->view->setThumbnail(folder, file, thumb);
1294
1356
}
1295
1357
 
1309
1371
void CameraUI::slotCapture()
1310
1372
{
1311
1373
    if (d->busy)
 
1374
    {
1312
1375
        return;
 
1376
    }
1313
1377
 
1314
 
    CaptureDlg *captureDlg = new CaptureDlg(this, d->controller, d->cameraTitle);
 
1378
    CaptureDlg* captureDlg = new CaptureDlg(this, d->controller, d->cameraTitle);
1315
1379
    captureDlg->show();
1316
1380
}
1317
1381
 
1318
1382
void CameraUI::slotInformation()
1319
1383
{
1320
1384
    if (d->busy)
 
1385
    {
1321
1386
        return;
 
1387
    }
1322
1388
 
1323
1389
    d->controller->getCameraInformation();
1324
1390
}
1325
1391
 
1326
1392
void CameraUI::slotCameraInformation(const QString& summary, const QString& manual, const QString& about)
1327
1393
{
1328
 
    CameraInfoDialog *infoDlg = new CameraInfoDialog(this, summary, manual, about);
 
1394
    CameraInfoDialog* infoDlg = new CameraInfoDialog(this, summary, manual, about);
1329
1395
    infoDlg->show();
1330
1396
}
1331
1397
 
1332
1398
void CameraUI::slotUpload()
1333
1399
{
1334
1400
    if (d->busy)
 
1401
    {
1335
1402
        return;
 
1403
    }
1336
1404
 
1337
1405
    QString fileformats;
1338
1406
 
1355
1423
    kDebug() << "fileformats=" << fileformats;
1356
1424
 
1357
1425
    KUrl::List urls = KFileDialog::getOpenUrls(CollectionManager::instance()->oneAlbumRootPath(),
1358
 
                                               fileformats, this, i18n("Select Image to Upload"));
 
1426
                      fileformats, this, i18n("Select Image to Upload"));
 
1427
 
1359
1428
    if (!urls.isEmpty())
 
1429
    {
1360
1430
        slotUploadItems(urls);
 
1431
    }
1361
1432
}
1362
1433
 
1363
1434
void CameraUI::slotUploadItems(const KUrl::List& urls)
1364
1435
{
1365
1436
    if (d->busy)
 
1437
    {
1366
1438
        return;
 
1439
    }
1367
1440
 
1368
1441
    if (urls.isEmpty())
 
1442
    {
1369
1443
        return;
 
1444
    }
1370
1445
 
1371
1446
    if (d->cameraFreeSpace->isValid())
1372
1447
    {
1373
1448
        // Check if space require to upload new items in camera is enough.
1374
1449
        quint64 totalKbSize = 0;
 
1450
 
1375
1451
        for (KUrl::List::const_iterator it = urls.constBegin() ; it != urls.constEnd() ; ++it)
1376
1452
        {
1377
1453
            QFileInfo fi((*it).toLocalFile());
1384
1460
                                          "to upload pictures.\n\n"
1385
1461
                                          "Space require: %1\n"
1386
1462
                                          "Available free space: %2",
1387
 
                                    KIO::convertSizeFromKiB(totalKbSize),
1388
 
                                    KIO::convertSizeFromKiB(d->cameraFreeSpace->kBAvail())));
 
1463
                                          KIO::convertSizeFromKiB(totalKbSize),
 
1464
                                          KIO::convertSizeFromKiB(d->cameraFreeSpace->kBAvail())));
1389
1465
            return;
1390
1466
        }
1391
1467
    }
1392
1468
 
1393
1469
    QPointer<CameraFolderDialog> dlg = new CameraFolderDialog(this, d->view, d->cameraFolderList,
1394
 
                                                              d->controller->cameraTitle(),
1395
 
                                                              d->controller->cameraPath());
 
1470
            d->controller->cameraTitle(),
 
1471
            d->controller->cameraPath());
1396
1472
 
1397
1473
    if (dlg->exec() != QDialog::Accepted)
1398
1474
    {
1402
1478
 
1403
1479
    // since we access members here, check if the pointer is still valid
1404
1480
    if (!dlg)
 
1481
    {
1405
1482
        return;
 
1483
    }
1406
1484
 
1407
1485
    QString cameraFolder = dlg->selectedFolderPath();
1408
1486
 
1409
1487
    for (KUrl::List::const_iterator it = urls.constBegin(); it != urls.constEnd(); ++it)
1410
1488
    {
1411
1489
        QFileInfo fi((*it).toLocalFile());
1412
 
        if (!fi.exists()) continue;
1413
 
        if (fi.isDir()) continue;
 
1490
 
 
1491
        if (!fi.exists())
 
1492
        {
 
1493
            continue;
 
1494
        }
 
1495
 
 
1496
        if (fi.isDir())
 
1497
        {
 
1498
            continue;
 
1499
        }
1414
1500
 
1415
1501
        QString ext  = QString(".") + fi.completeSuffix();
1416
1502
        QString name = fi.fileName();
1426
1512
            name = KInputDialog::getText(i18n("File already exists"), msg, name, &ok, this);
1427
1513
 
1428
1514
            if (!ok)
 
1515
            {
1429
1516
                return;
 
1517
            }
1430
1518
        }
1431
1519
 
1432
1520
        d->controller->upload(fi, name + ext, cameraFolder);
1438
1526
void CameraUI::slotUploaded(const GPItemInfo& itemInfo)
1439
1527
{
1440
1528
    if (d->closed)
 
1529
    {
1441
1530
        return;
 
1531
    }
1442
1532
 
1443
1533
    d->view->addItem(itemInfo);
1444
1534
    d->controller->getThumbnail(itemInfo.folder, itemInfo.name);
1465
1555
    slotDownload(false, true);
1466
1556
}
1467
1557
 
1468
 
void CameraUI::slotDownload(bool onlySelected, bool deleteAfter, Album *album)
 
1558
void CameraUI::slotDownload(bool onlySelected, bool deleteAfter, Album* album)
1469
1559
{
1470
1560
    // See B.K.O #143934: force to select all items to prevent problem
1471
1561
    // when !renameCustomizer->useDefault() ==> iconItem->getDownloadName()
1472
1562
    // can return an empty string in this case because it depends on selection.
1473
1563
    if (!onlySelected)
 
1564
    {
1474
1565
        d->view->slotSelectAll();
 
1566
    }
1475
1567
 
1476
1568
    QString   newDirName;
1477
1569
    IconItem* firstItem = d->view->firstItem();
 
1570
 
1478
1571
    if (firstItem)
1479
1572
    {
1480
1573
        CameraIconItem* iconItem = static_cast<CameraIconItem*>(firstItem);
1481
1574
 
1482
1575
        QDateTime dateTime = iconItem->itemInfo()->mtime;
1483
1576
 
1484
 
        switch(d->folderDateFormat->currentIndex())
 
1577
        switch (d->folderDateFormat->currentIndex())
1485
1578
        {
1486
1579
            case CameraUIPriv::TextDateFormat:
1487
1580
                newDirName = dateTime.date().toString(Qt::TextDate);
1502
1595
        AlbumManager* man = AlbumManager::instance();
1503
1596
 
1504
1597
        album = man->currentAlbum();
 
1598
 
1505
1599
        if (album && album->type() != Album::PHYSICAL)
 
1600
        {
1506
1601
            album = 0;
 
1602
        }
1507
1603
 
1508
1604
        QString header(i18n("<p>Please select the destination album from the digiKam library to "
1509
1605
                            "import the camera pictures into.</p>"));
1511
1607
        album = AlbumSelectDialog::selectAlbum(this, (PAlbum*)album, header, newDirName);
1512
1608
 
1513
1609
        if (!album)
 
1610
        {
1514
1611
            return;
1515
 
    }
1516
 
 
1517
 
    PAlbum *pAlbum = dynamic_cast<PAlbum*>(album);
1518
 
    if (!pAlbum) return;
 
1612
        }
 
1613
    }
 
1614
 
 
1615
    PAlbum* pAlbum = dynamic_cast<PAlbum*>(album);
 
1616
 
 
1617
    if (!pAlbum)
 
1618
    {
 
1619
        return;
 
1620
    }
1519
1621
 
1520
1622
    // -- Check disk space ------------------------
1521
1623
 
1526
1628
    d->view->itemsSelectionSizeInfo(fSize, dSize);
1527
1629
    QString albumRootPath = pAlbum->albumRootPath();
1528
1630
    unsigned long kBAvail = d->albumLibraryFreeSpace->kBAvail(albumRootPath);
 
1631
 
1529
1632
    if (dSize >= kBAvail)
1530
1633
    {
1531
1634
        KGuiItem cont = KStandardGuiItem::cont();
1533
1636
        KGuiItem cancel = KStandardGuiItem::cancel();
1534
1637
        cancel.setText(i18n("Cancel Download"));
1535
1638
        int result =
1536
 
        KMessageBox::warningYesNo(this,
1537
 
                                  i18n("There is not enough free space on the disk of the album you selected "
1538
 
                                       "to download and process the selected pictures from the camera.\n\n"
1539
 
                                       "Estimated space required: %1\n"
1540
 
                                       "Available free space: %2",
1541
 
                                       KIO::convertSizeFromKiB(dSize),
1542
 
                                       KIO::convertSizeFromKiB(kBAvail)),
1543
 
                                  i18n("Insufficient Disk Space"),
1544
 
                                  cont, cancel);
 
1639
            KMessageBox::warningYesNo(this,
 
1640
                                      i18n("There is not enough free space on the disk of the album you selected "
 
1641
                                           "to download and process the selected pictures from the camera.\n\n"
 
1642
                                           "Estimated space required: %1\n"
 
1643
                                           "Available free space: %2",
 
1644
                                           KIO::convertSizeFromKiB(dSize),
 
1645
                                           KIO::convertSizeFromKiB(kBAvail)),
 
1646
                                      i18n("Insufficient Disk Space"),
 
1647
                                      cont, cancel);
 
1648
 
1545
1649
        if (result == KMessageBox::No)
 
1650
        {
1546
1651
            return;
 
1652
        }
1547
1653
    }
1548
1654
 
1549
1655
    // -- Prepare downloading of camera items ------------------------
1569
1675
 
1570
1676
    QSet<QString> usedDownloadPaths;
1571
1677
    bool lastPhotoFirst = d->lastPhotoFirstAction->isChecked();
 
1678
 
1572
1679
    for (IconItem* item = (lastPhotoFirst ? d->view->lastItem() : d->view->firstItem()); item;
1573
1680
         item = (lastPhotoFirst ? item->prevItem() : item->nextItem()))
1574
1681
    {
1575
1682
        if (onlySelected && !(item->isSelected()))
 
1683
        {
1576
1684
            continue;
 
1685
        }
1577
1686
 
1578
1687
        CameraIconItem* iconItem = static_cast<CameraIconItem*>(item);
1579
1688
        downloadSettings.folder  = iconItem->itemInfo()->folder;
1590
1699
        {
1591
1700
            QString dirName;
1592
1701
 
1593
 
            switch(d->folderDateFormat->currentIndex())
 
1702
            switch (d->folderDateFormat->currentIndex())
1594
1703
            {
1595
1704
                case CameraUIPriv::TextDateFormat:
1596
1705
                    dirName = dateTime.date().toString(Qt::TextDate);
1606
1715
            // See B.K.O #136927 : we need to support file system which do not
1607
1716
            // handle upper case properly.
1608
1717
            dirName = dirName.toLower();
 
1718
 
1609
1719
            if (!createAutoAlbum(downloadUrl, dirName, dateTime.date(), errMsg))
1610
1720
            {
1611
1721
                KMessageBox::error(this, errMsg);
1624
1734
            QFileInfo fi(downloadName);
1625
1735
 
1626
1736
            QString subAlbum = fi.suffix().toUpper();
 
1737
 
1627
1738
            if (fi.suffix().toUpper() == QString("JPEG") ||
1628
1739
                fi.suffix().toUpper() == QString("JPE"))
 
1740
            {
1629
1741
                subAlbum = QString("JPG");
 
1742
            }
 
1743
 
1630
1744
            if (fi.suffix().toUpper() == QString("TIFF"))
 
1745
            {
1631
1746
                subAlbum = QString("TIF");
 
1747
            }
 
1748
 
1632
1749
            if (fi.suffix().toUpper() == QString("MPEG") ||
1633
1750
                fi.suffix().toUpper() == QString("MPE") ||
1634
1751
                fi.suffix().toUpper() == QString("MPO"))
 
1752
            {
1635
1753
                subAlbum = QString("MPG");
 
1754
            }
1636
1755
 
1637
1756
            // See B.K.O #136927 : we need to support file system which do not
1638
1757
            // handle upper case properly.
1639
1758
            subAlbum = subAlbum.toLower();
 
1759
 
1640
1760
            if (!createAutoAlbum(downloadUrl, subAlbum, dateTime.date(), errMsg))
1641
1761
            {
1642
1762
                KMessageBox::error(this, errMsg);
1658
1778
            // make sure that we create unique names
1659
1779
            downloadUrl.addPath(downloadName);
1660
1780
            QString suggestedPath = downloadUrl.toLocalFile();
 
1781
 
1661
1782
            if (usedDownloadPaths.contains(suggestedPath))
1662
1783
            {
1663
1784
                QFileInfo fi(downloadName);
1666
1787
                pathWithoutSuffix.chop(suffix.length());
1667
1788
                QString currentVariant;
1668
1789
                int counter = 1;
 
1790
 
1669
1791
                do
 
1792
                {
1670
1793
                    currentVariant = pathWithoutSuffix + '-' + QString::number(counter++) + suffix;
 
1794
                }
1671
1795
                while (usedDownloadPaths.contains(currentVariant));
1672
1796
 
1673
1797
                usedDownloadPaths << currentVariant;
1674
1798
                downloadUrl = KUrl(currentVariant);
1675
1799
            }
1676
1800
            else
 
1801
            {
1677
1802
                usedDownloadPaths << suggestedPath;
 
1803
            }
1678
1804
        }
1679
1805
 
1680
1806
        downloadSettings.dest = downloadUrl.toLocalFile();
1684
1810
    }
1685
1811
 
1686
1812
    if (total <= 0)
 
1813
    {
1687
1814
        return;
 
1815
    }
1688
1816
 
1689
1817
    d->lastDestURL = url;
1690
1818
    d->statusProgressBar->setProgressValue(0);
1701
1829
void CameraUI::slotDownloaded(const QString& folder, const QString& file, int status)
1702
1830
{
1703
1831
    CameraIconItem* iconItem = d->view->findItem(folder, file);
 
1832
 
1704
1833
    if (iconItem)
1705
1834
    {
1706
1835
        iconItem->setDownloaded(status);
1707
1836
 
1708
1837
        //if (iconItem->isSelected())
1709
 
          //  slotItemsSelected(iconItem, true);
 
1838
        //  slotItemsSelected(iconItem, true);
1710
1839
 
1711
1840
        if (status == GPItemInfo::DownloadedYes)
1712
1841
        {
1746
1875
void CameraUI::slotSkipped(const QString& folder, const QString& file)
1747
1876
{
1748
1877
    CameraIconItem* iconItem = d->view->findItem(folder, file);
 
1878
 
1749
1879
    if (iconItem)
 
1880
    {
1750
1881
        iconItem->setDownloaded(GPItemInfo::DownloadedNo);
 
1882
    }
1751
1883
 
1752
1884
    int curr = d->statusProgressBar->progressValue();
1753
1885
    d->statusProgressBar->setProgressValue(curr+1);
1759
1891
         item = item->nextItem())
1760
1892
    {
1761
1893
        CameraIconItem* iconItem = static_cast<CameraIconItem*>(item);
 
1894
 
1762
1895
        if (iconItem->isSelected())
1763
1896
        {
1764
1897
            iconItem->setDownloaded(GPItemInfo::DownloadedYes);
1765
1898
 
1766
1899
            DownloadHistory::setDownloaded(d->controller->cameraMD5ID(),
1767
 
                iconItem->itemInfo()->name,
1768
 
                iconItem->itemInfo()->size,
1769
 
                iconItem->itemInfo()->mtime);
 
1900
                                           iconItem->itemInfo()->name,
 
1901
                                           iconItem->itemInfo()->size,
 
1902
                                           iconItem->itemInfo()->mtime);
1770
1903
        }
1771
1904
    }
1772
1905
}
1775
1908
void CameraUI::slotToggleLock()
1776
1909
{
1777
1910
    int count = 0;
 
1911
 
1778
1912
    for (IconItem* item = d->view->firstItem(); item;
1779
1913
         item = item->nextItem())
1780
1914
    {
1781
1915
        CameraIconItem* iconItem = static_cast<CameraIconItem*>(item);
 
1916
 
1782
1917
        if (iconItem->isSelected())
1783
1918
        {
1784
1919
            QString folder = iconItem->itemInfo()->folder;
1788
1923
 
1789
1924
            // If item is currently locked, unlock it.
1790
1925
            if (writePerm == 0)
 
1926
            {
1791
1927
                lock = false;
 
1928
            }
1792
1929
 
1793
1930
            d->controller->lockFile(folder, file, lock);
1794
1931
            ++count;
1808
1945
    if (status)
1809
1946
    {
1810
1947
        CameraIconItem* iconItem = d->view->findItem(folder, file);
 
1948
 
1811
1949
        if (iconItem)
1812
1950
        {
1813
1951
            iconItem->toggleLock();
1814
1952
            //if (iconItem->isSelected())
1815
 
              //  slotItemsSelected(iconItem, true);
 
1953
            //  slotItemsSelected(iconItem, true);
1816
1954
        }
1817
1955
    }
1818
1956
 
1848
1986
    for (IconItem* item = d->view->firstItem(); item; item = item->nextItem())
1849
1987
    {
1850
1988
        CameraIconItem* iconItem = dynamic_cast<CameraIconItem*>(item);
 
1989
 
1851
1990
        if (iconItem)
1852
1991
        {
1853
1992
            if (onlySelected)
1857
1996
                    if (onlyDownloaded)
1858
1997
                    {
1859
1998
                        if (iconItem->isDownloaded())
 
1999
                        {
1860
2000
                            checkItem4Deletion(iconItem, folders, files, deleteList, lockedList);
 
2001
                        }
1861
2002
                    }
1862
2003
                    else
1863
2004
                    {
1870
2011
                if (onlyDownloaded)
1871
2012
                {
1872
2013
                    if (iconItem->isDownloaded())
 
2014
                    {
1873
2015
                        checkItem4Deletion(iconItem, folders, files, deleteList, lockedList);
 
2016
                    }
1874
2017
                }
1875
2018
                else
1876
2019
                {
1890
2033
    }
1891
2034
 
1892
2035
    if (folders.isEmpty())
 
2036
    {
1893
2037
        return;
 
2038
    }
1894
2039
 
1895
2040
    QString warnMsg(i18np("About to delete this image. "
1896
2041
                          "Deleted file is unrecoverable. "
1899
2044
                          "Deleted files are unrecoverable. "
1900
2045
                          "Are you sure?",
1901
2046
                          deleteList.count()));
 
2047
 
1902
2048
    if (KMessageBox::warningContinueCancelList(this, warnMsg,
1903
 
                                               deleteList,
1904
 
                                               i18n("Warning"),
1905
 
                                               KGuiItem(i18n("Delete")))
 
2049
            deleteList,
 
2050
            i18n("Warning"),
 
2051
            KGuiItem(i18n("Delete")))
1906
2052
        ==  KMessageBox::Continue)
1907
2053
    {
1908
2054
        QStringList::iterator itFolder = folders.begin();
1949
2095
void CameraUI::slotFileView()
1950
2096
{
1951
2097
    CameraIconItem* item = d->view->firstItemSelected();
 
2098
 
1952
2099
    if (item)
 
2100
    {
1953
2101
        slotFileView(item);
 
2102
    }
1954
2103
}
1955
2104
 
1956
2105
void CameraUI::slotFileView(CameraIconItem* item)
1961
2110
void CameraUI::slotExifFromFile(const QString& folder, const QString& file)
1962
2111
{
1963
2112
    CameraIconItem* item = d->view->findItem(folder, file);
 
2113
 
1964
2114
    if (!item)
 
2115
    {
1965
2116
        return;
 
2117
    }
1966
2118
 
1967
2119
    d->rightSideBar->itemChanged(item->itemInfo(), folder + QString("/") + file,
1968
2120
                                 QByteArray(), d->view, item);
1973
2125
    CameraIconItem* item = dynamic_cast<CameraIconItem*>(d->view->currentItem());
1974
2126
 
1975
2127
    if (!item)
 
2128
    {
1976
2129
        return;
 
2130
    }
1977
2131
 
1978
2132
    KUrl url(item->itemInfo()->folder + '/' + item->itemInfo()->name);
1979
2133
 
1987
2141
    if (!exifData.isEmpty())
1988
2142
    {
1989
2143
        int i = exifData.indexOf(*exifHeader);
 
2144
 
1990
2145
        if (i != -1)
1991
2146
        {
1992
2147
            kDebug() << "Exif header found at position " << i;
2004
2159
 
2005
2160
void CameraUI::slotNewSelection(bool hasSelection)
2006
2161
{
2007
 
    if (!d->controller) return;
 
2162
    if (!d->controller)
 
2163
    {
 
2164
        return;
 
2165
    }
2008
2166
 
2009
2167
    d->downloadSelectedAction->setEnabled(hasSelection);
2010
2168
    d->downloadDelSelectedAction->setEnabled(hasSelection && d->controller->cameraDeleteSupport());
2017
2175
        // only enable "Mark as downloaded" if at least one
2018
2176
        // selected image has not been downloaded
2019
2177
        bool haveNotDownloadedItem = false;
 
2178
 
2020
2179
        for (IconItem* item = d->view->firstItem(); item;
2021
 
            item = item->nextItem())
 
2180
             item = item->nextItem())
2022
2181
        {
2023
2182
            const CameraIconItem* const iconItem = static_cast<CameraIconItem*>(item);
 
2183
 
2024
2184
            if (iconItem->isSelected())
2025
2185
            {
2026
2186
                haveNotDownloadedItem = !iconItem->isDownloaded();
 
2187
 
2027
2188
                if (haveNotDownloadedItem)
 
2189
                {
2028
2190
                    break;
 
2191
                }
2029
2192
            }
2030
2193
        }
2031
2194
 
2032
2195
        d->markAsDownloadedAction->setEnabled(haveNotDownloadedItem);
2033
2196
    }
2034
2197
    else
 
2198
    {
2035
2199
        d->markAsDownloadedAction->setEnabled(false);
 
2200
    }
2036
2201
 
2037
2202
    unsigned long fSize = 0;
2038
2203
    unsigned long dSize = 0;
2042
2207
 
2043
2208
void CameraUI::slotItemsSelected(CameraIconItem* item, bool selected)
2044
2209
{
2045
 
    if (!d->controller) return;
 
2210
    if (!d->controller)
 
2211
    {
 
2212
        return;
 
2213
    }
2046
2214
 
2047
2215
    if (selected)
2048
2216
    {
2059
2227
        }
2060
2228
    }
2061
2229
    else
 
2230
    {
2062
2231
        d->rightSideBar->slotNoCurrentItem();
 
2232
    }
2063
2233
 
2064
2234
    // update availability of actions
2065
2235
    slotNewSelection(d->view->countSelected()>0);
2073
2243
 
2074
2244
    // first stat to see if the album exists
2075
2245
    QFileInfo info(u.toLocalFile());
 
2246
 
2076
2247
    if (info.exists())
2077
2248
    {
2078
2249
        // now check if its really a directory
2079
2250
        if (info.isDir())
 
2251
        {
2080
2252
            return true;
 
2253
        }
2081
2254
        else
2082
2255
        {
2083
2256
            errMsg = i18n("A file with the same name (%1) already exists in folder %2.",
2089
2262
    // looks like the directory does not exist, try to create it
2090
2263
 
2091
2264
    PAlbum* parent = AlbumManager::instance()->findPAlbum(parentURL);
 
2265
 
2092
2266
    if (!parent)
2093
2267
    {
2094
2268
        errMsg = i18n("Failed to find Album for path '%1'.", parentURL.toLocalFile());
2095
2269
        return false;
2096
2270
    }
 
2271
 
2097
2272
    return AlbumManager::instance()->createPAlbum(parent, sub, QString(), date, QString(), errMsg);
2098
2273
}
2099
2274
 
2100
2275
void CameraUI::slotFirstItem()
2101
2276
{
2102
 
    CameraIconItem *currItem = dynamic_cast<CameraIconItem*>(d->view->firstItem());
 
2277
    CameraIconItem* currItem = dynamic_cast<CameraIconItem*>(d->view->firstItem());
2103
2278
    d->view->clearSelection();
2104
2279
    d->view->updateContents();
 
2280
 
2105
2281
    if (currItem)
2106
 
       d->view->setCurrentItem(currItem);
 
2282
    {
 
2283
        d->view->setCurrentItem(currItem);
 
2284
    }
2107
2285
}
2108
2286
 
2109
2287
void CameraUI::slotPrevItem()
2110
2288
{
2111
 
    CameraIconItem *currItem = dynamic_cast<CameraIconItem*>(d->view->currentItem());
 
2289
    CameraIconItem* currItem = dynamic_cast<CameraIconItem*>(d->view->currentItem());
2112
2290
    d->view->clearSelection();
2113
2291
    d->view->updateContents();
 
2292
 
2114
2293
    if (currItem)
2115
 
       d->view->setCurrentItem(currItem->prevItem());
 
2294
    {
 
2295
        d->view->setCurrentItem(currItem->prevItem());
 
2296
    }
2116
2297
}
2117
2298
 
2118
2299
void CameraUI::slotNextItem()
2119
2300
{
2120
 
    CameraIconItem *currItem = dynamic_cast<CameraIconItem*>(d->view->currentItem());
 
2301
    CameraIconItem* currItem = dynamic_cast<CameraIconItem*>(d->view->currentItem());
2121
2302
    d->view->clearSelection();
2122
2303
    d->view->updateContents();
 
2304
 
2123
2305
    if (currItem)
2124
 
       d->view->setCurrentItem(currItem->nextItem());
 
2306
    {
 
2307
        d->view->setCurrentItem(currItem->nextItem());
 
2308
    }
2125
2309
}
2126
2310
 
2127
2311
void CameraUI::slotLastItem()
2128
2312
{
2129
 
    CameraIconItem *currItem = dynamic_cast<CameraIconItem*>(d->view->lastItem());
 
2313
    CameraIconItem* currItem = dynamic_cast<CameraIconItem*>(d->view->lastItem());
2130
2314
    d->view->clearSelection();
2131
2315
    d->view->updateContents();
 
2316
 
2132
2317
    if (currItem)
2133
 
       d->view->setCurrentItem(currItem);
 
2318
    {
 
2319
        d->view->setCurrentItem(currItem);
 
2320
    }
2134
2321
}
2135
2322
 
2136
2323
void CameraUI::slotDonateMoney()
2189
2376
 
2190
2377
        if (d->removeFullScreenButton)
2191
2378
        {
2192
 
            QList<KToolBar *> toolbars = toolBars();
2193
 
            foreach(KToolBar *toolbar, toolbars)
 
2379
            QList<KToolBar*> toolbars = toolBars();
 
2380
            foreach (KToolBar* toolbar, toolbars)
2194
2381
            {
2195
2382
                // name is set in ui.rc XML file
2196
2383
                if (toolbar->objectName() == "ToolBar")
2219
2406
        {
2220
2407
            showToolBars();
2221
2408
 
2222
 
            QList<KToolBar *> toolbars = toolBars();
2223
 
            KToolBar *mainToolbar = 0;
2224
 
            foreach(KToolBar *toolbar, toolbars)
 
2409
            QList<KToolBar*> toolbars = toolBars();
 
2410
            KToolBar* mainToolbar = 0;
 
2411
            foreach (KToolBar* toolbar, toolbars)
2225
2412
            {
2226
2413
                if (toolbar->objectName() == "ToolBar")
2227
2414
                {
2254
2441
void CameraUI::slotEscapePressed()
2255
2442
{
2256
2443
    if (d->fullScreen)
 
2444
    {
2257
2445
        d->fullScreenAction->activate(QAction::Trigger);
 
2446
    }
2258
2447
}
2259
2448
 
2260
2449
void CameraUI::showToolBars()
2261
2450
{
2262
 
    QList<KToolBar *> toolbars = toolBars();
2263
 
    foreach(KToolBar *toolbar, toolbars)
 
2451
    QList<KToolBar*> toolbars = toolBars();
 
2452
    foreach (KToolBar* toolbar, toolbars)
2264
2453
    {
2265
2454
        toolbar->show();
2266
2455
    }
2268
2457
 
2269
2458
void CameraUI::hideToolBars()
2270
2459
{
2271
 
    QList<KToolBar *> toolbars = toolBars();
2272
 
    foreach(KToolBar *toolbar, toolbars)
 
2460
    QList<KToolBar*> toolbars = toolBars();
 
2461
    foreach (KToolBar* toolbar, toolbars)
2273
2462
    {
2274
2463
        toolbar->hide();
2275
2464
    }
2309
2498
{
2310
2499
    QStringList themes(ThemeEngine::instance()->themeNames());
2311
2500
    int index = themes.indexOf(AlbumSettings::instance()->getCurrentTheme());
 
2501
 
2312
2502
    if (index == -1)
 
2503
    {
2313
2504
        index = themes.indexOf(i18n("Default"));
 
2505
    }
2314
2506
 
2315
2507
    d->themeMenuAction->setCurrentItem(index);
2316
2508
}
2339
2531
    d->albumLibraryFreeSpace->setPaths(CollectionManager::instance()->allAvailableAlbumRootPaths());
2340
2532
}
2341
2533
 
2342
 
void CameraUI::slotCollectionLocationStatusChanged(const CollectionLocation &, int)
 
2534
void CameraUI::slotCollectionLocationStatusChanged(const CollectionLocation&, int)
2343
2535
{
2344
2536
    refreshCollectionFreeSpace();
2345
2537
}