mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 00:11:21 +00:00
* Adjust code to use the improved KUrlNavigator API.
* Open a new tab if the URL navigator requests it. * Get rid of a cyclic dependency between DolphinViewContainer and DolphinMainWindow. BUG: 181223 svn path=/trunk/KDE/kdebase/apps/; revision=1079843
This commit is contained in:
parent
0ad9abf7b1
commit
e5eae108ca
|
@ -29,6 +29,7 @@
|
|||
#endif
|
||||
|
||||
#include "dolphinapplication.h"
|
||||
#include "dolphincontextmenu.h"
|
||||
#include "dolphinnewmenu.h"
|
||||
#include "search/dolphinsearchbox.h"
|
||||
#include "settings/dolphinsettings.h"
|
||||
|
@ -415,7 +416,7 @@ void DolphinMainWindow::openNewTab(const KUrl& url)
|
|||
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();
|
||||
|
@ -553,7 +554,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
|
|||
break;
|
||||
case KDialog::No:
|
||||
// Close only the current tab
|
||||
closeTab();
|
||||
closeTab();
|
||||
default:
|
||||
event->ignore();
|
||||
return;
|
||||
|
@ -576,12 +577,14 @@ void DolphinMainWindow::saveProperties(KConfigGroup& group)
|
|||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -840,7 +843,8 @@ void DolphinMainWindow::goBack(Qt::MouseButtons buttons)
|
|||
// 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -849,7 +853,8 @@ void DolphinMainWindow::goForward(Qt::MouseButtons buttons)
|
|||
// 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1043,6 +1048,8 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
|
|||
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"));
|
||||
|
@ -1055,6 +1062,25 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
|
|||
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) {
|
||||
|
@ -1068,6 +1094,12 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
|
|||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -1091,12 +1123,6 @@ void DolphinMainWindow::searchItems()
|
|||
#endif
|
||||
}
|
||||
|
||||
void DolphinMainWindow::slotTabMoved(int from, int to)
|
||||
{
|
||||
m_viewTab.move(from, to);
|
||||
m_tabIndex = m_tabBar->currentIndex();
|
||||
}
|
||||
|
||||
void DolphinMainWindow::showSearchOptions()
|
||||
{
|
||||
#ifdef HAVE_NEPOMUK
|
||||
|
@ -1104,6 +1130,37 @@ void DolphinMainWindow::showSearchOptions()
|
|||
#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();
|
||||
|
@ -1129,9 +1186,8 @@ void DolphinMainWindow::init()
|
|||
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);
|
||||
|
@ -1166,7 +1222,7 @@ void DolphinMainWindow::init()
|
|||
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)),
|
||||
|
@ -1633,6 +1689,8 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
|
|||
{
|
||||
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)),
|
||||
|
@ -1643,6 +1701,8 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
|
|||
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&)),
|
||||
|
@ -1710,7 +1770,7 @@ void DolphinMainWindow::createSecondaryView(int tabIndex)
|
|||
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);
|
||||
|
@ -1748,23 +1808,6 @@ void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
|
|||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -379,13 +379,19 @@ private slots:
|
|||
*/
|
||||
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
|
||||
|
@ -405,13 +411,6 @@ private slots:
|
|||
*/
|
||||
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.
|
||||
|
@ -430,6 +429,24 @@ private slots:
|
|||
*/
|
||||
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();
|
||||
|
|
|
@ -347,35 +347,6 @@ QItemSelectionModel* DolphinView::selectionModel() const
|
|||
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()) {
|
||||
|
@ -480,26 +451,6 @@ void DolphinView::refresh()
|
|||
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);
|
||||
|
@ -585,8 +536,22 @@ QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) c
|
|||
|
||||
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()
|
||||
|
@ -1072,9 +1037,9 @@ bool DolphinView::itemsExpandable() const
|
|||
return m_viewAccessor.itemsExpandable();
|
||||
}
|
||||
|
||||
void DolphinView::restoreState(QDataStream &stream)
|
||||
void DolphinView::restoreState(QDataStream& stream)
|
||||
{
|
||||
// current item
|
||||
// current item
|
||||
stream >> m_activeItemUrl;
|
||||
|
||||
// view position
|
||||
|
@ -1084,8 +1049,7 @@ void DolphinView::restoreState(QDataStream &stream)
|
|||
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()));
|
||||
}
|
||||
|
@ -1094,26 +1058,29 @@ void DolphinView::restoreState(QDataStream &stream)
|
|||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
@ -1139,21 +1106,6 @@ void DolphinView::selectAndScrollToCreatedItem()
|
|||
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);
|
||||
|
@ -1388,11 +1340,6 @@ void DolphinView::createView()
|
|||
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());
|
||||
}
|
||||
|
@ -1415,10 +1362,6 @@ void DolphinView::deleteView()
|
|||
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();
|
||||
}
|
||||
|
@ -1651,8 +1594,16 @@ void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -208,23 +208,6 @@ public:
|
|||
|
||||
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
|
||||
|
@ -279,16 +262,6 @@ public:
|
|||
*/
|
||||
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.
|
||||
|
@ -356,12 +329,12 @@ public:
|
|||
/**
|
||||
* 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:
|
||||
/**
|
||||
|
@ -523,9 +496,6 @@ signals:
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -647,12 +617,6 @@ private slots:
|
|||
*/
|
||||
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,
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
#include "dolphinsortfilterproxymodel.h"
|
||||
#include "dolphindetailsview.h"
|
||||
#include "dolphiniconsview.h"
|
||||
#include "dolphincontextmenu.h"
|
||||
#include "draganddrophelper.h"
|
||||
#include "filterbar.h"
|
||||
#include "statusbar/dolphinstatusbar.h"
|
||||
|
@ -63,12 +62,9 @@
|
|||
#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),
|
||||
|
@ -89,13 +85,15 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
|
|||
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()));
|
||||
|
||||
|
@ -132,10 +130,6 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
|
|||
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&)),
|
||||
|
@ -146,15 +140,15 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
|
|||
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()));
|
||||
|
||||
|
@ -197,9 +191,9 @@ DolphinViewContainer::~DolphinViewContainer()
|
|||
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)
|
||||
|
@ -207,7 +201,7 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,14 +224,14 @@ bool DolphinViewContainer::isFilterBarVisible() const
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -252,11 +246,6 @@ void DolphinViewContainer::showFilterBar(bool show)
|
|||
}
|
||||
}
|
||||
|
||||
bool DolphinViewContainer::isUrlEditable() const
|
||||
{
|
||||
return m_urlNavigator->isUrlEditable();
|
||||
}
|
||||
|
||||
void DolphinViewContainer::delayedStatusBarUpdate()
|
||||
{
|
||||
// Invoke updateStatusBar() with a small delay. This assures that
|
||||
|
@ -320,6 +309,7 @@ void DolphinViewContainer::slotDirListerCompleted()
|
|||
} else {
|
||||
updateStatusBar();
|
||||
}
|
||||
QMetaObject::invokeMethod(this, "restoreViewState", Qt::QueuedConnection);
|
||||
|
||||
// Enable the 'File'->'Create New...' menu only if the directory
|
||||
// supports writing.
|
||||
|
@ -333,7 +323,7 @@ void DolphinViewContainer::slotDirListerCompleted()
|
|||
}
|
||||
|
||||
if (isActive()) {
|
||||
m_mainWindow->newMenu()->menu()->setEnabled(m_isFolderWritable);
|
||||
emit writeStateChanged(m_isFolderWritable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,20 +371,11 @@ void DolphinViewContainer::setNameFilter(const QString& nameFilter)
|
|||
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();
|
||||
}
|
||||
|
||||
void DolphinViewContainer::saveContentsPos(int x, int y)
|
||||
{
|
||||
// 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);
|
||||
QByteArray locationState = m_urlNavigator->locationState();
|
||||
QDataStream stream(&locationState, QIODevice::ReadOnly);
|
||||
m_view->restoreState(stream);
|
||||
}
|
||||
|
||||
void DolphinViewContainer::activate()
|
||||
|
@ -402,10 +383,18 @@ void DolphinViewContainer::activate()
|
|||
setActive(true);
|
||||
}
|
||||
|
||||
void DolphinViewContainer::restoreView(const KUrl& url)
|
||||
void DolphinViewContainer::saveViewState()
|
||||
{
|
||||
QByteArray locationState;
|
||||
QDataStream stream(&locationState, QIODevice::WriteOnly);
|
||||
m_view->saveState(stream);
|
||||
m_urlNavigator->saveLocationState(locationState);
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -443,12 +432,6 @@ void DolphinViewContainer::restoreView(const KUrl& url)
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -459,7 +442,7 @@ void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -478,13 +461,11 @@ void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion com
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ class KUrl;
|
|||
class DolphinModel;
|
||||
class KUrlNavigator;
|
||||
class DolphinDirLister;
|
||||
class DolphinMainWindow;
|
||||
class DolphinSortFilterProxyModel;
|
||||
class DolphinStatusBar;
|
||||
|
||||
|
@ -62,17 +61,14 @@ class DolphinViewContainer : public QWidget
|
|||
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
|
||||
|
@ -84,12 +80,6 @@ public:
|
|||
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();
|
||||
|
||||
|
@ -125,6 +115,13 @@ signals:
|
|||
*/
|
||||
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
|
||||
|
@ -188,23 +185,7 @@ private slots:
|
|||
*/
|
||||
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
|
||||
|
@ -212,17 +193,17 @@ private slots:
|
|||
*/
|
||||
void activate();
|
||||
|
||||
/**
|
||||
* Saves the state of the current view: contents position,
|
||||
* root URL, ...
|
||||
*/
|
||||
void saveViewState();
|
||||
|
||||
/**
|
||||
* Restores the current view to show \a url and assures
|
||||
* that the root URL of the view is respected.
|
||||
*/
|
||||
void restoreView(const KUrl& url);
|
||||
|
||||
/**
|
||||
* Saves the root URL of the current URL \a url
|
||||
* into the URL navigator.
|
||||
*/
|
||||
void saveRootUrl(const KUrl& url);
|
||||
void slotUrlNavigatorLocationChanged(const KUrl& url);
|
||||
|
||||
/**
|
||||
* Is connected with the URL navigator and drops the URLs
|
||||
|
@ -251,7 +232,6 @@ private slots:
|
|||
private:
|
||||
bool m_isFolderWritable;
|
||||
|
||||
DolphinMainWindow* m_mainWindow;
|
||||
QVBoxLayout* m_topLayout;
|
||||
KUrlNavigator* m_urlNavigator;
|
||||
|
||||
|
|
Loading…
Reference in a new issue