mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Provide clickable resources for the Information Panel. Thanks to Sebastian Trüg für the patch!
CCMAIL: trueg@kde.org svn path=/trunk/KDE/kdebase/apps/; revision=1051553
This commit is contained in:
parent
f2c315a147
commit
2b6cceb0f6
10 changed files with 71 additions and 27 deletions
|
@ -1375,6 +1375,7 @@ void DolphinMainWindow::setupDockWidgets()
|
|||
infoDock->setObjectName("infoDock");
|
||||
infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
Panel* infoPanel = new InformationPanel(infoDock);
|
||||
connect(infoPanel, SIGNAL(urlActivated(KUrl)), activeViewContainer(), SLOT(setUrl(KUrl)));
|
||||
infoDock->setWidget(infoPanel);
|
||||
|
||||
QAction* infoAction = infoDock->toggleViewAction();
|
||||
|
|
|
@ -191,20 +191,6 @@ DolphinViewContainer::~DolphinViewContainer()
|
|||
m_dirLister = 0; // deleted by m_dolphinModel
|
||||
}
|
||||
|
||||
void DolphinViewContainer::setUrl(const KUrl& newUrl)
|
||||
{
|
||||
if (newUrl != m_urlNavigator->url()) {
|
||||
m_urlNavigator->setUrl(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const KUrl& DolphinViewContainer::url() const
|
||||
{
|
||||
return m_urlNavigator->url();
|
||||
|
@ -236,6 +222,20 @@ bool DolphinViewContainer::isFilterBarVisible() const
|
|||
return m_filterBar->isVisible();
|
||||
}
|
||||
|
||||
void DolphinViewContainer::setUrl(const KUrl& newUrl)
|
||||
{
|
||||
if (newUrl != m_urlNavigator->url()) {
|
||||
m_urlNavigator->setUrl(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinViewContainer::showFilterBar(bool show)
|
||||
{
|
||||
Q_ASSERT(m_filterBar != 0);
|
||||
|
|
|
@ -68,15 +68,6 @@ public:
|
|||
|
||||
virtual ~DolphinViewContainer();
|
||||
|
||||
/**
|
||||
* Sets the current active URL, where all actions are applied. The
|
||||
* URL navigator is synchronized with this URL. The signals
|
||||
* KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
|
||||
* are emitted.
|
||||
* @see DolphinViewContainer::urlNavigator()
|
||||
*/
|
||||
void setUrl(const KUrl& url);
|
||||
|
||||
/**
|
||||
* Returns the current active URL, where all actions are applied.
|
||||
* The URL navigator is synchronized with this URL.
|
||||
|
@ -114,6 +105,15 @@ public:
|
|||
bool isFilterBarVisible() const;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* Sets the current active URL, where all actions are applied. The
|
||||
* URL navigator is synchronized with this URL. The signals
|
||||
* KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
|
||||
* are emitted.
|
||||
* @see DolphinViewContainer::urlNavigator()
|
||||
*/
|
||||
void setUrl(const KUrl& url);
|
||||
|
||||
/**
|
||||
* Popups the filter bar above the status bar if \a show is true.
|
||||
*/
|
||||
|
@ -125,7 +125,7 @@ signals:
|
|||
*/
|
||||
void showFilterBarChanged(bool shown);
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
/**
|
||||
* Updates the number of items (= number of files + number of
|
||||
* directories) in the statusbar. If files are selected, the number
|
||||
|
|
|
@ -255,7 +255,7 @@ void InformationPanel::slotLeftDirectory(const QString& directory)
|
|||
// The signal 'leftDirectory' is also emitted when a media
|
||||
// has been unmounted. In this case no directory change will be
|
||||
// done in Dolphin, but the Information Panel must be updated to
|
||||
// indicate an invalid directory.
|
||||
// indicate an invalid directory.
|
||||
markUrlAsInvalid();
|
||||
}
|
||||
}
|
||||
|
@ -313,6 +313,7 @@ void InformationPanel::init()
|
|||
connect(dirNotify, SIGNAL(leftDirectory(QString)), SLOT(slotLeftDirectory(QString)));
|
||||
|
||||
m_content = new InformationPanelContent(this);
|
||||
connect(m_content, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl)));
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ public:
|
|||
/** @see QWidget::sizeHint() */
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
signals:
|
||||
void urlActivated(const KUrl& url);
|
||||
|
||||
public slots:
|
||||
/** @see Panel::setUrl() */
|
||||
virtual void setUrl(const KUrl& url);
|
||||
|
|
|
@ -103,6 +103,7 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
|
|||
|
||||
m_metaDataWidget = new KMetaDataWidget(parent);
|
||||
m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
||||
connect(m_metaDataWidget, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl)));
|
||||
|
||||
// Encapsulate the MetaDataWidget inside a container that has a dummy widget
|
||||
// at the bottom. This prevents that the meta data widget gets vertically stretched
|
||||
|
|
|
@ -100,7 +100,11 @@ void KLoadMetaDataThread::run()
|
|||
Item item;
|
||||
item.name = prop.name();
|
||||
item.label = tunedLabel(prop.label());
|
||||
item.value = formatValue(it.value());
|
||||
if (it.value().isResource() || it.value().isResourceList()) {
|
||||
item.resources = it.value().toResourceList();
|
||||
} else {
|
||||
item.value = formatValue(it.value());
|
||||
}
|
||||
m_items.append(item);
|
||||
}
|
||||
++it;
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
QString name;
|
||||
QString label;
|
||||
QString value;
|
||||
QList<Nepomuk::Resource> resources;
|
||||
};
|
||||
|
||||
KLoadMetaDataThread();
|
||||
|
|
|
@ -94,6 +94,7 @@ public:
|
|||
void slotCommentChanged(const QString& comment);
|
||||
|
||||
void slotMetaDataUpdateDone();
|
||||
void slotLinkActivated(const QString& link);
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
/**
|
||||
|
@ -107,6 +108,12 @@ public:
|
|||
* Merges items like 'width' and 'height' as one item.
|
||||
*/
|
||||
QList<KLoadMetaDataThread::Item> mergedItems(const QList<KLoadMetaDataThread::Item>& items);
|
||||
|
||||
/**
|
||||
* Returns a (clickable) text for the given item, that can be used for
|
||||
* the information value widget.
|
||||
*/
|
||||
QString labelText(const KLoadMetaDataThread::Item& item) const;
|
||||
#endif
|
||||
|
||||
bool m_sizeVisible;
|
||||
|
@ -365,7 +372,9 @@ void KMetaDataWidget::Private::slotLoadingFinished()
|
|||
} else {
|
||||
// create new row
|
||||
QLabel* infoLabel = new QLabel(item.label, q);
|
||||
QLabel* infoValue = new QLabel(item.value, q);
|
||||
QLabel* infoValue = new QLabel(labelText(item), q);
|
||||
connect(infoValue, SIGNAL(linkActivated(QString)),
|
||||
q, SLOT(slotLinkActivated(QString)));
|
||||
addRow(infoLabel, infoValue);
|
||||
}
|
||||
++index;
|
||||
|
@ -432,6 +441,11 @@ void KMetaDataWidget::Private::slotMetaDataUpdateDone()
|
|||
#endif
|
||||
}
|
||||
|
||||
void KMetaDataWidget::Private::slotLinkActivated(const QString& link)
|
||||
{
|
||||
emit q->urlActivated(KUrl(link));
|
||||
}
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
void KMetaDataWidget::Private::startChangeDataJob(KJob* job)
|
||||
{
|
||||
|
@ -489,6 +503,21 @@ QList<KLoadMetaDataThread::Item>
|
|||
|
||||
return mergedItems;
|
||||
}
|
||||
|
||||
QString KMetaDataWidget::Private::labelText(const KLoadMetaDataThread::Item& item) const
|
||||
{
|
||||
if (item.resources.isEmpty()) {
|
||||
return item.value;
|
||||
}
|
||||
|
||||
QStringList links;
|
||||
foreach(const Nepomuk::Resource& res, item.resources) {
|
||||
links << QString::fromLatin1("<a href=\"%1\">%2</a>")
|
||||
.arg(KUrl(res.resourceUri()).url())
|
||||
.arg(res.genericLabel());
|
||||
}
|
||||
return QLatin1String("<p>") + links.join(QLatin1String(";\n"));
|
||||
}
|
||||
#endif
|
||||
|
||||
KMetaDataWidget::KMetaDataWidget(QWidget* parent) :
|
||||
|
|
|
@ -122,6 +122,9 @@ public:
|
|||
/** @see QWidget::sizeHint() */
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void urlActivated(const KUrl& url);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private* d;
|
||||
|
@ -131,6 +134,7 @@ private:
|
|||
Q_PRIVATE_SLOT(d, void slotTagsChanged(const QList<Nepomuk::Tag>& tags))
|
||||
Q_PRIVATE_SLOT(d, void slotCommentChanged(const QString& comment))
|
||||
Q_PRIVATE_SLOT(d, void slotMetaDataUpdateDone())
|
||||
Q_PRIVATE_SLOT(d, void slotLinkActivated(const QString& link))
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(KMetaDataWidget::MetaDataTypes)
|
||||
|
|
Loading…
Reference in a new issue