Skip to content

Commit

Permalink
Feature added to merge two itemModel. Thus permanent exclusion of fil…
Browse files Browse the repository at this point in the history
…es is possible.
  • Loading branch information
RobertKrajewski committed Dec 30, 2014
1 parent b00d40e commit 9e79084
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
38 changes: 36 additions & 2 deletions browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ void Browser::on_refreshPushButton_clicked()
{
refreshCounter++;

// Löschen der alten Veranstaltungsliste
itemModel->clear();
oldItemModel = itemModel;

itemModel = new QStandardItemModel();
proxyModel.setSourceModel(itemModel);

// Zurücksetzen der freigeschalteten Schaltflächen
updateButtons();
Expand Down Expand Up @@ -344,6 +346,38 @@ void Browser::filesRecieved(QNetworkReply *reply)
}

itemModel->sort(0);

QLinkedList<Structureelement*> items;

QStandardItem* root = itemModel->invisibleRootItem();
for( int i=0; i < root->rowCount(); i++)
{
getStructureelementsList(static_cast<Structureelement*>(root->child(i)), items);
}

QLinkedList<Structureelement*> oldItems;
root = oldItemModel->invisibleRootItem();
for( int i=0; i < root->rowCount(); i++)
{
getStructureelementsList(static_cast<Structureelement*>(root->child(i)), oldItems);
}

foreach(Structureelement *item, items)
{
for(QLinkedList<Structureelement*>::iterator it = oldItems.begin(); it != oldItems.end(); it++)
{
Structureelement *oldItem = *it;
if(item->data(urlRole) == oldItem->data(urlRole) && item->text() == oldItem->text())
{
item->setData(oldItem->data(includeRole), includeRole);
oldItems.erase(it);
break;
}
}
}

oldItemModel->deleteLater();
oldItemModel = 0;
}
}

Expand Down
1 change: 1 addition & 0 deletions browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public slots:
QNetworkAccessManager *manager;
MySortFilterProxyModel proxyModel;
QStandardItemModel *itemModel;
QStandardItemModel *oldItemModel;
Structureelement *iter;
QFile output;
QMap<QNetworkReply*, Structureelement*> replies;
Expand Down

0 comments on commit 9e79084

Please sign in to comment.