// DeleteHistoryEntry void HistoryModel::deleteHistoryEntry(int index) { QList<int> list; list.append(index); deleteHistoryEntry(list); }
void HistoryModel::deleteHistoryEntry(const QString &url, const QString &title) { QSqlQuery query; query.prepare("SELECT id FROM history WHERE url=? AND title=?"); query.bindValue(0, url); query.bindValue(1, title); query.exec(); if (query.next()) { int id = query.value(0).toInt(); deleteHistoryEntry(id); } }
void EditEntryWidget::setupHistory() { m_historyUi->setupUi(m_historyWidget); add(tr("History"), m_historyWidget); m_sortModel->setSourceModel(m_historyModel); m_sortModel->setDynamicSortFilter(true); m_sortModel->setSortLocaleAware(true); m_sortModel->setSortCaseSensitivity(Qt::CaseInsensitive); m_sortModel->setSortRole(Qt::UserRole); m_historyUi->historyView->setModel(m_sortModel); m_historyUi->historyView->setRootIsDecorated(false); connect(m_historyUi->historyView, SIGNAL(activated(QModelIndex)), SLOT(histEntryActivated(QModelIndex))); connect(m_historyUi->historyView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(updateHistoryButtons(QModelIndex,QModelIndex))); connect(m_historyUi->showButton, SIGNAL(clicked()), SLOT(showHistoryEntry())); connect(m_historyUi->restoreButton, SIGNAL(clicked()), SLOT(restoreHistoryEntry())); connect(m_historyUi->deleteButton, SIGNAL(clicked()), SLOT(deleteHistoryEntry())); connect(m_historyUi->deleteAllButton, SIGNAL(clicked()), SLOT(deleteAllHistoryEntries())); }