void TabView::emitTabChanged(int index) { Q_UNUSED(index); if (count() == 0) { m_pLastTab = nullptr; emit tabTitleChanged(""); emit tabModified(false); emit tabChanged(nullptr, nullptr); return; } auto pCurrentTab = qobject_cast<Tab *>(currentWidget()); if (m_pLastTab != pCurrentTab) { if (pCurrentTab != nullptr) { if (m_pLastTab != nullptr) disconnectTab(m_pLastTab); connectTab(pCurrentTab); emit tabTitleChanged(pCurrentTab->title()); emit tabModified(pCurrentTab->isModified() || pCurrentTab->isNew()); emit tabChanged(m_pLastTab, pCurrentTab); } m_pLastTab = pCurrentTab; } }
DBManager::DBManager(QObject *parent) : QObject(parent) , m_maxTabId(0) { qRegisterMetaType<QList<Tab> >("QList<Tab>"); qRegisterMetaType<QList<Link> >("QList<Link>"); qRegisterMetaType<Tab>("Tab"); worker = new DBWorker(); worker->moveToThread(&workerThread); connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater())); connect(worker, SIGNAL(tabsAvailable(QList<Tab>)), this, SLOT(tabListAvailable(QList<Tab>))); connect(worker, SIGNAL(historyAvailable(QList<Link>)), this, SIGNAL(historyAvailable(QList<Link>))); connect(worker, SIGNAL(tabHistoryAvailable(int,QList<Link>)), this, SIGNAL(tabHistoryAvailable(int,QList<Link>))); connect(worker, SIGNAL(tabChanged(Tab)), this, SIGNAL(tabChanged(Tab))); connect(worker, SIGNAL(tabAvailable(Tab)), this, SIGNAL(tabAvailable(Tab))); connect(worker, SIGNAL(titleChanged(QString,QString)), this, SIGNAL(titleChanged(QString,QString))); connect(worker, SIGNAL(thumbPathChanged(QString,QString,int)), this, SIGNAL(thumbPathChanged(QString,QString,int))); workerThread.start(); QMetaObject::invokeMethod(worker, "init", Qt::BlockingQueuedConnection); QMetaObject::invokeMethod(worker, "getMaxTabId", Qt::BlockingQueuedConnection, Q_RETURN_ARG(int, m_maxTabId)); QMetaObject::invokeMethod(worker, "getSettings", Qt::BlockingQueuedConnection, Q_RETURN_ARG(SettingsMap, m_settings)); }
DeclarativeTabModel::DeclarativeTabModel(QObject *parent) : QAbstractListModel(parent) , m_loaded(false) , m_browsing(false) , m_nextTabId(DBManager::instance()->getMaxTabId() + 1) , m_backForwardNavigation(false) { connect(DBManager::instance(), SIGNAL(tabsAvailable(QList<Tab>)), this, SLOT(tabsAvailable(QList<Tab>))); connect(DBManager::instance(), SIGNAL(tabChanged(Tab)), this, SLOT(tabChanged(Tab))); }
DeclarativeTabModel::DeclarativeTabModel(QObject *parent) : QAbstractListModel(parent) , m_loaded(false) , m_browsing(false) , m_nextTabId(DBManager::instance()->getMaxTabId() + 1) { connect(DBManager::instance(), SIGNAL(tabsAvailable(QList<Tab>)), this, SLOT(tabsAvailable(QList<Tab>))); connect(DBManager::instance(), SIGNAL(tabChanged(Tab)), this, SLOT(tabChanged(Tab))); connect(DBManager::instance(), SIGNAL(titleChanged(int,int,QString,QString)), this, SLOT(updateTitle(int,int,QString,QString))); }
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: newFile(); break; case 1: open(); break; case 2: addObject(); break; case 3: { bool _r = save(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 4: { bool _r = saveAs(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 5: about(); break; case 6: recoverCameraPos(); break; case 7: showRenderDockWidget((*reinterpret_cast< bool(*)>(_a[1]))); break; case 8: showTimeLineDockWidget((*reinterpret_cast< bool(*)>(_a[1]))); break; case 9: showPropertyDockWidget((*reinterpret_cast< bool(*)>(_a[1]))); break; case 10: showGrid(); break; case 11: resizeEvent((*reinterpret_cast< QResizeEvent*(*)>(_a[1]))); break; case 12: tabChanged((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } _id -= 13; } return _id; }
void DBWorker::clearTabHistory(int tabId) { // Remove urls that are only related to this tab QSqlQuery 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 tab_history WHERE id IN (SELECT tab_history_id FROM tab WHERE tab_id = ?)));"); query.bindValue(0, tabId); query.bindValue(1, tabId); query.bindValue(2, tabId); execute(query); // Remove urls from history query = prepare("DELETE FROM history 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 != ?))"); query.bindValue(0, tabId); query.bindValue(1, tabId); execute(query); query = prepare("DELETE FROM tab_history WHERE tab_id = ? " "AND id NOT IN (SELECT tab_history_id FROM tab WHERE tab_id = ?);"); query.bindValue(0, tabId); query.bindValue(1, tabId); execute(query); emit tabChanged(getTabData(tabId)); }
void DesignerWidget::updateUi() { /* Update with a poketextedit */ ui->infoOutput->deleteLater(); ui->infoOutput = new PokeTextEdit(ui->infoTab); ui->infoOutput->setObjectName("infoOutput"); ui->infoLayout->insertWidget(1, ui->infoOutput); ui->descOutput->deleteLater(); ui->descOutput = new PokeTextEdit(ui->descTab); ui->descOutput->setObjectName("descOutput"); ui->descLayout->insertWidget(1, ui->descOutput); ui->annOutput->deleteLater(); ui->annOutput = new PokeTextEdit(ui->annTab); ui->annOutput->setObjectName("annOutput"); ui->annLayout->insertWidget(1, ui->annOutput); QString profileInfo = plugin->client->trainerTeam()->profile().info().info; if (profileInfo.trimmed().length() > 0) { ui->infoInput->setPlainText(profileInfo); } ui->infoOutput->show(); ui->descOutput->show(); ui->annOutput->show(); connect(ui->infoInput, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(ui->descInput, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(ui->annInput, SIGNAL(textChanged()), this, SLOT(textChanged())); /* Update everything */ tabChanged(0); }
void PropTabBar::setCurrentIndex(int index) { if (index >= m_btnGroup->buttons().size()) index = 0; // If asked to hide or if the currently selected tab is clicked if (index < 0 || m_currentIndex == index) { if (m_currentIndex >= 0) { m_btnGroup->button(m_currentIndex)->setDown(false); m_currentIndex = -1; emit visibilityToggled(false); } return; } // Unselect previous tab if (m_currentIndex >= 0) { m_btnGroup->button(m_currentIndex)->setDown(false); } else { // Nothing was selected, show! emit visibilityToggled(true); } // Select the new button m_btnGroup->button(index)->setDown(true); m_currentIndex = index; // Emit the signal emit tabChanged(index); }
void TabBar::mousePressEvent(QMouseEvent* ev) { if (d->tabs.count() == 0) { update(); return; } d->layoutTabs(); QPoint pos = ev->pos(); if (!isRightToLeft()) pos = pos - QPoint(d->offset, 0); int tab = d->tabAt(pos) + 1; if ((tab > 0) && (tab != d->activeTab)) { d->activeTab = tab; update(); emit tabChanged(d->tabs[ d->activeTab-1]); // scroll if partially visible if (d->tabRects[ tab-1 ].right() > width() - d->offset) scrollForward(); } if (ev->button() == Qt::RightButton) if (!d->readOnly) emit contextMenu(ev->globalPos()); }
DeclarativeTabModel::DeclarativeTabModel(QObject *parent) : QAbstractListModel(parent) , m_currentTab(0) , m_loaded(false) , m_browsing(false) , m_activeTabClosed(false) { connect(DBManager::instance(), SIGNAL(tabsAvailable(QList<Tab>)), this, SLOT(tabsAvailable(QList<Tab>))); connect(DBManager::instance(), SIGNAL(tabChanged(Tab)), this, SLOT(tabChanged(Tab))); connect(DBManager::instance(), SIGNAL(thumbPathChanged(QString,QString,int)), this, SLOT(updateThumbPath(QString,QString,int))); connect(DBManager::instance(), SIGNAL(titleChanged(QString,QString)), this, SLOT(updateTitle(QString,QString))); }
void Dialog::parseArguments() { bool ok; int tab = qApp->arguments().at(1).toInt(&ok); if (ok) { comboBox->setCurrentIndex(tab); stackedWidget->setCurrentIndex(tab); tabChanged(tab); } }
void AppearanceConfigTab::onShowPresenceChangesChanged(int state) { if (state == Qt::Checked) { ui->chatView->setShowPresenceChanges(true); } else { ui->chatView->setShowPresenceChanges(false); } ui->chatView->initialise(m_demoChatHeader); tabChanged(); }
void OverwritersTab::setInfoLabel() { if (Overwriter *owr = intToOwr(owrTable->selectedItems().first()->row())) { infoLabel->setText(owr->getDescription()); delete owr; } emit tabChanged(); }
SettingsDialog::SettingsDialog(QWidget *parent) : QWidget(parent, Qt::Dialog) { setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint); setWindowTitle(tr("Settings - %1").arg(qApp->applicationName())); settings = new QSettings(QString("/etc/%1.ini").arg(qApp->applicationName()), QSettings::IniFormat, this); buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Reset | QDialogButtonBox::Cancel, Qt::Horizontal, this); okButton = buttonBox->button(QDialogButtonBox::Ok); applyButton = buttonBox->button(QDialogButtonBox::Apply); resetButton = buttonBox->button(QDialogButtonBox::Reset); cancelButton = buttonBox->button(QDialogButtonBox::Cancel); tabs = new QTabWidget(this); generalTab = new GeneralTab(this); tabs->addTab(generalTab, QIcon::fromTheme("preferences-system"), tr("&General")); owrTab = new OverwritersTab(this); tabs->addTab(owrTab, QIcon::fromTheme("preferences-other"), tr("&Erasing schemes")); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(tabs); mainLayout->addWidget(buttonBox); setLayout(mainLayout); setWindowModality(Qt::ApplicationModal); connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); connect(okButton, SIGNAL(clicked()), this, SLOT(okClicked())); connect(owrTab, SIGNAL(tabChanged()), this, SLOT(enableApply())); connect(applyButton, SIGNAL(clicked()), this, SLOT(applyClicked())); connect(generalTab, SIGNAL(tabChanged()), this, SLOT(enableApply())); connect(resetButton, SIGNAL(clicked()), this, SLOT(resetSettings())); }
void SideTabs::setCurrentTab(OpenTab* newTab) { OpenTab* oldTab = this->openTab; this->openTab = newTab; if (!newTab->isSelected()) newTab->setSelected(true); if (oldTab != NULL && oldTab != newTab) oldTab->setSelected(false); this->ui->widgets->setCurrentWidget(newTab->widget()); emit tabChanged(oldTab, newTab); }
SideTabs::SideTabs(QWidget *parent) : QWidget(parent), ui(new Ui::SideTabs()), openTab(NULL) { this->ui->setupUi(this); this->connect(this->ui->tabs, SIGNAL(itemSelectionChanged()), SLOT(tabChanged())); this->ui->tabs->setFocusPolicy(Qt::NoFocus); this->ui->tabs->setSelectionMode(QAbstractItemView::SingleSelection); }
void KoTabBar::wheelEvent( QWheelEvent * e ) { if ( d->tabs.count() == 0 ) { update(); return; } // Currently one wheel movement is a delta of 120. // The 'unused' delta is stored for devices that allow // a higher scrolling resolution. // The delta required to move one tab is one wheel movement: const int deltaRequired = 120; d->wheelDelta += e->delta(); int tabDelta = - (d->wheelDelta / deltaRequired); d->wheelDelta = d->wheelDelta % deltaRequired; int numTabs = d->tabs.size(); if(d->activeTab + tabDelta > numTabs) { // Would take us past the last tab d->activeTab = numTabs; } else if (d->activeTab + tabDelta < 1) { // Would take us before the first tab d->activeTab = 1; } else { d->activeTab = d->activeTab + tabDelta; } // Find the left and right edge of the new tab. If we're // going forward, and the right of the new tab isn't visible // then scroll forward. Likewise, if going back, and the // left of the new tab isn't visible, then scroll back. int activeTabRight = d->tabRects[ d->activeTab-1 ].right(); int activeTabLeft = d->tabRects[ d->activeTab-1 ].left(); if(tabDelta > 0 && activeTabRight > width() - d->offset ) { scrollForward(); } else if(tabDelta < 0 && activeTabLeft < width() - d->offset ) { scrollBack(); } update(); emit tabChanged( d->tabs[ d->activeTab-1] ); }
void DBWorker::updateTab(int tabId, QString url, QString title, QString path) { Link currentLink = getCurrentLink(tabId); if (!currentLink.isValid()) { qWarning() << "attempt to update url that is not stored in db." << tabId << title << url << path << currentLink.linkId() << currentLink.url(); return; } #ifdef DEBUG_LOGS qDebug() << tabId << title << url << path; #endif updateLink(currentLink.linkId(), url, title, path); emit tabChanged(getTabData(tabId)); }
void TabBar::setActiveTab(const QString& text) { int i = d->tabs.indexOf(text); if (i == -1) return; if (i + 1 == d->activeTab) return; d->activeTab = i + 1; d->updateButtons(); update(); emit tabChanged(text); }
void AppearanceConfigTab::onStyleSelected(int index) { //load the style. QString styleId = ui->styleComboBox->itemData(index).toString(); ChatWindowStyle *style = ChatWindowStyleManager::self()->getValidStyleFromPool(styleId); if (style) { ui->chatView->setChatStyle(style); updateVariantsList(); ui->showHeader->setEnabled(style->hasHeader()); ui->chatView->initialise(m_demoChatHeader); } tabChanged(); }
BTSettingsMainWindow::BTSettingsMainWindow(QWidget *parent, Qt::WFlags fl) : QMainWindow(parent, fl), m_localDevice(new QBluetoothLocalDevice(this)), m_controller(0) { if (!m_localDevice->isValid()) { QLabel *label = new QLabel(tr("(Bluetooth not available.)")); label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); label->setWordWrap(true); label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setCentralWidget(label); return; } QScrollArea* scroll = new QScrollArea(); scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scroll->setWidgetResizable(true); scroll->setFrameStyle(QFrame::NoFrame); m_menu = QSoftMenuBar::menuFor(this); m_tabs = new QTabWidget(); m_controller = new QCommDeviceController(m_localDevice->deviceName().toLatin1(), this); SettingsDisplay *settings = new SettingsDisplay(m_localDevice, m_controller); scroll->setWidget(settings); scroll->setFocusProxy(settings); m_tabs->addTab(scroll, tr("Settings")); // Delay initialization of tabs other than the first m_tabs->addTab(new QWidget, tr("Paired Devices")); m_tabs->setTabEnabled(1, false); m_tabs->setCurrentIndex(0); // change the context menu when the tab changes connect(m_tabs, SIGNAL(currentChanged(int)), SLOT(tabChanged(int))); // set the current context menu tabChanged(m_tabs->currentIndex()); setCentralWidget(m_tabs); setWindowTitle(tr("Bluetooth")); QTimer::singleShot(0, this, SLOT(init())); }
void SearchTabs::handleHitsCount(const QString& query, int count) { if (count < 1) return; int active = tabs->currentIndex(); QMapIterator<QString, QString> i(querynames); while (i.hasNext()) { i.next(); if (query == i.key() + this->query) { QString tabname = i.value() + " (" + QString::number(count) + ')'; int t = tabs->addTab(tabname); tabs->setTabData(t, query); break; } } if (active != tabs->currentIndex()) { tabChanged(tabs->currentIndex()); } }
bool SceneTreeWidget::setScene(SceneFile* sceneFile) { if( sceneFile ) { if (m_sceneTreeView->loadSceneGraph(sceneFile->sceneGraphFile())) { m_extraTreeView->loadExtras(sceneFile); tabChanged(m_tabWidget->currentIndex()); return true; } else return false; } else { m_extraTreeView->closeTree(); m_sceneTreeView->closeTree(); return true; } }
void SideTabs::closeCurrentTab(bool suppressSignals) { OpenTab* oldTab = this->openTab; // Remove the webview from the stack this->ui->widgets->removeWidget(this->openTab->widget()); // Promote first child to parent if one exists QTreeWidgetItem* newCurrent = this->openTab->removeSelf(); // And of course we must be sure to always have some sort of tab if (newCurrent != NULL) { this->openTab = dynamic_cast<OpenTab*>(newCurrent); this->ui->tabs->clearSelection(); this->openTab->setSelected(true); this->openTab->setExpanded(true); } if (!suppressSignals) { emit tabChanged(oldTab, dynamic_cast<OpenTab*>(newCurrent)); emit closedTab(this->ui->tabs->invisibleRootItem()->childCount()); } }
void DBWorker::goBack(int tabId) { QSqlQuery query = prepare("SELECT id FROM tab_history WHERE tab_id = ? AND id < (SELECT tab_history_id FROM tab WHERE tab_id = ?) ORDER BY id DESC LIMIT 1;"); query.bindValue(0, tabId); query.bindValue(1, tabId); if (!execute(query)) { return; } int historyId = 0; if (query.first()) { historyId = query.value(0).toInt(); } if (historyId > 0) { if (updateTab(tabId, historyId)) { emit tabChanged(getTabData(tabId, historyId)); } } }
void MainUI::groupModeChanged(bool active){ if(!active){ return; } //on every change, all radio buttons will call this function - only run this once though bool usetabs = radio_view_tabs->isChecked(); if(usetabs){ settings->setValue("groupmode","tabs"); //Now clean up all the tabs (remove the generic one and add the specific ones) for(int i=0; i<tabBar->count(); i++){ //Remove all the browser tabs if( !tabBar->tabWhatsThis(i).startsWith("#") ){ tabBar->removeTab(i); i--; //go back one to ensure nothing is missed } } //Create all the specific browser tabs for open browsers for(int i=0; i<DWLIST.length(); i++){ qDebug() << "Add specific tab:" << DWLIST[i]->currentDir() << DWLIST[i]->id(); int tab = tabBar->addTab( LXDG::findIcon("folder-open",""), DWLIST[i]->currentDir().section("/",-1) ); tabBar->setTabWhatsThis(tab, DWLIST[i]->id() ); DWLIST[i]->setShowCloseButton(false); } }else{ settings->setValue("groupmode","columns"); //Now clean up the tabs (remove the specific ones and add a generic one) for(int i=0; i<tabBar->count(); i++){ //Remove all the browser tabs if( !tabBar->tabWhatsThis(i).startsWith("#") ){ tabBar->removeTab(i); i--; //go back one to ensure nothing is missed } } //Now create the generic "browser" tab int tab = tabBar->addTab( LXDG::findIcon("folder-open",""), tr("Browser") ); tabBar->setTabWhatsThis(tab, "browser" ); for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->setShowCloseButton(true); } } if(tabBar->currentIndex()<0){ tabBar->setCurrentIndex(0); } tabBar->setVisible( tabBar->count() > 1 ); QTimer::singleShot(20, this, SLOT(tabChanged()) ); }
void MainWindow::startComparing() { for (int i=0; i<mFrames.length(); i++) { if (i<mFrames.length()-1) { ui->mainTabWidget->setCurrentIndex(i); } mFrames.at(i)->startGetData(); } for (int i=0; i<mFrames.length(); i++) { delete mFrames.at(i)->mTableWidget; } ui->mainHorizontalLayout->removeWidget(mFrames.last()); ui->mainTabWidget->addTab(mFrames.last(), "QTableWidget"); for (int i=0; i<ui->mainTabWidget->count(); i++) { ui->cloneTabWidget->addTab(new StatisticsFrame((StatisticsFrame*)ui->mainTabWidget->widget(i), this), ui->mainTabWidget->tabText(i)); } ui->cloneTabWidget->setVisible(true); resize(width(), 0); ui->mainTabWidget->setCurrentIndex(0); ui->cloneTabWidget->setCurrentIndex(ui->cloneTabWidget->count()-1); connect(ui->mainTabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); connect(ui->cloneTabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); tabChanged(-1); }
MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf ) { setWindowTitle( qtr( "Messages" ) ); setWindowRole( "vlc-messages" ); /* Build Ui */ ui.setupUi( this ); ui.bottomButtonsBox->addButton( new QPushButton( qtr("&Close"), this ), QDialogButtonBox::RejectRole ); /* Modules tree */ ui.modulesTree->setHeaderHidden( true ); /* Buttons and general layout */ ui.saveLogButton->setToolTip( qtr( "Saves all the displayed logs to a file" ) ); int i_verbosity = var_InheritInteger( p_intf, "verbose" ); changeVerbosity( i_verbosity ); ui.verbosityBox->setValue( qMin( i_verbosity, 2 ) ); getSettings()->beginGroup( "Messages" ); ui.filterEdit->setText( getSettings()->value( "messages-filter" ).toString() ); getSettings()->endGroup(); updateButton = new QPushButton( QIcon(":/update"), "" ); updateButton->setFlat( true ); ui.mainTab->setCornerWidget( updateButton ); #ifndef NDEBUG QWidget *pldebugTab = new QWidget(); QVBoxLayout *pldebugTabLayout = new QVBoxLayout(); pldebugTab->setLayout( pldebugTabLayout ); ui.mainTab->addTab( pldebugTab, "Playlist Tree" ); pldebugTree = new QTreeWidget(); pldebugTree->headerItem()->setText( 0, "Name" ); pldebugTree->headerItem()->setText( 1, "PL id" ); pldebugTree->headerItem()->setText( 2, "Item id" ); pldebugTree->headerItem()->setText( 3, "PL flags" ); pldebugTree->headerItem()->setText( 4, "Item flags" ); pldebugTree->setColumnCount( 5 ); pldebugTabLayout->addWidget( pldebugTree ); #endif tabChanged(0); BUTTONACT( updateButton, updateOrClear() ); BUTTONACT( ui.saveLogButton, save() ); CONNECT( ui.filterEdit, editingFinished(), this, updateConfig() ); CONNECT( ui.filterEdit, textChanged(QString), this, filterMessages() ); CONNECT( ui.bottomButtonsBox, rejected(), this, hide() ); CONNECT( ui.verbosityBox, valueChanged( int ), this, changeVerbosity( int ) ); CONNECT( ui.mainTab, currentChanged( int ), this, tabChanged( int ) ); /* General action */ restoreWidgetPosition( "Messages", QSize( 600, 450 ) ); /* Hook up to LibVLC messaging */ vlc_LogSet( p_intf->p_libvlc, MsgCallback, this ); buildTree( NULL, VLC_OBJECT( p_intf->p_libvlc ) ); }
void ViewConfigurationDialog::viewChanged(const QItemSelection &selected, const QItemSelection &deselected) { Q_UNUSED(deselected); if( ! selected.indexes().isEmpty() ) { int currentView = selected.indexes().first().row(); if( mTabsModel != 0 ) { delete mTabsModel; } mView = mProject->views()->at( currentView ); mTabsModel = new TabsModel( mView ); ui->tabView->setModel(mTabsModel); connect(ui->tabView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(tabChanged(QItemSelection,QItemSelection)) ); setTabWidgetsEnabled(true); if( ui->tabView->selectionModel()->selectedRows().count() == 0 ) { setItemWidgetsEnabled(false); } } else { setTabWidgetsEnabled(false); } }
void MainUI::OpenDirs(QStringList dirs){ //Now open the dirs if(dirs.isEmpty()){ dirs << QDir::homePath(); } QStringList invalid; for(int i=0; i<dirs.length(); i++){ if(dirs[i].simplified().isEmpty()){ continue; } //Open this directory in a viewer if(dirs[i].endsWith("/")){ dirs[i].chop(1); } if(!QFile::exists(dirs[i])){ invalid << dirs[i]; continue; } if(DEBUG){ qDebug() << "Open Directory:" << dirs[i]; } ///Get a new Unique ID int id = 0; for(int j=0; j<DWLIST.length(); j++){ if(DWLIST[j]->id().section("-",1,1).toInt() >= id){ id = DWLIST[j]->id().section("-",1,1).toInt()+1; } } //Create the new DirWidget DirWidget *DW = new DirWidget("DW-"+QString::number(id), this); DW->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); ui->BrowserLayout->addWidget(DW); DWLIST << DW; //Connect the signals/slots for it connect(DW, SIGNAL(OpenDirectories(QStringList)), this, SLOT(OpenDirs(QStringList)) ); connect(DW, SIGNAL(LoadDirectory(QString, QString)), worker, SLOT(GetDirData(QString, QString)) ); connect(DW, SIGNAL(findSnaps(QString, QString)), worker, SLOT(GetSnapshotData(QString, QString)) ); connect(DW, SIGNAL(PlayFiles(LFileInfoList)), this, SLOT(OpenPlayer(LFileInfoList)) ); connect(DW, SIGNAL(ViewFiles(LFileInfoList)), this, SLOT(OpenImages(LFileInfoList)) ); connect(DW, SIGNAL(LaunchTerminal(QString)), this, SLOT(OpenTerminal(QString)) ); connect(DW, SIGNAL(CutFiles(QStringList)), this, SLOT(CutFiles(QStringList)) ); connect(DW, SIGNAL(CopyFiles(QStringList)), this, SLOT(CopyFiles(QStringList)) ); connect(DW, SIGNAL(FavoriteFiles(QStringList)), this, SLOT(FavoriteFiles(QStringList)) ); connect(DW, SIGNAL(RenameFiles(QStringList)), this, SLOT(RenameFiles(QStringList)) ); connect(DW, SIGNAL(RemoveFiles(QStringList)), this, SLOT(RemoveFiles(QStringList)) ); connect(DW, SIGNAL(PasteFiles(QString,QStringList)), this, SLOT(PasteFiles(QString, QStringList)) ); connect(DW, SIGNAL(CloseBrowser(QString)), this, SLOT(CloseBrowser(QString)) ); //Now create the tab for this if(radio_view_tabs->isChecked()){ int index = tabBar->addTab( LXDG::findIcon("folder-open",""), dirs[i].section("/",-1) ); tabBar->setTabWhatsThis( index, "DW-"+QString::number(id) ); tabBar->setCurrentIndex(index); }else{ //Just make sure the browser tab is visible bool found = false; for(int i=0; i<tabBar->count() && !found; i++){ if(tabBar->tabWhatsThis(i)=="browser"){ tabBar->setCurrentIndex(i); found=true; } } if(!found){ //Need to create the generic Browser tab int index = tabBar->addTab( LXDG::findIcon("folder-open",""), "Browser" ); tabBar->setTabWhatsThis( index, "browser" ); tabBar->setCurrentIndex(index); } } //Initialize the widget with the proper settings DW->setShowDetails(radio_view_details->isChecked()); DW->setShowSidebar(ui->actionShow_Action_Buttons->isChecked()); QList<DirWidget::DETAILTYPES> details; details <<DirWidget::NAME << DirWidget::SIZE << DirWidget::TYPE << DirWidget::DATEMOD; DW->setDetails(details); //Which details to show and in which order (L->R) DW->setShowThumbnails(ui->actionShow_Thumbnails->isChecked()); DW->setThumbnailSize(settings->value("iconsize", 32).toInt()); DW->setDirCompleter(dirCompleter); DW->setShowCloseButton(!radio_view_tabs->isChecked()); //Now load the directory DW->ChangeDir(dirs[i]); //kick off loading the directory info } //Update visibilities tabChanged(tabBar->currentIndex()); tabBar->setVisible( tabBar->count() > 1 ); if(!invalid.isEmpty()){ QMessageBox::warning(this, tr("Invalid Directories"), tr("The following directories are invalid and could not be opened:")+"\n"+invalid.join(", ") ); } //Double check that there is at least 1 dir loaded //qDebug() << "OpenDirs:" << DWLIST.length() << dirs << invalid << tabBar->currentIndex(); if(DWLIST.isEmpty()){ OpenDirs(QStringList()); } }