void DBWorker::removeTab(int tabId) { #ifdef DEBUG_LOGS qDebug() << "tab id:" << tabId; #endif QSqlQuery query = prepare("DELETE FROM tab WHERE tab_id = ?;"); query.bindValue(0, tabId); execute(query); // Remove links that are only related to this tab query = prepare("DELETE FROM link WHERE link_id IN " "(SELECT DISTINCT link_id FROM tab_history WHERE tab_id = ? " "AND link_id NOT IN (SELECT link_id FROM tab_history WHERE tab_id != ? " "UNION SELECT link_id FROM history))"); query.bindValue(0, tabId); query.bindValue(1, tabId); // Remove history query = prepare("DELETE FROM tab_history WHERE tab_id = ?;"); query.bindValue(0, tabId); execute(query); // Check last tab closed if (!tabCount()) { emit tabAvailable(Tab(-1, Link(), -1, -1)); } }
void DBWorker::removeAllTabs(bool noFeedback) { int oldTabCount(0); if (!noFeedback) { oldTabCount = tabCount(); } QSqlQuery query = prepare("DELETE FROM tab;"); execute(query); // Remove links that are not stored in history query = prepare("DELETE FROM link WHERE link_id IN " "(SELECT DISTINCT link_id FROM tab_history)"); execute(query); // Remove history query = prepare("DELETE FROM tab_history;"); execute(query); QList<Tab> tabList; if (oldTabCount != 0) { emit tabsAvailable(tabList); } }
void TabWidget::addTab(int index, const std::string &label, Widget *tab) { assert(index <= tabCount()); // It is important to add the content first since the callback // of the header will automatically fire when a new tab is added. mContent->addChild(index, tab); mHeader->addTab(index, label); assert(mHeader->tabCount() == mContent->childCount()); }
void MainWindow::closeTab(int index) { FILELOADMANAGER()->suspend(tabWidgetAt(index)); LOGVIEWERMANAGER()->deleteEditor(tabWidgetAt(index)); keywordButtonGroup()->removeState(tabWidgetAt(index)); if (tabCount() == 1) static_cast<MenuBar*>(menuBar())->setEnableTabbar(false); }
void MainWindow::openFile(const QString& fileName, bool openNewTab, bool reload, bool saveCurrentDir) { if (fileName.isEmpty()) return; if (!reload && (tabCount() == 0 || openNewTab || !LOGVIEWERMANAGER()->isEmpty(currentTabWidget()))) newTab(); if (saveCurrentDir || sender() == m_fileBrowser) INIMANAGER()->setRecentDirectory(QFileInfo(fileName).absolutePath()); m_tabWidget->setTabName(currentTabIndex(), QFileInfo(fileName).fileName(), fileName); recentFilesMenu()->appendRecentFile(fileName); FILELOADMANAGER()->load(currentTabWidget(), fileName, LOGVIEWERMANAGER()->textCodec(currentTabWidget())->name()); }
void DBWorker::clearHistory() { int oldTabCount = tabCount(); QSqlQuery query = prepare("DELETE FROM browser_history;"); execute(query); removeAllTabs(); query = prepare("DELETE FROM link;"); execute(query); QList<Link> linkList; emit historyAvailable(linkList); if (oldTabCount != 0) { QList<Tab> tabList; emit tabsAvailable(tabList); } }
void MainWindow::newTab(const QString& text) { static int count = 0; QWidget* viewer = LOGVIEWERMANAGER()->createViewer(this); if (!text.isEmpty()) LOGVIEWERMANAGER()->appendText(text, viewer); QString tabTitle = tr("Untitled %1").arg(++count); m_tabWidget->addTab(viewer, tabTitle); m_tabWidget->setCurrentIndex(m_tabWidget->count() - 1); viewer->setFocus(); showWindowTitle(tabTitle); if (tabCount() == 1) static_cast<MenuBar*>(menuBar())->setEnableTabbar(true); }
void Panel::OnNcLButtonUp( UINT nHitTest, CPoint point ) { int lastBut = buttonDown_; buttonDown_ = 0; paintCaptionButtons( nHitTest ); switch ( nHitTest ) { case BUT_CLOSE: if ( lastBut != nHitTest ) break; if ( onClose() ) { if ( tabCount() == 0 ) Manager::instance().dock()->removePanel( this ); return; } break; case BUT_ROLLUP: if ( lastBut != nHitTest ) break; setExpanded( !isExpanded_ ); SetFocus(); activate(); break; case BUT_CLONE: if ( lastBut != nHitTest ) break; if ( activeTab_ ) { CRect rect; GetWindowRect( &rect ); // position is hand-hacked, but should work well in all cases cloneTab( activeTab_->getContent(), ( rect.left + 10 ) % (GetSystemMetrics( SM_CXMAXIMIZED ) - 64), ( rect.top ) % (GetSystemMetrics( SM_CYMAXIMIZED ) - 64) ); } break; } }
void TabWidget::addTab(const std::string &name, Widget *tab) { addTab(tabCount(), name, tab); }
Widget* TabWidget::createTab(const std::string &label) { return createTab(tabCount(), label); }