#include <QApplication>
#include <QPoint>
#include <QScrollBar>
+#include <QTimer>
#include <QTimeLine>
/**
QAbstractItemView(parent),
m_controller(controller),
m_restoreActiveColumnFocus(false),
+ m_dirListerCompleted(false),
m_index(-1),
m_contentX(0),
m_columns(),
connect(m_dolphinModel, SIGNAL(expand(const QModelIndex&)),
this, SLOT(triggerReloadColumns(const QModelIndex&)));
+ KDirLister* dirLister = m_dolphinModel->dirLister();
+ connect(dirLister, SIGNAL(started(const KUrl&)),
+ this, SLOT(slotDirListerStarted(const KUrl&)));
+ connect(dirLister, SIGNAL(completed()),
+ this, SLOT(slotDirListerCompleted()));
+
activeColumn()->setModel(model);
QAbstractItemView::setModel(model);
}
+void DolphinColumnView::invertSelection()
+{
+ // TODO: this approach of inverting the selection is quite slow. It should
+ // be possible to speedup the implementation by using QItemSelection, but
+ // all adempts have failed yet...
+
+ ColumnWidget* column = activeColumn();
+ QItemSelectionModel* selModel = column->selectionModel();
+
+ KDirLister* dirLister = m_dolphinModel->dirLister();
+ const KFileItemList list = dirLister->itemsForDir(column->url());
+ foreach (KFileItem* item, list) {
+ const QModelIndex index = m_dolphinModel->indexForUrl(item->url());
+ selModel->select(m_proxyModel->mapFromSource(index), QItemSelectionModel::Toggle);
+ }
+}
+
void DolphinColumnView::reload()
{
// Due to the reloading of the model all columns will be reset to show
m_restoreActiveColumnFocus = true;
}
column->hide();
- }
+ }
// all columns are hidden, now reload the directory lister
KDirLister* dirLister = m_dolphinModel->dirLister();
- connect(dirLister, SIGNAL(completed()),
- this, SLOT(expandToActiveUrl()));
- const KUrl rootUrl = m_columns[0]->url();
+ const KUrl& rootUrl = m_columns[0]->url();
dirLister->openUrl(rootUrl, false, true);
-}
-
-void DolphinColumnView::invertSelection()
-{
- // TODO: this approach of inverting the selection is quite slow. It should
- // be possible to speedup the implementation by using QItemSelection, but
- // all adempts have failed yet...
-
- ColumnWidget* column = activeColumn();
- QItemSelectionModel* selModel = column->selectionModel();
-
- KDirLister* dirLister = m_dolphinModel->dirLister();
- const KFileItemList list = dirLister->itemsForDir(column->url());
- foreach (KFileItem* item, list) {
- const QModelIndex index = m_dolphinModel->indexForUrl(item->url());
- selModel->select(m_proxyModel->mapFromSource(index), QItemSelectionModel::Toggle);
- }
+ updateColumns();
}
void DolphinColumnView::showColumn(const KUrl& url)
columnIndex++;
ColumnWidget* column = new ColumnWidget(viewport(), this, childUrl);
- column->setVerticalScrollMode(ColumnWidget::ScrollPerPixel);
- column->setHorizontalScrollMode(ColumnWidget::ScrollPerPixel);
column->setModel(model());
column->setRootIndex(proxyIndex);
column->setActive(false);
activeColumn()->setActive(false);
m_index = columnIndex;
activeColumn()->setActive(true);
-
- expandToActiveUrl();
}
void DolphinColumnView::selectAll()
Q_ASSERT(lastIndex >= 0);
const KUrl& activeUrl = m_columns[lastIndex]->url();
const KUrl rootUrl = m_dolphinModel->dirLister()->url();
- const bool expand = rootUrl.isParentOf(activeUrl)
+ const bool expand = m_dirListerCompleted
+ && rootUrl.isParentOf(activeUrl)
&& !rootUrl.equals(activeUrl, KUrl::CompareWithoutTrailingSlash);
if (expand) {
m_dolphinModel->expandToUrl(activeUrl);
- reloadColumns();
}
+ updateColumns();
}
-void DolphinColumnView::triggerReloadColumns(const QModelIndex& index)
+void DolphinColumnView::triggerUpdateColumns(const QModelIndex& index)
{
Q_UNUSED(index);
- // the reloading of the columns may not be done in the context of this slot
- QMetaObject::invokeMethod(this, "reloadColumns", Qt::QueuedConnection);
+ // the updating of the columns may not be done in the context of this slot
+ QMetaObject::invokeMethod(this, "updateColumns", Qt::QueuedConnection);
}
-void DolphinColumnView::reloadColumns()
+void DolphinColumnView::updateColumns()
{
+ KDirLister* dirLister = m_dolphinModel->dirLister();
+ foreach (ColumnWidget* column, m_columns) {
+ dirLister->updateDirectory(column->url());
+ }
+
const int end = m_columns.count() - 2; // next to last column
for (int i = 0; i <= end; ++i) {
ColumnWidget* nextColumn = m_columns[i + 1];
-
- KDirLister* dirLister = m_dolphinModel->dirLister();
- dirLister->updateDirectory(nextColumn->url());
-
const QModelIndex rootIndex = nextColumn->rootIndex();
if (rootIndex.isValid()) {
nextColumn->show();
assureVisibleActiveColumn();
}
+void DolphinColumnView::slotDirListerStarted(const KUrl& url)
+{
+ Q_UNUSED(url);
+ m_dirListerCompleted = false;
+}
+
+void DolphinColumnView::slotDirListerCompleted()
+{
+ m_dirListerCompleted = true;
+ QMetaObject::invokeMethod(this, "expandToActiveUrl", Qt::QueuedConnection);
+}
+
bool DolphinColumnView::isZoomInPossible() const
{
ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();