[Digikam-devel] [Bug 229795] Position in album lost when switching album forth and back [patch]
konstantin
krivakin at gmail.com
Sun Apr 11 10:36:18 BST 2010
https://bugs.kde.org/show_bug.cgi?id=229795
--- Comment #18 from konstantin <krivakin gmail com> 2010-04-11 11:35:52 ---
(From update of attachment 42661)
diff -u ./dk.original/graphics/digikam/digikam/albumhistory.cpp
./dk.patch/graphics/digikam/digikam/albumhistory.cpp
--- ./dk.original/graphics/digikam/digikam/albumhistory.cpp 2010-04-07
01:53:31.744391200 +0400
+++ ./dk.patch/graphics/digikam/digikam/albumhistory.cpp 2010-04-11
13:31:53.936729064 +0400
@@ -32,6 +32,8 @@
// Local includes
#include "album.h"
+#include "imageinfo.h"
+#include "albummanager.h"
namespace Digikam
{
@@ -65,11 +67,36 @@
QWidget* widget;
};
+class HistoryPosition
+{
+public:
+
+ HistoryPosition()
+ {
+
+ };
+
+ HistoryPosition(ImageInfo c, KUrl::List s)
+ {
+ current = c;
+ select = s;
+ };
+
+ bool operator==(const HistoryPosition& item)
+ {
+ return (current == item.current) && (select == item.select);
+ }
+
+ ImageInfo current;
+ KUrl::List select;
+};
+
AlbumHistory::AlbumHistory()
{
m_backwardStack = new AlbumStack;
m_forwardStack = new AlbumStack;
m_moving = false;
+ m_blockSelection = false;
}
AlbumHistory::~AlbumHistory()
@@ -344,4 +371,75 @@
return (m_backwardStack->count() <= 1) ? true : false;
}
+void AlbumHistory::slotAlbumSelected()
+{
+ Album* currentAlbum = AlbumManager::instance()->currentAlbum();
+ if (m_historyPos.contains(currentAlbum))
+ {
+ if (currentAlbum->type() == Album::PHYSICAL || currentAlbum->type() ==
Album::TAG)
+ {
+ m_blockSelection = true;
+ emit signalSetCurrent(m_historyPos[currentAlbum].current.id());
+ }
+ }
+}
+
+void AlbumHistory::slotAlbumCurrentChanged()
+{
+ Album* currentAlbum = AlbumManager::instance()->currentAlbum();
+ if (m_historyPos.contains(currentAlbum))
+ {
+ if (currentAlbum->type() == Album::PHYSICAL || currentAlbum->type() ==
Album::TAG)
+ {
+ if (m_historyPos[currentAlbum].select.size())
+ {
+ emit signalSetSelectedUrls(m_historyPos[currentAlbum].select);
+ }
+ }
+ }
+ m_blockSelection = false;
+}
+
+void AlbumHistory::slotCurrentChange(const ImageInfo& info)
+{
+ Album* currentAlbum = AlbumManager::instance()->currentAlbum();
+ m_historyPos[currentAlbum].current = info;
+}
+
+void AlbumHistory::slotImageSelected(const ImageInfoList& selectedImage)
+{
+ if (m_blockSelection)
+ return;
+ Album *currentAlbum = AlbumManager::instance()->currentAlbum();
+ if (m_historyPos.contains(currentAlbum))
+ m_historyPos[currentAlbum].select.clear();
+ for (int i = 0; i < selectedImage.count(); i++)
+ {
+ if
(!m_historyPos[currentAlbum].select.contains(selectedImage[i].fileUrl()))
+ {
+ m_historyPos[currentAlbum].select.insert(0,
selectedImage[i].fileUrl());
+ }
+ }
+}
+
+void AlbumHistory::slotClearSelectPAlbum(const ImageInfo& imageInfo)
+{
+ Album* album =
dynamic_cast<Album*>(AlbumManager::instance()->findPAlbum(imageInfo.albumId()));
+ if (m_historyPos.contains(album))
+ m_historyPos[album].select.clear();
+}
+
+void AlbumHistory::slotClearSelectTAlbum(int id)
+{
+ Album* album =
dynamic_cast<Album*>(AlbumManager::instance()->findTAlbum(id));
+ if (m_historyPos.contains(album))
+ m_historyPos[album].select.clear();
+}
+
+void AlbumHistory::slotAlbumDeleted(Album* album)
+{
+ if (m_historyPos.contains(album))
+ m_historyPos.remove(album);
+}
+
} // namespace Digikam
diff -u ./dk.original/graphics/digikam/digikam/albumhistory.h
./dk.patch/graphics/digikam/digikam/albumhistory.h
--- ./dk.original/graphics/digikam/digikam/albumhistory.h 2010-04-07
01:53:31.796392789 +0400
+++ ./dk.patch/graphics/digikam/digikam/albumhistory.h 2010-04-11
13:25:49.872729576 +0400
@@ -30,14 +30,21 @@
// Qt includes
#include <QList>
+#include <QMap>
#include <QObject>
#include <QStringList>
+//KDE includes
+#include <KUrl>
+
namespace Digikam
{
class Album;
class HistoryItem;
+class HistoryPosition;
+class ImageInfo;
+class ImageInfoList;
/**
* Manages the history of the last visited albums.
@@ -67,6 +74,21 @@
bool isForwardEmpty() const;
bool isBackwardEmpty() const;
+Q_SIGNALS:
+
+ void signalSetCurrent(qlonglong imageId);
+ void signalSetSelectedUrls(const KUrl::List&);
+
+public Q_SLOTS:
+
+ void slotAlbumCurrentChanged();
+ void slotAlbumDeleted(Album* album);
+ void slotAlbumSelected();
+ void slotClearSelectPAlbum(const ImageInfo& imageInfo);
+ void slotClearSelectTAlbum(int id);
+ void slotCurrentChange(const ImageInfo& info);
+ void slotImageSelected(const ImageInfoList& selectedImage);
+
private:
HistoryItem* getCurrentAlbum() const;
@@ -76,10 +98,12 @@
typedef QList<HistoryItem*> AlbumStack;
- bool m_moving;
+ bool m_moving;
+ bool m_blockSelection;
AlbumStack *m_backwardStack;
AlbumStack *m_forwardStack;
+ QMap<Album*, HistoryPosition> m_historyPos;
};
} // namespace Digikam
diff -u ./dk.original/graphics/digikam/digikam/digikamview.cpp
./dk.patch/graphics/digikam/digikam/digikamview.cpp
--- ./dk.original/graphics/digikam/digikam/digikamview.cpp 2010-04-07
01:53:31.580397973 +0400
+++ ./dk.patch/graphics/digikam/digikam/digikamview.cpp 2010-04-11
00:26:00.100730406 +0400
@@ -495,6 +495,34 @@
connect(AlbumSettings::instance(), SIGNAL(setupChanged()),
this, SLOT(slotSidebarTabTitleStyleChanged()));
+
+ // -- Album History -----------------
+ connect(this, SIGNAL(signalAlbumSelected(bool)),
+ d->albumHistory, SLOT(slotAlbumSelected()));
+
+ connect(this, SIGNAL(signalImageSelected(const ImageInfoList&, bool, bool,
const ImageInfoList&)),
+ d->albumHistory, SLOT(slotImageSelected(const ImageInfoList&)));
+
+ connect(d->iconView, SIGNAL(currentChanged(const ImageInfo&)),
+ d->albumHistory, SLOT(slotCurrentChange(const ImageInfo&)));
+
+ connect(d->iconView, SIGNAL(gotoAlbumAndImageRequested(const ImageInfo&)),
+ d->albumHistory, SLOT(slotClearSelectPAlbum(const ImageInfo&)));
+
+ connect(d->iconView, SIGNAL(gotoTagAndImageRequested(int)),
+ d->albumHistory, SLOT(slotClearSelectTAlbum(int)));
+
+ connect(d->iconView->imageModel(),
SIGNAL(imageInfosAdded(QList<ImageInfo>)),
+ d->albumHistory, SLOT(slotAlbumCurrentChanged()));
+
+ connect(d->albumHistory, SIGNAL(signalSetCurrent(qlonglong)),
+ d->iconView, SLOT(setCurrentWhenAvailable(qlonglong)));
+
+ connect(d->albumHistory, SIGNAL(signalSetSelectedUrls(KUrl::List)),
+ d->iconView, SLOT(setSelectedUrls(KUrl::List)));
+
+ connect(d->albumManager, SIGNAL(signalAlbumDeleted(Album*)),
+ d->albumHistory, SLOT(slotAlbumDeleted(Album*)));
}
void DigikamView::connectIconViewFilter(AlbumIconViewFilter *filter)
Общие подкаталоги: ./dk.original/graphics/digikam/digikam/.svn и
./dk.patch/graphics/digikam/digikam/.svn
--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Digikam-devel
mailing list