void TabView::close(int index) { assert(index >= 0 && index < count()); if (index < 0 || index >= count()) return; if (auto pTab = qobject_cast<Tab*>(widget(index))) { removeTab(index); pTab->deleteLater(); } emit countChanged(count()); }
/** * @brief Closes the editor at the specified index without confirmation. * @param index An editor index. */ void EditorTabs::remove_editor(int index) { Editor* editor = get_editor(index); QString path = editor->get_file_path(); undo_group->removeStack(&editor->get_undo_stack()); // Tell the quest that this file is now closed. editor->get_quest().set_path_open(path, false); editors.remove(path); removeTab(index); }
void Workspace::removeWorkSheet() { WorkSheet *current = (WorkSheet*)currentWidget(); if ( current ) { saveWorkSheet( current ); removeTab(indexOf( current )); mSheetList.removeAll( current ); } else { QString msg = i18n( "There are no tabs that could be deleted." ); KMessageBox::error( this, msg ); } }
void TabbedArea::death(const Event& event) { Widget* source = event.getSource(); Tab* tab = dynamic_cast<Tab*>(source); if (tab != NULL) { removeTab(tab); } else { BasicContainer::death(event); } }
bool TabWidget::swapTabs(int index1, int index2) { if (index1==index2) return false; int t1 = qMin(index1,index2); int t2 = qMax(index1,index2); index1=t1; index2=t2; QString name1 = tabBar()->tabText(index1); QString name2 = tabBar()->tabText(index2); QWidget *editor1 = widget(index1); QWidget *editor2 = widget(index2); removeTab(index2); removeTab(index1); insertTab(index1,editor2,name2); insertTab(index2,editor1,name1); return true; }
//---------------------------------------------------------------------------- // HRESULT CAnchoAddonService::removeTabs(LPDISPATCH aTabs, LPDISPATCH aCallback) { VariantVector tabs; IF_FAILED_RET(addJSArrayToVariantVector(aTabs, tabs)); for(VariantVector::iterator it = tabs.begin(); it != tabs.end(); ++it) { if( it->vt == VT_I4 ) { removeTab(it->intVal, aCallback); } else { ATLTRACE(L"Problem with specified tabId - not an integer\n"); } } return S_OK; }
TabButton * TabBar::addTab( QWidget * _w, const QString & _text, int _id, bool _add_stretch, bool _text_is_tooltip ) { // already tab with id? if( m_tabs.contains( _id ) ) { // then remove it removeTab( _id ); } QString caption = ( _text_is_tooltip ) ? QString( "" ) : _text; // create tab-button TabButton * b = new TabButton( caption, _id, this ); connect( b, SIGNAL( clicked( int ) ), this, SLOT( tabClicked( int ) ) ); b->setIconSize( QSize( 48, 48 ) ); b->setFixedSize( 64, 64 ); b->show(); if( _text_is_tooltip ) { ToolTip::add( b, _text ); } // small workaround, because QBoxLayout::addWidget(...) doesn't // work properly, so we first have to remove all tabs from the // layout and them add them in the correct order QMap<int, QPair<TabButton *, QWidget *> >::iterator it; for( it = m_tabs.begin(); it != m_tabs.end(); ++it ) { m_layout->removeWidget( it.value().first ); } m_tabs.insert( _id, qMakePair( b, _w ) ); for( it = m_tabs.begin(); it != m_tabs.end(); ++it ) { m_layout->addWidget( it.value().first ); } if( _add_stretch ) { m_layout->addStretch(); } // we assume, parent-widget is a widget acting as widget-stack so all // widgets have the same size and only the one on the top is visible _w->setFixedSize( _w->parentWidget()->size() ); b->setFont( pointSize<8>( b->font() ) ); return( b ); }
void TabWidget::showSubownerTab( bool b ) { if ( b && !mSubVisible ) { insertTab( 1, mSubownerTab, QIcon( ":/icons/conf/targets.png" ), "Subowned SRs" ); mSubVisible = true; } else if ( !b && mSubVisible ) { removeTab( indexOf( mSubownerTab ) ); mSubVisible = false; } rebuildMaps(); }
bool TaskbarPreviews::WasTabRemoved(HWND hwnd) { QWidget *internal = m_tabs.internal(hwnd); if (internal) { QWidget *owner = m_tabs.owner(hwnd); bool ignore = false; emit tabAboutToRemove(m_tabs.user(hwnd), &ignore); if (!ignore) { SetNoTabActive((HWND)owner->winId()); removeTab(m_tabs.user(hwnd)); } return true; } else return false; }
void TabWidget::removeTextEdit(QString title) { for(int i = 0; i < count(); i++) { if(title.compare(tabText(i)) == 0) { QWidget *tabwidget = widget(i); if(tabwidget) { removeTab(i); delete tabwidget; } } } }
void CChartTable::slotCloseTab( int _iTabIndex ) { QMutex* __pqMutexDataChange = QVCTRuntime::useMutexDataChange(); __pqMutexDataChange->lock(); CChart* __poChart = (CChart*)widget( _iTabIndex ); removeTab( _iTabIndex ); delete __poChart; if( QTabWidget::currentIndex() < 0 ) { oGeoPositionReference = CDataPosition::UNDEFINED; fdScaleReference = -1.0; } __pqMutexDataChange->unlock(); bProjectModified = true; }
//! [3] void AddressWidget::addEntry(QString name, QString address) { if (!table->getContacts().contains({ name, address })) { table->insertRows(0, 1, QModelIndex()); QModelIndex index = table->index(0, 0, QModelIndex()); table->setData(index, name, Qt::EditRole); index = table->index(0, 1, QModelIndex()); table->setData(index, address, Qt::EditRole); removeTab(indexOf(newAddressTab)); } else { QMessageBox::information(this, tr("Duplicate Name"), tr("The name \"%1\" already exists.").arg(name)); } }
void DeclarativeTabModel::clear() { if (count() == 0) return; beginResetModel(); for (int i = m_tabs.count() - 1; i >= 0; --i) { removeTab(m_tabs.at(i), i); } emit countChanged(); closeActiveTab(); endResetModel(); // No need guard anything as all tabs got closed. m_activeTabClosed = false; }
QWidget *TabWidget::unregisterTab(int index) { Tab *tab = (Tab*)widget(index); Q_ASSERT(tab); removeTab(index); removeEventFilterFromChildren(tab); tab->disconnect(this); this->disconnect(tab); changeMenu(currentIndex()); return tab; }
/*! \brief TabWidget::closeTab \param index */ void TabWidget::closeTab(int index) { Q_ASSERT(index < count()); if(index < 0) { index = currentIndex(); } QWidget *widget = this->widget(index); if(widget && widget->close()) { removeTab(index); widget->deleteLater(); } emit tabClosed(index); }
GUI::Widget::TabManager::TabContainerPtrType GUI::Widget::TabManager::addTab(const TabKeyType& key, TabContainerPtrType container) { removeTab(key); if (!container) { //Create container if one was not given. container.reset(new GUI::Widget::Container()); } tabs[key] = container; if (tabs.size() == 1) { selectedTabKey = tabs.begin()->first; } return container; }
//----------------------------------------------------------------------------- bool CTabView::removeAllTabs () { setCurrentChild (0); CTabChildView* v = lastChild; while (v) { CTabChildView* next = v->previous; removeTab (v->view); v = next; } firstChild = 0; lastChild = 0; numberOfChilds = 0; currentTab = -1; return true; }
void DockingCont::removeToolbar(tTbData TbData) { // remove from list for (size_t iTb = 0; iTb < _vTbData.size(); iTb++) { if (_vTbData[iTb]->hClient == TbData.hClient) { // remove tab removeTab(_vTbData[iTb]); // free resources delete _vTbData[iTb]; vector<tTbData*>::iterator itr = _vTbData.begin() + iTb; _vTbData.erase(itr); } } }
bool ExtendedTabWidget::closeWindow(QWidget* wnd) { Q_ASSERT_X(wnd, "bool ExtendedTabWidget::close(int index)", "Can't get window"); if(wnd->close()) { emit tabBeforeClose(wnd); removeTab(indexOf(wnd)); delete wnd; tabsUpdate(); return true; } return false; }
ViewConfigurationDialog::ViewConfigurationDialog(Project *project, QWidget *parent) : QDialog(parent), ui(new Ui::ViewConfigurationDialog), mProject(project) { ui->setupUi(this); mViewModel = new ViewsModel(mProject); ui->viewView->setModel( mViewModel ); mTabsModel = 0; mItemsModel = 0; mPhrasalGlossesModel = 0; mView = 0; mTab = 0; connect(ui->addView, SIGNAL(clicked()), this, SLOT(addView()) ); connect(ui->removeView, SIGNAL(clicked()), this, SLOT(removeView()) ); connect(ui->addTab, SIGNAL(clicked()), this, SLOT(addTab()) ); connect(ui->removeTab, SIGNAL(clicked()), this, SLOT(removeTab()) ); connect(ui->addItem, SIGNAL(clicked()), this, SLOT(addItem()) ); connect(ui->removeItem, SIGNAL(clicked()), this, SLOT(removeItem()) ); connect(ui->itemView, SIGNAL(activated(QModelIndex)), this, SLOT(editItem(QModelIndex)) ); connect(ui->addPhrasalGloss, SIGNAL(clicked()), this, SLOT(addPhrasalGloss()) ); connect(ui->removePhrasalGloss, SIGNAL(clicked()), this, SLOT(removePhrasalGloss()) ); connect(ui->phrasalGlossView, SIGNAL(activated(QModelIndex)), this, SLOT(editPhrasalGloss(QModelIndex)) ); connect(ui->viewView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(viewChanged(QItemSelection,QItemSelection))); connect(ui->itemWritingSystemsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(indexLanguageChanged(int))); connect(ui->viewUp, SIGNAL(clicked()), this, SLOT(viewUp())); connect(ui->viewDown, SIGNAL(clicked()), this, SLOT(viewDown())); connect(ui->tabUp, SIGNAL(clicked()), this, SLOT(tabUp())); connect(ui->tabDown, SIGNAL(clicked()), this, SLOT(tabDown())); connect(ui->itemUp, SIGNAL(clicked()), this, SLOT(itemUp())); connect(ui->itemDown, SIGNAL(clicked()), this, SLOT(itemDown())); connect(ui->phrasalGlossUp, SIGNAL(clicked()), this, SLOT(phrasalGlossUp())); connect(ui->phrasalGlossDown, SIGNAL(clicked()), this, SLOT(phrasalGlossDown())); setTabWidgetsEnabled(false); setItemWidgetsEnabled(false); }
void DeclarativeTabModel::closeActiveTab() { if (m_activeTab.isValid()) { #ifdef DEBUG_LOGS qDebug() << &m_activeTab; #endif // Clear active tab data and try to active a tab from the first model index. int activeTabId = m_activeTab.tabId(); // Invalidate m_activeTab.setTabId(0); removeTab(activeTabId, m_activeTab.thumbnailPath()); if (!activateTab(0)) { // Last active tab got closed. emit activeTabChanged(activeTabId, 0); } } }
/************************************************************************* Internal version of removing a child window *************************************************************************/ void TabControl::removeChild_impl(Window* wnd) { // protect against possible null pointers if (!wnd) return; // Look for __auto_TabPane__ in the name (hopefully no-one will use this!) if (wnd->getName().find(ContentPaneNameSuffix) != String::npos) { // perform normal removeChild Window::removeChild_impl(wnd); } else { // This is some user window, therefore remove as a tab removeTab(wnd->getName()); } }
bool KateViewSpace::showView(KTextEditor::Document *document) { const int index = m_lruDocList.lastIndexOf(document); if (index < 0) { return false; } if (! m_docToView.contains(document)) { return false; } KTextEditor::View *kv = m_docToView[document]; // move view to end of list m_lruDocList.removeAt(index); m_lruDocList.append(document); stack->setCurrentWidget(kv); kv->show(); // in case a tab does not exist, add one if (! m_docToTabId.contains(document)) { // if space is available, add button if (m_tabBar->count() < m_tabBar->maxTabCount()) { // just insert insertTab(m_tabBar->count(), document); } else { // remove "oldest" button and replace with new one Q_ASSERT(m_lruDocList.size() > m_tabBar->count()); // we need to subtract by 1 more, as we just added ourself to the end of the lru list! KTextEditor::Document * docToHide = m_lruDocList[m_lruDocList.size() - m_tabBar->maxTabCount() - 1]; Q_ASSERT(m_docToTabId.contains(docToHide)); const int insertIndex = removeTab(docToHide, false); // add new one at removed position insertTab(insertIndex, document); } } // follow current view Q_ASSERT(m_docToTabId.contains(document)); m_tabBar->setCurrentTab(m_docToTabId.value(document, -1)); return true; }
void pTabBar::dropEvent( QDropEvent* event ) { if ( !event->mimeData()->hasUrls() ) { // get drop tab int ni = tabAt( event->pos() ); // if get it if ( ni != -1 ) { // get original tab infos int oi = event->mimeData()->data( "x-tabindex" ).toInt(); QVariant otd = tabData( oi ); QIcon oti = tabIcon( oi ); QString ott = tabText( oi ); QColor ottc = tabTextColor( oi ); QString ottt = tabToolTip( oi ); QString otwt = tabWhatsThis( oi ); // remove original tab removeTab( oi ); // insert new one with correct infos int i = insertTab( ni, oti, ott ); setTabData( i, otd ); setTabTextColor( i, ottc ); setTabToolTip( i, ottt ); setTabWhatsThis( i, otwt ); //accept event->acceptProposedAction(); // emit signal emit tabDropped( oi, i ); // set new current index setCurrentIndex( i ); } } else emit urlsDropped( event->mimeData()->urls () ); // default event QTabBar::dropEvent( event ); }
void InterfacesTabWidget::load(const QList<QTM_PREPEND_NAMESPACE(QServiceInterfaceDescriptor)> &descriptors) { QWidget *widg; while (count() > 0) { widg = widget(count()-1); if (widg) { removeTab(count()-1); delete widg; } } for (int i=0; i<descriptors.count(); i++) addInterface(descriptors[i]); if (count() == 0) addInterface(); // blank placeholder interface setCurrentIndex(0); }
void DockingCont::removeToolbar(tTbData TbData) { // remove from list // items in _vTbData are removed in the loop so _vTbData.size() should be checked in every iteration for (size_t iTb = 0 ; iTb < _vTbData.size(); ++iTb) { if (_vTbData[iTb]->hClient == TbData.hClient) { // remove tab removeTab(_vTbData[iTb]); // free resources delete _vTbData[iTb]; vector<tTbData*>::iterator itr = _vTbData.begin() + iTb; _vTbData.erase(itr); } } }
void DockableTabWidget::undockTab() { // extract currently active tab QIcon extractedPageIcon; QString extractedPageLabel; QWidget* extractedPageWidget = NULL; { int currentTabIdx = currentIndex(); extractedPageIcon = tabIcon( currentTabIdx ); extractedPageLabel = tabText( currentTabIdx ); extractedPageWidget = currentWidget(); removeTab( currentTabIdx ); } // notify the observers emit onTabUndocked( extractedPageIcon, extractedPageLabel, extractedPageWidget ); }
void DatabaseTabWidget::deleteDatabase(Database* db) { const DatabaseManagerStruct dbStruct = m_dbList.value(db); bool emitDatabaseWithFileClosed = dbStruct.saveToFilename; QString filePath = dbStruct.filePath; int index = databaseIndex(db); removeTab(index); toggleTabbar(); m_dbList.remove(db); delete dbStruct.dbWidget; delete db; if (emitDatabaseWithFileClosed) { Q_EMIT databaseWithFileClosed(filePath); } }
void SeparateTabBar::tabInserted (int index) { QTabBar::tabInserted (index); int length = 0; for (int i = 0; i < count (); ++i) length += tabRect (i).width (); if (length + 30 > width () && IsLastTab_) { IsLastTab_ = false; removeTab (count () - 1); emit showAddTabButton (true); } if (index != count () - 1 && (IsLastTab_)) emit tabWasInserted (index); }
void QueuePool::slotRemoveCurrentQueue() { QueueListView* queue = currentQueue(); if (!queue) { return; } removeTab(indexOf(queue)); if (count() == 0) { slotAddQueue(); } emit signalQueuePoolChanged(); }