┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-09-26 13:15:16 +0000
committerPeter Penz <[email protected]>2007-09-26 13:15:16 +0000
commit89a12482f7b7bf75068b711f6c1f80c1211021b1 (patch)
treea5bf8c0658ce297112b44bc2cd603c6afffd9304 /src
parent8df41dd0061fb92882aefe532bd762341df64072 (diff)
assure that the width of the name-column cannot get too small when decreasing the width of the viewport
CCMAIL: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=717258
Diffstat (limited to 'src')
-rw-r--r--src/dolphindetailsview.cpp53
-rw-r--r--src/dolphindetailsview.h1
2 files changed, 44 insertions, 10 deletions
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index 2eca0860c..3170f6c90 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -297,6 +297,39 @@ void DolphinDetailsView::keyPressEvent(QKeyEvent* event)
}
}
+void DolphinDetailsView::resizeEvent(QResizeEvent* event)
+{
+ QTreeView::resizeEvent(event);
+
+ // assure that the width of the name-column does not get too small
+ const int minWidth = 120;
+ QHeaderView* headerView = header();
+ bool useFixedWidth = (headerView->sectionSize(KDirModel::Name) <= minWidth)
+ && (headerView->resizeMode(0) != QHeaderView::Fixed);
+ if (useFixedWidth) {
+ // the current width of the name-column is too small, hence
+ // use a fixed size
+ headerView->setResizeMode(QHeaderView::Interactive);
+ headerView->setResizeMode(0, QHeaderView::Fixed);
+ headerView->resizeSection(KDirModel::Name, minWidth);
+ } else if (headerView->resizeMode(0) != QHeaderView::Stretch) {
+ // check whether there is enough available viewport width
+ // to automatically resize the columns
+ const int availableWidth = viewport()->width();
+
+ int headerWidth = 0;
+ const int count = headerView->count();
+ for (int i = 0; i < count; ++i) {
+ headerWidth += headerView->sectionSize(i);
+ }
+
+ if (headerWidth < availableWidth) {
+ headerView->setResizeMode(QHeaderView::ResizeToContents);
+ headerView->setResizeMode(0, QHeaderView::Stretch);
+ }
+ }
+}
+
void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
{
QHeaderView* headerView = header();
@@ -368,6 +401,16 @@ void DolphinDetailsView::zoomOut()
}
}
+void DolphinDetailsView::slotItemActivated(const QModelIndex& index)
+{
+ if (index.isValid() && (index.column() == KDirModel::Name)) {
+ m_controller->triggerItem(index);
+ } else {
+ clearSelection();
+ m_controller->emitItemEntered(index);
+ }
+}
+
bool DolphinDetailsView::isZoomInPossible() const
{
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
@@ -422,14 +465,4 @@ static bool isValidNameIndex(const QModelIndex& index)
return index.isValid() && (index.column() == KDirModel::Name);
}
-void DolphinDetailsView::slotItemActivated(const QModelIndex& index)
-{
- if (!isValidNameIndex(index)) {
- clearSelection();
- m_controller->emitItemEntered(index);
- } else {
- m_controller->triggerItem(index);
- }
-}
-
#include "dolphindetailsview.moc"
diff --git a/src/dolphindetailsview.h b/src/dolphindetailsview.h
index dc79c31cc..862a49613 100644
--- a/src/dolphindetailsview.h
+++ b/src/dolphindetailsview.h
@@ -57,6 +57,7 @@ protected:
virtual void dropEvent(QDropEvent* event);
virtual void paintEvent(QPaintEvent* event);
virtual void keyPressEvent(QKeyEvent* event);
+ virtual void resizeEvent(QResizeEvent* event);
private slots:
/**