[Digikam-devel] [Bug 139519] Digikam silently fails to import when out of disc space
Gilles Caulier
caulier.gilles at gmail.com
Sat Sep 1 16:02:48 BST 2007
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=139519
caulier.gilles gmail com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
------- Additional Comments From caulier.gilles gmail com 2007-09-01 17:02 -------
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,
More information about the Digikam-devel
mailing list