┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-05-17 14:51:54 +0000
committerPeter Penz <[email protected]>2007-05-17 14:51:54 +0000
commit2ed4d8dcc483ac6067149647eb457d46be7111c5 (patch)
treedc4a1fe49253c7ff6479ad09f1253d447d2fd802
parentc35843f38c596eda4a9b04ba4c6a3247f3bdebc9 (diff)
information sidebar fixes:
- 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
-rw-r--r--src/dolphinmainwindow.cpp9
-rw-r--r--src/dolphinmainwindow.h14
-rw-r--r--src/infosidebarpage.cpp57
-rw-r--r--src/infosidebarpage.h28
4 files changed, 70 insertions, 38 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 5b7fde6ce..43b699ee2 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -353,6 +353,11 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
emit selectionChanged(selection);
}
+void DolphinMainWindow::slotRequestItemInfo(const KUrl& url)
+{
+ emit requestItemInfo(url);
+}
+
void DolphinMainWindow::slotHistoryChanged()
{
updateHistory();
@@ -1247,6 +1252,8 @@ void DolphinMainWindow::setupDockWidgets()
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"));
@@ -1461,6 +1468,8 @@ void DolphinMainWindow::connectViewSignals(int viewIndex)
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)),
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index 35b1b5267..8d44a1086 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -143,6 +143,12 @@ signals:
*/
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);
@@ -379,9 +385,15 @@ private slots:
/** 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);
+ /** Emits the signal requestItemInfo(). */
+ void slotRequestItemInfo(const KUrl& url);
+
/**
* Updates the state of the 'Back' and 'Forward' menu
* actions corresponding the the current history.
diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp
index 8d99ddece..07887e2bd 100644
--- a/src/infosidebarpage.cpp
+++ b/src/infosidebarpage.cpp
@@ -21,17 +21,18 @@
#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>
@@ -77,19 +78,13 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
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);
- KSeparator* sep2 = new KSeparator(this);
-
if (MetaDataWidget::metaDataAvailable()) {
m_metadataWidget = new MetaDataWidget(this);
}
@@ -97,9 +92,9 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
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(sep2);
+ layout->addWidget(new KSeparator(this));
if (m_metadataWidget) {
layout->addWidget(m_metadataWidget);
layout->addWidget(new KSeparator(this));
@@ -130,12 +125,6 @@ void InfoSidebarPage::setSelection(const KFileItemList& selection)
showItemInfo();
}
-void InfoSidebarPage::showEvent(QShowEvent* event)
-{
- SidebarPage::showEvent(event);
- showItemInfo();
-}
-
void InfoSidebarPage::requestDelayedItemInfo(const KUrl& url)
{
cancelRequest();
@@ -147,6 +136,22 @@ void InfoSidebarPage::requestDelayedItemInfo(const KUrl& url)
}
}
+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()) {
diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h
index 5aa4f5d07..9fcf449be 100644
--- a/src/infosidebarpage.h
+++ b/src/infosidebarpage.h
@@ -60,24 +60,30 @@ public:
virtual ~InfoSidebarPage();
public slots:
+ /** @see SidebarPage::setUrl() */
virtual void setUrl(const KUrl& url);
+
+ /** @see SidebarPage::setSelection() */
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);
-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);
+private slots:
/**
- * 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();
@@ -102,9 +108,9 @@ private slots:
private:
/**
- * 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.
- * @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);