X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/3b8c3c1b1e2d05d09aca2de0b0bf922fb9530b0d..d6488887ecf69d7f192b94de8dce34fae0b7eb76:/src/dolphincolumnview.cpp diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp index c0f08eaeb..e0d48e5fa 100644 --- a/src/dolphincolumnview.cpp +++ b/src/dolphincolumnview.cpp @@ -47,7 +47,9 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control m_index(-1), m_contentX(0), m_columns(), - m_animation(0) + m_emptyViewport(0), + m_animation(0), + m_nameFilter() { Q_ASSERT(controller != 0); @@ -55,22 +57,24 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control setDragDropMode(QAbstractItemView::DragDrop); setDropIndicatorShown(false); setSelectionMode(ExtendedSelection); + setFocusPolicy(Qt::NoFocus); + setFrameShape(QFrame::NoFrame); - connect(this, SIGNAL(entered(const QModelIndex&)), - controller, SLOT(emitItemEntered(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, SIGNAL(showHiddenFilesChanged(bool)), - this, SLOT(slotShowHiddenFilesChanged(bool))); - connect(controller, SIGNAL(showPreviewChanged(bool)), - this, SLOT(slotShowPreviewChanged(bool))); connect(controller, SIGNAL(activationChanged(bool)), this, SLOT(updateColumnsBackground(bool))); + const DolphinView* view = controller->dolphinView(); + connect(view, SIGNAL(showHiddenFilesChanged()), + this, SLOT(slotShowHiddenFilesChanged())); + connect(view, SIGNAL(showPreviewChanged()), + this, SLOT(slotShowPreviewChanged())); + connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(moveContentHorizontally(int))); @@ -81,6 +85,9 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control m_columns.append(column); setActiveColumnIndex(0); + m_emptyViewport = new QFrame(viewport()); + m_emptyViewport->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); + updateDecorationSize(); updateColumnsBackground(true); } @@ -141,14 +148,17 @@ void DolphinColumnView::setRootUrl(const KUrl& url) void DolphinColumnView::setNameFilter(const QString& nameFilter) { - foreach (DolphinColumnWidget* column, m_columns) { - column->setNameFilter(nameFilter); + if (nameFilter != m_nameFilter) { + m_nameFilter = nameFilter; + foreach (DolphinColumnWidget* column, m_columns) { + column->setNameFilter(nameFilter); + } } } QString DolphinColumnView::nameFilter() const { - return activeColumn()->nameFilter(); + return m_nameFilter; } KUrl DolphinColumnView::rootUrl() const @@ -168,6 +178,7 @@ void DolphinColumnView::showColumn(const KUrl& url) if (column->url() == url) { // the column represents already the requested URL, hence activate it requestActivation(column); + layoutColumns(); return; } else if (!column->url().isParentOf(url)) { // the column is no parent of the requested URL, hence @@ -392,11 +403,8 @@ void DolphinColumnView::updateColumnsBackground(bool active) m_active = active; // dim the background of the viewport - QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color(); - color.setAlpha(150); - QPalette palette; - palette.setColor(viewport()->backgroundRole(), color); + palette.setColor(viewport()->backgroundRole(), QColor(0, 0, 0, 0)); viewport()->setPalette(palette); foreach (DolphinColumnWidget* column, m_columns) { @@ -404,15 +412,17 @@ void DolphinColumnView::updateColumnsBackground(bool active) } } -void DolphinColumnView::slotShowHiddenFilesChanged(bool show) +void DolphinColumnView::slotShowHiddenFilesChanged() { + const bool show = m_controller->dolphinView()->showHiddenFiles(); foreach (DolphinColumnWidget* column, m_columns) { column->setShowHiddenFiles(show); } } -void DolphinColumnView::slotShowPreviewChanged(bool show) +void DolphinColumnView::slotShowPreviewChanged() { + const bool show = m_controller->dolphinView()->showPreview(); foreach (DolphinColumnWidget* column, m_columns) { column->setShowPreview(show); } @@ -449,29 +459,40 @@ void DolphinColumnView::setActiveColumnIndex(int index) void DolphinColumnView::layoutColumns() { + const int gap = 4; + ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings(); const int columnWidth = settings->columnWidth(); + + QRect emptyViewportRect; if (isRightToLeft()) { int x = viewport()->width() - columnWidth + m_contentX; foreach (DolphinColumnWidget* column, m_columns) { - column->setGeometry(QRect(x, 0, columnWidth, viewport()->height())); + column->setGeometry(QRect(x, 0, columnWidth - gap, viewport()->height())); x -= columnWidth; } + emptyViewportRect = QRect(0, 0, x + columnWidth - gap, viewport()->height()); } else { int x = m_contentX; foreach (DolphinColumnWidget* column, m_columns) { - column->setGeometry(QRect(x, 0, columnWidth, viewport()->height())); + column->setGeometry(QRect(x, 0, columnWidth - gap, viewport()->height())); x += columnWidth; } + emptyViewportRect = QRect(x, 0, viewport()->width() - x - gap, viewport()->height()); + } + + if (emptyViewportRect.isValid()) { + m_emptyViewport->show(); + m_emptyViewport->setGeometry(emptyViewportRect); + } else { + m_emptyViewport->hide(); } } void DolphinColumnView::updateScrollBar() { - int contentWidth = 0; - foreach (DolphinColumnWidget* column, m_columns) { - contentWidth += column->width(); - } + ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings(); + const int contentWidth = m_columns.count() * settings->columnWidth(); horizontalScrollBar()->setPageStep(contentWidth); horizontalScrollBar()->setRange(0, contentWidth - viewport()->width()); @@ -481,7 +502,10 @@ void DolphinColumnView::assureVisibleActiveColumn() { const int viewportWidth = viewport()->width(); const int x = activeColumn()->x(); - const int width = activeColumn()->width(); + + ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings(); + const int width = settings->columnWidth(); + if (x + width > viewportWidth) { const int newContentX = m_contentX - x - width + viewportWidth; if (isRightToLeft()) {