[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/apps/dolphin/src
From: Peter Penz <peter.penz19 () gmail ! com>
Date: 2010-12-15 18:40:08
Message-ID: 20101215184008.9CF53AC8AA () svn ! kde ! org
[Download RAW message or body]
SVN commit 1206749 by ppenz:
Fix issue that the enabled state of the "Create New..." menu is not updated correctly in the column-view.
BUG: 258534
FIXED-IN: 4.6.0
M +2 -28 dolphinviewcontainer.cpp
M +0 -2 dolphinviewcontainer.h
M +66 -28 views/dolphinview.cpp
M +23 -0 views/dolphinview.h
--- trunk/KDE/kdebase/apps/dolphin/src/dolphinviewcontainer.cpp #1206748:1206749
@@ -38,7 +38,6 @@
#include <kmenu.h>
#include <knewmenu.h>
#include <konqmimedata.h>
-#include <kfileitemlistproperties.h>
#include <konq_operations.h>
#include <kshell.h>
#include <kurl.h>
@@ -65,7 +64,6 @@
DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
QWidget(parent),
- m_isFolderWritable(false),
m_topLayout(0),
m_urlNavigator(0),
m_searchBox(0),
@@ -155,6 +153,8 @@
this, SLOT(slotStartedPathLoading()));
connect(m_view, SIGNAL(finishedPathLoading(KUrl)),
this, SLOT(slotFinishedPathLoading()));
+ connect(m_view, SIGNAL(writeStateChanged(bool)),
+ this, SIGNAL(writeStateChanged(bool)));
connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
this, SLOT(slotUrlNavigatorLocationChanged(const KUrl&)));
@@ -209,10 +209,7 @@
{
m_urlNavigator->setActive(active);
m_view->setActive(active);
- if (active) {
- emit writeStateChanged(m_isFolderWritable);
}
-}
bool DolphinViewContainer::isActive() const
{
@@ -291,16 +288,8 @@
{
if (newUrl != m_urlNavigator->locationUrl()) {
m_urlNavigator->setLocationUrl(newUrl);
-
- // Temporary disable the 'File'->'Create New...' menu until
- // the write permissions can be checked in a fast way at
- // DolphinViewContainer::slotDirListerCompleted().
- m_isFolderWritable = false;
- if (isActive()) {
- emit writeStateChanged(false);
}
}
-}
void DolphinViewContainer::setFilterBarVisible(bool visible)
{
@@ -389,23 +378,8 @@
} else {
updateStatusBar();
}
-
- // Enable the 'File'->'Create New...' menu only if the directory
- // supports writing.
- KFileItem item = m_dirLister->rootItem();
- if (item.isNull()) {
- // it is unclear whether writing is supported
- m_isFolderWritable = true;
- } else {
- KFileItemListProperties capabilities(KFileItemList() << item);
- m_isFolderWritable = capabilities.supportsWriting();
}
- if (isActive()) {
- emit writeStateChanged(m_isFolderWritable);
- }
-}
-
void DolphinViewContainer::showItemInfo(const KFileItem& item)
{
if (item.isNull()) {
--- trunk/KDE/kdebase/apps/dolphin/src/dolphinviewcontainer.h #1206748:1206749
@@ -265,8 +265,6 @@
bool isSearchUrl(const KUrl& url) const;
private:
- bool m_isFolderWritable;
-
QVBoxLayout* m_topLayout;
KUrlNavigator* m_urlNavigator;
DolphinSearchBox* m_searchBox;
--- trunk/KDE/kdebase/apps/dolphin/src/views/dolphinview.cpp #1206748:1206749
@@ -34,6 +34,7 @@
#include <kdirlister.h>
#include <kiconeffect.h>
#include <kfileitem.h>
+#include <kfileitemlistproperties.h>
#include <klocale.h>
#include <kio/deletejob.h>
#include <kio/netaccess.h>
@@ -76,6 +77,8 @@
m_tabsForFiles(false),
m_isContextMenuOpen(false),
m_assureVisibleCurrentIndex(false),
+ m_expanderActive(false),
+ m_isFolderWritable(true),
m_mode(DolphinView::IconsView),
m_topLayout(0),
m_dolphinViewController(0),
@@ -123,7 +126,7 @@
connect(m_dolphinViewController, SIGNAL(viewportEntered()),
this, SLOT(clearHoverInformation()));
connect(m_dolphinViewController, SIGNAL(urlChangeRequested(KUrl)),
- m_viewModeController, SLOT(setUrl(KUrl)));
+ this, SLOT(slotUrlChangeRequested(KUrl)));
// When a new item has been created by the "Create New..." menu, the item should
// get selected and it must be assured that the item will get visible. As the
@@ -169,9 +172,7 @@
m_active = active;
QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
- if (active) {
- emitSelectionChangedSignal();
- } else {
+ if (!active) {
color.setAlpha(150);
}
@@ -185,6 +186,8 @@
if (active) {
m_viewAccessor.itemView()->setFocus();
emit activated();
+ emitSelectionChangedSignal();
+ emit writeStateChanged(m_isFolderWritable);
}
m_viewModeController->indicateActivationChange(active);
@@ -970,6 +973,34 @@
m_createdItemUrl = KUrl();
}
+void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
+{
+ if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash)) {
+ emit redirection(oldUrl, newUrl);
+ m_viewModeController->redirectToUrl(newUrl); // #186947
+ }
+}
+
+void DolphinView::restoreContentsPosition()
+{
+ if (!m_restoredContentsPosition.isNull()) {
+ const int x = m_restoredContentsPosition.x();
+ const int y = m_restoredContentsPosition.y();
+ m_restoredContentsPosition = QPoint();
+
+ QAbstractItemView* view = m_viewAccessor.itemView();
+ Q_ASSERT(view != 0);
+ view->horizontalScrollBar()->setValue(x);
+ view->verticalScrollBar()->setValue(y);
+ }
+}
+
+void DolphinView::slotUrlChangeRequested(const KUrl& url)
+{
+ m_viewModeController->setUrl(url);
+ updateWritableState();
+}
+
void DolphinView::showHoverInformation(const KFileItem& item)
{
emit requestItemInfo(item);
@@ -989,6 +1020,18 @@
}
}
+void DolphinView::slotDirListerStarted(const KUrl& url)
+{
+ // Disable the writestate temporary until it can be determined in a fast way
+ // in DolphinView::slotDirListerCompleted()
+ if (m_isFolderWritable) {
+ m_isFolderWritable = false;
+ emit writeStateChanged(m_isFolderWritable);
+ }
+
+ emit startedPathLoading(url);
+}
+
void DolphinView::slotDirListerCompleted()
{
if (!m_expanderActive) {
@@ -1013,6 +1056,8 @@
m_newFileNames.clear();
}
+
+ updateWritableState();
}
void DolphinView::slotLoadingCompleted()
@@ -1277,7 +1322,7 @@
connect(dirLister, SIGNAL(redirection(KUrl,KUrl)),
this, SLOT(slotRedirection(KUrl,KUrl)));
connect(dirLister, SIGNAL(started(KUrl)),
- this, SIGNAL(startedPathLoading(KUrl)));
+ this, SLOT(slotDirListerStarted(KUrl)));
connect(dirLister, SIGNAL(completed()),
this, SLOT(slotDirListerCompleted()));
connect(dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
@@ -1294,7 +1339,7 @@
disconnect(dirLister, SIGNAL(redirection(KUrl,KUrl)),
this, SLOT(slotRedirection(KUrl,KUrl)));
disconnect(dirLister, SIGNAL(started(KUrl)),
- this, SIGNAL(startedPathLoading(KUrl)));
+ this, SLOT(slotDirListerStarted(KUrl)));
disconnect(dirLister, SIGNAL(completed()),
this, SLOT(slotDirListerCompleted()));
disconnect(dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
@@ -1305,6 +1350,21 @@
this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
}
+void DolphinView::updateWritableState()
+{
+ const bool wasFolderWritable = m_isFolderWritable;
+ m_isFolderWritable = true;
+
+ const KFileItem item = m_viewAccessor.dirLister()->rootItem();
+ if (!item.isNull()) {
+ KFileItemListProperties capabilities(KFileItemList() << item);
+ m_isFolderWritable = capabilities.supportsWriting();
+ }
+ if (m_isFolderWritable != wasFolderWritable) {
+ emit writeStateChanged(m_isFolderWritable);
+ }
+}
+
DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel* proxyModel) :
m_rootUrl(),
m_iconsView(0),
@@ -1503,26 +1563,4 @@
return dirModel()->dirLister();
}
-void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
-{
- if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash)) {
- emit redirection(oldUrl, newUrl);
- m_viewModeController->redirectToUrl(newUrl); // #186947
- }
-}
-
-void DolphinView::restoreContentsPosition()
-{
- if (!m_restoredContentsPosition.isNull()) {
- const int x = m_restoredContentsPosition.x();
- const int y = m_restoredContentsPosition.y();
- m_restoredContentsPosition = QPoint();
-
- QAbstractItemView* view = m_viewAccessor.itemView();
- Q_ASSERT(view != 0);
- view->horizontalScrollBar()->setValue(x);
- view->verticalScrollBar()->setValue(y);
- }
-}
-
#include "dolphinview.moc"
--- trunk/KDE/kdebase/apps/dolphin/src/views/dolphinview.h #1206748:1206749
@@ -529,6 +529,13 @@
*/
void redirection(const KUrl& oldUrl, const KUrl& newUrl);
+ /**
+ * Is emitted when the write state of the folder has been changed. The application
+ * should disable all actions like "Create New..." that depend on the write
+ * state.
+ */
+ void writeStateChanged(bool isFolderWritable);
+
protected:
/** @see QWidget::mouseReleaseEvent */
virtual void mouseReleaseEvent(QMouseEvent* event);
@@ -624,6 +631,12 @@
void slotDeleteFileFinished(KJob* job);
/**
+ * Invoked when the directory lister has been started the
+ * loading of \a url.
+ */
+ void slotDirListerStarted(const KUrl& url);
+
+ /**
* Invoked when the directory lister has completed the loading of
* items. Assures that pasted items and renamed items get seleced.
*/
@@ -666,6 +679,8 @@
*/
void restoreContentsPosition();
+ void slotUrlChangeRequested(const KUrl& url);
+
private:
void loadDirectory(const KUrl& url, bool reload = false);
@@ -726,6 +741,13 @@
void connectViewAccessor();
void disconnectViewAccessor();
+ /**
+ * Updates m_isFolderWritable dependent on whether the folder represented by
+ * the current URL is writable. If the state has changed, the signal
+ * writeableStateChanged() will be emitted.
+ */
+ void updateWritableState();
+
private:
/**
* Abstracts the access to the different view implementations
@@ -795,6 +817,7 @@
bool m_isContextMenuOpen : 1; // TODO: workaround for Qt-issue 207192
bool m_assureVisibleCurrentIndex : 1;
bool m_expanderActive : 1;
+ bool m_isFolderWritable : 1;
Mode m_mode;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic