Commit 3255a77e authored by Teemu Rytilahti's avatar Teemu Rytilahti
Browse files

- Use KUrl and make sure that the folder has a trailing slash. Otherwise call...

- Use KUrl and make sure that the folder has a trailing slash. Otherwise call to setFileName() causes the end of the path to be removed and breaking the URLs for history.
- When listing files, request the status from history database for the current state.
- Also use only model and path information for PTP cameras, as port number changes on the fly, therefore breaking the hashes. Unfortunately this means that the old download history for PTP devices is lost.
- Use DownloadedNo to indicate "new" photos for the time being.

BUGS:313678
FIXED-IN:4.0.0
parent 1bb93ec5
......@@ -49,6 +49,7 @@
#include "thumbnailschemaupdater.h"
#include "dbactiontype.h"
//#define DATABASCOREBACKEND_DEBUG 1
namespace Digikam
{
......
......@@ -42,9 +42,10 @@ public:
enum Status
{
StatusUnknown,
Downloaded,
NotDownloaded
StatusUnknown = -1,
NotDownloaded = 0,
Downloaded = 1,
};
/**
......
......@@ -74,6 +74,7 @@ extern "C"
#include "gpcamera.h"
#include "umscamera.h"
#include "jpegutils.h"
#include "downloadhistory.h"
namespace Digikam
{
......@@ -525,6 +526,10 @@ void CameraController::executeCommand(CameraCommand* const cmd)
// skip
continue;
}
DownloadHistory::Status status = DownloadHistory::status(d->camera->cameraMD5ID(), info.name, info.size, info.ctime);
// TODO this is ugly, using different enums to point the similar status..
// TODO can we differentiate at all between whether the status is unknown and not downloaded? how?
info.downloaded = status;
numberOfItems++;
info.id += numberOfItems;
list.append(info);
......
......@@ -74,6 +74,7 @@ KUrl CamItemInfo::url() const
{
KUrl url;
url.addPath(folder);
url.adjustPath(KUrl::AddTrailingSlash);
url.setFileName(name);
return url;
}
......
......@@ -170,7 +170,8 @@ QByteArray GPCamera::cameraMD5ID()
// We don't use camera title from digiKam settings panel to compute MD5 fingerprint,
// because it can be changed by users between session.
camData.append(model());
camData.append(port());
// TODO is it really necessary to have a path here? I think model+filename+size+ctime should be enough to give unique fingerprint
// while still allowing you to move files around in the camera if needed
camData.append(path());
KMD5 md5(camData.toUtf8());
md5data = md5.hexDigest();
......
......@@ -178,7 +178,7 @@ bool ImportDownloadOverlay::checkIndex(const QModelIndex& index) const
return true;
}
if (info.downloaded == CamItemInfo::NewPicture)
if (info.downloaded == CamItemInfo::DownloadedNo) // TODO: CamItemInfo::NewPicture
{
m_widget->setToolTip(i18nc("@info:tooltip", "This item download status is new"));
return true;
......
......@@ -457,7 +457,7 @@ void ItemViewImportDelegate::drawDownloadIndicator(QPainter* p, const QRect& r,
icon = KIconLoader::global()->loadIcon("dialog-information", KIconLoader::NoGroup, KIconLoader::SizeSmall);
}
if (itemType == CamItemInfo::NewPicture)
if (itemType == CamItemInfo::DownloadedNo) // TODO: CamItemInfo::NewPicture
{
icon = KIconLoader::global()->loadIcon("get-hot-new-stuff", KIconLoader::NoGroup, KIconLoader::SizeSmall);
}
......
......@@ -1194,6 +1194,7 @@ void ImportUI::slotFolderList(const QStringList& folderList)
}
}
// FIXME d->filesToBeAdded seems to be unused...
void ImportUI::slotFileList(const CamItemInfoList& fileList)
{
if (d->closed)
......@@ -2288,6 +2289,7 @@ void ImportUI::slotNewSelection(bool hasSelection)
d->renameCustomizer->renameManager()->parseFiles();
}
// TODO why new name is calculated on selection basis?!
slotDownloadNameChanged();
unsigned long fSize = 0;
......
......@@ -146,7 +146,10 @@ int ImportIconView::fitToWidthIcons()
CamItemInfo ImportIconView::camItemInfo(const QString& folder, const QString& file)
{
QModelIndex indexForCamItemInfo = importFilterModel()->indexForPath(QString(folder + file));
KUrl url(folder);
url.adjustPath(KUrl::AddTrailingSlash);
url.setFileName(file);
QModelIndex indexForCamItemInfo = importFilterModel()->indexForPath(url.toLocalFile());
if(indexForCamItemInfo.isValid())
{
......@@ -158,7 +161,10 @@ CamItemInfo ImportIconView::camItemInfo(const QString& folder, const QString& fi
CamItemInfo& ImportIconView::camItemInfoRef(const QString& folder, const QString& file)
{
QModelIndex indexForCamItemInfo = importFilterModel()->indexForPath(QString(folder + file));
KUrl url(folder);
url.adjustPath(KUrl::AddTrailingSlash);
url.setFileName(file);
QModelIndex indexForCamItemInfo = importFilterModel()->indexForPath(url.toLocalFile());
QModelIndex mappedIndex = importFilterModel()->mapToSource(indexForCamItemInfo);
return importImageModel()->camItemInfoRef(mappedIndex);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment