- provide meta information when hovering items
- don't increase the sidebar width, if the item name is longer than the available width
svn path=/trunk/KDE/kdebase/apps/; revision=665646
emit selectionChanged(selection);
}
emit selectionChanged(selection);
}
+void DolphinMainWindow::slotRequestItemInfo(const KUrl& url)
+{
+ emit requestItemInfo(url);
+}
+
void DolphinMainWindow::slotHistoryChanged()
{
updateHistory();
void DolphinMainWindow::slotHistoryChanged()
{
updateHistory();
infoWidget, SLOT(setUrl(KUrl)));
connect(this, SIGNAL(selectionChanged(KFileItemList)),
infoWidget, SLOT(setSelection(KFileItemList)));
infoWidget, SLOT(setUrl(KUrl)));
connect(this, SIGNAL(selectionChanged(KFileItemList)),
infoWidget, SLOT(setSelection(KFileItemList)));
+ connect(this, SIGNAL(requestItemInfo(KUrl)),
+ infoWidget, SLOT(requestDelayedItemInfo(KUrl)));
// setup "Tree View"
QDockWidget* treeViewDock = new QDockWidget(i18n("Folders"));
// setup "Tree View"
QDockWidget* treeViewDock = new QDockWidget(i18n("Folders"));
this, SLOT(slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation)));
connect(view, SIGNAL(selectionChanged(KFileItemList)),
this, SLOT(slotSelectionChanged(KFileItemList)));
this, SLOT(slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation)));
connect(view, SIGNAL(selectionChanged(KFileItemList)),
this, SLOT(slotSelectionChanged(KFileItemList)));
+ connect(view, SIGNAL(requestItemInfo(KUrl)),
+ this, SLOT(slotRequestItemInfo(KUrl)));
connect(view, SIGNAL(showFilterBarChanged(bool)),
this, SLOT(updateFilterBarAction(bool)));
connect(view, SIGNAL(urlChanged(KUrl)),
connect(view, SIGNAL(showFilterBarChanged(bool)),
this, SLOT(updateFilterBarAction(bool)));
connect(view, SIGNAL(urlChanged(KUrl)),
*/
void urlChanged(const KUrl& url);
*/
void urlChanged(const KUrl& url);
+ /**
+ * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
+ * It the URL is empty, no item information request is pending.
+ */
+ void requestItemInfo(const KUrl& url);
+
protected:
/** @see QMainWindow::closeEvent */
virtual void closeEvent(QCloseEvent* event);
protected:
/** @see QMainWindow::closeEvent */
virtual void closeEvent(QCloseEvent* event);
/** Updates the state of the 'Additional Information' actions. */
void slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info);
/** Updates the state of the 'Additional Information' actions. */
void slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info);
- /** Updates the state of the 'Edit' menu actions. */
+ /**
+ * Updates the state of the 'Edit' menu actions and emits
+ * the signal selectionChanged().
+ */
void slotSelectionChanged(const KFileItemList& selection);
void slotSelectionChanged(const KFileItemList& selection);
+ /** Emits the signal requestItemInfo(). */
+ void slotRequestItemInfo(const KUrl& url);
+
/**
* Updates the state of the 'Back' and 'Forward' menu
* actions corresponding the the current history.
/**
* Updates the state of the 'Back' and 'Forward' menu
* actions corresponding the the current history.
#include "infosidebarpage.h"
#include "infosidebarpage.h"
-#include <QtGui/QLayout>
-#include <QtGui/QPixmap>
-#include <QtGui/QLabel>
-#include <QtCore/QTimer>
-#include <QtGui/QPushButton>
-#include <QtGui/QMenu>
-#include <QtGui/QPainter>
-#include <QtGui/QFontMetrics>
-#include <QtCore/QEvent>
-#include <QtGui/QInputDialog>
-#include <QtCore/QDir>
+#include <QDir>
+#include <QEvent>
+#include <QFontMetrics>
+#include <QInputDialog>
+#include <QLabel>
+#include <QLayout>
+#include <QMenu>
+#include <QPainter>
+#include <QPixmap>
+#include <QPushButton>
+#include <QResizeEvent>
+#include <QTimer>
#include <kfileplacesmodel.h>
#include <klocale.h>
#include <kfileplacesmodel.h>
#include <klocale.h>
m_name = new QLabel(this);
m_name->setTextFormat(Qt::RichText);
m_name->setAlignment(m_name->alignment() | Qt::AlignHCenter);
m_name = new QLabel(this);
m_name->setTextFormat(Qt::RichText);
m_name->setAlignment(m_name->alignment() | Qt::AlignHCenter);
- QFontMetrics fontMetrics(m_name->font());
- m_name->setMinimumHeight(fontMetrics.height() * 3);
- m_name->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
-
- KSeparator* sep1 = new KSeparator(this);
+ m_name->setWordWrap(true);
// general information
m_infos = new QLabel(this);
m_infos->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
m_infos->setTextFormat(Qt::RichText);
// general information
m_infos = new QLabel(this);
m_infos->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
m_infos->setTextFormat(Qt::RichText);
- KSeparator* sep2 = new KSeparator(this);
-
if (MetaDataWidget::metaDataAvailable()) {
m_metadataWidget = new MetaDataWidget(this);
}
if (MetaDataWidget::metaDataAvailable()) {
m_metadataWidget = new MetaDataWidget(this);
}
layout->addItem(new QSpacerItem(spacing, spacing, QSizePolicy::Preferred, QSizePolicy::Fixed));
layout->addWidget(m_preview);
layout->addWidget(m_name);
layout->addItem(new QSpacerItem(spacing, spacing, QSizePolicy::Preferred, QSizePolicy::Fixed));
layout->addWidget(m_preview);
layout->addWidget(m_name);
- layout->addWidget(sep1);
+ layout->addWidget(new KSeparator(this));
layout->addWidget(m_infos);
layout->addWidget(m_infos);
- layout->addWidget(sep2);
+ layout->addWidget(new KSeparator(this));
if (m_metadataWidget) {
layout->addWidget(m_metadataWidget);
layout->addWidget(new KSeparator(this));
if (m_metadataWidget) {
layout->addWidget(m_metadataWidget);
layout->addWidget(new KSeparator(this));
-void InfoSidebarPage::showEvent(QShowEvent* event)
-{
- SidebarPage::showEvent(event);
- showItemInfo();
-}
-
void InfoSidebarPage::requestDelayedItemInfo(const KUrl& url)
{
cancelRequest();
void InfoSidebarPage::requestDelayedItemInfo(const KUrl& url)
{
cancelRequest();
+void InfoSidebarPage::showEvent(QShowEvent* event)
+{
+ SidebarPage::showEvent(event);
+ showItemInfo();
+}
+
+void InfoSidebarPage::resizeEvent(QResizeEvent* event)
+{
+ // If the item name cannot get wrapped, the maximum width of
+ // the label is increased, so that the width of the information sidebar
+ // gets increased. To prevent this, the maximum width is adjusted to
+ // the current width of the sidebar.
+ m_name->setMaximumWidth(event->size().width() - KDialog::spacingHint() * 4);
+ SidebarPage::resizeEvent(event);
+}
+
void InfoSidebarPage::showItemInfo()
{
if (!isVisible()) {
void InfoSidebarPage::showItemInfo()
{
if (!isVisible()) {
virtual ~InfoSidebarPage();
public slots:
virtual ~InfoSidebarPage();
public slots:
+ /** @see SidebarPage::setUrl() */
virtual void setUrl(const KUrl& url);
virtual void setUrl(const KUrl& url);
+
+ /** @see SidebarPage::setSelection() */
virtual void setSelection(const KFileItemList& selection);
virtual void setSelection(const KFileItemList& selection);
+ /**
+ * Does a delayed request of information for the item of the given URL.
+ * If within this delay InfoSidebarPage::setUrl() or InfoSidebarPage::setSelection()
+ * are invoked, then the request will be skipped. Requesting a delayed item information
+ * makes sense when hovering items.
+ */
+ void requestDelayedItemInfo(const KUrl& url);
+
protected:
/** @see QWidget::showEvent() */
virtual void showEvent(QShowEvent* event);
protected:
/** @see QWidget::showEvent() */
virtual void showEvent(QShowEvent* event);
-private slots:
- /**
- * Does a delayed request of information for the item of the given Url and
- * provides default actions.
- *
- * @see InfoSidebarPage::showItemInfo()
- */
- void requestDelayedItemInfo(const KUrl& url);
+ /** @see QWidget::resizeEvent() */
+ virtual void resizeEvent(QResizeEvent* event);
- * Shows the information for the item of the Url which has been provided by
+ * Shows the information for the item of the URL which has been provided by
* InfoSidebarPage::requestItemInfo() and provides default actions.
*/
void showItemInfo();
* InfoSidebarPage::requestItemInfo() and provides default actions.
*/
void showItemInfo();
- * Checks whether the an Url is repesented by a bookmark. If yes,
+ * Checks whether the an URL is repesented by a bookmark. If yes,
* then the bookmark icon and name are shown instead of a preview.
* then the bookmark icon and name are shown instead of a preview.
- * @return True, if the Url represents exactly a bookmark.
+ * @return True, if the URL represents exactly a bookmark.
* @param url The url to check.
*/
bool applyBookmark(const KUrl& url);
* @param url The url to check.
*/
bool applyBookmark(const KUrl& url);