some cleanups for the sidebar pages (move protected members to private section etc.)

svn path=/trunk/KDE/kdebase/apps/; revision=661815
This commit is contained in:
Peter Penz 2007-05-06 17:25:50 +00:00
parent 5f87a8130e
commit bafaf9496c
6 changed files with 46 additions and 30 deletions

View file

@ -54,7 +54,6 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
m_multipleSelection(false), //TODO: check if I'm needed
m_pendingPreview(false),
m_timer(0),
m_currentSelection(KFileItemList()),
m_preview(0),
m_name(0),
m_infos(0),
@ -126,8 +125,8 @@ void InfoSidebarPage::setUrl(const KUrl& url)
void InfoSidebarPage::setSelection(const KFileItemList& selection)
{
cancelRequest();
m_currentSelection = selection;
m_multipleSelection = (m_currentSelection.size() > 1);
SidebarPage::setSelection(selection);
m_multipleSelection = (selection.size() > 1);
showItemInfo();
}
@ -146,7 +145,8 @@ void InfoSidebarPage::showItemInfo()
{
cancelRequest();
KFileItemList selectedItems = m_currentSelection;
const KFileItemList& selectedItems = selection();
KUrl file;
if (selectedItems.count() == 0) {
file = m_shownUrl;
@ -246,7 +246,8 @@ void InfoSidebarPage::cancelRequest()
void InfoSidebarPage::createMetaInfo()
{
beginInfoLines();
if (m_currentSelection.size() == 0) {
const KFileItemList& selectedItems = selection();
if (selectedItems.size() == 0) {
KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl);
fileItem.refresh();
@ -256,8 +257,8 @@ void InfoSidebarPage::createMetaInfo()
if (MetaDataWidget::metaDataAvailable()) {
m_metadataWidget->setFile(fileItem.url());
}
} else if (m_currentSelection.count() == 1) {
KFileItem* fileItem = m_currentSelection.at(0);
} else if (selectedItems.count() == 1) {
KFileItem* fileItem = selectedItems.at(0);
addInfoLine(i18n("Type:"), fileItem->mimeComment());
QString sizeText(KIO::convertSize(fileItem->size()));
@ -279,11 +280,11 @@ void InfoSidebarPage::createMetaInfo()
}
} else {
if (MetaDataWidget::metaDataAvailable()) {
m_metadataWidget->setFiles(m_currentSelection.urlList());
m_metadataWidget->setFiles(selectedItems.urlList());
}
unsigned long int totSize = 0;
foreach(KFileItem* item, m_currentSelection) {
foreach(KFileItem* item, selectedItems) {
totSize += item->size(); //FIXME what to do with directories ? (same with the one-item-selected-code), item->size() does not return the size of the content : not very instinctive for users
}
addInfoLine(i18n("Total size:"), KIO::convertSize(totSize));

View file

@ -49,9 +49,7 @@ class PixmapViewer;
class MetaDataWidget;
/**
* @brief Prototype for a information sidebar.
*
* Will be exchanged in future releases by pluggable sidebar pages...
* @brief Sidebar for showing meta information of one ore more selected items.
*/
class InfoSidebarPage : public SidebarPage
{
@ -62,8 +60,8 @@ public:
virtual ~InfoSidebarPage();
public slots:
void setUrl(const KUrl& url);
void setSelection(const KFileItemList& selection);
virtual void setUrl(const KUrl& url);
virtual void setSelection(const KFileItemList& selection);
private slots:
/**
@ -130,7 +128,6 @@ private:
QTimer* m_timer;
KUrl m_shownUrl;
KUrl m_urlCandidate;
KFileItemList m_currentSelection;
PixmapViewer* m_preview;
QLabel* m_name;

View file

@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
* Copyright (C) 2006 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 *
@ -23,13 +24,25 @@
#include <kurl.h>
SidebarPage::SidebarPage(QWidget* parent) :
QWidget(parent),
m_url(KUrl()),
m_currentSelection(KFileItemList())
{}
QWidget(parent),
m_url(KUrl()),
m_currentSelection(KFileItemList())
{
}
SidebarPage::~SidebarPage()
{}
{
}
const KUrl& SidebarPage::url() const
{
return m_url;
}
const KFileItemList& SidebarPage::selection() const
{
return m_currentSelection;
}
void SidebarPage::setUrl(const KUrl& url)
{

View file

@ -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 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 *
@ -27,7 +27,6 @@
/**
* @brief Base widget for all pages that can be embedded into the Sidebar.
*
*/
class SidebarPage : public QWidget
{
@ -36,16 +35,22 @@ public:
explicit SidebarPage(QWidget* parent = 0);
virtual ~SidebarPage();
/** Returns the current set URL of the active Dolphin view. */
const KUrl& url() const;
/** Returns the current selected items of the active Dolphin view. */
const KFileItemList& selection() const;
public slots:
/**
* This is invoked every time the folder being displayed in the
* file-management views changes.
* active Dolphin view changes.
*/
virtual void setUrl(const KUrl& url);
/**
* This is invoked to inform the sidebar that the user has selected a new
* set of files.
* set of items.
*/
virtual void setSelection(const KFileItemList& selection);
@ -73,7 +78,7 @@ signals:
*/
void urlsDropped(const KUrl::List& urls, const KUrl& destination);
protected:
private:
KUrl m_url;
KFileItemList m_currentSelection;
};

View file

@ -81,11 +81,11 @@ TreeViewSidebarPage::~TreeViewSidebarPage()
void TreeViewSidebarPage::setUrl(const KUrl& url)
{
if (!url.isValid() || (url == m_url)) {
if (!url.isValid() || (url == SidebarPage::url())) {
return;
}
m_url = url;
SidebarPage::setUrl(url);
// adjust the root of the tree to the base bookmark
KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel();
@ -156,7 +156,7 @@ void TreeViewSidebarPage::expandSelectionParent()
this, SLOT(expandSelectionParent()));
// expand the parent folder of the selected item
KUrl parentUrl = m_url.upUrl();
KUrl parentUrl = url().upUrl();
if (!m_dirLister->url().isParentOf(parentUrl)) {
return;
}
@ -167,7 +167,7 @@ void TreeViewSidebarPage::expandSelectionParent()
m_treeView->setExpanded(proxyIndex, true);
// select the item and assure that the item is visible
index = m_dirModel->indexForUrl(m_url);
index = m_dirModel->indexForUrl(url());
if (index.isValid()) {
proxyIndex = m_proxyModel->mapFromSource(index);
m_treeView->scrollTo(proxyIndex);

View file

@ -49,7 +49,7 @@ public slots:
/**
* Changes the current selection inside the tree to \a url.
*/
void setUrl(const KUrl& url);
virtual void setUrl(const KUrl& url);
protected:
/** @see QWidget::showEvent() */