* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "dolphindetailsview.h"
-#include <qpainter.h>
-#include <qobject.h>
-#include <q3header.h>
-#include <qclipboard.h>
-#include <qpainter.h>
-//Added by qt3to4:
-#include <Q3ValueList>
-#include <QPixmap>
-#include <QDragMoveEvent>
-#include <QDropEvent>
-#include <QResizeEvent>
-#include <QMouseEvent>
-#include <QEvent>
-#include <QPaintEvent>
-#include <QStyleOptionFocusRect>
-#include <klocale.h>
-#include <kglobalsettings.h>
-#include <kicontheme.h>
-#include <qscrollbar.h>
-#include <qcursor.h>
-#include <qstyle.h>
-#include <assert.h>
-
-#include "dolphinview.h"
-#include "viewproperties.h"
-#include "dolphin.h"
-#include "kiconeffect.h"
+#include "dolphinmodel.h"
+#include "dolphincontroller.h"
#include "dolphinsettings.h"
-#include "dolphinstatusbar.h"
-#include "detailsmodesettings.h"
+#include "dolphinsortfilterproxymodel.h"
+#include "draganddrophelper.h"
+#include "viewproperties.h"
-DolphinDetailsView::DolphinDetailsView(DolphinView* parent) :
- KFileDetailView(parent),
- m_dolphinView(parent),
- m_resizeTimer(0),
- m_scrollTimer(0),
- m_rubber(0)
-{
- m_resizeTimer = new QTimer(this);
- connect(m_resizeTimer, SIGNAL(timeout()),
- this, SLOT(updateColumnsWidth()));
+#include "dolphin_detailsmodesettings.h"
+
+#include <kdirmodel.h>
+#include <klocale.h>
+#include <kmenu.h>
+
+#include <QAbstractProxyModel>
+#include <QAction>
+#include <QApplication>
+#include <QHeaderView>
+#include <QRubberBand>
+#include <QPainter>
+#include <QScrollBar>
+
+DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* controller) :
+ QTreeView(parent),
+ m_controller(controller),
+ m_font(),
+ m_decorationSize(),
+ m_clearAdditionalInfo(false),
+ m_dragging(false),
+ m_showElasticBand(false),
+ m_elasticBandOrigin(),
+ m_elasticBandDestination()
+{
+ Q_ASSERT(controller != 0);
setAcceptDrops(true);
- setSelectionMode(KFile::Extended);
- setHScrollBarMode(Q3ScrollView::AlwaysOff);
+ setRootIsDecorated(false);
+ setSortingEnabled(true);
+ setUniformRowHeights(true);
+ setSelectionBehavior(SelectItems);
+ setDragDropMode(QAbstractItemView::DragDrop);
+ setDropIndicatorShown(false);
+ setAlternatingRowColors(true);
+ setItemsExpandable(false);
- setColumnAlignment(SizeColumn, Qt::AlignRight);
- for (int i = DateColumn; i <= GroupColumn; ++i) {
- setColumnAlignment(i, Qt::AlignHCenter);
- }
+ setMouseTracking(true);
+ viewport()->setAttribute(Qt::WA_Hover);
+
+ const ViewProperties props(controller->url());
+ setSortIndicatorSection(props.sorting());
+ setSortIndicatorOrder(props.sortOrder());
+
+ QHeaderView* headerView = header();
+ connect(headerView, SIGNAL(sectionClicked(int)),
+ this, SLOT(synchronizeSortingState(int)));
+ headerView->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)),
+ this, SLOT(configureColumns(const QPoint&)));
+
+ connect(parent, SIGNAL(sortingChanged(DolphinView::Sorting)),
+ this, SLOT(setSortIndicatorSection(DolphinView::Sorting)));
+ connect(parent, SIGNAL(sortOrderChanged(Qt::SortOrder)),
+ this, SLOT(setSortIndicatorOrder(Qt::SortOrder)));
+
+ // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
+ // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
+ // necessary connecting the signal 'singleClick()' or 'doubleClick' and to handle the
+ // RETURN-key in keyPressEvent().
+ if (KGlobalSettings::singleClick()) {
+ connect(this, SIGNAL(clicked(const QModelIndex&)),
+ this, SLOT(triggerItem(const QModelIndex&)));
+ } else {
+ connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
+ this, SLOT(triggerItem(const QModelIndex&)));
+ }
+ connect(this, SIGNAL(entered(const QModelIndex&)),
+ this, SLOT(slotEntered(const QModelIndex&)));
+ connect(this, SIGNAL(viewportEntered()),
+ controller, SLOT(emitViewportEntered()));
+ connect(controller, SIGNAL(zoomIn()),
+ this, SLOT(zoomIn()));
+ connect(controller, SIGNAL(zoomOut()),
+ this, SLOT(zoomOut()));
+ connect(controller->dolphinView(), SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
+ this, SLOT(updateColumnVisibility()));
+
+ // apply the details mode settings to the widget
+ const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+ Q_ASSERT(settings != 0);
- Dolphin& dolphin = Dolphin::mainWin();
-
- connect(this, SIGNAL(onItem(Q3ListViewItem*)),
- this, SLOT(slotOnItem(Q3ListViewItem*)));
- connect(this, SIGNAL(onViewport()),
- this, SLOT(slotOnViewport()));
- connect(this, SIGNAL(contextMenuRequested(Q3ListViewItem*, const QPoint&, int)),
- this, SLOT(slotContextMenuRequested(Q3ListViewItem*, const QPoint&, int)));
- connect(this, SIGNAL(selectionChanged()),
- &dolphin, SLOT(slotSelectionChanged()));
- connect(&dolphin, SIGNAL(activeViewChanged()),
- this, SLOT(slotActivationUpdate()));
- connect(this, SIGNAL(itemRenamed(Q3ListViewItem*, const QString&, int)),
- this, SLOT(slotItemRenamed(Q3ListViewItem*, const QString&, int)));
- connect(this, SIGNAL(dropped(QDropEvent*, const KUrl::List&, const KUrl&)),
- parent, SLOT(slotUrlListDropped(QDropEvent*, const KUrl::List&, const KUrl&)));
-
- QClipboard* clipboard = QApplication::clipboard();
- connect(clipboard, SIGNAL(dataChanged()),
- this, SLOT(slotUpdateDisabledItems()));
-
- Q3Header* viewHeader = header();
- viewHeader->setResizeEnabled(false);
- viewHeader->setMovingEnabled(false);
- connect(viewHeader, SIGNAL(clicked(int)),
- this, SLOT(slotHeaderClicked(int)));
+ m_font = QFont(settings->fontFamily(), settings->fontSize());
- setMouseTracking(true);
- setDefaultRenameAction(Q3ListView::Accept);
+// TODO: Remove this check when 4.3.2 is released and KDE requires it... this
+// check avoids a division by zero happening on versions before 4.3.1.
+// Right now KDE in theory can be shipped with Qt 4.3.0 and above.
+// ereslibre
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 2) || defined(QT_KDE_QT_COPY))
+ setVerticalScrollMode(QTreeView::ScrollPerPixel);
+ setHorizontalScrollMode(QTreeView::ScrollPerPixel);
+#endif
- refreshSettings();
-}
+ updateDecorationSize();
-DolphinDetailsView::~DolphinDetailsView()
-{
- delete m_rubber;
- m_rubber = 0;
+ setFocus();
}
-void DolphinDetailsView::beginItemUpdates()
+DolphinDetailsView::~DolphinDetailsView()
{
}
-void DolphinDetailsView::endItemUpdates()
+bool DolphinDetailsView::event(QEvent* event)
{
- updateDisabledItems();
+ if (event->type() == QEvent::Polish) {
+ QHeaderView* headerView = header();
+ headerView->setResizeMode(QHeaderView::Interactive);
+ headerView->setMovable(false);
- // Restore the current item. Use the information stored in the history if
- // available. Otherwise use the first item as current item.
+ updateColumnVisibility();
- const KFileListViewItem* item = static_cast<const KFileListViewItem*>(firstChild());
- if (item != 0) {
- setCurrentItem(item->fileInfo());
+ hideColumn(DolphinModel::Rating);
+ hideColumn(DolphinModel::Tags);
}
-
- int index = 0;
- const Q3ValueList<UrlNavigator::HistoryElem> history = m_dolphinView->urlHistory(index);
- if (!history.isEmpty()) {
- KFileView* fileView = static_cast<KFileView*>(this);
- fileView->setCurrentItem(history[index].currentFileName());
- setContentsPos(history[index].contentsX(), history[index].contentsY());
+// TODO: Remove this check when 4.3.2 is released and KDE requires it... this
+// check avoids a division by zero happening on versions before 4.3.1.
+// Right now KDE in theory can be shipped with Qt 4.3.0 and above.
+// ereslibre
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 2) || defined(QT_KDE_QT_COPY))
+ else if (event->type() == QEvent::UpdateRequest) {
+ // a wheel movement will scroll 4 items
+ if (model()->rowCount() > 0) {
+ verticalScrollBar()->setSingleStep((sizeHintForRow(0) / 3) * 4);
+ }
}
+#endif
- updateColumnsWidth();
+ return QTreeView::event(event);
}
-void DolphinDetailsView::insertItem(KFileItem* fileItem)
+QStyleOptionViewItem DolphinDetailsView::viewOptions() const
{
- KFileView::insertItem(fileItem);
-
- DolphinListViewItem* item = new DolphinListViewItem(static_cast<Q3ListView*>(this), fileItem);
-
- QDir::SortFlags spec = KFileView::sorting();
- if (spec & QDir::Time) {
- item->setKey(sortingKey(fileItem->time(KIO::UDS_MODIFICATION_TIME),
- fileItem->isDir(),
- spec));
- }
- else if (spec & QDir::Size) {
- item->setKey(sortingKey(fileItem->size(), fileItem->isDir(), spec));
- }
- else {
- item->setKey(sortingKey(fileItem->text(), fileItem->isDir(), spec));
- }
-
- fileItem->setExtraData(this, item);
+ QStyleOptionViewItem viewOptions = QTreeView::viewOptions();
+ viewOptions.font = m_font;
+ viewOptions.showDecorationSelected = true;
+ viewOptions.decorationSize = m_decorationSize;
+ return viewOptions;
}
-bool DolphinDetailsView::isOnFilename(const Q3ListViewItem* item, const QPoint& pos) const
+void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
{
- const QPoint absPos(mapToGlobal(QPoint(0, 0)));
- return (pos.x() - absPos.x()) <= filenameWidth(item);
+ QTreeView::contextMenuEvent(event);
+ m_controller->triggerContextMenuRequest(event->pos());
}
-void DolphinDetailsView::refreshSettings()
+void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
{
- const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
- assert(settings != 0);
-
- if (!settings->showGroup()) {
- removeColumn(GroupColumn);
- }
- if (!settings->showOwner()) {
- removeColumn(OwnerColumn);
- }
- if (!settings->showPermissions()) {
- removeColumn(PermissionsColumn);
- }
- if (!settings->showDate()) {
- removeColumn(DateColumn);
- }
+ m_controller->requestActivation();
- QFont adjustedFont(font());
- adjustedFont.setFamily(settings->fontFamily());
- adjustedFont.setPointSize(settings->fontSize());
- setFont(adjustedFont);
-
- updateView(true);
-}
+ QTreeView::mousePressEvent(event);
-void DolphinDetailsView::zoomIn()
-{
- if (isZoomInPossible()) {
- DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
- switch (settings->iconSize()) {
- case K3Icon::SizeSmall: settings->setIconSize(K3Icon::SizeMedium); break;
- case K3Icon::SizeMedium: settings->setIconSize(K3Icon::SizeLarge); break;
- default: assert(false); break;
+ const QModelIndex index = indexAt(event->pos());
+ if (!index.isValid() || (index.column() != DolphinModel::Name)) {
+ const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
+ if (!(modifier & Qt::ShiftModifier) && !(modifier & Qt::ControlModifier)) {
+ clearSelection();
}
- ItemEffectsManager::zoomIn();
}
-}
-void DolphinDetailsView::zoomOut()
-{
- if (isZoomOutPossible()) {
- DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
- switch (settings->iconSize()) {
- case K3Icon::SizeLarge: settings->setIconSize(K3Icon::SizeMedium); break;
- case K3Icon::SizeMedium: settings->setIconSize(K3Icon::SizeSmall); break;
- default: assert(false); break;
- }
- ItemEffectsManager::zoomOut();
- }
-}
+ if (event->button() == Qt::LeftButton) {
+ m_showElasticBand = true;
-bool DolphinDetailsView::isZoomInPossible() const
-{
- DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
- return settings->iconSize() < K3Icon::SizeLarge;
+ const QPoint pos(contentsPos());
+ m_elasticBandOrigin = event->pos();
+ m_elasticBandOrigin.setX(m_elasticBandOrigin.x() + pos.x());
+ m_elasticBandOrigin.setY(m_elasticBandOrigin.y() + pos.y());
+ m_elasticBandDestination = event->pos();
+ }
}
-bool DolphinDetailsView::isZoomOutPossible() const
+void DolphinDetailsView::mouseMoveEvent(QMouseEvent* event)
{
- DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
- return settings->iconSize() > K3Icon::SizeSmall;
-}
+ if (m_showElasticBand) {
+ const QPoint mousePos = event->pos();
+ const QModelIndex index = indexAt(mousePos);
+ if (!index.isValid()) {
+ // the destination of the selection rectangle is above the viewport. In this
+ // case QTreeView does no selection at all, which is not the wanted behavior
+ // in Dolphin -> select all items within the elastic band rectangle
+ clearSelection();
-void DolphinDetailsView::resizeContents(int width, int height)
-{
- KFileDetailView::resizeContents(width, height);
+ const int nameColumnWidth = header()->sectionSize(DolphinModel::Name);
+ QRect selRect = QRect(m_elasticBandOrigin, m_elasticBandDestination).normalized();
+ const QRect nameColumnsRect(0, 0, nameColumnWidth, viewport()->height());
+ selRect = nameColumnsRect.intersected(selRect);
- // When loading several 1000 items a punch of resize events
- // drops in. As updating the column width is a quite expensive
- // operation, this operation will be postponed until there is
- // no resize event for at least 50 milliseconds.
- m_resizeTimer->stop();
- m_resizeTimer->start(50, true);
-}
+ setSelection(selRect, QItemSelectionModel::Select);
+ }
-void DolphinDetailsView::slotOnItem(Q3ListViewItem* item)
-{
- if (isOnFilename(item, QCursor::pos())) {
- activateItem(item);
- KFileItem* fileItem = static_cast<KFileListViewItem*>(item)->fileInfo();
- m_dolphinView->requestItemInfo(fileItem->url());
- }
- else {
- resetActivatedItem();
+ QTreeView::mouseMoveEvent(event);
+ updateElasticBand();
+ } else {
+ QTreeView::mouseMoveEvent(event);
}
}
-void DolphinDetailsView::slotOnViewport()
+void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event)
{
- resetActivatedItem();
- m_dolphinView->requestItemInfo(KUrl());
+ QTreeView::mouseReleaseEvent(event);
+ if (m_showElasticBand) {
+ updateElasticBand();
+ m_showElasticBand = false;
+ }
}
-void DolphinDetailsView::setContextPixmap(void* context,
- const QPixmap& pixmap)
+void DolphinDetailsView::startDrag(Qt::DropActions supportedActions)
{
- reinterpret_cast<KFileListViewItem*>(context)->setPixmap(0, pixmap);
+ DragAndDropHelper::startDrag(this, supportedActions);
}
-const QPixmap* DolphinDetailsView::contextPixmap(void* context)
+void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* event)
{
- return reinterpret_cast<KFileListViewItem*>(context)->pixmap(0);
-}
+ if (event->mimeData()->hasUrls()) {
+ event->acceptProposedAction();
+ }
-void* DolphinDetailsView::firstContext()
-{
- return reinterpret_cast<void*>(firstChild());
+ if (m_showElasticBand) {
+ updateElasticBand();
+ m_showElasticBand = false;
+ }
+ m_dragging = true;
}
-void* DolphinDetailsView::nextContext(void* context)
+void DolphinDetailsView::dragLeaveEvent(QDragLeaveEvent* event)
{
- KFileListViewItem* listViewItem = reinterpret_cast<KFileListViewItem*>(context);
- return reinterpret_cast<void*>(listViewItem->nextSibling());
-}
+ QTreeView::dragLeaveEvent(event);
-KFileItem* DolphinDetailsView::contextFileInfo(void* context)
-{
- return reinterpret_cast<KFileListViewItem*>(context)->fileInfo();
+ // TODO: remove this code when the issue #160611 is solved in Qt 4.4
+ m_dragging = false;
+ setDirtyRegion(m_dropRect);
}
-
-void DolphinDetailsView::contentsDragMoveEvent(QDragMoveEvent* event)
+void DolphinDetailsView::dragMoveEvent(QDragMoveEvent* event)
{
- KFileDetailView::contentsDragMoveEvent(event);
-
- // If a dragging is done above a directory, show the icon as 'active' for
- // a visual feedback
- KFileListViewItem* item = static_cast<KFileListViewItem*>(itemAt(event->pos()));
+ QTreeView::dragMoveEvent(event);
- bool showActive = false;
- if (item != 0) {
- const KFileItem* fileInfo = item->fileInfo();
- showActive = (fileInfo != 0) && fileInfo->isDir();
+ // TODO: remove this code when the issue #160611 is solved in Qt 4.4
+ setDirtyRegion(m_dropRect);
+ const QModelIndex index = indexAt(event->pos());
+ if (!index.isValid() || (index.column() != DolphinModel::Name)) {
+ m_dragging = false;
+ } else {
+ m_dragging = true;
+ const KFileItem item = itemForIndex(index);
+ if (!item.isNull() && item.isDir()) {
+ m_dropRect = visualRect(index);
+ } else {
+ m_dropRect.setSize(QSize()); // set as invalid
+ }
+ setDirtyRegion(m_dropRect);
}
- if (showActive) {
- slotOnItem(item);
- }
- else {
- slotOnViewport();
+ if (event->mimeData()->hasUrls()) {
+ // accept url drops, independently from the destination item
+ event->acceptProposedAction();
}
}
-void DolphinDetailsView::resizeEvent(QResizeEvent* event)
+void DolphinDetailsView::dropEvent(QDropEvent* event)
{
- KFileDetailView::resizeEvent(event);
-
- // When loading several 1000 items a punch of resize events
- // drops in. As updating the column width is a quite expensive
- // operation, this operation will be postponed until there is
- // no resize event for at least 50 milliseconds.
- m_resizeTimer->stop();
- m_resizeTimer->start(50, true);
-}
-
-bool DolphinDetailsView::acceptDrag(QDropEvent* event) const
-{
- KUrl::List uriList = KUrl::List::fromMimeData( event->mimeData() );
- bool accept = !uriList.isEmpty() &&
- (event->action() == QDropEvent::Copy ||
- event->action() == QDropEvent::Move ||
- event->action() == QDropEvent::Link);
- if (accept) {
- if (static_cast<const QWidget*>(event->source()) == this) {
- KFileListViewItem* item = static_cast<KFileListViewItem*>(itemAt(event->pos()));
- accept = (item != 0);
- if (accept) {
- KFileItem* fileItem = item->fileInfo();
- accept = fileItem->isDir();
- }
+ const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
+ if (!urls.isEmpty()) {
+ event->acceptProposedAction();
+ const QModelIndex index = indexAt(event->pos());
+ KFileItem item;
+ if (index.isValid() && (index.column() == DolphinModel::Name)) {
+ item = itemForIndex(index);
}
+ m_controller->indicateDroppedUrls(urls,
+ m_controller->url(),
+ item);
}
-
- return accept;
+ QTreeView::dropEvent(event);
+ m_dragging = false;
}
-void DolphinDetailsView::contentsDropEvent(QDropEvent* event)
+void DolphinDetailsView::paintEvent(QPaintEvent* event)
{
- // KFileDetailView::contentsDropEvent does not care whether the mouse
- // cursor is above a filename or not, the destination Url is always
- // the Url of the item. This is fixed here in a way that the destination
- // Url is only the Url of the item if the cursor is above the filename.
- const QPoint pos(QCursor::pos());
- const QPoint viewportPos(viewport()->mapToGlobal(QPoint(0, 0)));
- Q3ListViewItem* item = itemAt(QPoint(pos.x() - viewportPos.x(), pos.y() - viewportPos.y()));
- if ((item == 0) || ((item != 0) && isOnFilename(item, pos))) {
- // dropping is done on the viewport or directly above a filename
- KFileDetailView::contentsDropEvent(event);
- return;
- }
+ QTreeView::paintEvent(event);
+ if (m_showElasticBand) {
+ // The following code has been taken from QListView
+ // and adapted to DolphinDetailsView.
+ // (C) 1992-2007 Trolltech ASA
+ QStyleOptionRubberBand opt;
+ opt.initFrom(this);
+ opt.shape = QRubberBand::Rectangle;
+ opt.opaque = false;
+ opt.rect = elasticBandRect();
- // Dropping is done above an item, but the mouse cursor is not above the file name.
- // In this case the signals of the base implementation will be blocked and send
- // in a corrected manner afterwards.
- assert(item != 0);
- const bool block = signalsBlocked();
- blockSignals(true);
- KFileDetailView::contentsDropEvent(event);
- blockSignals(block);
-
- if (!acceptDrag(event)) {
- return;
+ QPainter painter(viewport());
+ painter.save();
+ style()->drawControl(QStyle::CE_RubberBand, &opt, &painter);
+ painter.restore();
}
- emit dropped(event, 0);
- KUrl::List urls = KUrl::List::fromMimeData( event->mimeData() );
- if (!urls.isEmpty()) {
- emit dropped(event, urls, KUrl());
- sig->dropURLs(0, event, urls);
+ // TODO: remove this code when the issue #160611 is solved in Qt 4.4
+ if (m_dragging) {
+ const QBrush& brush = viewOptions().palette.brush(QPalette::Normal, QPalette::Highlight);
+ DragAndDropHelper::drawHoverIndication(this, m_dropRect, brush);
}
}
-void DolphinDetailsView::contentsMousePressEvent(QMouseEvent* event)
+void DolphinDetailsView::keyPressEvent(QKeyEvent* event)
{
- if (m_rubber != 0) {
- drawRubber();
- delete m_rubber;
- m_rubber = 0;
- }
-
- // Swallow the base implementation of the mouse press event
- // if the mouse cursor is not above the filename. This prevents
- // that the item gets selected and simulates an equal usability
- // like in the icon view.
- const QPoint pos(QCursor::pos());
- const QPoint viewportPos(viewport()->mapToGlobal(QPoint(0, 0)));
- Q3ListViewItem* item = itemAt(QPoint(pos.x() - viewportPos.x(), pos.y() - viewportPos.y()));
- if ((item != 0) && isOnFilename(item, pos)) {
- KFileDetailView::contentsMousePressEvent(event);
- }
- else if (event->button() == Qt::LeftButton) {
- const Qt::KeyboardModifiers keyboardState = QApplication::keyboardModifiers();
- const bool isSelectionActive = (keyboardState & Qt::ShiftModifier) ||
- (keyboardState & Qt::ControlModifier);
- if (!isSelectionActive) {
- clearSelection();
- }
+ QTreeView::keyPressEvent(event);
- assert(m_rubber == 0);
- m_rubber = new QRect(event->x(), event->y(), 0, 0);
+ const QItemSelectionModel* selModel = selectionModel();
+ const QModelIndex currentIndex = selModel->currentIndex();
+ const bool trigger = currentIndex.isValid()
+ && (event->key() == Qt::Key_Return)
+ && (selModel->selectedIndexes().count() <= 1);
+ if (trigger) {
+ triggerItem(currentIndex);
}
-
- resetActivatedItem();
- emit signalRequestActivation();
-
- m_dolphinView->statusBar()->clear();
}
-void DolphinDetailsView::contentsMouseMoveEvent(QMouseEvent* event)
+void DolphinDetailsView::resizeEvent(QResizeEvent* event)
{
- if (m_rubber != 0) {
- slotAutoScroll();
- return;
+ QTreeView::resizeEvent(event);
+
+ // TODO: There seems to be no easy way to find out whether the resize event
+ // has been triggered because of resizing the window or by adjusting the column-width
+ // by a left mouse-click (the columns should only be resized automatically when the window
+ // size is adjusted). The following workaround works well, but it should be
+ // considered solving this in a more transparent way.
+ if (!(QApplication::mouseButtons() & Qt::LeftButton)) {
+ resizeColumns();
}
+}
- KFileDetailView::contentsMouseMoveEvent(event);
+void DolphinDetailsView::closeEvent(QCloseEvent* event)
+{
+ if (m_clearAdditionalInfo) {
+ disconnect(m_controller->dolphinView(), SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
+ this, SLOT(updateColumnVisibility()));
- const QPoint& pos = event->globalPos();
- const QPoint viewportPos = viewport()->mapToGlobal(QPoint(0, 0));
- Q3ListViewItem* item = itemAt(QPoint(pos.x() - viewportPos.x(), pos.y() - viewportPos.y()));
- if ((item != 0) && isOnFilename(item, pos)) {
- activateItem(item);
- }
- else {
- resetActivatedItem();
+ KFileItemDelegate::InformationList info;
+ info.append(KFileItemDelegate::NoInformation);
+ m_controller->indicateAdditionalInfoChange(info);
+ m_clearAdditionalInfo = false;
}
+ QTreeView::closeEvent(event);
}
-void DolphinDetailsView::contentsMouseReleaseEvent(QMouseEvent* event)
+void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
{
- if (m_rubber != 0) {
- drawRubber();
- delete m_rubber;
- m_rubber = 0;
- }
+ QHeaderView* headerView = header();
+ headerView->setSortIndicator(sorting, headerView->sortIndicatorOrder());
+}
- if (m_scrollTimer != 0) {
- disconnect(m_scrollTimer, SIGNAL(timeout()),
- this, SLOT(slotAutoScroll()));
- m_scrollTimer->stop();
- delete m_scrollTimer;
- m_scrollTimer = 0;
- }
+void DolphinDetailsView::setSortIndicatorOrder(Qt::SortOrder sortOrder)
+{
+ QHeaderView* headerView = header();
+ headerView->setSortIndicator(headerView->sortIndicatorSection(), sortOrder);
+}
- KFileDetailView::contentsMouseReleaseEvent(event);
+void DolphinDetailsView::synchronizeSortingState(int column)
+{
+ // The sorting has already been changed in QTreeView if this slot is
+ // invoked, but Dolphin is not informed about this.
+ DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(column);
+ const Qt::SortOrder sortOrder = header()->sortIndicatorOrder();
+ m_controller->indicateSortingChange(sorting);
+ m_controller->indicateSortOrderChange(sortOrder);
}
-void DolphinDetailsView::paintEmptyArea(QPainter* painter, const QRect& rect)
+void DolphinDetailsView::slotEntered(const QModelIndex& index)
{
- if (m_dolphinView->isActive()) {
- KFileDetailView::paintEmptyArea(painter, rect);
+ const QPoint pos = viewport()->mapFromGlobal(QCursor::pos());
+ const int nameColumnWidth = header()->sectionSize(DolphinModel::Name);
+ if (pos.x() < nameColumnWidth) {
+ m_controller->emitItemEntered(itemForIndex(index));
}
else {
- const QBrush brush(colorGroup().background());
- painter->fillRect(rect, brush);
+ m_controller->emitViewportEntered();
}
}
-void DolphinDetailsView::drawRubber()
+void DolphinDetailsView::updateElasticBand()
{
- // Parts of the following code have been taken
- // from the class KonqBaseListViewWidget located in
- // konqueror/listview/konq_listviewwidget.h of Konqueror.
- // (Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
- // 2001, 2002, 2004 Michael Brade <brade@kde.org>)
- if (m_rubber == 0) {
- return;
+ if (m_showElasticBand) {
+ QRect dirtyRegion(elasticBandRect());
+ m_elasticBandDestination = viewport()->mapFromGlobal(QCursor::pos());
+ dirtyRegion = dirtyRegion.united(elasticBandRect());
+ setDirtyRegion(dirtyRegion);
}
-
- QPainter p;
- p.begin(viewport());
- //p.setRasterOp(NotROP);
- p.setPen(QPen(Qt::color0, 1));
- p.setBrush(Qt::NoBrush);
-
- QPoint point(m_rubber->x(), m_rubber->y());
- point = contentsToViewport(point);
- QStyleOptionFocusRect option;
- option.initFrom(this);
- option.rect = QRect(point.x(), point.y(), m_rubber->width(), m_rubber->height());
- style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &p);
- p.end();
}
-void DolphinDetailsView::viewportPaintEvent(QPaintEvent* paintEvent)
+QRect DolphinDetailsView::elasticBandRect() const
{
- drawRubber();
- KFileDetailView::viewportPaintEvent(paintEvent);
- drawRubber();
+ const QPoint pos(contentsPos());
+ const QPoint topLeft(m_elasticBandOrigin.x() - pos.x(), m_elasticBandOrigin.y() - pos.y());
+ return QRect(topLeft, m_elasticBandDestination).normalized();
}
-void DolphinDetailsView::leaveEvent(QEvent* event)
-{
- KFileDetailView::leaveEvent(event);
- slotOnViewport();
-}
-
-void DolphinDetailsView::slotActivationUpdate()
+void DolphinDetailsView::zoomIn()
{
- update();
-
- // TODO: there must be a simpler way to say
- // "update all children"
- const QList<QObject*> list = children();
- if (list.isEmpty()) {
- return;
- }
-
- QListIterator<QObject*> it(list);
- QObject* object = 0;
- while (it.hasNext()) {
- object = it.next();
- if (object->inherits("QWidget")) {
- QWidget* widget = static_cast<QWidget*>(object);
- widget->update();
+ if (isZoomInPossible()) {
+ DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+ switch (settings->iconSize()) {
+ case KIconLoader::SizeSmall: settings->setIconSize(KIconLoader::SizeMedium); break;
+ case KIconLoader::SizeMedium: settings->setIconSize(KIconLoader::SizeLarge); break;
+ default: Q_ASSERT(false); break;
}
+ updateDecorationSize();
}
}
-void DolphinDetailsView::slotContextMenuRequested(Q3ListViewItem* item,
- const QPoint& pos,
- int /* col */)
+void DolphinDetailsView::zoomOut()
{
- KFileItem* fileInfo = 0;
- if ((item != 0) && isOnFilename(item, pos)) {
- fileInfo = static_cast<KFileListViewItem*>(item)->fileInfo();
+ if (isZoomOutPossible()) {
+ DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+ switch (settings->iconSize()) {
+ case KIconLoader::SizeLarge: settings->setIconSize(KIconLoader::SizeMedium); break;
+ case KIconLoader::SizeMedium: settings->setIconSize(KIconLoader::SizeSmall); break;
+ default: Q_ASSERT(false); break;
+ }
+ updateDecorationSize();
}
- m_dolphinView->openContextMenu(fileInfo, pos);
-
}
-void DolphinDetailsView::slotUpdateDisabledItems()
+void DolphinDetailsView::triggerItem(const QModelIndex& index)
{
- updateDisabledItems();
+ const KFileItem item = itemForIndex(index);
+ if (index.isValid() && (index.column() == KDirModel::Name)) {
+ m_controller->triggerItem(item);
+ } else {
+ clearSelection();
+ m_controller->emitItemEntered(item);
+ }
}
-void DolphinDetailsView::slotAutoScroll()
+void DolphinDetailsView::configureColumns(const QPoint& pos)
{
- // Parts of the following code have been taken
- // from the class KonqBaseListViewWidget located in
- // konqueror/listview/konq_listviewwidget.h of Konqueror.
- // (Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
- // 2001, 2002, 2004 Michael Brade <brade@kde.org>)
-
- const QPoint pos(viewport()->mapFromGlobal(QCursor::pos()));
- const QPoint vc(viewportToContents(pos));
+ KMenu popup(this);
+ popup.addTitle(i18nc("@title:menu", "Columns"));
- if (vc == m_rubber->bottomRight()) {
- return;
+ QHeaderView* headerView = header();
+ for (int i = DolphinModel::Size; i <= DolphinModel::Type; ++i) {
+ const int logicalIndex = headerView->logicalIndex(i);
+ const QString text = model()->headerData(i, Qt::Horizontal).toString();
+ QAction* action = popup.addAction(text);
+ action->setCheckable(true);
+ action->setChecked(!headerView->isSectionHidden(logicalIndex));
+ action->setData(i);
}
- drawRubber();
-
- m_rubber->setBottomRight(vc);
-
- Q3ListViewItem* item = itemAt(QPoint(0,0));
+ QAction* activatedAction = popup.exec(header()->mapToGlobal(pos));
+ if (activatedAction != 0) {
+ const bool show = activatedAction->isChecked();
+ const int columnIndex = activatedAction->data().toInt();
- const bool block = signalsBlocked();
- blockSignals(true);
-
- const QRect rubber(m_rubber->normalize());
- const int bottom = contentsY() + visibleHeight() - 1;
-
- // select all items which intersect with the rubber, deselect all others
- bool bottomReached = false;
- while ((item != 0) && !bottomReached) {
- QRect rect(itemRect(item));
- rect.setWidth(filenameWidth(item));
- rect = QRect(viewportToContents(rect.topLeft()),
- viewportToContents(rect.bottomRight()));
- if (rect.isValid() && (rect.top() <= bottom)) {
- const KFileItem* fileItem = static_cast<KFileListViewItem*>(item)->fileInfo();
- setSelected(fileItem, rect.intersects(rubber));
- item = item->itemBelow();
- }
- else {
- bottomReached = true;
+ KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo();
+ const KFileItemDelegate::Information info = infoForColumn(columnIndex);
+ if (show) {
+ Q_ASSERT(!list.contains(info));
+ list.append(info);
+ } else {
+ Q_ASSERT(list.contains(info));
+ const int index = list.indexOf(info);
+ list.removeAt(index);
}
- }
- blockSignals(block);
- emit selectionChanged();
-
- drawRubber();
-
- // scroll the viewport if the top or bottom margin is reached
- const int scrollMargin = 40;
- ensureVisible(vc.x(), vc.y(), scrollMargin, scrollMargin);
- const bool scroll = !QRect(scrollMargin,
- scrollMargin,
- viewport()->width() - 2 * scrollMargin,
- viewport()->height() - 2 * scrollMargin).contains(pos);
- if (scroll) {
- if (m_scrollTimer == 0) {
- m_scrollTimer = new QTimer( this );
- connect(m_scrollTimer, SIGNAL(timeout()),
- this, SLOT(slotAutoScroll()));
- m_scrollTimer->start(100, false);
- }
- }
- else if (m_scrollTimer != 0) {
- disconnect(m_scrollTimer, SIGNAL(timeout()),
- this, SLOT(slotAutoScroll()));
- m_scrollTimer->stop();
- delete m_scrollTimer;
- m_scrollTimer = 0;
+ m_controller->indicateAdditionalInfoChange(list);
+ setColumnHidden(columnIndex, !show);
}
}
-void DolphinDetailsView::updateColumnsWidth()
+void DolphinDetailsView::updateColumnVisibility()
{
- const int columnCount = columns();
- int requiredWidth = 0;
- for (int i = 1; i < columnCount; ++i) {
- // When a directory contains no items, a minimum width for
- // the column must be available, so that the header is readable.
- // TODO: use header data instead of the hardcoded 64 value...
- int columnWidth = 64;
- QFontMetrics fontMetrics(font());
- for (Q3ListViewItem* item = firstChild(); item != 0; item = item->nextSibling()) {
- const int width = item->width(fontMetrics, this, i);
- if (width > columnWidth) {
- columnWidth = width;
- }
- }
- columnWidth += 16; // add custom margin
- setColumnWidth(i, columnWidth);
- requiredWidth += columnWidth;
+ KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo();
+ const bool useDefaultColumns = !isVisible() &&
+ (list.isEmpty() ||
+ list.contains(KFileItemDelegate::NoInformation));
+ if (useDefaultColumns) {
+ // Using the details view without any additional information (-> additional column)
+ // makes no sense and leads to a usability problem as no viewport area is available
+ // anymore. Hence as fallback provide at least a size and date column.
+ list.clear();
+ list.append(KFileItemDelegate::Size);
+ list.append(KFileItemDelegate::ModificationTime);
+ m_controller->indicateAdditionalInfoChange(list);
+ m_clearAdditionalInfo = true;
}
- // resize the first column in a way that the
- // whole available width is used
- int firstColumnWidth = visibleWidth() - requiredWidth;
- if (firstColumnWidth < 128) {
- firstColumnWidth = 128;
+ for (int i = DolphinModel::Size; i <= DolphinModel::Type; ++i) {
+ const KFileItemDelegate::Information info = infoForColumn(i);
+ const bool hide = !list.contains(info);
+ if (isColumnHidden(i) != hide) {
+ setColumnHidden(i, hide);
+ m_clearAdditionalInfo = false;
+ }
}
- setColumnWidth(0, firstColumnWidth);
+
+ resizeColumns();
}
-void DolphinDetailsView::slotItemRenamed(Q3ListViewItem* item,
- const QString& name,
- int /* column */)
+bool DolphinDetailsView::isZoomInPossible() const
{
- KFileItem* fileInfo = static_cast<KFileListViewItem*>(item)->fileInfo();
- m_dolphinView->rename(KUrl(fileInfo->url()), name);
+ DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+ return settings->iconSize() < KIconLoader::SizeLarge;
}
-void DolphinDetailsView::slotHeaderClicked(int /* section */)
+bool DolphinDetailsView::isZoomOutPossible() const
{
- // The sorting has already been changed in QListView if this slot is
- // invoked, but Dolphin was not informed about this (no signal is available
- // which indicates a change of the sorting). This is bypassed by changing
- // the sorting and sort order to a temporary other value and readjust it again.
- const int column = sortColumn();
- if (column <= DateColumn) {
- DolphinView::Sorting sorting = DolphinView::SortByName;
- switch (column) {
- case SizeColumn: sorting = DolphinView::SortBySize; break;
- case DateColumn: sorting = DolphinView::SortByDate; break;
- case NameColumn:
- default: break;
- }
+ DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+ return settings->iconSize() > KIconLoader::SizeSmall;
+}
- const Qt::SortOrder currSortOrder = sortOrder();
+void DolphinDetailsView::updateDecorationSize()
+{
+ DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+ const int iconSize = settings->iconSize();
+ m_decorationSize = QSize(iconSize, iconSize);
- // temporary adjust the sorting and sort order to different values...
- const DolphinView::Sorting tempSorting = (sorting == DolphinView::SortByName) ?
- DolphinView::SortBySize :
- DolphinView::SortByName;
- m_dolphinView->setSorting(tempSorting);
- const Qt::SortOrder tempSortOrder = (currSortOrder == Qt::Ascending) ?
- Qt::Descending : Qt::Ascending;
- m_dolphinView->setSortOrder(tempSortOrder);
+ m_controller->setZoomInPossible(isZoomInPossible());
+ m_controller->setZoomOutPossible(isZoomOutPossible());
- // ... so that setting them again results in storing the new setting.
- m_dolphinView->setSorting(sorting);
- m_dolphinView->setSortOrder(currSortOrder);
- }
+ doItemsLayout();
}
-DolphinDetailsView::DolphinListViewItem::DolphinListViewItem(Q3ListView* parent,
- KFileItem* fileItem) :
- KFileListViewItem(parent, fileItem)
+QPoint DolphinDetailsView::contentsPos() const
{
- const int iconSize = DolphinSettings::instance().detailsModeSettings()->iconSize();
- KFileItem* info = fileInfo();
- setPixmap(DolphinDetailsView::NameColumn, info->pixmap(iconSize));
+ // implementation note: the horizonal position is ignored currently, as no
+ // horizontal scrolling is done anyway during a selection
+ const QScrollBar* scrollbar = verticalScrollBar();
+ Q_ASSERT(scrollbar != 0);
- // The base class KFileListViewItem represents the column 'Size' only as byte values.
- // Adjust those values in a way that a mapping to GBytes, MBytes, KBytes and Bytes
- // is done. As the file size for directories is useless (only the size of the directory i-node
- // is given), it is removed completely.
- if (fileItem->isDir()) {
- setText(SizeColumn, " - ");
- }
- else {
- QString sizeText(KIO::convertSize(fileItem->size()));
- sizeText.append(" ");
- setText(SizeColumn, sizeText);
+ const int maxHeight = maximumViewportSize().height();
+ const int height = scrollbar->maximum() - scrollbar->minimum() + 1;
+ const int visibleHeight = model()->rowCount() + 1 - height;
+ if (visibleHeight <= 0) {
+ return QPoint(0, 0);
}
- // Dolphin allows to remove specific columns, but the base class KFileListViewItem
- // is not aware about this (or at least the class KFileDetailView does not react on
- // QListView::remove()). Therefore the columns are rearranged here.
- const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
- assert(settings != 0);
-
- int column_idx = DateColumn; // the columns for 'name' and 'size' cannot get removed
- for (int i = DolphinDetailsView::DateColumn; i <= DolphinDetailsView::GroupColumn; ++i) {
- if (column_idx < i) {
- setText(column_idx, text(i));
- }
-
- bool inc = false;
- switch (i) {
- case DateColumn: inc = settings->showDate(); break;
- case PermissionsColumn: inc = settings->showPermissions(); break;
- case OwnerColumn: inc = settings->showOwner(); break;
- case GroupColumn: inc = settings->showGroup(); break;
- default: break;
- }
-
- if (inc) {
- ++column_idx;
- }
- }
+ const int y = scrollbar->sliderPosition() * maxHeight / visibleHeight;
+ return QPoint(0, y);
}
-DolphinDetailsView::DolphinListViewItem::~DolphinListViewItem()
-{
-}
-
-void DolphinDetailsView::DolphinListViewItem::paintCell(QPainter* painter,
- const QColorGroup& colorGroup,
- int column,
- int cellWidth,
- int alignment)
-{
- const Q3ListView* view = listView();
- const bool isActive = view->parent() == Dolphin::mainWin().activeView();
- if (isSelected()) {
- // Per default the selection is drawn above the whole width of the item. As a consistent
- // behavior with the icon view is wanted, only the the column containing the file name
- // should be shown as selected.
- QColorGroup defaultColorGroup(colorGroup);
- const QColor highlightColor(isActive ? backgroundColor(column) : view->colorGroup().background());
- defaultColorGroup.setColor(QColorGroup::Highlight , highlightColor);
- defaultColorGroup.setColor(QColorGroup::HighlightedText, colorGroup.color(QColorGroup::Text));
- KFileListViewItem::paintCell(painter, defaultColorGroup, column, cellWidth, alignment);
-
- if (column == 0) {
- // draw the selection only on the first column
- Q3ListView* parent = listView();
- const int itemWidth = width(parent->fontMetrics(), parent, 0);
- if (isActive) {
- KFileListViewItem::paintCell(painter, colorGroup, column, itemWidth, alignment);
- }
- else {
- Q3ListViewItem::paintCell(painter, colorGroup, column, itemWidth, alignment);
- }
- }
- }
- else {
- if (isActive) {
- KFileListViewItem::paintCell(painter, colorGroup, column, cellWidth, alignment);
- }
- else {
- Q3ListViewItem::paintCell(painter, colorGroup, column, cellWidth, alignment);
- }
- }
-
- if (column < listView()->columns() - 1) {
- // draw a separator between columns
- painter->setPen(KGlobalSettings::buttonBackground());
- painter->drawLine(cellWidth - 1, 0, cellWidth - 1, height() - 1);
- }
+KFileItem DolphinDetailsView::itemForIndex(const QModelIndex& index) const
+{
+ QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(model());
+ KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
+ const QModelIndex dirIndex = proxyModel->mapToSource(index);
+ return dirModel->itemForIndex(dirIndex);
}
-void DolphinDetailsView::DolphinListViewItem::paintFocus(QPainter* painter,
- const QColorGroup& colorGroup,
- const QRect& rect)
+KFileItemDelegate::Information DolphinDetailsView::infoForColumn(int columnIndex) const
{
- // draw the focus consistently with the selection (see implementation notes
- // in DolphinListViewItem::paintCell)
- Q3ListView* parent = listView();
- int visibleWidth = width(parent->fontMetrics(), parent, 0);
- const int colWidth = parent->columnWidth(0);
- if (visibleWidth > colWidth) {
- visibleWidth = colWidth;
- }
+ KFileItemDelegate::Information info = KFileItemDelegate::NoInformation;
- QRect focusRect(rect);
- focusRect.setWidth(visibleWidth);
+ switch (columnIndex) {
+ case DolphinModel::Size: info = KFileItemDelegate::Size; break;
+ case DolphinModel::ModifiedTime: info = KFileItemDelegate::ModificationTime; break;
+ case DolphinModel::Permissions: info = KFileItemDelegate::Permissions; break;
+ case DolphinModel::Owner: info = KFileItemDelegate::Owner; break;
+ case DolphinModel::Group: info = KFileItemDelegate::OwnerAndGroup; break;
+ case DolphinModel::Type: info = KFileItemDelegate::FriendlyMimeType; break;
+ default: break;
+ }
- KFileListViewItem::paintFocus(painter, colorGroup, focusRect);
+ return info;
}
-int DolphinDetailsView::filenameWidth(const Q3ListViewItem* item) const
+void DolphinDetailsView::resizeColumns()
{
- assert(item != 0);
+ // Using the resize mode QHeaderView::ResizeToContents is too slow (it takes
+ // around 3 seconds for each (!) resize operation when having > 10000 items).
+ // This gets a problem especially when opening large directories, where several
+ // resize operations are received for showing the currently available items during
+ // loading (the application hangs around 20 seconds when loading > 10000 items).
+
+ QHeaderView* headerView = header();
+ QFontMetrics fontMetrics(viewport()->font());
- int visibleWidth = item->width(fontMetrics(), this, 0);
- const int colWidth = columnWidth(0);
- if (visibleWidth > colWidth) {
- visibleWidth = colWidth;
+ int columnWidth[KDirModel::ColumnCount];
+ columnWidth[KDirModel::Size] = fontMetrics.width("00000 Items");
+ columnWidth[KDirModel::ModifiedTime] = fontMetrics.width("0000-00-00 00:00");
+ columnWidth[KDirModel::Permissions] = fontMetrics.width("xxxxxxxxxx");
+ columnWidth[KDirModel::Owner] = fontMetrics.width("xxxxxxxxxx");
+ columnWidth[KDirModel::Group] = fontMetrics.width("xxxxxxxxxx");
+ columnWidth[KDirModel::Type] = fontMetrics.width("XXXX Xxxxxxx");
+
+ int requiredWidth = 0;
+ for (int i = KDirModel::Size; i <= KDirModel::Type; ++i) {
+ if (!isColumnHidden(i)) {
+ columnWidth[i] += 20; // provide a default gap
+ requiredWidth += columnWidth[i];
+ headerView->resizeSection(i, columnWidth[i]);
+ }
}
- return visibleWidth;
+ // resize the name column in a way that the whole available width is used
+ columnWidth[KDirModel::Name] = viewport()->width() - requiredWidth;
+ if (columnWidth[KDirModel::Name] < 120) {
+ columnWidth[KDirModel::Name] = 120;
+ }
+ headerView->resizeSection(KDirModel::Name, columnWidth[KDirModel::Name]);
}
+
#include "dolphindetailsview.moc"