void DeclarativeTabModel::remove(int index) {
    if (!m_tabs.isEmpty() && index >= 0 && index < m_tabs.count()) {
        beginRemoveRows(QModelIndex(), index, index);
        removeTab(m_tabs.at(index).tabId(), m_tabs.at(index).thumbnailPath(), index);
        endRemoveRows();
        saveTabOrder();
    }
}
void DeclarativeTabModel::remove(const int index) {
    if (!m_tabs.isEmpty() && index >= 0 && index < m_tabs.count()) {
        beginRemoveRows(QModelIndex(), index, index);
        removeTab(m_tabs.at(index), index);
        emit countChanged();
        endRemoveRows();
        saveTabOrder();
    }
}
void DeclarativeTabModel::updateActiveTab(const Tab &activeTab)
{
#ifdef DEBUG_LOGS
    qDebug() << "old active tab: " << &m_activeTab << m_tabs.count();
    qDebug() << "new active tab: " << &activeTab;
#endif
    if (m_activeTab != activeTab) {
        int oldTabId = m_activeTab.tabId();
        m_activeTab = activeTab;
        emit activeTabChanged(oldTabId, activeTab.tabId());
        saveTabOrder();
    }
}
void DeclarativeTabModel::updateActiveTab(const Tab &newActiveTab, bool updateCurrentTab)
{
#ifdef DEBUG_LOGS
    qDebug() << "change tab: " << updateCurrentTab << m_currentTab;
    qDebug() << "old active tab: " << m_activeTab.tabId() << m_activeTab.isValid() << m_activeTab.currentLink().url() << m_tabs.count();
    qDebug() << "new active tab: " << newActiveTab.tabId() << newActiveTab.isValid() << newActiveTab.currentLink().url();
#endif
    m_activeTab = newActiveTab;
    emit currentTabIdChanged();

    saveTabOrder();
    if (updateCurrentTab && m_currentTab) {
        m_currentTab->tabChanged(m_activeTab);
    }
}