mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-04 17:30:55 +00:00
Update for using a proxy model: prevent accessing the model by model() and doing a cast do KDirModel afterwards. Instead the access to the KDirModel is done by a member variable. Still the proxy model does not seem to work and leads to a crash as soon as the QListView should work with the proxy model -> in the meantime in line 112 from DolphinView.cpp the KDirModel is used instead of the proxy model.
svn path=/trunk/playground/utils/dolphin/; revision=613768
This commit is contained in:
parent
3bd97ea34c
commit
3b4dfa2040
|
@ -58,6 +58,10 @@ void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
|
|||
|
||||
const QModelIndex index = indexAt(event->pos());
|
||||
if (index.isValid()) {
|
||||
// TODO: assuming that model() returns an instance of the class
|
||||
// KDirModel is dangerous, especially in combination with a proxy model.
|
||||
// As the current test implementation of proxy model does not work, this
|
||||
// will be cleaned up later.
|
||||
KDirModel* dirModel = static_cast<KDirModel*>(model());
|
||||
item = dirModel->itemForIndex(index);
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ public:
|
|||
Qt::SortOrder sortOrder() const { return m_sortOrder; }
|
||||
|
||||
protected:
|
||||
virtual bool lessThan(const QModelIndex& left,
|
||||
const QModelIndex& right) const;
|
||||
virtual bool lessThan(const QModelIndex& left,
|
||||
const QModelIndex& right) const;
|
||||
|
||||
private:
|
||||
DolphinView::Sorting m_sorting;
|
||||
|
|
|
@ -67,6 +67,7 @@ DolphinView::DolphinView(DolphinMainWindow *mainWindow,
|
|||
m_iconsView(0),
|
||||
m_filterBar(0),
|
||||
m_statusBar(0),
|
||||
m_dirModel(0),
|
||||
m_dirLister(0),
|
||||
m_proxyModel(0)
|
||||
{
|
||||
|
@ -102,20 +103,19 @@ DolphinView::DolphinView(DolphinMainWindow *mainWindow,
|
|||
m_iconsView = new DolphinIconsView(this);
|
||||
applyModeToView();
|
||||
|
||||
KDirModel* model = new KDirModel();
|
||||
model->setDirLister(m_dirLister);
|
||||
m_dirModel = new KDirModel();
|
||||
m_dirModel->setDirLister(m_dirLister);
|
||||
|
||||
m_proxyModel = new DolphinSortFilterProxyModel(this);
|
||||
m_proxyModel->setSourceModel(model);
|
||||
m_proxyModel->setDynamicSortFilter(true);
|
||||
m_proxyModel->setSourceModel(m_dirModel);
|
||||
|
||||
m_iconsView->setModel(model);
|
||||
m_iconsView->setModel(m_dirModel); // TODO: using m_proxyModel crashed when clicking on an item
|
||||
|
||||
KFileItemDelegate* delegate = new KFileItemDelegate(this);
|
||||
m_iconsView->setItemDelegate(delegate);
|
||||
|
||||
m_dirLister->setDelayedMimeTypes(true);
|
||||
new KMimeTypeResolver(m_iconsView, model);
|
||||
new KMimeTypeResolver(m_iconsView, m_dirModel);
|
||||
|
||||
m_iconSize = K3Icon::SizeMedium;
|
||||
|
||||
|
@ -476,12 +476,11 @@ KFileItemList DolphinView::selectedItems() const
|
|||
|
||||
KFileItemList itemList;
|
||||
if (selModel->hasSelection()) {
|
||||
KDirModel* dirModel = static_cast<KDirModel*>(m_iconsView->model());
|
||||
const QModelIndexList indexList = selModel->selectedIndexes();
|
||||
|
||||
QModelIndexList::const_iterator end = indexList.end();
|
||||
for (QModelIndexList::const_iterator it = indexList.begin(); it != end; ++it) {
|
||||
KFileItem* item = dirModel->itemForIndex(*it);
|
||||
KFileItem* item = m_dirModel->itemForIndex(*it);
|
||||
if (item != 0) {
|
||||
itemList.append(item);
|
||||
}
|
||||
|
@ -648,8 +647,7 @@ void DolphinView::triggerIconsViewItem(Q3IconViewItem* item)
|
|||
|
||||
void DolphinView::triggerItem(const QModelIndex& index)
|
||||
{
|
||||
KDirModel* dirModel = static_cast<KDirModel*>(m_iconsView->model());
|
||||
KFileItem* item = dirModel->itemForIndex(index);
|
||||
KFileItem* item = m_dirModel->itemForIndex(index);
|
||||
if (item == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ class DolphinDetailsView;
|
|||
class DolphinSortFilterProxyModel;
|
||||
class ViewProperties;
|
||||
class KProgress;
|
||||
class KDirModel;
|
||||
class FilterBar;
|
||||
|
||||
class QModelIndex;
|
||||
|
@ -464,6 +465,7 @@ private:
|
|||
FilterBar *m_filterBar;
|
||||
DolphinStatusBar* m_statusBar;
|
||||
|
||||
KDirModel* m_dirModel;
|
||||
DolphinDirLister* m_dirLister;
|
||||
DolphinSortFilterProxyModel* m_proxyModel;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user