svn path=/trunk/KDE/kdebase/apps/; revision=661815
m_multipleSelection(false), //TODO: check if I'm needed
m_pendingPreview(false),
m_timer(0),
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),
m_preview(0),
m_name(0),
m_infos(0),
void InfoSidebarPage::setSelection(const KFileItemList& selection)
{
cancelRequest();
void InfoSidebarPage::setSelection(const KFileItemList& selection)
{
cancelRequest();
- m_currentSelection = selection;
- m_multipleSelection = (m_currentSelection.size() > 1);
+ SidebarPage::setSelection(selection);
+ m_multipleSelection = (selection.size() > 1);
- KFileItemList selectedItems = m_currentSelection;
+ const KFileItemList& selectedItems = selection();
+
KUrl file;
if (selectedItems.count() == 0) {
file = m_shownUrl;
KUrl file;
if (selectedItems.count() == 0) {
file = m_shownUrl;
void InfoSidebarPage::createMetaInfo()
{
beginInfoLines();
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();
KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl);
fileItem.refresh();
if (MetaDataWidget::metaDataAvailable()) {
m_metadataWidget->setFile(fileItem.url());
}
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()));
addInfoLine(i18n("Type:"), fileItem->mimeComment());
QString sizeText(KIO::convertSize(fileItem->size()));
}
} else {
if (MetaDataWidget::metaDataAvailable()) {
}
} else {
if (MetaDataWidget::metaDataAvailable()) {
- m_metadataWidget->setFiles(m_currentSelection.urlList());
+ m_metadataWidget->setFiles(selectedItems.urlList());
}
unsigned long int totSize = 0;
}
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));
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));
class MetaDataWidget;
/**
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
{
*/
class InfoSidebarPage : public SidebarPage
{
virtual ~InfoSidebarPage();
public slots:
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);
QTimer* m_timer;
KUrl m_shownUrl;
KUrl m_urlCandidate;
QTimer* m_timer;
KUrl m_shownUrl;
KUrl m_urlCandidate;
- KFileItemList m_currentSelection;
PixmapViewer* m_preview;
QLabel* m_name;
PixmapViewer* m_preview;
QLabel* m_name;
/***************************************************************************
* Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
/***************************************************************************
* 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 *
* *
* 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 *
#include <kurl.h>
SidebarPage::SidebarPage(QWidget* parent) :
#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()
SidebarPage::~SidebarPage()
+{
+}
+
+const KUrl& SidebarPage::url() const
+{
+ return m_url;
+}
+
+const KFileItemList& SidebarPage::selection() const
+{
+ return m_currentSelection;
+}
void SidebarPage::setUrl(const KUrl& url)
{
void SidebarPage::setUrl(const KUrl& url)
{
/***************************************************************************
* Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
/***************************************************************************
* 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 *
* *
* 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 *
/**
* @brief Base widget for all pages that can be embedded into the Sidebar.
/**
* @brief Base widget for all pages that can be embedded into the Sidebar.
*/
class SidebarPage : public QWidget
{
*/
class SidebarPage : public QWidget
{
explicit SidebarPage(QWidget* parent = 0);
virtual ~SidebarPage();
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
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
*/
virtual void setUrl(const KUrl& url);
/**
* This is invoked to inform the sidebar that the user has selected a new
*/
virtual void setSelection(const KFileItemList& selection);
*/
virtual void setSelection(const KFileItemList& selection);
*/
void urlsDropped(const KUrl::List& urls, const KUrl& destination);
*/
void urlsDropped(const KUrl::List& urls, const KUrl& destination);
KUrl m_url;
KFileItemList m_currentSelection;
};
KUrl m_url;
KFileItemList m_currentSelection;
};
void TreeViewSidebarPage::setUrl(const KUrl& url)
{
void TreeViewSidebarPage::setUrl(const KUrl& url)
{
- if (!url.isValid() || (url == m_url)) {
+ if (!url.isValid() || (url == SidebarPage::url())) {
+ SidebarPage::setUrl(url);
// adjust the root of the tree to the base bookmark
KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel();
// adjust the root of the tree to the base bookmark
KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel();
this, SLOT(expandSelectionParent()));
// expand the parent folder of the selected item
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;
}
if (!m_dirLister->url().isParentOf(parentUrl)) {
return;
}
m_treeView->setExpanded(proxyIndex, true);
// select the item and assure that the item is visible
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);
if (index.isValid()) {
proxyIndex = m_proxyModel->mapFromSource(index);
m_treeView->scrollTo(proxyIndex);
/**
* Changes the current selection inside the tree to \a url.
*/
/**
* 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() */
protected:
/** @see QWidget::showEvent() */