mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Internal cleanup for panels: Let the panel-implementations decide whether they accept an URL or not.
svn path=/trunk/KDE/kdebase/apps/; revision=1183480
This commit is contained in:
parent
06b0569613
commit
431da0482c
10 changed files with 75 additions and 61 deletions
|
@ -103,23 +103,20 @@ void FoldersPanel::rename(const KFileItem& item)
|
|||
}
|
||||
}
|
||||
|
||||
void FoldersPanel::setUrl(const KUrl& url)
|
||||
bool FoldersPanel::urlChanged()
|
||||
{
|
||||
if (!url.isValid() || (url == Panel::url())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.protocol().contains("search")) {
|
||||
if (!url().isValid() || url().protocol().contains("search")) {
|
||||
// Skip results shown by a search, as possible identical
|
||||
// directory names are useless without parent-path information.
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
Panel::setUrl(url);
|
||||
if (m_dirLister != 0) {
|
||||
m_setLeafVisible = true;
|
||||
loadTree(url);
|
||||
loadTree(url());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FoldersPanel::showEvent(QShowEvent* event)
|
||||
|
|
|
@ -59,13 +59,10 @@ signals:
|
|||
*/
|
||||
void changeUrl(const KUrl& url, Qt::MouseButtons buttons);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* Changes the current selection inside the tree to \a url.
|
||||
*/
|
||||
virtual void setUrl(const KUrl& url);
|
||||
|
||||
protected:
|
||||
/** @see Panel::urlChanged() */
|
||||
virtual bool urlChanged();
|
||||
|
||||
/** @see QWidget::showEvent() */
|
||||
virtual void showEvent(QShowEvent* event);
|
||||
|
||||
|
|
|
@ -52,24 +52,6 @@ QSize InformationPanel::sizeHint() const
|
|||
return size;
|
||||
}
|
||||
|
||||
void InformationPanel::setUrl(const KUrl& url)
|
||||
{
|
||||
Panel::setUrl(url);
|
||||
if (!url.isValid() || isEqualToShownUrl(url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_shownUrl = url;
|
||||
if (isVisible()) {
|
||||
cancelRequest();
|
||||
// Update the content with a delay. This gives
|
||||
// the directory lister the chance to show the content
|
||||
// before expensive operations are done to show
|
||||
// meta information.
|
||||
m_urlChangedTimer->start();
|
||||
}
|
||||
}
|
||||
|
||||
void InformationPanel::setSelection(const KFileItemList& selection)
|
||||
{
|
||||
if (!isVisible()) {
|
||||
|
@ -126,6 +108,25 @@ void InformationPanel::requestDelayedItemInfo(const KFileItem& item)
|
|||
}
|
||||
}
|
||||
|
||||
bool InformationPanel::urlChanged()
|
||||
{
|
||||
if (!url().isValid() || isEqualToShownUrl(url())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_shownUrl = url();
|
||||
if (isVisible()) {
|
||||
cancelRequest();
|
||||
// Update the content with a delay. This gives
|
||||
// the directory lister the chance to show the content
|
||||
// before expensive operations are done to show
|
||||
// meta information.
|
||||
m_urlChangedTimer->start();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InformationPanel::showEvent(QShowEvent* event)
|
||||
{
|
||||
Panel::showEvent(event);
|
||||
|
|
|
@ -42,9 +42,6 @@ signals:
|
|||
void urlActivated(const KUrl& url);
|
||||
|
||||
public slots:
|
||||
/** @see Panel::setUrl() */
|
||||
virtual void setUrl(const KUrl& url);
|
||||
|
||||
/**
|
||||
* This is invoked to inform the panel that the user has selected a new
|
||||
* set of items.
|
||||
|
@ -60,6 +57,9 @@ public slots:
|
|||
void requestDelayedItemInfo(const KFileItem& item);
|
||||
|
||||
protected:
|
||||
/** @see Panel::urlChanged() */
|
||||
virtual bool urlChanged();
|
||||
|
||||
/** @see QWidget::showEvent() */
|
||||
virtual void showEvent(QShowEvent* event);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
#include "pixmapviewer.h"
|
||||
|
||||
InformationPanelContent::InformationPanelContent(QWidget* parent) :
|
||||
Panel(parent),
|
||||
QWidget(parent),
|
||||
m_item(),
|
||||
m_pendingPreview(false),
|
||||
m_outdatedPreviewTimer(0),
|
||||
|
@ -262,7 +262,7 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
|
|||
break;
|
||||
}
|
||||
|
||||
return Panel::eventFilter(obj, event);
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void InformationPanelContent::configureSettings()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
|
||||
* Copyright (C) 2009-2010 by Peter Penz <peter.penz@gmx.at> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
|
@ -20,13 +20,12 @@
|
|||
#ifndef INFORMATIONPANELCONTENT_H
|
||||
#define INFORMATIONPANELCONTENT_H
|
||||
|
||||
#include <panels/panel.h>
|
||||
|
||||
#include <kconfig.h>
|
||||
#include <kfileitem.h>
|
||||
#include <kurl.h>
|
||||
#include <kvbox.h>
|
||||
|
||||
class KFileItem;
|
||||
class KFileItemList;
|
||||
class KFileMetaDataWidget;
|
||||
class PhononWidget;
|
||||
class PixmapViewer;
|
||||
|
@ -39,7 +38,7 @@ class QScrollArea;
|
|||
* @brief Manages the widgets that display the meta information
|
||||
* for file items of the Information Panel.
|
||||
*/
|
||||
class InformationPanelContent : public Panel
|
||||
class InformationPanelContent : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
|
||||
* Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
|
||||
* Copyright (C) 2006-2010 by Peter Penz <peter.penz@gmx.at> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
|
@ -31,14 +31,23 @@ Panel::~Panel()
|
|||
{
|
||||
}
|
||||
|
||||
const KUrl& Panel::url() const
|
||||
KUrl Panel::url() const
|
||||
{
|
||||
return m_url;
|
||||
}
|
||||
|
||||
void Panel::setUrl(const KUrl& url)
|
||||
{
|
||||
if (url.equals(m_url, KUrl::CompareWithoutTrailingSlash)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const KUrl oldUrl = m_url;
|
||||
m_url = url;
|
||||
const bool accepted = urlChanged();
|
||||
if (!accepted) {
|
||||
m_url = oldUrl;
|
||||
}
|
||||
}
|
||||
|
||||
#include "panel.moc"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
|
||||
* Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
|
||||
* Copyright (C) 2006-2010 by Peter Penz <peter.penz@gmx.at> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
|
@ -37,14 +37,24 @@ public:
|
|||
virtual ~Panel();
|
||||
|
||||
/** Returns the current set URL of the active Dolphin view. */
|
||||
const KUrl& url() const;
|
||||
KUrl url() const;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* This is invoked every time the folder being displayed in the
|
||||
* active Dolphin view changes.
|
||||
*/
|
||||
virtual void setUrl(const KUrl& url);
|
||||
void setUrl(const KUrl& url);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Must be implemented by derived classes and is invoked when
|
||||
* the URL has been changed (see Panel::setUrl()).
|
||||
* @return True, if the new URL will get accepted by the derived
|
||||
* class. If false is returned,
|
||||
* the URL will be reset to the previous URL.
|
||||
*/
|
||||
virtual bool urlChanged() = 0;
|
||||
|
||||
private:
|
||||
KUrl m_url;
|
||||
|
|
|
@ -52,26 +52,26 @@ QSize TerminalPanel::sizeHint() const
|
|||
return size;
|
||||
}
|
||||
|
||||
void TerminalPanel::setUrl(const KUrl& url)
|
||||
void TerminalPanel::terminalExited()
|
||||
{
|
||||
if (!url.isValid() || (url == Panel::url())) {
|
||||
return;
|
||||
}
|
||||
emit hideTerminalPanel();
|
||||
m_terminal = 0;
|
||||
}
|
||||
|
||||
Panel::setUrl(url);
|
||||
bool TerminalPanel::urlChanged()
|
||||
{
|
||||
if (!url().isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool sendInput = (m_terminal != 0)
|
||||
&& (m_terminal->foregroundProcessId() == -1)
|
||||
&& isVisible();
|
||||
if (sendInput) {
|
||||
changeDir(url);
|
||||
changeDir(url());
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalPanel::terminalExited()
|
||||
{
|
||||
emit hideTerminalPanel();
|
||||
m_terminal = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TerminalPanel::showEvent(QShowEvent* event)
|
||||
|
|
|
@ -46,14 +46,15 @@ public:
|
|||
virtual QSize sizeHint() const;
|
||||
|
||||
public slots:
|
||||
/** @see Panel::setUrl(). */
|
||||
virtual void setUrl(const KUrl& url);
|
||||
void terminalExited();
|
||||
|
||||
signals:
|
||||
void hideTerminalPanel();
|
||||
|
||||
protected:
|
||||
/** @see Panel::urlChanged() */
|
||||
virtual bool urlChanged();
|
||||
|
||||
/** @see QWidget::showEvent() */
|
||||
virtual void showEvent(QShowEvent* event);
|
||||
|
||||
|
|
Loading…
Reference in a new issue