HistoryManager::HistoryManager(QupZilla* mainClass, QWidget* parent)
    : QWidget(parent)
    , ui(new Ui::HistoryManager)
    , p_QupZilla(mainClass)
    , m_historyModel(mApp->history())
{
    ui->setupUi(this);
    ui->historyTree->setDefaultItemShowMode(TreeWidget::ItemsCollapsed);
    ui->historyTree->setSelectionMode(QAbstractItemView::ExtendedSelection);
    ui->deleteB->setShortcut(QKeySequence("Del"));

    connect(ui->historyTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*)));
    connect(ui->historyTree, SIGNAL(itemMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*)));

    connect(ui->deleteB, SIGNAL(clicked()), this, SLOT(deleteItem()));
    connect(ui->clearAll, SIGNAL(clicked()), this, SLOT(clearHistory()));
    connect(ui->historyTree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));

    connect(m_historyModel, SIGNAL(historyEntryAdded(HistoryEntry)), this, SLOT(historyEntryAdded(HistoryEntry)));
    connect(m_historyModel, SIGNAL(historyEntryDeleted(HistoryEntry)), this, SLOT(historyEntryDeleted(HistoryEntry)));
    connect(m_historyModel, SIGNAL(historyEntryEdited(HistoryEntry, HistoryEntry)), this, SLOT(historyEntryEdited(HistoryEntry, HistoryEntry)));
    connect(m_historyModel, SIGNAL(historyClear()), ui->historyTree, SLOT(clear()));

    connect(ui->optimizeDb, SIGNAL(clicked(QPoint)), this, SLOT(optimizeDb()));

    //QTimer::singleShot(0, this, SLOT(refreshTable()));

    ui->historyTree->setFocus();
}
Exemple #2
0
HistoryModel::HistoryModel(History* history)
    : QAbstractItemModel(history)
    , m_rootItem(new HistoryItem(0))
    , m_todayItem(0)
    , m_history(history)
{
    init();

    connect(m_history, SIGNAL(resetHistory()), this, SLOT(resetHistory()));
    connect(m_history, SIGNAL(historyEntryAdded(HistoryEntry)), this, SLOT(historyEntryAdded(HistoryEntry)));
    connect(m_history, SIGNAL(historyEntryDeleted(HistoryEntry)), this, SLOT(historyEntryDeleted(HistoryEntry)));
    connect(m_history, SIGNAL(historyEntryEdited(HistoryEntry,HistoryEntry)), this, SLOT(historyEntryEdited(HistoryEntry,HistoryEntry)));
}
Exemple #3
0
void HistoryModel::slotDeleteHistoryEntry(const QList<int> &list)
{
    QSqlDatabase db = QSqlDatabase::database();
    db.transaction();

    foreach(int index, list) {
        QSqlQuery query;
        query.prepare("SELECT id, count, date, url, title FROM history WHERE id=?");
        query.bindValue(0, index);
        query.exec();

        HistoryEntry entry;
        entry.id = query.value(0).toInt();
        entry.count = query.value(1).toInt();
        entry.date = QDateTime::fromMSecsSinceEpoch(query.value(2).toLongLong());
        entry.url = query.value(3).toUrl();
        entry.title = query.value(4).toString();

        query.prepare("DELETE FROM history WHERE id=?");
        query.bindValue(0, index);
        query.exec();

        query.prepare("DELETE FROM icons WHERE url=?");
        query.bindValue(0, entry.url.toEncoded(QUrl::RemoveFragment));
        query.exec();

        emit historyEntryDeleted(entry);
    }
Exemple #4
0
void HistoryModel::slotDeleteHistoryEntry(int index)
{
    QSqlQuery query;
    query.prepare("SELECT id, count, date, url, title FROM history WHERE id=?");
    query.bindValue(0, index);
    query.exec();
    if (!query.next()) {
        return;
    }

    HistoryEntry entry;
    entry.id = query.value(0).toInt();
    entry.count = query.value(1).toInt();
    entry.date = QDateTime::fromMSecsSinceEpoch(query.value(2).toLongLong());
    entry.url = query.value(3).toUrl();
    entry.title = query.value(4).toString();

    query.prepare("DELETE FROM history WHERE id=?");
    query.bindValue(0, index);
    query.exec();
    query.prepare("DELETE FROM icons WHERE url=?");
    query.bindValue(0, entry.url.toEncoded(QUrl::RemoveFragment));
    query.exec();

    emit historyEntryDeleted(entry);
}