void DeclarativeTabModel::tabsAvailable(QList<Tab> tabs) { beginResetModel(); int oldCount = count(); m_tabs.clear(); m_tabs = tabs; if (m_tabs.count() > 0) { loadTabOrder(); qSort(m_tabs.begin(), m_tabs.end(), DeclarativeTabModel::tabSort); m_activeTab = m_tabs.at(0); m_tabs.removeAt(0); } else { m_activeTab = Tab(); emit tabsCleared(); } endResetModel(); if (count() != oldCount) { emit countChanged(); } int maxTabId = DBManager::instance()->getMaxTabId(); if (m_nextTabId != maxTabId + 1) { m_nextTabId = maxTabId + 1; emit nextTabIdChanged(); } // Startup should be synced to this. if (!m_loaded) { m_loaded = true; emit loadedChanged(); } }
void DeclarativeTabModel::clear() { if (count() == 0) return; beginResetModel(); for (int i = m_tabs.count() - 1; i >= 0; --i) { removeTab(m_tabs.at(i).tabId(), m_tabs.at(i).thumbnailPath(), i); } closeActiveTab(); endResetModel(); resetNewTabData(); emit tabsCleared(); }
void DeclarativeWebContainer::setTabModel(DeclarativeTabModel *model) { if (m_model != model) { if (m_model) { disconnect(m_model); } m_model = model; if (m_model) { connect(m_model, SIGNAL(activeTabChanged(int,int,bool)), this, SLOT(onActiveTabChanged(int,int,bool))); connect(m_model, SIGNAL(loadedChanged()), this, SLOT(initialize())); connect(m_model, SIGNAL(tabClosed(int)), this, SLOT(releasePage(int))); connect(m_model, SIGNAL(tabsCleared()), this, SLOT(onTabsCleared())); connect(m_model, SIGNAL(newTabRequested(QString,QString,int)), this, SLOT(onNewTabRequested(QString,QString,int))); } emit tabModelChanged(); } }