mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
* some internal cleanups
* assure that a column gets created if no existing column can be used for showing an URL svn path=/trunk/KDE/kdebase/apps/; revision=714407
This commit is contained in:
parent
539531e1df
commit
9d277154e1
2 changed files with 28 additions and 18 deletions
|
@ -104,7 +104,7 @@ private:
|
||||||
ColumnWidget::ColumnWidget(QWidget* parent,
|
ColumnWidget::ColumnWidget(QWidget* parent,
|
||||||
DolphinColumnView* columnView,
|
DolphinColumnView* columnView,
|
||||||
const KUrl& url) :
|
const KUrl& url) :
|
||||||
QListView(columnView),
|
QListView(parent),
|
||||||
m_active(true),
|
m_active(true),
|
||||||
m_view(columnView),
|
m_view(columnView),
|
||||||
m_url(url),
|
m_url(url),
|
||||||
|
@ -244,10 +244,8 @@ void ColumnWidget::paintEvent(QPaintEvent* event)
|
||||||
{
|
{
|
||||||
if (!m_childUrl.isEmpty()) {
|
if (!m_childUrl.isEmpty()) {
|
||||||
// indicate the shown URL of the next column by highlighting the shown folder item
|
// indicate the shown URL of the next column by highlighting the shown folder item
|
||||||
const QAbstractProxyModel* proxyModel = static_cast<const QAbstractProxyModel*>(m_view->model());
|
const QModelIndex dirIndex = m_view->m_dolphinModel->indexForUrl(m_childUrl);
|
||||||
const DolphinModel* dolphinModel = static_cast<const DolphinModel*>(proxyModel->sourceModel());
|
const QModelIndex proxyIndex = m_view->m_proxyModel->mapFromSource(dirIndex);
|
||||||
const QModelIndex dirIndex = dolphinModel->indexForUrl(m_childUrl);
|
|
||||||
const QModelIndex proxyIndex = proxyModel->mapFromSource(dirIndex);
|
|
||||||
if (proxyIndex.isValid() && !selectionModel()->isSelected(proxyIndex)) {
|
if (proxyIndex.isValid() && !selectionModel()->isSelected(proxyIndex)) {
|
||||||
const QRect itemRect = visualRect(proxyIndex);
|
const QRect itemRect = visualRect(proxyIndex);
|
||||||
QPainter painter(viewport());
|
QPainter painter(viewport());
|
||||||
|
@ -347,10 +345,8 @@ void ColumnWidget::activate()
|
||||||
if (!m_childUrl.isEmpty()) {
|
if (!m_childUrl.isEmpty()) {
|
||||||
// assure that the current index is set on the index that represents
|
// assure that the current index is set on the index that represents
|
||||||
// the child URL
|
// the child URL
|
||||||
const QAbstractProxyModel* proxyModel = static_cast<const QAbstractProxyModel*>(model());
|
const QModelIndex dirIndex = m_view->m_dolphinModel->indexForUrl(m_childUrl);
|
||||||
const KDirModel* dirModel = static_cast<const KDirModel*>(proxyModel->sourceModel());
|
const QModelIndex proxyIndex = m_view->m_proxyModel->mapFromSource(dirIndex);
|
||||||
const QModelIndex dirIndex = dirModel->indexForUrl(m_childUrl);
|
|
||||||
const QModelIndex proxyIndex = proxyModel->mapFromSource(dirIndex);
|
|
||||||
selectionModel()->setCurrentIndex(proxyIndex, QItemSelectionModel::Current);
|
selectionModel()->setCurrentIndex(proxyIndex, QItemSelectionModel::Current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +387,9 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control
|
||||||
m_index(-1),
|
m_index(-1),
|
||||||
m_contentX(0),
|
m_contentX(0),
|
||||||
m_columns(),
|
m_columns(),
|
||||||
m_animation(0)
|
m_animation(0),
|
||||||
|
m_dolphinModel(0),
|
||||||
|
m_proxyModel(0)
|
||||||
{
|
{
|
||||||
Q_ASSERT(controller != 0);
|
Q_ASSERT(controller != 0);
|
||||||
|
|
||||||
|
@ -454,12 +452,16 @@ QRect DolphinColumnView::visualRect(const QModelIndex& index) const
|
||||||
|
|
||||||
void DolphinColumnView::setModel(QAbstractItemModel* model)
|
void DolphinColumnView::setModel(QAbstractItemModel* model)
|
||||||
{
|
{
|
||||||
|
m_proxyModel = static_cast<const QAbstractProxyModel*>(model);
|
||||||
|
m_dolphinModel = static_cast<const DolphinModel*>(m_proxyModel->sourceModel());
|
||||||
|
|
||||||
activeColumn()->setModel(model);
|
activeColumn()->setModel(model);
|
||||||
QAbstractItemView::setModel(model);
|
QAbstractItemView::setModel(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DolphinColumnView::isIndexHidden(const QModelIndex& index) const
|
bool DolphinColumnView::isIndexHidden(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(index);
|
||||||
return false;//activeColumn()->isIndexHidden(index);
|
return false;//activeColumn()->isIndexHidden(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,6 +506,8 @@ QModelIndex DolphinColumnView::moveCursor(CursorAction cursorAction, Qt::Keyboar
|
||||||
|
|
||||||
void DolphinColumnView::setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags)
|
void DolphinColumnView::setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(rect);
|
||||||
|
Q_UNUSED(flags);
|
||||||
//activeColumn()->setSelection(rect, flags);
|
//activeColumn()->setSelection(rect, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,9 +576,7 @@ void DolphinColumnView::triggerItem(const QModelIndex& index)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QAbstractProxyModel* proxyModel = static_cast<const QAbstractProxyModel*>(model());
|
const KFileItem item = m_dolphinModel->itemForIndex(m_proxyModel->mapToSource(index));
|
||||||
const KDirModel* dirModel = static_cast<const KDirModel*>(proxyModel->sourceModel());
|
|
||||||
const KFileItem item = dirModel->itemForIndex(proxyModel->mapToSource(index));
|
|
||||||
if ((item.url() != activeColumn()->url()) && item.isDir()) {
|
if ((item.url() != activeColumn()->url()) && item.isDir()) {
|
||||||
deleteInactiveChildColumns();
|
deleteInactiveChildColumns();
|
||||||
|
|
||||||
|
@ -627,16 +629,20 @@ void DolphinColumnView::showColumn(const KUrl& url)
|
||||||
deleteInactiveChildColumns();
|
deleteInactiveChildColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QAbstractProxyModel* proxyModel = static_cast<const QAbstractProxyModel*>(model());
|
const QModelIndex dirIndex = m_dolphinModel->indexForUrl(url);
|
||||||
const KDirModel* dirModel = static_cast<const KDirModel*>(proxyModel->sourceModel());
|
|
||||||
const QModelIndex dirIndex = dirModel->indexForUrl(url);
|
|
||||||
if (dirIndex.isValid()) {
|
if (dirIndex.isValid()) {
|
||||||
triggerItem(proxyModel->mapFromSource(dirIndex));
|
triggerItem(m_proxyModel->mapFromSource(dirIndex));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
++columnIndex;
|
++columnIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no existing column has been replaced and a new column must be created
|
||||||
|
const QModelIndex dirIndex = m_dolphinModel->indexForUrl(url);
|
||||||
|
if (dirIndex.isValid()) {
|
||||||
|
triggerItem(m_proxyModel->mapFromSource(dirIndex));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinColumnView::updateDecorationSize()
|
void DolphinColumnView::updateDecorationSize()
|
||||||
|
|
|
@ -26,8 +26,9 @@
|
||||||
|
|
||||||
class ColumnWidget;
|
class ColumnWidget;
|
||||||
class DolphinController;
|
class DolphinController;
|
||||||
class KDirLister;
|
class DolphinModel;
|
||||||
class KUrl;
|
class KUrl;
|
||||||
|
class QAbstractProxyModel;
|
||||||
class QTimeLine;
|
class QTimeLine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,6 +129,9 @@ private:
|
||||||
QList<ColumnWidget*> m_columns;
|
QList<ColumnWidget*> m_columns;
|
||||||
QTimeLine* m_animation;
|
QTimeLine* m_animation;
|
||||||
|
|
||||||
|
DolphinModel* m_dolphinModel;
|
||||||
|
QAbstractProxyModel* m_proxyModel;
|
||||||
|
|
||||||
friend class ColumnWidget;
|
friend class ColumnWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue