-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitemcommand.cpp
More file actions
39 lines (34 loc) · 1.25 KB
/
itemcommand.cpp
File metadata and controls
39 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "itemcommand.h"
#include "dictionarymodel.h"
#include <QAbstractItemView>
#include <QSortFilterProxyModel>
ItemCommand::ItemCommand(QAbstractItemView *view, const QModelIndex &index) :
pView(view)
{
proxyModel = qobject_cast<QSortFilterProxyModel*>(view->model());
Q_ASSERT(proxyModel);
sourceModel = qobject_cast<DictionaryModel*>(proxyModel->sourceModel());
Q_ASSERT(sourceModel);
mIndex = proxyModel->mapToSource(index.sibling(index.row(), 0));
QModelIndex proxyParentIndex = index.parent();
mParentIndex = proxyModel->mapToSource(proxyParentIndex);
QModelIndex proxyGrandParentIndex = proxyParentIndex.parent();
mGrandParentIndex = proxyModel->mapToSource(proxyGrandParentIndex);
QModelIndex proxyRootParentIndex = proxyGrandParentIndex.parent();
mRootParentIndex = proxyModel->mapToSource(proxyRootParentIndex);
}
ItemCommand::~ItemCommand()
{
}
void ItemCommand::reinitializeIndexes()
{
if (mGrandParentIndex.isValid())
{
mGrandParentIndex = sourceModel->index(mGrandParentIndex.row(), mGrandParentIndex.column(), mRootParentIndex);
}
if (mParentIndex.isValid())
{
mParentIndex = sourceModel->index(mParentIndex.row(), mParentIndex.column(), mGrandParentIndex);
}
mIndex = sourceModel->index(mIndex.row(), mIndex.column(), mParentIndex);
}