Exemple #1
0
void DBWorker::navigateTo(int tabId, QString url, QString title, QString path) {
    // TODO: rollback in case of failure
    if (url.isEmpty()) {
        return;
    }

    // Return if the current url of the tab is the same as the parameter url
    Link currentLink = getCurrentLink(tabId);
    if (currentLink.isValid() && currentLink.url() == url) {
        return;
    }

    clearDeprecatedTabHistory(tabId, currentLink.linkId());

    int linkId = createLink(url, title, path);

    if (addToBrowserHistory(url, title) == Error) {
        qWarning() << Q_FUNC_INFO << "failed to add url to history" << url;
    }

    int historyId = addToTabHistory(tabId, linkId);
    if (historyId > 0) {
        updateTab(tabId, historyId);
    } else {
        qWarning() << Q_FUNC_INFO << "failed to add url to tab history" << url;
    }

#if DEBUG_LOGS
    qDebug() << "emit tab changed:" << tabId << historyId << title << url;
#endif
}
void DBWorker::createTab(const Tab &tab)
{
#if DEBUG_LOGS
    qDebug() << "new tab id: " << tab.tabId();
#endif
    QSqlQuery query = prepare("INSERT INTO tab (tab_id, tab_history_id) VALUES (?,?);");
    query.bindValue(0, tab.tabId());
    query.bindValue(1, 0);
    execute(query);

    if (tab.url().isEmpty()) {
        return;
    }

    int linkId = createLink(tab.url(), tab.title(), tab.thumbnailPath());

    if (addToBrowserHistory(tab.url(), tab.title()) == Error) {
        qWarning() << Q_FUNC_INFO << "failed to add url to history" << tab.url();
    }

    int historyId = addToTabHistory(tab.tabId(), linkId);
    if (historyId > 0) {
        updateTab(tab.tabId(), historyId);
    } else {
        qWarning() << Q_FUNC_INFO << "failed to add url to tab history" << tab.url();
    }

#if DEBUG_LOGS
    qDebug() << "created link:" << linkId << "with history id:" << historyId << "for tab:" << tab.tabId() << tab.url();
#endif
}
Exemple #3
0
int DBWorker::createLink(int tabId, QString url)
{
    if (url.isEmpty()) {
        return 0;
    }

    int linkId = createLink(url, "", "");

    if (!addToHistory(linkId)) {
        qWarning() << Q_FUNC_INFO << "failed to add url to history" << url;
    }

    int historyId = addToTabHistory(tabId, linkId);
    if (historyId > 0) {
        updateTab(tabId, historyId);
    } else {
        qWarning() << Q_FUNC_INFO << "failed to add url to tab history" << url;
    }

#ifdef DEBUG_LOGS
    qDebug() << "created link:" << linkId << "with history id:" << historyId << "for tab:" << tabId << url;
#endif
    return linkId;
}