┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphindetailsview.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2009-11-14 15:51:47 +0000
committerFrank Reininghaus <[email protected]>2009-11-14 15:51:47 +0000
commit487215f0c459ca38c68619325edac4a2fe42ca4b (patch)
tree15ab897d8696f0093dbe93319cb434a6fa20088c /src/dolphindetailsview.cpp
parentd49bdf8f9c7b8b2445e4355c955763ddf6339c19 (diff)
When navigating back/forward in the DolphinPart inside Konqueror, remember
1. the current item, 2. the scroll position of the view, and 3. the expansion state of the details view. Before 3. can be implemented in Dolphin itself, some changes in KUrlNavigator are required. This fix will be in KDE 4.4. BUG: 193549 BUG: 198073 BUG: 213137 svn path=/trunk/KDE/kdebase/apps/; revision=1049164
Diffstat (limited to 'src/dolphindetailsview.cpp')
-rw-r--r--src/dolphindetailsview.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index 9d32dd247..bc1598541 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -57,6 +57,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent,
m_controller(controller),
m_extensionsFactory(0),
m_expandableFoldersAction(0),
+ m_expandedUrls(),
m_font(),
m_decorationSize(),
m_band()
@@ -151,6 +152,9 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent,
connect(m_expandableFoldersAction, SIGNAL(toggled(bool)),
this, SLOT(setFoldersExpandable(bool)));
+ connect(this, SIGNAL(expanded(const QModelIndex&)), this, SLOT(slotExpanded(const QModelIndex&)));
+ connect(this, SIGNAL(collapsed(const QModelIndex&)), this, SLOT(slotCollapsed(const QModelIndex&)));
+
updateDecorationSize(view->showPreview());
m_extensionsFactory = new ViewExtensionsFactory(this, controller);
@@ -162,6 +166,11 @@ DolphinDetailsView::~DolphinDetailsView()
{
}
+QSet<KUrl> DolphinDetailsView::expandedUrls() const
+{
+ return m_expandedUrls;
+}
+
bool DolphinDetailsView::event(QEvent* event)
{
if (event->type() == QEvent::Polish) {
@@ -867,6 +876,43 @@ void DolphinDetailsView::setFoldersExpandable(bool expandable)
setItemsExpandable(expandable);
}
+void DolphinDetailsView::slotExpanded(const QModelIndex& index)
+{
+ KFileItem item = m_controller->itemForIndex(index);
+ if (!item.isNull()) {
+ m_expandedUrls.insert(item.url());
+ }
+}
+
+void DolphinDetailsView::slotCollapsed(const QModelIndex& index)
+{
+ KFileItem item = m_controller->itemForIndex(index);
+ if (!item.isNull()) {
+ m_expandedUrls.remove(item.url());
+ }
+}
+
+void DolphinDetailsView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
+{
+ removeExpandedIndexes(parent, start, end);
+ QTreeView::rowsAboutToBeRemoved(parent, start, end);
+}
+
+void DolphinDetailsView::removeExpandedIndexes(const QModelIndex& parent, int start, int end)
+{
+ if (m_expandedUrls.isEmpty()) {
+ return;
+ }
+
+ for (int row = start; row <= end; row++) {
+ const QModelIndex index = model()->index(row, 0, parent);
+ if (isExpanded(index)) {
+ slotCollapsed(index);
+ removeExpandedIndexes(index, 0, model()->rowCount(index) - 1);
+ }
+ }
+}
+
void DolphinDetailsView::updateDecorationSize(bool showPreview)
{
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();