[Digikam-devel] [Bug 139519] Digikam silently fails to import when out of disc space
Gilles Caulier
caulier.gilles at gmail.com
Fri Aug 31 15:48:07 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
------- Additional Comments From caulier.gilles gmail com 2007-08-31 16:48 -------
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();
More information about the Digikam-devel
mailing list