Summary: | Digikam silently fails to import when out of disc space | ||
---|---|---|---|
Product: | [Applications] digikam | Reporter: | Stephen Bridges <widget-bugs> |
Component: | Import-MainView | Assignee: | Digikam Developers <digikam-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 0.9.0 | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | 0.9.3 | |
Sentry Crash Report: |
Description
Stephen Bridges
2007-01-02 20:31:02 UTC
SVN commit 706910 by cgilles: digiKam from KDE3 branch : Camera GUI improvements. - Add a new bargraph to report free space available on Album library path before and after to download pictures from camera. - If free space available is not enough, display a error message if user try to download. CCBUGS: 139519 CCBUGS: 136927 M +1 -1 Makefile.am M +39 -1 cameraiconview.cpp M +2 -0 cameraiconview.h M +59 -23 cameraui.cpp M +3 -1 cameraui.h A freespacewidget.cpp [License: GPL] A freespacewidget.h [License: GPL] --- branches/extragear/kde3/graphics/digikam/utilities/cameragui/Makefile.am #706909:706910 @@ -11,7 +11,7 @@ animwidget.cpp renamecustomizer.cpp \ dkcamera.cpp umscamera.cpp gpiteminfo.cpp \ camerainfodialog.cpp albumselectdialog.cpp \ - camerafolderdialog.cpp + camerafolderdialog.cpp freespacewidget.cpp libcameragui_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) --- branches/extragear/kde3/graphics/digikam/utilities/cameragui/cameraiconview.cpp #706909:706910 @@ -709,5 +709,43 @@ return downloaded; } +void CameraIconView::itemsSelectionSizeInfo(unsigned long& fSize, unsigned long& dSize) +{ + fSize = 0; // Files size + dSize = 0; // Estimated space requires to download and process files. + for (IconItem* item = firstItem(); item; item = item->nextItem()) + { + if (item->isSelected()) + { + CameraIconViewItem* iconItem = static_cast<CameraIconViewItem*>(item); + fSize += iconItem->itemInfo()->size; + + if (iconItem->itemInfo()->mime == QString("image/jpeg")) + { + if (d->cameraUI->convertLosslessJpegFiles()) + { + // Estimated size is aroud 5 x original size when JPEG=>PNG. + dSize += iconItem->itemInfo()->size*5; + } + else if (d->cameraUI->autoRotateJpegFiles()) + { + // We need a double size to perform rotation. + dSize += iconItem->itemInfo()->size*2; + } + else + { + // Real file size is added. + dSize += iconItem->itemInfo()->size; + } + } + else + dSize += iconItem->itemInfo()->size; + + } + } + + fSize /= 1024; + dSize /= 1024; +} + } // namespace Digikam - --- branches/extragear/kde3/graphics/digikam/utilities/cameragui/cameraiconview.h #706909:706910 @@ -84,6 +84,8 @@ virtual QRect itemRect() const; QString defaultDownloadName(CameraIconViewItem *item); + + void itemsSelectionSizeInfo(unsigned long& fSize, unsigned long& dSize); signals: --- branches/extragear/kde3/graphics/digikam/utilities/cameragui/cameraui.cpp #706909:706910 @@ -102,6 +102,7 @@ #include "albumselectdialog.h" #include "renamecustomizer.h" #include "animwidget.h" +#include "freespacewidget.h" #include "camerafolderdialog.h" #include "camerainfodialog.h" #include "cameraiconview.h" @@ -219,6 +220,8 @@ AnimWidget *anim; ImagePropertiesSideBarCamGui *rightSidebar; + + FreeSpaceWidget *freeSpaceWidget; }; CameraUI::CameraUI(QWidget* /*parent*/, const QString& cameraTitle, @@ -233,19 +236,13 @@ i18n("&Images")) { d = new CameraUIPriv; - d->lastAccess = lastAccess; - d->cameraTitle = cameraTitle; + d->lastAccess = lastAccess; + d->cameraTitle = cameraTitle; setHelp("camerainterface.anchor", "digikam"); // ------------------------------------------------------------------------- - QGridLayout* viewBoxLayout = new QGridLayout(plainPage(), 2, 5); - viewBoxLayout->setColStretch( 0, 0 ); - viewBoxLayout->setColStretch( 1, 0 ); - viewBoxLayout->setColStretch( 2, 3 ); - viewBoxLayout->setColStretch( 3, 1 ); - viewBoxLayout->setColStretch( 4, 0 ); - viewBoxLayout->setColStretch( 5, 0 ); + QGridLayout* viewBoxLayout = new QGridLayout(plainPage(), 2, 7); QHBox* widget = new QHBox(plainPage()); d->splitter = new QSplitter(widget); @@ -352,11 +349,6 @@ i18n("On the Fly Operations (JPEG only)")); d->rightSidebar->appendTab(d->advBox, SmallIcon("configure"), i18n("Settings")); - - // ------------------------------------------------------------------------- - - viewBoxLayout->addMultiCellWidget(widget, 0, 0, 0, 5); - viewBoxLayout->setRowSpacing(1, spacingHint()); d->rightSidebar->loadViewState(); // ------------------------------------------------------------------------- @@ -384,20 +376,35 @@ QString directory = KGlobal::dirs()->findResourceDir("logo-digikam", "logo-digikam.png"); pixmapLogo->setPixmap( QPixmap( directory + "logo-digikam.png" ) ); pixmapLogo->setFocusPolicy(QWidget::NoFocus); - + d->anim = new AnimWidget(frame, pixmapLogo->height()-2); - + layout->setMargin(0); layout->setSpacing(0); layout->addWidget( pixmapLogo ); layout->addWidget( d->anim ); + d->freeSpaceWidget = new FreeSpaceWidget(plainPage(), 100, + KURL(AlbumSettings::instance()->getAlbumLibraryPath())); + + viewBoxLayout->addMultiCellWidget(widget, 0, 0, 0, 7); viewBoxLayout->addMultiCellWidget(d->cancelBtn, 2, 2, 0, 0); viewBoxLayout->addMultiCellWidget(d->status, 2, 2, 2, 2); viewBoxLayout->addMultiCellWidget(d->progress, 2, 2, 3, 3); - viewBoxLayout->addMultiCellWidget(frame, 2, 2, 5, 5); + viewBoxLayout->addMultiCellWidget(d->freeSpaceWidget, 2, 2, 5, 5); + viewBoxLayout->addMultiCellWidget(frame, 2, 2, 7, 7); + viewBoxLayout->setRowSpacing(1, spacingHint()); viewBoxLayout->setColSpacing(1, spacingHint()); viewBoxLayout->setColSpacing(4, spacingHint()); + viewBoxLayout->setColSpacing(6, spacingHint()); + viewBoxLayout->setColStretch( 0, 0 ); + viewBoxLayout->setColStretch( 1, 0 ); + viewBoxLayout->setColStretch( 2, 3 ); + viewBoxLayout->setColStretch( 3, 1 ); + viewBoxLayout->setColStretch( 4, 0 ); + viewBoxLayout->setColStretch( 5, 0 ); + viewBoxLayout->setColStretch( 6, 0 ); + viewBoxLayout->setColStretch( 7, 0 ); // ------------------------------------------------------------------------- @@ -512,12 +519,17 @@ connect(d->rightSidebar, SIGNAL(signalLastItem()), this, SLOT(slotLastItem())); - // -- Read settings -------------------------------------------------- + // ------------------------------------------------------------------------- + + connect(d->cancelBtn, SIGNAL(clicked()), + this, SLOT(slotCancelButton())); + // -- Read settings & Check free space availability on album root path ----- + readSettings(); + + // -- camera controller ---------------------------------------------------- - // -- camera controller ----------------------------------------------- - d->controller = new CameraController(this, d->cameraTitle, model, port, path); connect(d->controller, SIGNAL(signalConnected(bool)), @@ -565,8 +577,7 @@ connect(d->controller, SIGNAL(signalUploaded(const GPItemInfo&)), this, SLOT(slotUploaded(const GPItemInfo&))); - connect(d->cancelBtn, SIGNAL(clicked()), - this, SLOT(slotCancelButton())); + // ------------------------------------------------------------------------- d->view->setFocus(); QTimer::singleShot(0, d->controller, SLOT(slotConnect())); @@ -650,6 +661,11 @@ return d->convertJpegCheck->isChecked(); } +bool CameraUI::autoRotateJpegFiles() const +{ + return d->autoRotateCheck->isChecked(); +} + QString CameraUI::losslessFormat() { return d->losslessFormat->currentText(); @@ -1086,6 +1102,22 @@ if (!onlySelected) d->view->slotSelectAll(); + // See B.K.O #139519: Always check free space available before to + // download items selection from camera. + unsigned long fSize = 0; + unsigned long dSize = 0; + d->view->itemsSelectionSizeInfo(fSize, dSize); + if (d->freeSpaceWidget->isValid() && (dSize >= d->freeSpaceWidget->kBAvail())) + { + KMessageBox::error(this, i18n("There is no enough free space on Album Library Path " + "to download and process selected pictures from camera.\n\n" + "Estimated space require: %1\n" + "Available free space: %2") + .arg(KIO::convertSizeFromKB(dSize)) + .arg(KIO::convertSizeFromKB(d->freeSpaceWidget->kBAvail()))); + return; + } + QString newDirName; IconItem* firstItem = d->view->firstItem(); if (firstItem) @@ -1552,6 +1584,11 @@ d->downloadMenu->setItemEnabled(0, hasSelection); d->downloadMenu->setItemEnabled(2, hasSelection); } + + unsigned long fSize = 0; + unsigned long dSize = 0; + d->view->itemsSelectionSizeInfo(fSize, dSize); + d->freeSpaceWidget->setEstimatedDSizeKb(dSize); } void CameraUI::slotItemsSelected(CameraIconViewItem* item, bool selected) @@ -1706,4 +1743,3 @@ } } // namespace Digikam - --- branches/extragear/kde3/graphics/digikam/utilities/cameragui/cameraui.h #706909:706910 @@ -61,7 +61,9 @@ bool isBusy() const; bool isClosed() const; - // Get status of JPEG conversion files to lossless format during download. + bool autoRotateJpegFiles() const; + + /** Get status of JPEG conversion files to lossless format during download.*/ bool convertLosslessJpegFiles() const; QString losslessFormat(); To Stephen, Normally your problem is solved now in current implementation of digiKam dedicaced to KDE3 (next 0.9.3 release). To All, I will be happy if somebody can test this patch. Thanks in advance... To Arnd, Backport this patch to KDE4 implemention is require before to close this file. Gilles SVN commit 707338 by cgilles: digiKam from trunk (KDE4) : backport commits #706910 from KDE3 branch BUG: 139519 CCBUGS: 136927 M +0 -4 animwidget.cpp M +39 -0 cameraiconview.cpp M +2 -0 cameraiconview.h M +35 -0 cameraui.cpp M +3 -1 cameraui.h M +3 -2 cameraui.rc M +9 -6 freespacewidget.cpp --- trunk/extragear/graphics/digikam/utilities/cameragui/animwidget.cpp #707337:707338 @@ -30,10 +30,6 @@ #include <QColor> #include <QTimer> -// KDE includes. - -#include <ktoolbar.h> - // Local includes. #include "animwidget.h" --- trunk/extragear/graphics/digikam/utilities/cameragui/cameraiconview.cpp #707337:707338 @@ -721,4 +721,43 @@ return downloaded; } +void CameraIconView::itemsSelectionSizeInfo(unsigned long& fSize, unsigned long& dSize) +{ + fSize = 0; // Files size + dSize = 0; // Estimated space requires to download and process files. + for (IconItem* item = firstItem(); item; item = item->nextItem()) + { + if (item->isSelected()) + { + CameraIconViewItem* iconItem = static_cast<CameraIconViewItem*>(item); + fSize += iconItem->itemInfo()->size; + + if (iconItem->itemInfo()->mime == QString("image/jpeg")) + { + if (d->cameraUI->convertLosslessJpegFiles()) + { + // Estimated size is aroud 5 x original size when JPEG=>PNG. + dSize += iconItem->itemInfo()->size*5; + } + else if (d->cameraUI->autoRotateJpegFiles()) + { + // We need a double size to perform rotation. + dSize += iconItem->itemInfo()->size*2; + } + else + { + // Real file size is added. + dSize += iconItem->itemInfo()->size; + } + } + else + dSize += iconItem->itemInfo()->size; + + } + } + + fSize /= 1024; + dSize /= 1024; +} + } // namespace Digikam --- trunk/extragear/graphics/digikam/utilities/cameragui/cameraiconview.h #707337:707338 @@ -88,6 +88,8 @@ QString defaultDownloadName(CameraIconViewItem *item); + void itemsSelectionSizeInfo(unsigned long& fSize, unsigned long& dSize); + signals: void signalSelected(CameraIconViewItem*, bool); --- trunk/extragear/graphics/digikam/utilities/cameragui/cameraui.cpp #707337:707338 @@ -106,6 +106,7 @@ #include "albumselectdialog.h" #include "renamecustomizer.h" #include "animwidget.h" +#include "freespacewidget.h" #include "collectionscanner.h" #include "collectionmanager.h" #include "camerafolderdialog.h" @@ -187,6 +188,7 @@ donateMoneyAction = 0; cameraCancelAction = 0; imageViewAction = 0; + freeSpaceWidget = 0; } bool busy; @@ -261,6 +263,8 @@ StatusZoomBar *statusZoomBar; StatusProgressBar *statusProgressBar; StatusNavigateBar *statusNavigateBar; + + FreeSpaceWidget *freeSpaceWidget; }; CameraUI::CameraUI(QWidget* parent, const QString& cameraTitle, @@ -562,6 +566,11 @@ // --------------------------------------------------------------------------------- + d->freeSpaceWidget = new FreeSpaceWidget(this, 100); + QWidgetAction *freeSpaceAction = new QWidgetAction(this); + freeSpaceAction->setDefaultWidget(d->freeSpaceWidget); + actionCollection()->addAction("freespace_action", freeSpaceAction); + DLogoAction *logoAction = new DLogoAction(this); actionCollection()->addAction("logo_action", logoAction); @@ -789,6 +798,11 @@ return d->closed; } +bool CameraUI::autoRotateJpegFiles() const +{ + return d->autoRotateCheck->isChecked(); +} + bool CameraUI::convertLosslessJpegFiles() const { return d->convertJpegCheck->isChecked(); @@ -1209,6 +1223,22 @@ if (!onlySelected) d->view->slotSelectAll(); + // See B.K.O #139519: Always check free space available before to + // download items selection from camera. + unsigned long fSize = 0; + unsigned long dSize = 0; + d->view->itemsSelectionSizeInfo(fSize, dSize); + if (d->freeSpaceWidget->isValid() && (dSize >= d->freeSpaceWidget->kBAvail())) + { + KMessageBox::error(this, i18n("There is no enough free space on Album Library Path " + "to download and process selected pictures from camera.\n\n" + "Estimated space require: %1\n" + "Available free space: %2", + KIO::convertSizeFromKiB(dSize)), + KIO::convertSizeFromKiB(d->freeSpaceWidget->kBAvail())); + return; + } + QString newDirName; IconItem* firstItem = d->view->firstItem(); if (firstItem) @@ -1687,6 +1717,11 @@ d->deleteSelectedAction->setEnabled(hasSelection); d->imageViewAction->setEnabled(hasSelection); } + + unsigned long fSize = 0; + unsigned long dSize = 0; + d->view->itemsSelectionSizeInfo(fSize, dSize); + d->freeSpaceWidget->setEstimatedDSizeKb(dSize); } void CameraUI::slotItemsSelected(CameraIconViewItem* item, bool selected) --- trunk/extragear/graphics/digikam/utilities/cameragui/cameraui.h #707337:707338 @@ -64,7 +64,9 @@ bool isBusy() const; bool isClosed() const; - // Get status of JPEG conversion files to lossless format during download. + bool autoRotateJpegFiles() const; + + /** Get status of JPEG conversion files to lossless format during download.*/ bool convertLosslessJpegFiles() const; QString losslessFormat(); --- trunk/extragear/graphics/digikam/utilities/cameragui/cameraui.rc #707337:707338 @@ -1,5 +1,5 @@ <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> -<gui version="8" name="cameraui" > +<gui version="9" name="cameraui" > <MenuBar> @@ -67,7 +67,8 @@ <Action name="cameraui_imageupload" /> <Action name="cameraui_imagelock" /> <Merge /> - <WeakSeparator/> + <WeakSeparator/> + <Action name="freespace_action" /> <Action name="logo_action" /> <Action name="anim_action" /> </ToolBar> --- trunk/extragear/graphics/digikam/utilities/cameragui/freespacewidget.cpp #707337:707338 @@ -194,12 +194,15 @@ void FreeSpaceWidget::slotTimeout() { - KMountPoint::Ptr mp = KMountPoint::currentMountPoints(). - findByPath(AlbumSettings::componentData()->getAlbumLibraryPath()); - KDiskFreeSpace *job = new KDiskFreeSpace; - connect(job, SIGNAL(foundMountPoint(QString, quint64, quint64, quint64)), - this, SLOT(slotAvailableFreeSpace(QString, quint64, quint64, quint64))); - job->readDF(mp->mountPoint()); + QString path = AlbumSettings::componentData()->getAlbumLibraryPath(); + KMountPoint::Ptr mp = KMountPoint::currentMountPoints().findByPath(path); + if (mp) + { + KDiskFreeSpace *job = new KDiskFreeSpace; + connect(job, SIGNAL(foundMountPoint(QString, quint64, quint64, quint64)), + this, SLOT(slotAvailableFreeSpace(QString, quint64, quint64, quint64))); + job->readDF(mp->mountPoint()); + } } void FreeSpaceWidget::slotAvailableFreeSpace(QString mountPoint, quint64 kBSize, |