m_dirLister->setDelayedMimeTypes(true);
const bool showHiddenFiles = m_container->m_dolphinViewController->view()->showHiddenFiles();
m_dirLister->setShowingDotFiles(showHiddenFiles);
+ connect(m_dirLister, SIGNAL(completed()), this, SLOT(slotDirListerCompleted()));
m_dolphinModel = new DolphinModel(this);
m_dolphinModel->setDirLister(m_dirLister);
updateDecorationSize(view->showPreview());
}
+void DolphinColumnView::slotDirListerCompleted()
+{
+ if (!m_childUrl.isEmpty()) {
+ return;
+ }
+
+ // Try to optimize the width of the column, so that no name gets clipped
+ const int requiredWidth = sizeHintForColumn(DolphinModel::Name);
+
+ const ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
+ if (requiredWidth > settings->columnWidth()) {
+ int frameAroundContents = 0;
+ if (style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents)) {
+ // TODO: Using 2 PM_DefaultFrameWidths are not sufficient. Check Qt-code
+ // for other pixelmetrics that should be added...
+ frameAroundContents = style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 4;
+ }
+
+ const int scrollBarWidth = style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, verticalScrollBar());
+
+ setMaximumWidth(requiredWidth + frameAroundContents + scrollBarWidth);
+ m_container->layoutColumns();
+ if (m_active) {
+ m_container->assureVisibleActiveColumn();
+ }
+ }
+}
+
void DolphinColumnView::activate()
{
setFocus(Qt::OtherFocusReason);
m_emptyViewport(0),
m_animation(0),
m_dragSource(0),
- m_activeUrlTimer(0)
+ m_activeUrlTimer(0),
+ m_assureVisibleActiveColumnTimer(0)
{
Q_ASSERT(dolphinViewController != 0);
Q_ASSERT(viewModeController != 0);
connect(m_activeUrlTimer, SIGNAL(timeout()),
this, SLOT(updateActiveUrl()));
+ // Assuring that the active column gets fully visible is done with a small delay. This
+ // prevents that for temporary activations an animation gets started (e. g. when clicking
+ // on any folder of the parent column, the child column gets activated).
+ m_assureVisibleActiveColumnTimer = new QTimer(this);
+ m_assureVisibleActiveColumnTimer->setSingleShot(true);
+ m_assureVisibleActiveColumnTimer->setInterval(200);
+ connect(m_assureVisibleActiveColumnTimer, SIGNAL(timeout()),
+ this, SLOT(slotAssureVisibleActiveColumn()));
+
DolphinColumnView* column = new DolphinColumnView(viewport(), this, viewModeController->url());
m_columns.append(column);
requestActivation(column);
m_dolphinViewController->requestUrlChange(activeUrl);
}
+void DolphinColumnViewContainer::slotAssureVisibleActiveColumn()
+{
+ const int viewportWidth = viewport()->width();
+ const int x = activeColumn()->x();
+
+ // When a column that is partly visible on the left side gets activated,
+ // it is useful to also assure that the previous column is partly visible.
+ // This allows the user to scroll to the first column without using the
+ // scrollbar and drag & drop operations to invisible columns.
+ const int previousColumnGap = 3 * style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, verticalScrollBar());
+
+ const int width = activeColumn()->maximumWidth();
+ if (x + width > viewportWidth) {
+ const int newContentX = m_contentX - x - width + viewportWidth;
+ if (isRightToLeft()) {
+ m_animation->setFrameRange(m_contentX, newContentX + previousColumnGap);
+ } else {
+ m_animation->setFrameRange(-m_contentX, -newContentX);
+ }
+ if (m_animation->state() != QTimeLine::Running) {
+ m_animation->start();
+ }
+ } else if (x < 0) {
+ const int newContentX = m_contentX - x;
+ if (isRightToLeft()) {
+ m_animation->setFrameRange(m_contentX, newContentX);
+ } else {
+ m_animation->setFrameRange(-m_contentX, -newContentX - previousColumnGap);
+ }
+ if (m_animation->state() != QTimeLine::Running) {
+ m_animation->start();
+ }
+ }
+}
+
+void DolphinColumnViewContainer::assureVisibleActiveColumn()
+{
+ m_assureVisibleActiveColumnTimer->start();
+}
+
void DolphinColumnViewContainer::layoutColumns()
{
// Layout the position of the columns corresponding to their maximum width
contentWidth += column->maximumWidth();
}
- horizontalScrollBar()->setPageStep(contentWidth);
- horizontalScrollBar()->setRange(0, contentWidth - viewport()->width());
-}
+ if (horizontalScrollBar()->pageStep() != contentWidth) {
+ disconnect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
+ this, SLOT(moveContentHorizontally(int)));
-void DolphinColumnViewContainer::assureVisibleActiveColumn()
-{
- const int viewportWidth = viewport()->width();
- const int x = activeColumn()->x();
+ horizontalScrollBar()->setPageStep(contentWidth);
+ horizontalScrollBar()->setRange(0, contentWidth - viewport()->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()) {
- m_animation->setFrameRange(m_contentX, newContentX);
- } else {
- m_animation->setFrameRange(-m_contentX, -newContentX);
- }
- if (m_animation->state() != QTimeLine::Running) {
- m_animation->start();
- }
- } else if (x < 0) {
- const int newContentX = m_contentX - x;
- if (isRightToLeft()) {
- m_animation->setFrameRange(m_contentX, newContentX);
- } else {
- m_animation->setFrameRange(-m_contentX, -newContentX);
- }
- if (m_animation->state() != QTimeLine::Running) {
- m_animation->start();
- }
+ connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
+ this, SLOT(moveContentHorizontally(int)));
}
}
setFocusProxy(column);
}
- if (column->isActive()) {
- assureVisibleActiveColumn();
- } else {
+ if (!column->isActive()) {
// Deactivate the currently active column
if (m_index >= 0) {
m_columns[m_index]->setActive(false);
m_index = index;
m_columns[m_index]->setActive(true);
- assureVisibleActiveColumn();
m_activeUrlTimer->start(); // calls slot updateActiveUrl()
}
+
+ assureVisibleActiveColumn();
}
void DolphinColumnViewContainer::removeAllColumns()
assureVisibleActiveColumn();
}
-QPoint DolphinColumnViewContainer::columnPosition(DolphinColumnView* column, const QPoint& point) const
-{
- const QPoint topLeft = column->frameGeometry().topLeft();
- return QPoint(point.x() - topLeft.x(), point.y() - topLeft.y());
-}
-
void DolphinColumnViewContainer::deleteColumn(DolphinColumnView* column)
{
if (column == 0) {
*/
void updateActiveUrl();
-private:
- void layoutColumns();
-
/**
+ * Invoked when m_assureVisibleActiveColumnTimer has been exceeded.
* Assures that the currently active column is fully visible
* by adjusting the horizontal position of the content.
*/
+ void slotAssureVisibleActiveColumn();
+
+private:
+ /**
+ * Assures that the currently active column is fully visible
+ * by adjusting the horizontal position of the content. The
+ * adjustment is done with a small delay (see
+ * slotAssureVisibleActiveColumn();
+ */
void assureVisibleActiveColumn();
+ void layoutColumns();
+
/**
* Request the activation for the column \a column. It is assured
* that the columns gets fully visible by adjusting the horizontal
/** Removes all columns except of the root column. */
void removeAllColumns();
- /**
- * Returns the position of the point \a point relative to the column
- * \a column.
- */
- QPoint columnPosition(DolphinColumnView* column, const QPoint& point) const;
-
/**
* Deletes the column. If the itemview of the controller is set to the column,
* the controllers itemview is set to 0.
QAbstractItemView* m_dragSource;
QTimer* m_activeUrlTimer;
+ QTimer* m_assureVisibleActiveColumnTimer;
friend class DolphinColumnView;
};