HistoryItem* HistoryManager::addItem(const QUrl& url, const QString& title, const QDateTime& visitTime) { HistoryItem* oldItem; int index; for(index = 0; index < count(); index++) { oldItem = item(index); if(oldItem->url() == url) { break; } } int counter = 1; if(index < count()) { counter = oldItem->counter() + 1; removeItem(index); } HistoryItem* item = new HistoryItem(url, title, visitTime, counter, this); beginInsertRows(QModelIndex(), 0, 0); _items.prepend(item); endInsertRows(); return item; }