SVN commit 708726 by cgilles:
digiKam from trunk (KDE4) : Camera gui is now able to display the free space avaialble on camera media. CCMAIL: [hidden email] M +24 -6 cameracontroller.cpp M +13 -13 cameracontroller.h M +19 -5 cameraui.cpp M +1 -0 cameraui.h M +10 -8 dkcamera.h M +68 -32 freespacewidget.cpp M +17 -2 freespacewidget.h M +1 -1 gpcamera.cpp M +2 -2 gpcamera.h M +3 -3 umscamera.cpp M +2 -2 umscamera.h --- trunk/extragear/graphics/digikam/utilities/cameragui/cameracontroller.cpp #708725:708726 @@ -78,7 +78,8 @@ gp_lock, gp_thumbnail, gp_exif, - gp_open + gp_open, + gp_freeSpace }; Action action; @@ -209,11 +210,6 @@ delete d; } -CameraDriverType CameraController::cameraDriverType() -{ - return d->camera->cameraDriverType(); -} - void CameraController::slotCancel() { d->canceled = true; @@ -281,6 +277,15 @@ emit signalCameraInformations(summary, manual, about); break; } + case(CameraCommand::gp_freeSpace): + { + sendInfo(i18n("Getting camera freespace available...")); + unsigned long kBSize = 0; + unsigned long kBAvail = 0; + d->camera->getFreeSpace(kBSize, kBAvail); + emit signalFreeSpace(kBSize, kBAvail); + break; + } case(CameraCommand::gp_listfolders): { sendInfo(i18n("Listing folders...")); @@ -787,6 +792,11 @@ return d->camera->title(); } +DKCamera::CameraDriverType CameraController::cameraDriverType() +{ + return d->camera->cameraDriverType(); +} + void CameraController::slotConnect() { d->canceled = false; @@ -840,6 +850,14 @@ addCommand(cmd); } +void CameraController::getFreeSpace() +{ + d->canceled = false; + CameraCommand *cmd = new CameraCommand; + cmd->action = CameraCommand::gp_freeSpace; + addCommand(cmd); +} + void CameraController::upload(const QFileInfo& srcFileInfo, const QString& destFile, const QString& destFolder) { d->canceled = false; --- trunk/extragear/graphics/digikam/utilities/cameragui/cameracontroller.h #708725:708726 @@ -58,11 +58,13 @@ void listFolders(); void listFiles(const QString& folder); + void getFreeSpace(); void getThumbnail(const QString& folder, const QString& file); void getExif(const QString& folder, const QString& file); void getCameraInformations(); QString getCameraPath(); QString getCameraTitle(); + DKCamera::CameraDriverType cameraDriverType(); void downloadPrep(); void download(DownloadSettingsContainer downloadSettings); @@ -70,15 +72,15 @@ void deleteFile(const QString& folder, const QString& file); void lockFile(const QString& folder, const QString& file, bool lock); void openFile(const QString& folder, const QString& file); - - CameraDriverType cameraDriverType(); signals: void signalBusy(bool val); void signalInfoMsg(const QString& msg); void signalErrorMsg(const QString& msg); - void signalCameraInformations(const QString& summary, const QString& manual, const QString& about); + void signalCameraInformations(const QString& summary, const QString& manual, + const QString& about); + void signalFreeSpace(unsigned long kBSize, unsigned long kBAvail); void signalConnected(bool val); void signalFolderList(const QStringList& folderList); @@ -92,6 +94,14 @@ void signalExifFromFile(const QString& folder, const QString& file); void signalExifData(const QByteArray& exifData); + void signalInternalCheckRename(const QString &folder, const QString &file, + const QString &destination, const QString &temp); + void signalInternalDownloadFailed(const QString &folder, const QString &file); + void signalInternalUploadFailed(const QString &folder, const QString &file, const QString &src); + void signalInternalDeleteFailed(const QString &folder, const QString &file); + void signalInternalLockFailed(const QString &folder, const QString &file); + void signalInternalOpen(const QString &folder, const QString &file, const QString &dest); + public slots: void slotCancel(); @@ -102,16 +112,6 @@ void run(); void executeCommand(CameraCommand *cmd); -signals: - - void signalInternalCheckRename(const QString &folder, const QString &file, - const QString &destination, const QString &temp); - void signalInternalDownloadFailed(const QString &folder, const QString &file); - void signalInternalUploadFailed(const QString &folder, const QString &file, const QString &src); - void signalInternalDeleteFailed(const QString &folder, const QString &file); - void signalInternalLockFailed(const QString &folder, const QString &file); - void signalInternalOpen(const QString &folder, const QString &file, const QString &dest); - private slots: void slotCheckRename(const QString &folder, const QString &file, --- trunk/extragear/graphics/digikam/utilities/cameragui/cameraui.cpp #708725:708726 @@ -519,13 +519,13 @@ //------------------------------------------------------------------------------ d->albumLibraryFreeSpace = new FreeSpaceWidget(statusBar(), 100); - d->albumLibraryFreeSpace->setIcon("folder-image"); + d->albumLibraryFreeSpace->setMode(FreeSpaceWidget::AlbumLibrary); + d->albumLibraryFreeSpace->setPath(AlbumSettings::instance()->getAlbumLibraryPath()); statusBar()->addWidget(d->albumLibraryFreeSpace, 1); //------------------------------------------------------------------------------ d->cameraFreeSpace = new FreeSpaceWidget(statusBar(), 100); - d->cameraFreeSpace->setIcon("camera"); statusBar()->addWidget(d->cameraFreeSpace, 1); //------------------------------------------------------------------------------ @@ -545,9 +545,17 @@ { d->controller = new CameraController(this, d->cameraTitle, model, port, path); - // Until libgphoto2 2.4.0, there is no method to get camera media free space. - if (d->controller->cameraDriverType() == GPhotoDriver) - d->cameraFreeSpace->hide(); + if (d->controller->cameraDriverType() == DKCamera::GPhotoDriver) + { + d->cameraFreeSpace->setMode(FreeSpaceWidget::GPhotoCamera); + connect(d->controller, SIGNAL(signalFreeSpace(unsigned long, unsigned long)), + this, SLOT(slotCameraFreeSpaceInfo(unsigned long, unsigned long))); + } + else + { + d->cameraFreeSpace->setMode(FreeSpaceWidget::UMSCamera); + d->cameraFreeSpace->setPath(d->controller->getCameraPath()); + } connect(d->controller, SIGNAL(signalConnected(bool)), this, SLOT(slotConnected(bool))); @@ -908,6 +916,7 @@ } else { + d->controller->getFreeSpace(); d->controller->listFolders(); } } @@ -1851,4 +1860,9 @@ } } +void CameraUI::slotCameraFreeSpaceInfo(unsigned long kBSize, unsigned long kBAvail) +{ + d->cameraFreeSpace->setInformations(kBSize, kBSize-kBAvail, kBAvail, QString()); +} + } // namespace Digikam --- trunk/extragear/graphics/digikam/utilities/cameragui/cameraui.h #708725:708726 @@ -116,6 +116,7 @@ void slotErrorMsg(const QString& msg); void slotInformations(); void slotCameraInformations(const QString&, const QString&, const QString&); + void slotCameraFreeSpaceInfo(unsigned long kBSize, unsigned long kBAvail); void slotFolderList(const QStringList& folderList); void slotFileList(const GPItemInfoList& fileList); --- trunk/extragear/graphics/digikam/utilities/cameragui/dkcamera.h #708725:708726 @@ -39,17 +39,19 @@ namespace Digikam { -enum CameraDriverType -{ - GPhotoDriver = 0, - UMSDriver -}; - class DKCamera { public: + enum CameraDriverType + { + GPhotoDriver = 0, + UMSDriver + }; + +public: + DKCamera(const QString& title, const QString& model, const QString& port, const QString& path); virtual ~DKCamera(); @@ -75,9 +77,9 @@ virtual bool setLockItem(const QString& folder, const QString& itemName, bool lock) = 0; - virtual CameraDriverType cameraDriverType() = 0; + virtual DKCamera::CameraDriverType cameraDriverType() = 0; - virtual bool getFreeSpace(unsigned long& capacityKb, unsigned long& availableKb) = 0; + virtual bool getFreeSpace(unsigned long& kBSize, unsigned long& kBAvail) = 0; QString title() const; QString model() const; --- trunk/extragear/graphics/digikam/utilities/cameragui/freespacewidget.cpp #708725:708726 @@ -64,23 +64,27 @@ kBAvail = 0; dSizeKb = 0; percentUsed = 0; + mode = FreeSpaceWidget::AlbumLibrary; } - bool isValid; + bool isValid; - int percentUsed; + int percentUsed; - unsigned long dSizeKb; - unsigned long kBSize; - unsigned long kBUsed; - unsigned long kBAvail; + unsigned long dSizeKb; + unsigned long kBSize; + unsigned long kBUsed; + unsigned long kBAvail; - QString mountPoint; + QString mountPoint; + QString path; - QTimer *timer; + QTimer *timer; - QPixmap pix; - QPixmap iconPix; + QPixmap pix; + QPixmap iconPix; + + FreeSpaceWidget::FreeSpaceMode mode; }; FreeSpaceWidget::FreeSpaceWidget(QWidget* parent, int width) @@ -90,14 +94,10 @@ setAttribute(Qt::WA_DeleteOnClose); setFixedWidth(width); setMaximumHeight(fontMetrics().height()+4); - slotTimeout(); - d->timer = new QTimer(this); - + connect(d->timer, SIGNAL(timeout()), this, SLOT(slotTimeout())); - - d->timer->start(10000); } FreeSpaceWidget::~FreeSpaceWidget() @@ -107,11 +107,55 @@ delete d; } -void FreeSpaceWidget::setIcon(const QString& name) +void FreeSpaceWidget::setMode(FreeSpaceMode mode) { - d->iconPix = SmallIcon(name); + d->mode = mode; + if (d->mode == FreeSpaceWidget::AlbumLibrary) + { + d->iconPix = SmallIcon("folder-image"); + } + else if (d->mode == FreeSpaceWidget::UMSCamera) + { + d->iconPix = SmallIcon("camera"); + } + else // GPhotoCamera + { + d->iconPix = SmallIcon("camera"); + } + updatePixmap(); } +void FreeSpaceWidget::setPath(const QString& path) +{ + d->timer->stop(); + d->path = path; + slotTimeout(); + d->timer->start(10000); +} + +void FreeSpaceWidget::setInformations(unsigned long kBSize, + unsigned long kBUsed, unsigned long kBAvail, + const QString& mountPoint) +{ + d->mountPoint = mountPoint; + d->kBSize = kBSize; + d->kBUsed = kBUsed; + d->kBAvail = kBAvail; + + if (kBSize <= 0) + { + d->percentUsed = 0; + d->isValid = false; + } + else + { + d->percentUsed = 100 - (int)(100.0*kBAvail/kBSize); + d->isValid = true; + } + updatePixmap(); + repaint(); +} + void FreeSpaceWidget::setEstimatedDSizeKb(unsigned long dSize) { d->dSizeKb = dSize; @@ -177,15 +221,15 @@ (int)(((double)d->pix.width()-3.0-d->iconPix.width()-2.0)*(pClamp/100.0)), d->pix.height()-3); p.drawRect(gRect); - + QRect tRect(d->iconPix.height()+2, 1, d->pix.width()-3-d->iconPix.width()-2, d->pix.height()-3); - QString text = QString("%1%").arg(peUsed); - p.setPen(palette().text().color()); + QString text = QString("%1%").arg(peUsed); QFontMetrics fontMt = p.fontMetrics(); QRect fontRect = fontMt.boundingRect(tRect.x(), tRect.y(), - tRect.width(), tRect.height(), 0, text); + tRect.width(), tRect.height(), 0, text); + p.setPen(palette().text().color()); p.drawText(tRect, Qt::AlignCenter, text); - + QString info; if (d->dSizeKb > 0) @@ -221,9 +265,8 @@ void FreeSpaceWidget::slotTimeout() { - QString path = AlbumSettings::instance()->getAlbumLibraryPath(); KMountPoint::List list = KMountPoint::currentMountPoints(); - KMountPoint::Ptr mp = list.findByPath(path); + KMountPoint::Ptr mp = list.findByPath(d->path); if (mp) { KDiskFreeSpace *job = new KDiskFreeSpace; @@ -236,14 +279,7 @@ void FreeSpaceWidget::slotAvailableFreeSpace(QString mountPoint, quint64 kBSize, quint64 kBUsed, quint64 kBAvail) { - d->mountPoint = mountPoint; - d->kBSize = kBSize; - d->kBUsed = kBUsed; - d->kBAvail = kBAvail; - d->percentUsed = 100 - (int)(100.0*kBAvail/kBSize); - d->isValid = true; - updatePixmap(); - repaint(); + setInformations(kBSize, kBUsed, kBAvail, mountPoint); } } // namespace Digikam --- trunk/extragear/graphics/digikam/utilities/cameragui/freespacewidget.h #708725:708726 @@ -40,24 +40,39 @@ class FreeSpaceWidget : public QWidget { + Q_OBJECT + +public: + + enum FreeSpaceMode + { + AlbumLibrary = 0, + UMSCamera, + GPhotoCamera + }; public: FreeSpaceWidget(QWidget* parent, int width); ~FreeSpaceWidget(); - void setIcon(const QString& name); void setEstimatedDSizeKb(unsigned long dSize); unsigned long estimatedDSizeKb(); - bool isValid() ; + bool isValid(); int percentUsed(); unsigned long kBSize(); unsigned long kBUsed(); unsigned long kBAvail(); QString mountPoint(); + void setMode(FreeSpaceMode mode); + void setPath(const QString& path); + void setInformations(unsigned long kBSize, + unsigned long kBUsed, unsigned long kBAvail, + const QString& mountPoint); + protected: void paintEvent(QPaintEvent*); --- trunk/extragear/graphics/digikam/utilities/cameragui/gpcamera.cpp #708725:708726 @@ -155,7 +155,7 @@ return d->globalPath; } -bool GPCamera::getFreeSpace(unsigned long& capacityKb, unsigned long& availableKb) +bool GPCamera::getFreeSpace(unsigned long& kBSize, unsigned long& kBAvail) { return false; // TODO : not yet implemented. } --- trunk/extragear/graphics/digikam/utilities/cameragui/gpcamera.h #708725:708726 @@ -85,9 +85,9 @@ QString port() const; QString path() const; - CameraDriverType cameraDriverType(){ return GPhotoDriver; }; + DKCamera::CameraDriverType cameraDriverType(){ return DKCamera::GPhotoDriver; }; - bool getFreeSpace(unsigned long& capacityKb, unsigned long& availableKb); + bool getFreeSpace(unsigned long& kBSize, unsigned long& kBAvail); // Public static methods shared with Setup Camera --- trunk/extragear/graphics/digikam/utilities/cameragui/umscamera.cpp #708725:708726 @@ -69,9 +69,9 @@ { } -bool UMSCamera::getFreeSpace(unsigned long& capacityKb, unsigned long& availableKb) +bool UMSCamera::getFreeSpace(unsigned long& /*kBSize*/, unsigned long& /*kBAvail*/) { - return false; // TODO : not yet implemented. + return false; // NOTE: implemented in gui, outside the camera thread. } bool UMSCamera::doConnect() @@ -95,7 +95,7 @@ bool UMSCamera::getItemsInfoList(const QString& folder, GPItemInfoList& infoList, bool getImageDimensions) { - d->cancel = false; + m_cancel = false; infoList.clear(); QDir dir(folder); --- trunk/extragear/graphics/digikam/utilities/cameragui/umscamera.h #708725:708726 @@ -63,9 +63,9 @@ bool cameraManual(QString& manual); bool cameraAbout(QString& about); - bool getFreeSpace(unsigned long& capacityKb, unsigned long& availableKb); + bool getFreeSpace(unsigned long& kBSize, unsigned long& kBAvail); - CameraDriverType cameraDriverType(){ return UMSDriver; }; + DKCamera::CameraDriverType cameraDriverType(){ return DKCamera::UMSDriver; }; private: _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |