diff options
author | Arno <am@disconnect.de> | 2011-05-14 13:26:41 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2011-05-14 13:26:41 +0200 |
commit | 3a70006747322708b81b91f52b447abb33d91df0 (patch) | |
tree | 1a8b53c7990bf2de08f3b2dc36de9a62fda3bc00 /seriestreewidget.cpp | |
parent | a6a1c319ee5a77cc8341eaeccc72da35cbcf17c5 (diff) | |
download | SheMov-3a70006747322708b81b91f52b447abb33d91df0.tar.gz SheMov-3a70006747322708b81b91f52b447abb33d91df0.tar.bz2 SheMov-3a70006747322708b81b91f52b447abb33d91df0.zip |
Use new field IsLocal in SeriesTreeModel
Use field IsLocal in SeriesTreeModel when filtering local or
archived files.
Diffstat (limited to 'seriestreewidget.cpp')
-rw-r--r-- | seriestreewidget.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/seriestreewidget.cpp b/seriestreewidget.cpp index dd986b3..5a97587 100644 --- a/seriestreewidget.cpp +++ b/seriestreewidget.cpp @@ -337,7 +337,11 @@ void SeriesTreeWidget::itemCollaped(const QModelIndex &what){ } void SeriesTreeWidget::expandItems(const QStringList &items){ - foreach(QString s, items){ + QStringList expand = items; + if(items.isEmpty()){ + expand = mExpandedItems; + } + foreach(QString s, expand){ QModelIndex idx = mProxy->mapFromSource(mModel->findValue(s)); mView->expand(idx); } @@ -482,6 +486,43 @@ bool SeriesTreeSortModel::lessThan(const QModelIndex &left, const QModelIndex &r return QSortFilterProxyModel::lessThan(left, right); } +bool SeriesTreeSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { + SeriesTreeModel *seriesModel = static_cast<SeriesTreeModel*>(sourceModel()); + int rowFilter = seriesModel->rowFilter(); + QModelIndex curIdx = sourceModel()->index(source_row, 0, source_parent); + QString name = curIdx.data(SeriesTreeModel::NameRole).toString(); + QRegExp filterRe = filterRegExp(); + if(rowFilter == SeriesTreeModel::All){ + if(filterRe.isEmpty()){ + return true; + }else{ + return (filterRe.indexIn(name) != -1); + } + } + if(!curIdx.isValid()){ + return true; + } + int type = curIdx.data(SeriesTreeModel::TypeRole).toInt(); + bool filterLocal = (rowFilter == SeriesTreeModel::Local); + if(type == SeriesTreeModel::Series){ + int row = 0; + QModelIndex child = curIdx.child(row, 0); + while(child.isValid()){ + bool hasLocals = child.data(SeriesTreeModel::IsLocalRole).toBool(); + if(hasLocals == filterLocal){ + return (filterRe.indexIn(name) != -1); + } + child = curIdx.child(++row, 0); + } + }else if(type == SeriesTreeModel::Part){ + bool accept = (curIdx.data(SeriesTreeModel::IsLocalRole).toBool() == filterLocal); + if(accept){ + return (filterRe.indexIn(name) != -1); + } + } + return false; +} + AddCoverDialog::AddCoverDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ //File selection QLabel *l1 = new QLabel(tr("Select file")); |