1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : Camera interface
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>
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)
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.
24
* ============================================================ */
1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : Camera interface
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>
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)
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.
24
* ============================================================ */
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)
141
141
setXMLFile("cameraui.rc");
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"));
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>"));
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());
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 "
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."));
325
326
d->advBox->addItem(onFlyBox, SmallIcon("system-run"), i18n("On the Fly Operations (JPEG only)"),
326
327
QString("OnFlyBox"), true);
538
539
// -- Keyboard-only actions added to <MainWindow> ------------------------------
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
// -------------------------------------------------------------------------
632
633
connect(d->zoomBar, SIGNAL(signalZoomSliderChanged(int)),
633
this, SLOT(slotZoomSliderChanged(int)));
634
this, SLOT(slotZoomSliderChanged(int)));
635
636
connect(this, SIGNAL(signalWindowHasMoved()),
636
637
d->zoomBar, SLOT(slotUpdateTrackerPos()));
638
639
// -------------------------------------------------------------------------
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)));
643
644
connect(AlbumSettings::instance(), SIGNAL(setupChanged()),
644
645
this, SLOT(slotSidebarTabTitleStyleChanged()));
843
844
void CameraUI::refreshFreeSpace()
845
846
if (d->controller->cameraDriverType() == DKCamera::GPhotoDriver)
846
848
d->controller->getFreeSpace();
848
852
d->cameraFreeSpace->refresh();
851
856
void CameraUI::closeEvent(QCloseEvent* e)
853
858
if (dialogClosed())
859
void CameraUI::moveEvent(QMoveEvent *e)
868
void CameraUI::moveEvent(QMoveEvent* e)
862
871
emit signalWindowHasMoved();
1045
1067
d->decreaseThumbsAction->setEnabled(true);
1047
1069
if (d->view->thumbnailSize() == ThumbnailSize::Small)
1048
1071
d->decreaseThumbsAction->setEnabled(false);
1050
1074
if (d->view->thumbnailSize() == ThumbnailSize::Huge)
1051
1076
d->increaseThumbsAction->setEnabled(false);
1054
1080
void CameraUI::slotConnected(bool val)
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()));
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)
1094
QTimer::singleShot(0, d->controller, SLOT(slotConnect()));
1078
1108
void CameraUI::slotFolderList(const QStringList& folderList)
1083
1115
d->statusProgressBar->setProgressValue(0);
1084
1116
d->statusProgressBar->setProgressTotalSteps(0);
1086
1118
d->cameraFolderList = folderList;
1087
1120
for (QStringList::const_iterator it = folderList.constBegin();
1088
1121
it != folderList.constEnd(); ++it)
1136
1179
QStringList list = settings->getAllFileFilter().toLower().split(' ');
1138
1181
QMultiMap<QDateTime, GPItemInfo> map;
1139
CameraIconItem *citem = static_cast<CameraIconItem*>(d->view->firstItem());
1182
CameraIconItem* citem = static_cast<CameraIconItem*>(d->view->firstItem());
1142
1186
info.setFile(citem->itemInfo()->name);
1143
1187
map.insertMulti(citem->itemInfo()->mtime, *citem->itemInfo());
1147
1191
GPItemInfoList::iterator it = d->filesToBeAdded.begin();
1148
1193
while (it != d->filesToBeAdded.end())
1150
1195
info.setFile((*it).name);
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())))
1155
1201
map.insertMulti((*it).mtime, *it);
1157
1204
it = d->filesToBeAdded.erase(it);
1160
1207
citem = static_cast<CameraIconItem*>(d->view->firstItem());
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);
1190
if (lastPhotoFirst) --it;
1193
1246
d->view->addItem(item);
1194
1247
itemsList.append(QStringList() << item.folder << item.name);
1196
if (!lastPhotoFirst) it++;
1249
if (!lastPhotoFirst)
1198
while((lastPhotoFirst ? it != _map.begin() : it != _map.end()));
1254
while ((lastPhotoFirst ? it != _map.begin() : it != _map.end()));
1200
1256
d->controller->getThumbnails(itemsList);
1205
1261
saveSettings();
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;
1212
1269
info.setFile(item->itemInfo()->name);
1213
1270
map.insertMulti(item->itemInfo()->mtime, *item->itemInfo());
1285
1345
QString file = item.url().fileName();
1286
1346
QString folder = item.url().toLocalFile().remove(QString("/") + file);
1287
1347
QImage thumb = pix.toImage();
1288
1349
if (thumb.isNull())
1290
1351
// This call must be run outside Camera Controller thread.
1291
1352
thumb = d->controller->mimeTypeThumbnail(file).toImage();
1293
1355
d->view->setThumbnail(folder, file, thumb);
1309
1371
void CameraUI::slotCapture()
1314
CaptureDlg *captureDlg = new CaptureDlg(this, d->controller, d->cameraTitle);
1378
CaptureDlg* captureDlg = new CaptureDlg(this, d->controller, d->cameraTitle);
1315
1379
captureDlg->show();
1318
1382
void CameraUI::slotInformation()
1323
1389
d->controller->getCameraInformation();
1326
1392
void CameraUI::slotCameraInformation(const QString& summary, const QString& manual, const QString& about)
1328
CameraInfoDialog *infoDlg = new CameraInfoDialog(this, summary, manual, about);
1394
CameraInfoDialog* infoDlg = new CameraInfoDialog(this, summary, manual, about);
1329
1395
infoDlg->show();
1332
1398
void CameraUI::slotUpload()
1337
1405
QString fileformats;
1355
1423
kDebug() << "fileformats=" << fileformats;
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"));
1359
1428
if (!urls.isEmpty())
1360
1430
slotUploadItems(urls);
1363
1434
void CameraUI::slotUploadItems(const KUrl::List& urls)
1368
1441
if (urls.isEmpty())
1371
1446
if (d->cameraFreeSpace->isValid())
1373
1448
// Check if space require to upload new items in camera is enough.
1374
1449
quint64 totalKbSize = 0;
1375
1451
for (KUrl::List::const_iterator it = urls.constBegin() ; it != urls.constEnd() ; ++it)
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())));
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());
1397
1473
if (dlg->exec() != QDialog::Accepted)
1403
1479
// since we access members here, check if the pointer is still valid
1407
1485
QString cameraFolder = dlg->selectedFolderPath();
1409
1487
for (KUrl::List::const_iterator it = urls.constBegin(); it != urls.constEnd(); ++it)
1411
1489
QFileInfo fi((*it).toLocalFile());
1412
if (!fi.exists()) continue;
1413
if (fi.isDir()) continue;
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);
1432
1520
d->controller->upload(fi, name + ext, cameraFolder);
1465
1555
slotDownload(false, true);
1468
void CameraUI::slotDownload(bool onlySelected, bool deleteAfter, Album *album)
1558
void CameraUI::slotDownload(bool onlySelected, bool deleteAfter, Album* album)
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)
1474
1565
d->view->slotSelectAll();
1476
1568
QString newDirName;
1477
1569
IconItem* firstItem = d->view->firstItem();
1480
1573
CameraIconItem* iconItem = static_cast<CameraIconItem*>(firstItem);
1482
1575
QDateTime dateTime = iconItem->itemInfo()->mtime;
1484
switch(d->folderDateFormat->currentIndex())
1577
switch (d->folderDateFormat->currentIndex())
1486
1579
case CameraUIPriv::TextDateFormat:
1487
1580
newDirName = dateTime.date().toString(Qt::TextDate);
1502
1595
AlbumManager* man = AlbumManager::instance();
1504
1597
album = man->currentAlbum();
1505
1599
if (album && album->type() != Album::PHYSICAL)
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);
1517
PAlbum *pAlbum = dynamic_cast<PAlbum*>(album);
1518
if (!pAlbum) return;
1615
PAlbum* pAlbum = dynamic_cast<PAlbum*>(album);
1520
1622
// -- Check disk space ------------------------
1526
1628
d->view->itemsSelectionSizeInfo(fSize, dSize);
1527
1629
QString albumRootPath = pAlbum->albumRootPath();
1528
1630
unsigned long kBAvail = d->albumLibraryFreeSpace->kBAvail(albumRootPath);
1529
1632
if (dSize >= kBAvail)
1531
1634
KGuiItem cont = KStandardGuiItem::cont();
1533
1636
KGuiItem cancel = KStandardGuiItem::cancel();
1534
1637
cancel.setText(i18n("Cancel Download"));
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"),
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"),
1545
1649
if (result == KMessageBox::No)
1549
1655
// -- Prepare downloading of camera items ------------------------
1570
1676
QSet<QString> usedDownloadPaths;
1571
1677
bool lastPhotoFirst = d->lastPhotoFirstAction->isChecked();
1572
1679
for (IconItem* item = (lastPhotoFirst ? d->view->lastItem() : d->view->firstItem()); item;
1573
1680
item = (lastPhotoFirst ? item->prevItem() : item->nextItem()))
1575
1682
if (onlySelected && !(item->isSelected()))
1578
1687
CameraIconItem* iconItem = static_cast<CameraIconItem*>(item);
1579
1688
downloadSettings.folder = iconItem->itemInfo()->folder;
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();
1609
1719
if (!createAutoAlbum(downloadUrl, dirName, dateTime.date(), errMsg))
1611
1721
KMessageBox::error(this, errMsg);
1624
1734
QFileInfo fi(downloadName);
1626
1736
QString subAlbum = fi.suffix().toUpper();
1627
1738
if (fi.suffix().toUpper() == QString("JPEG") ||
1628
1739
fi.suffix().toUpper() == QString("JPE"))
1629
1741
subAlbum = QString("JPG");
1630
1744
if (fi.suffix().toUpper() == QString("TIFF"))
1631
1746
subAlbum = QString("TIF");
1632
1749
if (fi.suffix().toUpper() == QString("MPEG") ||
1633
1750
fi.suffix().toUpper() == QString("MPE") ||
1634
1751
fi.suffix().toUpper() == QString("MPO"))
1635
1753
subAlbum = QString("MPG");
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();
1640
1760
if (!createAutoAlbum(downloadUrl, subAlbum, dateTime.date(), errMsg))
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();
1661
1782
if (usedDownloadPaths.contains(suggestedPath))
1663
1784
QFileInfo fi(downloadName);
1666
1787
pathWithoutSuffix.chop(suffix.length());
1667
1788
QString currentVariant;
1668
1789
int counter = 1;
1670
1793
currentVariant = pathWithoutSuffix + '-' + QString::number(counter++) + suffix;
1671
1795
while (usedDownloadPaths.contains(currentVariant));
1673
1797
usedDownloadPaths << currentVariant;
1674
1798
downloadUrl = KUrl(currentVariant);
1677
1802
usedDownloadPaths << suggestedPath;
1680
1806
downloadSettings.dest = downloadUrl.toLocalFile();
1701
1829
void CameraUI::slotDownloaded(const QString& folder, const QString& file, int status)
1703
1831
CameraIconItem* iconItem = d->view->findItem(folder, file);
1706
1835
iconItem->setDownloaded(status);
1708
1837
//if (iconItem->isSelected())
1709
// slotItemsSelected(iconItem, true);
1838
// slotItemsSelected(iconItem, true);
1711
1840
if (status == GPItemInfo::DownloadedYes)
1746
1875
void CameraUI::slotSkipped(const QString& folder, const QString& file)
1748
1877
CameraIconItem* iconItem = d->view->findItem(folder, file);
1750
1881
iconItem->setDownloaded(GPItemInfo::DownloadedNo);
1752
1884
int curr = d->statusProgressBar->progressValue();
1753
1885
d->statusProgressBar->setProgressValue(curr+1);
1759
1891
item = item->nextItem())
1761
1893
CameraIconItem* iconItem = static_cast<CameraIconItem*>(item);
1762
1895
if (iconItem->isSelected())
1764
1897
iconItem->setDownloaded(GPItemInfo::DownloadedYes);
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);
1775
1908
void CameraUI::slotToggleLock()
1778
1912
for (IconItem* item = d->view->firstItem(); item;
1779
1913
item = item->nextItem())
1781
1915
CameraIconItem* iconItem = static_cast<CameraIconItem*>(item);
1782
1917
if (iconItem->isSelected())
1784
1919
QString folder = iconItem->itemInfo()->folder;
1810
1947
CameraIconItem* iconItem = d->view->findItem(folder, file);
1813
1951
iconItem->toggleLock();
1814
1952
//if (iconItem->isSelected())
1815
// slotItemsSelected(iconItem, true);
1953
// slotItemsSelected(iconItem, true);
1899
2044
"Deleted files are unrecoverable. "
1900
2045
"Are you sure?",
1901
2046
deleteList.count()));
1902
2048
if (KMessageBox::warningContinueCancelList(this, warnMsg,
1905
KGuiItem(i18n("Delete")))
2051
KGuiItem(i18n("Delete")))
1906
2052
== KMessageBox::Continue)
1908
2054
QStringList::iterator itFolder = folders.begin();
1961
2110
void CameraUI::slotExifFromFile(const QString& folder, const QString& file)
1963
2112
CameraIconItem* item = d->view->findItem(folder, file);
1967
2119
d->rightSideBar->itemChanged(item->itemInfo(), folder + QString("/") + file,
1968
2120
QByteArray(), d->view, item);
2005
2160
void CameraUI::slotNewSelection(bool hasSelection)
2007
if (!d->controller) return;
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;
2020
2179
for (IconItem* item = d->view->firstItem(); item;
2021
item = item->nextItem())
2180
item = item->nextItem())
2023
2182
const CameraIconItem* const iconItem = static_cast<CameraIconItem*>(item);
2024
2184
if (iconItem->isSelected())
2026
2186
haveNotDownloadedItem = !iconItem->isDownloaded();
2027
2188
if (haveNotDownloadedItem)
2032
2195
d->markAsDownloadedAction->setEnabled(haveNotDownloadedItem);
2035
2199
d->markAsDownloadedAction->setEnabled(false);
2037
2202
unsigned long fSize = 0;
2038
2203
unsigned long dSize = 0;
2074
2244
// first stat to see if the album exists
2075
2245
QFileInfo info(u.toLocalFile());
2076
2247
if (info.exists())
2078
2249
// now check if its really a directory
2079
2250
if (info.isDir())
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
2091
2264
PAlbum* parent = AlbumManager::instance()->findPAlbum(parentURL);
2094
2268
errMsg = i18n("Failed to find Album for path '%1'.", parentURL.toLocalFile());
2097
2272
return AlbumManager::instance()->createPAlbum(parent, sub, QString(), date, QString(), errMsg);
2100
2275
void CameraUI::slotFirstItem()
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();
2106
d->view->setCurrentItem(currItem);
2283
d->view->setCurrentItem(currItem);
2109
2287
void CameraUI::slotPrevItem()
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();
2115
d->view->setCurrentItem(currItem->prevItem());
2295
d->view->setCurrentItem(currItem->prevItem());
2118
2299
void CameraUI::slotNextItem()
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();
2124
d->view->setCurrentItem(currItem->nextItem());
2307
d->view->setCurrentItem(currItem->nextItem());
2127
2311
void CameraUI::slotLastItem()
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();
2133
d->view->setCurrentItem(currItem);
2319
d->view->setCurrentItem(currItem);
2136
2323
void CameraUI::slotDonateMoney()
2190
2377
if (d->removeFullScreenButton)
2192
QList<KToolBar *> toolbars = toolBars();
2193
foreach(KToolBar *toolbar, toolbars)
2379
QList<KToolBar*> toolbars = toolBars();
2380
foreach (KToolBar* toolbar, toolbars)
2195
2382
// name is set in ui.rc XML file
2196
2383
if (toolbar->objectName() == "ToolBar")
2220
2407
showToolBars();
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)
2226
2413
if (toolbar->objectName() == "ToolBar")
2254
2441
void CameraUI::slotEscapePressed()
2256
2443
if (d->fullScreen)
2257
2445
d->fullScreenAction->activate(QAction::Trigger);
2260
2449
void CameraUI::showToolBars()
2262
QList<KToolBar *> toolbars = toolBars();
2263
foreach(KToolBar *toolbar, toolbars)
2451
QList<KToolBar*> toolbars = toolBars();
2452
foreach (KToolBar* toolbar, toolbars)
2265
2454
toolbar->show();
2269
2458
void CameraUI::hideToolBars()
2271
QList<KToolBar *> toolbars = toolBars();
2272
foreach(KToolBar *toolbar, toolbars)
2460
QList<KToolBar*> toolbars = toolBars();
2461
foreach (KToolBar* toolbar, toolbars)
2274
2463
toolbar->hide();
2310
2499
QStringList themes(ThemeEngine::instance()->themeNames());
2311
2500
int index = themes.indexOf(AlbumSettings::instance()->getCurrentTheme());
2312
2502
if (index == -1)
2313
2504
index = themes.indexOf(i18n("Default"));
2315
2507
d->themeMenuAction->setCurrentItem(index);
2339
2531
d->albumLibraryFreeSpace->setPaths(CollectionManager::instance()->allAvailableAlbumRootPaths());
2342
void CameraUI::slotCollectionLocationStatusChanged(const CollectionLocation &, int)
2534
void CameraUI::slotCollectionLocationStatusChanged(const CollectionLocation&, int)
2344
2536
refreshCollectionFreeSpace();