#endif
#include "dolphinapplication.h"
+#include "dolphincontextmenu.h"
#include "dolphinnewmenu.h"
#include "search/dolphinsearchbox.h"
#include "settings/dolphinsettings.h"
ViewTab viewTab;
viewTab.splitter = new QSplitter(this);
viewTab.splitter->setChildrenCollapsible(false);
- viewTab.primaryView = new DolphinViewContainer(this, viewTab.splitter, url);
+ viewTab.primaryView = new DolphinViewContainer(url, viewTab.splitter);
viewTab.primaryView->setActive(false);
connectViewSignals(viewTab.primaryView);
viewTab.primaryView->view()->reload();
break;
case KDialog::No:
// Close only the current tab
- closeTab();
+ closeTab();
default:
event->ignore();
return;
for (int i = 0; i < tabCount; ++i) {
const DolphinViewContainer* cont = m_viewTab[i].primaryView;
group.writeEntry(tabProperty("Primary URL", i), cont->url().url());
- group.writeEntry(tabProperty("Primary Editable", i), cont->isUrlEditable());
+ group.writeEntry(tabProperty("Primary Editable", i),
+ cont->urlNavigator()->isUrlEditable());
cont = m_viewTab[i].secondaryView;
if (cont != 0) {
group.writeEntry(tabProperty("Secondary URL", i), cont->url().url());
- group.writeEntry(tabProperty("Secondary Editable", i), cont->isUrlEditable());
+ group.writeEntry(tabProperty("Secondary Editable", i),
+ cont->urlNavigator()->isUrlEditable());
}
}
}
// The default case (left button pressed) is handled in goBack().
if (buttons == Qt::MidButton) {
KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
- openNewTab(urlNavigator->historyUrl(urlNavigator->historyIndex() + 1));
+ const int index = urlNavigator->historyIndex() + 1;
+ openNewTab(urlNavigator->locationUrl(index));
}
}
// The default case (left button pressed) is handled in goForward().
if (buttons == Qt::MidButton) {
KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
- openNewTab(urlNavigator->historyUrl(urlNavigator->historyIndex() - 1));
+ const int index = urlNavigator->historyIndex() - 1;
+ openNewTab(urlNavigator->locationUrl(index));
}
}
QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
newTabAction->setShortcut(actionCollection()->action("new_tab")->shortcut());
+ QAction* detachTabAction = menu.addAction(KIcon("tab-detach"), i18nc("@action:inmenu", "Detach Tab"));
+
QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
tab.secondaryView->url() : tab.primaryView->url();
openNewTab(url);
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
+ } else if (selectedAction == detachTabAction) {
+ const ViewTab& tab = m_viewTab[index];
+ Q_ASSERT(tab.primaryView != 0);
+ const KUrl primaryUrl = tab.primaryView->url();
+ DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
+ window->changeUrl(primaryUrl);
+
+ if (tab.secondaryView != 0) {
+ const KUrl secondaryUrl = tab.secondaryView->url();
+ window->toggleSplitView();
+ window->m_viewTab[0].secondaryView->setUrl(secondaryUrl);
+ if (tab.primaryView->isActive()) {
+ window->m_viewTab[0].primaryView->setActive(true);
+ } else {
+ window->m_viewTab[0].secondaryView->setActive(true);
+ }
+ }
+ window->show();
+ closeTab(index);
} else if (selectedAction == closeOtherTabsAction) {
const int count = m_tabBar->count();
for (int i = 0; i < index; ++i) {
}
}
+void DolphinMainWindow::slotTabMoved(int from, int to)
+{
+ m_viewTab.move(from, to);
+ m_tabIndex = m_tabBar->currentIndex();
+}
+
void DolphinMainWindow::handlePlacesClick(const KUrl& url, Qt::MouseButtons buttons)
{
if (buttons & Qt::MidButton) {
#endif
}
-void DolphinMainWindow::slotTabMoved(int from, int to)
-{
- m_viewTab.move(from, to);
- m_tabIndex = m_tabBar->currentIndex();
-}
-
void DolphinMainWindow::showSearchOptions()
{
#ifdef HAVE_NEPOMUK
#endif
}
+void DolphinMainWindow::handleUrl(const KUrl& url)
+{
+ if (KProtocolManager::supportsListing(url)) {
+ activeViewContainer()->setUrl(url);
+ } else {
+ new KRun(url, this);
+ }
+}
+
+void DolphinMainWindow::slotCaptionStatFinished(KJob* job)
+{
+ m_captionStatJob = 0;
+ const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
+ const QString name = entry.stringValue(KIO::UDSEntry::UDS_DISPLAY_NAME);
+ setCaption(name);
+}
+
+void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
+{
+ newMenu()->setEnabled(isFolderWritable);
+}
+
+void DolphinMainWindow::openContextMenu(const KFileItem& item,
+ const KUrl& url,
+ const QList<QAction*>& customActions)
+{
+ DolphinContextMenu contextMenu(this, item, url);
+ contextMenu.setCustomActions(customActions);
+ contextMenu.open();
+}
+
void DolphinMainWindow::init()
{
DolphinSettings& settings = DolphinSettings::instance();
connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
ViewProperties props(homeUrl);
- m_viewTab[m_tabIndex].primaryView = new DolphinViewContainer(this,
- m_viewTab[m_tabIndex].splitter,
- homeUrl);
+ m_viewTab[m_tabIndex].primaryView = new DolphinViewContainer(homeUrl,
+ m_viewTab[m_tabIndex].splitter);
m_activeViewContainer = m_viewTab[m_tabIndex].primaryView;
connectViewSignals(m_activeViewContainer);
connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*, bool&)),
this, SLOT(slotTestCanDecode(const QDragMoveEvent*, bool&)));
connect(m_tabBar, SIGNAL(wheelDelta(int)),
- this, SLOT(slotWheelMoved(int)));
+ this, SLOT(slotWheelMoved(int)));
connect(m_tabBar, SIGNAL(mouseMiddleClick(int)),
this, SLOT(closeTab(int)));
connect(m_tabBar, SIGNAL(tabMoved(int, int)),
{
connect(container, SIGNAL(showFilterBarChanged(bool)),
this, SLOT(updateFilterBarAction(bool)));
+ connect(container, SIGNAL(writeStateChanged(bool)),
+ this, SLOT(slotWriteStateChanged(bool)));
DolphinView* view = container->view();
connect(view, SIGNAL(selectionChanged(KFileItemList)),
this, SLOT(toggleActiveView()));
connect(view, SIGNAL(tabRequested(const KUrl&)),
this, SLOT(openNewTab(const KUrl&)));
+ connect(view, SIGNAL(requestContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)),
+ this, SLOT(openContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)));
const KUrlNavigator* navigator = container->urlNavigator();
connect(navigator, SIGNAL(urlChanged(const KUrl&)),
const int newWidth = (m_viewTab[tabIndex].primaryView->width() - splitter->handleWidth()) / 2;
const DolphinView* view = m_viewTab[tabIndex].primaryView->view();
- m_viewTab[tabIndex].secondaryView = new DolphinViewContainer(this, 0, view->rootUrl());
+ m_viewTab[tabIndex].secondaryView = new DolphinViewContainer(view->rootUrl(), 0);
splitter->addWidget(m_viewTab[tabIndex].secondaryView);
splitter->setSizes(QList<int>() << newWidth << newWidth);
connectViewSignals(m_viewTab[tabIndex].secondaryView);
}
}
-void DolphinMainWindow::handleUrl(const KUrl& url)
-{
- if (KProtocolManager::supportsListing(url)) {
- activeViewContainer()->setUrl(url);
- } else {
- new KRun(url, this);
- }
-}
-
-void DolphinMainWindow::slotCaptionStatFinished(KJob* job)
-{
- m_captionStatJob = 0;
- const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
- const QString name = entry.stringValue(KIO::UDSEntry::UDS_DISPLAY_NAME);
- setCaption(name);
-}
-
QString DolphinMainWindow::squeezedText(const QString& text) const
{
const QFontMetrics fm = fontMetrics();
*/
void closeTab(int index);
-
/**
* Opens a context menu for the tab with the index \a index
* on the position \a pos.
*/
void openTabContextMenu(int index, const QPoint& pos);
+ /**
+ * Is connected to the QTabBar signal tabMoved(int from, int to).
+ * Reorders the list of tabs after a tab was moved in the tab bar
+ * and sets m_tabIndex to the new index of the current tab.
+ */
+ void slotTabMoved(int from, int to);
+
/**
* Handles a click on a places item: if the middle mouse button is
* clicked, a new tab is opened for \a url, otherwise the current
*/
void searchItems();
- /**
- * Is connected to the QTabBar signal tabMoved(int from, int to).
- * Reorders the list of tabs after a tab was moved in the tab bar
- * and sets m_tabIndex to the new index of the current tab.
- */
- void slotTabMoved(int from, int to);
-
/**
* Is connected to the searchbox signal 'requestSearchOptions' and
* takes care to show the search options.
*/
void slotCaptionStatFinished(KJob* job);
+ /**
+ * Is invoked when the write state of a folder has been changed and
+ * enables/disables the "Create New..." menu entry.
+ */
+ void slotWriteStateChanged(bool isFolderWritable);
+
+ /**
+ * Opens the context menu on the current mouse position.
+ * @item File item context. If item is null, the context menu
+ * should be applied to \a url.
+ * @url URL which contains \a item.
+ * @customActions Actions that should be added to the context menu,
+ * if the file item is null.
+ */
+ void openContextMenu(const KFileItem& item,
+ const KUrl& url,
+ const QList<QAction*>& customActions);
+
private:
DolphinMainWindow(int id);
void init();
return m_viewAccessor.itemView()->selectionModel();
}
-void DolphinView::setContentsPosition(int x, int y)
-{
- QAbstractItemView* view = m_viewAccessor.itemView();
- Q_ASSERT(view != 0);
- view->horizontalScrollBar()->setValue(x);
- view->verticalScrollBar()->setValue(y);
-
- m_loadingDirectory = false;
-}
-
-void DolphinView::setRestoredContentsPosition(const QPoint& pos)
-{
- // TODO: This function is called by DolphinViewContainer.
- // If it makes use of DolphinView::restoreState(...) to restore the
- // view state in KDE 4.5, this function can be removed.
- m_restoredContentsPosition = pos;
-}
-
-QPoint DolphinView::contentsPosition() const
-{
- // TODO: If DolphinViewContainer uses DolphinView::saveState(...) to save the
- // view state in KDE 4.5, this code can be moved to DolphinView::saveState.
- QAbstractItemView* view = m_viewAccessor.itemView();
- Q_ASSERT(view != 0);
- const int x = view->horizontalScrollBar()->value();
- const int y = view->verticalScrollBar()->value();
- return QPoint(x, y);
-}
-
void DolphinView::setZoomLevel(int level)
{
if (level < ZoomLevelInfo::minimumLevel()) {
updateZoomLevel(oldZoomLevel);
}
-void DolphinView::updateView(const KUrl& url, const KUrl& rootUrl)
-{
- Q_UNUSED(rootUrl); // TODO: remove after columnview-cleanup has been finished
-
- if (m_controller->url() == url) {
- return;
- }
-
- m_controller->setUrl(url); // emits urlChanged, which we forward
- m_viewAccessor.prepareUrlChange(url);
- applyViewProperties();
- loadDirectory(url);
-
- // When changing the URL there is no need to keep the version
- // data of the previous URL.
- m_viewAccessor.dirModel()->clearVersionData();
-
- emit startedPathLoading(url);
-}
-
void DolphinView::setNameFilter(const QString& nameFilter)
{
m_controller->setNameFilter(nameFilter);
void DolphinView::setUrl(const KUrl& url)
{
+ if (m_controller->url() == url) {
+ return;
+ }
+
m_newFileNames.clear();
- updateView(url, KUrl());
+
+ m_controller->setUrl(url); // emits urlChanged, which we forward
+ m_viewAccessor.prepareUrlChange(url);
+ applyViewProperties();
+ loadDirectory(url);
+
+ // When changing the URL there is no need to keep the version
+ // data of the previous URL.
+ m_viewAccessor.dirModel()->clearVersionData();
+
+ emit startedPathLoading(url);
}
void DolphinView::selectAll()
return m_viewAccessor.itemsExpandable();
}
-void DolphinView::restoreState(QDataStream &stream)
+void DolphinView::restoreState(QDataStream& stream)
{
- // current item
+ // current item
stream >> m_activeItemUrl;
// view position
QSet<KUrl> urlsToExpand;
stream >> urlsToExpand;
const DolphinDetailsViewExpander* expander = m_viewAccessor.setExpandedUrls(urlsToExpand);
-
- if (expander) {
+ if (expander != 0) {
m_expanderActive = true;
connect (expander, SIGNAL(completed()), this, SLOT(slotLoadingCompleted()));
}
}
}
-void DolphinView::saveState(QDataStream &stream)
+void DolphinView::saveState(QDataStream& stream)
{
// current item
KFileItem currentItem;
const QAbstractItemView* view = m_viewAccessor.itemView();
- if(view) {
+ if (view != 0) {
const QModelIndex proxyIndex = view->currentIndex();
const QModelIndex dirModelIndex = m_viewAccessor.proxyModel()->mapToSource(proxyIndex);
currentItem = m_viewAccessor.dirModel()->itemForIndex(dirModelIndex);
}
KUrl currentUrl;
- if (!currentItem.isNull())
+ if (!currentItem.isNull()) {
currentUrl = currentItem.url();
+ }
stream << currentUrl;
// view position
- stream << contentsPosition();
+ const int x = view->horizontalScrollBar()->value();
+ const int y = view->verticalScrollBar()->value();
+ stream << QPoint(x, y);
// expanded folders (only relevant for the details view - the set will be empty in other view modes)
stream << m_viewAccessor.expandedUrls();
m_createdItemUrl = KUrl();
}
-void DolphinView::emitContentsMoved()
-{
- // TODO: If DolphinViewContainer uses DolphinView::saveState(...) to save the
- // view state in KDE 4.5, the contentsMoved signal might not be needed anymore,
- // depending on how the implementation is done.
- // In that case, the code in contentsPosition() can be moved to saveState().
-
- // only emit the contents moved signal if no directory loading is ongoing
- // (this would reset the contents position always to (0, 0))
- if (!m_loadingDirectory) {
- const QPoint pos(contentsPosition());
- emit contentsMoved(pos.x(), pos.y());
- }
-}
-
void DolphinView::showHoverInformation(const KFileItem& item)
{
emit requestItemInfo(item);
connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this, SLOT(slotSelectionChanged(const QItemSelection&, const QItemSelection&)));
- connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)),
- this, SLOT(emitContentsMoved()));
- connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)),
- this, SLOT(emitContentsMoved()));
-
setFocusProxy(m_viewAccessor.layoutTarget());
m_topLayout->insertWidget(1, m_viewAccessor.layoutTarget());
}
disconnect(view);
m_controller->disconnect(view);
view->disconnect();
- disconnect(view->verticalScrollBar(), SIGNAL(valueChanged(int)),
- this, SLOT(emitContentsMoved()));
- disconnect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)),
- this, SLOT(emitContentsMoved()));
m_viewAccessor.deleteView();
}
void DolphinView::restoreContentsPosition()
{
if (!m_restoredContentsPosition.isNull()) {
- setContentsPosition(m_restoredContentsPosition.x(), m_restoredContentsPosition.y());
+ 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);
+
+ m_loadingDirectory = false;
}
}
QItemSelectionModel* selectionModel() const;
- /**
- * Sets the upper left position of the view content
- * to (x,y). The content of the view might be larger than the visible area
- * and hence a scrolling must be done.
- */
- void setContentsPosition(int x, int y);
-
- /**
- * Sets the upper left position of the view content
- * to (x,y) after the directory loading is finished.
- * This is useful when going back or forward in history.
- */
- void setRestoredContentsPosition(const QPoint& pos);
-
- /** Returns the upper left position of the view content. */
- QPoint contentsPosition() const;
-
/**
* Sets the zoom level to \a level. It is assured that the used
* level is adjusted to be inside the range ZoomLevelInfo::minimumLevel() and
*/
void refresh();
- /**
- * Changes the directory of the view to \a url. If \a rootUrl is empty, the view
- * properties from \a url are used for adjusting the view mode and the other properties.
- * If \a rootUrl is not empty, the view properties from the root URL are considered
- * instead. Specifying a root URL is only required if a view having a different root URL
- * (e. g. the column view) should be restored. Usually using DolphinView::setUrl()
- * is enough for changing the current URL.
- */
- void updateView(const KUrl& url, const KUrl& rootUrl);
-
/**
* Filters the currently shown items by \a nameFilter. All items
* which contain the given filter string will be shown.
/**
* Restores the view state (current item, contents position, details view expansion state)
*/
- void restoreState(QDataStream &stream);
+ void restoreState(QDataStream& stream);
/**
* Saves the view state (current item, contents position, details view expansion state)
*/
- void saveState(QDataStream &stream);
+ void saveState(QDataStream& stream);
public slots:
/**
*/
void requestItemInfo(const KFileItem& item);
- /** Is emitted if the contents has been moved to \a x, \a y. */
- void contentsMoved(int x, int y);
-
/**
* Is emitted whenever the selection has been changed.
*/
*/
void updateAdditionalInfo(const KFileItemDelegate::InformationList& info);
- /**
- * Emits the signal contentsMoved with the current coordinates
- * of the viewport as parameters.
- */
- void emitContentsMoved();
-
/**
* Updates the status bar to show hover information for the
* item \a item. If currently other items are selected,
#include "dolphinsortfilterproxymodel.h"
#include "dolphindetailsview.h"
#include "dolphiniconsview.h"
-#include "dolphincontextmenu.h"
#include "draganddrophelper.h"
#include "filterbar.h"
#include "statusbar/dolphinstatusbar.h"
#include "settings/dolphinsettings.h"
#include "dolphin_generalsettings.h"
-DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
- QWidget* parent,
- const KUrl& url) :
+DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
QWidget(parent),
m_isFolderWritable(false),
- m_mainWindow(mainWindow),
m_topLayout(0),
m_urlNavigator(0),
m_view(0),
this, SLOT(dropUrls(const KUrl&, QDropEvent*)));
connect(m_urlNavigator, SIGNAL(activated()),
this, SLOT(activate()));
+ //connect(m_urlNavigator, SIGNAL(tabRequested(const KUrl&)),
+ // this,
connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion)));
const GeneralSettings* settings = DolphinSettings::instance().generalSettings();
m_urlNavigator->setUrlEditable(settings->editableUrl());
m_urlNavigator->setShowFullPath(settings->showFullPath());
- m_urlNavigator->setHomeUrl(settings->homeUrl());
+ m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl()));
KUrlComboBox* editor = m_urlNavigator->editor();
editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode()));
m_view = new DolphinView(this, url, m_proxyModel);
connect(m_view, SIGNAL(urlChanged(const KUrl&)),
m_urlNavigator, SLOT(setUrl(const KUrl&)));
- connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)),
- this, SLOT(openContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)));
- connect(m_view, SIGNAL(contentsMoved(int, int)),
- this, SLOT(saveContentsPos(int, int)));
connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
this, SLOT(showItemInfo(KFileItem)));
connect(m_view, SIGNAL(errorMessage(const QString&)),
this, SLOT(showOperationCompletedMessage(const QString&)));
connect(m_view, SIGNAL(itemTriggered(KFileItem)),
this, SLOT(slotItemTriggered(KFileItem)));
- connect(m_view, SIGNAL(startedPathLoading(const KUrl&)),
- this, SLOT(saveRootUrl(const KUrl&)));
connect(m_view, SIGNAL(redirection(KUrl, KUrl)),
this, SLOT(redirect(KUrl, KUrl)));
connect(m_view, SIGNAL(selectionChanged(const KFileItemList&)),
this, SLOT(delayedStatusBarUpdate()));
connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
- this, SLOT(restoreView(const KUrl&)));
+ this, SLOT(slotUrlNavigatorLocationChanged(const KUrl&)));
+ connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(const KUrl&)),
+ this, SLOT(saveViewState()));
connect(m_urlNavigator, SIGNAL(historyChanged()),
this, SLOT(slotHistoryChanged()));
m_dirLister = 0; // deleted by m_dolphinModel
}
-const KUrl& DolphinViewContainer::url() const
+KUrl DolphinViewContainer::url() const
{
- return m_urlNavigator->url();
+ return m_urlNavigator->locationUrl();
}
void DolphinViewContainer::setActive(bool active)
m_urlNavigator->setActive(active);
m_view->setActive(active);
if (active) {
- m_mainWindow->newMenu()->menu()->setEnabled(m_isFolderWritable);
+ emit writeStateChanged(m_isFolderWritable);
}
}
void DolphinViewContainer::setUrl(const KUrl& newUrl)
{
- if (newUrl != m_urlNavigator->url()) {
- m_urlNavigator->setUrl(newUrl);
+ 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()) {
- m_mainWindow->newMenu()->menu()->setEnabled(false);
+ emit writeStateChanged(false);
}
}
}
}
}
-bool DolphinViewContainer::isUrlEditable() const
-{
- return m_urlNavigator->isUrlEditable();
-}
-
void DolphinViewContainer::delayedStatusBarUpdate()
{
// Invoke updateStatusBar() with a small delay. This assures that
} else {
updateStatusBar();
}
+ QMetaObject::invokeMethod(this, "restoreViewState", Qt::QueuedConnection);
// Enable the 'File'->'Create New...' menu only if the directory
// supports writing.
}
if (isActive()) {
- m_mainWindow->newMenu()->menu()->setEnabled(m_isFolderWritable);
+ emit writeStateChanged(m_isFolderWritable);
}
}
delayedStatusBarUpdate();
}
-void DolphinViewContainer::openContextMenu(const KFileItem& item,
- const KUrl& url,
- const QList<QAction*>& customActions)
+void DolphinViewContainer::restoreViewState()
{
- DolphinContextMenu contextMenu(m_mainWindow, item, url);
- contextMenu.setCustomActions(customActions);
- contextMenu.open();
+ QByteArray locationState = m_urlNavigator->locationState();
+ QDataStream stream(&locationState, QIODevice::ReadOnly);
+ m_view->restoreState(stream);
}
-void DolphinViewContainer::saveContentsPos(int x, int y)
+void DolphinViewContainer::activate()
{
- // TODO: If DolphinViewContainer uses DolphinView::saveState(...) to save the
- // view state in KDE 4.5, this funciton can be removed.
- m_urlNavigator->savePosition(x, y);
+ setActive(true);
}
-void DolphinViewContainer::activate()
+void DolphinViewContainer::saveViewState()
{
- setActive(true);
+ QByteArray locationState;
+ QDataStream stream(&locationState, QIODevice::WriteOnly);
+ m_view->saveState(stream);
+ m_urlNavigator->saveLocationState(locationState);
}
-void DolphinViewContainer::restoreView(const KUrl& url)
+void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
{
if (KProtocolManager::supportsListing(url)) {
- m_view->updateView(url, m_urlNavigator->savedRootUrl());
+ m_view->setUrl(url);
if (isActive()) {
// When an URL has been entered, the view should get the focus.
// The focus must be requested asynchronously, as changing the URL might create
}
}
-void DolphinViewContainer::saveRootUrl(const KUrl& url)
-{
- Q_UNUSED(url);
- m_urlNavigator->saveRootUrl(m_view->rootUrl());
-}
-
void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
{
DragAndDropHelper::instance().dropUrls(KFileItem(), destination, event, this);
Q_UNUSED(oldUrl);
const bool block = m_urlNavigator->signalsBlocked();
m_urlNavigator->blockSignals(true);
- m_urlNavigator->setUrl(newUrl);
+ m_urlNavigator->setLocationUrl(newUrl);
m_urlNavigator->blockSignals(block);
}
void DolphinViewContainer::slotHistoryChanged()
{
const int index = m_urlNavigator->historyIndex();
- if (index > 0) {
+ if (index > 0) {
// The "Go Forward" action is enabled. Try to mark
// the previous directory as active item:
- const KUrl url = m_urlNavigator->historyUrl(index - 1);
+ const KUrl url = m_urlNavigator->locationUrl(index - 1);
m_view->activateItem(url);
- QPoint pos = m_urlNavigator->savedPosition();
- m_view->setRestoredContentsPosition(pos);
}
}
class DolphinModel;
class KUrlNavigator;
class DolphinDirLister;
-class DolphinMainWindow;
class DolphinSortFilterProxyModel;
class DolphinStatusBar;
Q_OBJECT
public:
- DolphinViewContainer(DolphinMainWindow* mainwindow,
- QWidget *parent,
- const KUrl& url);
-
+ DolphinViewContainer(const KUrl& url, QWidget* parent);
virtual ~DolphinViewContainer();
/**
* Returns the current active URL, where all actions are applied.
* The URL navigator is synchronized with this URL.
*/
- const KUrl& url() const;
+ KUrl url() const;
/**
* If \a active is true, the view container will marked as active. The active
const DolphinStatusBar* statusBar() const;
DolphinStatusBar* statusBar();
- /**
- * Returns true, if the URL shown by the navigation bar is editable.
- * @see KUrlNavigator
- */
- bool isUrlEditable() const;
-
const KUrlNavigator* urlNavigator() const;
KUrlNavigator* urlNavigator();
*/
void showFilterBarChanged(bool shown);
+ /**
+ * 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);
+
private slots:
/**
* Updates the number of items (= number of files + number of
*/
void setNameFilter(const QString& nameFilter);
- /**
- * Opens the context menu on the current mouse position.
- * @item File item context. If item is null, the context menu
- * should be applied to \a url.
- * @url URL which contains \a item.
- * @customActions Actions that should be added to the context menu,
- * if the file item is null.
- */
- void openContextMenu(const KFileItem& item,
- const KUrl& url,
- const QList<QAction*>& customActions);
-
- /**
- * Saves the position of the contents to the
- * current history element.
- */
- void saveContentsPos(int x, int y);
+ void restoreViewState();
/**
* Marks the view container as active
void activate();
/**
- * Restores the current view to show \a url and assures
- * that the root URL of the view is respected.
+ * Saves the state of the current view: contents position,
+ * root URL, ...
*/
- void restoreView(const KUrl& url);
+ void saveViewState();
/**
- * Saves the root URL of the current URL \a url
- * into the URL navigator.
+ * Restores the current view to show \a url and assures
+ * that the root URL of the view is respected.
*/
- void saveRootUrl(const KUrl& url);
+ void slotUrlNavigatorLocationChanged(const KUrl& url);
/**
* Is connected with the URL navigator and drops the URLs
private:
bool m_isFolderWritable;
- DolphinMainWindow* m_mainWindow;
QVBoxLayout* m_topLayout;
KUrlNavigator* m_urlNavigator;