WOrk on correct expand after filtered in.
This commit is contained in:
parent
e0016d10a1
commit
eb3f2e0174
3 changed files with 26 additions and 1 deletions
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
|
|
||||||
FeedsProxyModel::FeedsProxyModel(QObject *parent)
|
FeedsProxyModel::FeedsProxyModel(QObject *parent)
|
||||||
: QSortFilterProxyModel(parent), m_selectedItem(NULL), m_showUnreadOnly(false) {
|
: QSortFilterProxyModel(parent), m_selectedItem(NULL), m_showUnreadOnly(false), m_hiddenIndices(QList<QPair<int,QModelIndex> >()) {
|
||||||
m_sourceModel = new FeedsModel(this);
|
m_sourceModel = new FeedsModel(this);
|
||||||
|
|
||||||
setObjectName(QSL("FeedsProxyModel"));
|
setObjectName(QSL("FeedsProxyModel"));
|
||||||
|
|
@ -183,6 +183,22 @@ bool FeedsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedsProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
|
bool FeedsProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
|
||||||
|
bool should_show = filterAcceptsRowInternal(source_row, source_parent);
|
||||||
|
|
||||||
|
if (should_show && m_hiddenIndices.contains(QPair<int,QModelIndex>(source_row, source_parent))) {
|
||||||
|
// TODO: dodělat
|
||||||
|
|
||||||
|
m_hiddenIndices.removeAll(QPair<int,QModelIndex>(source_row, source_parent));
|
||||||
|
|
||||||
|
// Load status.
|
||||||
|
emit expandAfterFilterIn(m_sourceModel->index(source_row, 0, source_parent));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return should_show;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FeedsProxyModel::filterAcceptsRowInternal(int source_row, const QModelIndex &source_parent) const {
|
||||||
if (!m_showUnreadOnly) {
|
if (!m_showUnreadOnly) {
|
||||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,15 +56,20 @@ class FeedsProxyModel : public QSortFilterProxyModel {
|
||||||
private slots:
|
private slots:
|
||||||
void invalidateFilter();
|
void invalidateFilter();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void expandAfterFilterIn(const QModelIndex &idx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Compares two rows of data.
|
// Compares two rows of data.
|
||||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
||||||
|
bool filterAcceptsRowInternal(int source_row, const QModelIndex &source_parent) const;
|
||||||
|
|
||||||
// Source model pointer.
|
// Source model pointer.
|
||||||
FeedsModel *m_sourceModel;
|
FeedsModel *m_sourceModel;
|
||||||
const RootItem *m_selectedItem;
|
const RootItem *m_selectedItem;
|
||||||
bool m_showUnreadOnly;
|
bool m_showUnreadOnly;
|
||||||
|
QList<QPair<int,QModelIndex> > m_hiddenIndices;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FEEDSPROXYMODEL_H
|
#endif // FEEDSPROXYMODEL_H
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,10 @@ FeedsView::FeedsView(QWidget *parent)
|
||||||
connect(m_sourceModel, SIGNAL(itemExpandStateSaveRequested(RootItem*)), this, SLOT(onItemExpandStateSaveRequested(RootItem*)));
|
connect(m_sourceModel, SIGNAL(itemExpandStateSaveRequested(RootItem*)), this, SLOT(onItemExpandStateSaveRequested(RootItem*)));
|
||||||
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
||||||
|
|
||||||
|
connect(m_proxyModel, &FeedsProxyModel::expandAfterFilterIn, [=](const QModelIndex &idx) {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
setModel(m_proxyModel);
|
setModel(m_proxyModel);
|
||||||
setupAppearance();
|
setupAppearance();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue