dmz::V8Value dmz::JsModuleUiV8QtBasic::_list_widget_item (const v8::Arguments &Args) { v8::HandleScope scope; V8Value result = v8::Undefined (); JsModuleUiV8QtBasic *self = _to_self (Args); if (self) { QListWidget *lw = self->v8_to_qobject<QListWidget> (Args.This ()); if (lw) { if (Args.Length ()) { QListWidgetItem *item = lw->item (v8_to_int32 (Args[0])); if (item) { result = self->create_v8_qlistwidgetitem (item); } } } } return scope.Close (result); }
void OBSBasicFilters::RemoveFilter(OBSSource filter) { uint32_t flags = obs_source_get_output_flags(filter); bool async = (flags & OBS_SOURCE_ASYNC) != 0; QListWidget *list = async ? ui->asyncFilters : ui->effectFilters; for (int i = 0; i < list->count(); i++) { QListWidgetItem *item = list->item(i); QVariant v = item->data(Qt::UserRole); OBSSource curFilter = v.value<OBSSource>(); if (filter == curFilter) { DeleteListItem(list, item); break; } } const char *filterName = obs_source_get_name(filter); const char *sourceName = obs_source_get_name(source); if (!sourceName || !filterName) return; const char *filterId = obs_source_get_id(filter); blog(LOG_INFO, "User removed filter '%s' (%s) from source '%s'", filterName, filterId, sourceName); main->SaveProject(); }
void HistoryLog::undo() { int size = ui->HistoryLogList->count(); if(size > 0) { QString last = historyLog.back(); QListWidgetItem* it = ui->HistoryLogList->takeItem(size-1); delete it; QStringList pieces = last.split( ":" ); QString itemPiece = pieces[0].mid(0,pieces[0].count()-4).trimmed(); QString fromPiece = pieces[1].mid(0,pieces[1].count()-4).trimmed(); QString toPiece = pieces[2].trimmed(); QListWidget* from = findWidgetByName(fromPiece); QListWidget* to = findWidgetByName(toPiece); QListWidgetItem* item; for(int idx = 0; idx< to->count(); idx++) { if(to->item(idx)->text() == itemPiece) { item = to->takeItem(idx); from->addItem(item); break; } } historyLog.erase(historyLog.end()-1); } }
QWidget* ProjectWindow::setupParametersWidget() { ParametersWidget* parameters = new ParametersWidget(projectData.projectParameterData(), projectData.projectParameterData()->getLookupTable().keys(), 1); QGridLayout* mainLayout = new QGridLayout(); QHBoxLayout* headerLayout = new QHBoxLayout; headerLayout->addStretch(0); QLabel* searchLabel = new QLabel("Search Parameters:"); QLineEdit* searchEditBox = new QLineEdit(); searchEditBox->setFrame(false); searchLabel->setBuddy(searchEditBox); searchEditBox->setPlaceholderText("Search Parameters"); searchEditBox->setFixedWidth(200); connect(searchEditBox, &QLineEdit::editingFinished, [=]() { parameters->searchParams(searchEditBox->text()); }); headerLayout->addWidget(searchLabel, 0); headerLayout->addWidget(searchEditBox, 0); headerLayout->addStretch(1); QListWidget* imagesBox = new QListWidget(); imagesBox->setSelectionMode(QAbstractItemView::SingleSelection); imagesBox->addItem("Project Parameters"); imagesBox->setCurrentRow(0); for (ProjectImage* image : projectData.projectImageList()) { imagesList_.append(image); imagesBox->addItem(image->toString()); } connect(&projectData, &ProjectData::imageAdded, [ = ](ProjectImage * image){ imagesList_.append(image); imagesBox->addItem(image->toString()); }); connect(&projectData, &ProjectData::imageMoved, [ = ](ProjectImage* image) { int idx = imagesList_.indexOf(image) + 1; if(idx > 0) { imagesBox->item(idx)->setText(image->toString()); } }); connect(imagesBox, &QListWidget::currentRowChanged, [ = ](int id) { if(id == 0) parameters->resetConf(projectData.projectParameterData()); else parameters->resetConf(imagesList_[id -1]->parameters()); }); BlockContainer* imagesBoxContainer = new BlockContainer("Select the scope of parameters", imagesBox); imagesBoxContainer->setMaximumWidth(300); mainLayout->addLayout(headerLayout, 0, 0, 1, 1); mainLayout->addWidget(parameters, 1, 0, 1, 1); mainLayout->addWidget(imagesBoxContainer, 0, 1, 2, 1); QWidget* mainWid = new QWidget; mainWid->setLayout(mainLayout); return mainWid; }
void MainWindow::on_exportSavePushButton_clicked() { QListWidget* savesList = findChild<QListWidget*>("vesselsInSaveListView"); QTextEdit* savePathTextField = this->findChild<QTextEdit*>("SavePathTextEdit"); QString pathToSave = savePathTextField->toPlainText(); QFile saveFile(pathToSave); if(!saveFile.exists() || !pathToSave.endsWith(".sfs") || !saveFile.open(QIODevice::ReadOnly)) { QMessageBox::warning(0, "Unable to open save file for writing", "When attempting to export new save, file was not opened."); } QString saveText(saveFile.readAll()); std::size_t headerEnd = saveText.indexOf("VESSEL"); QString header = saveText.left(headerEnd); saveFile.close(); saveFile.open(QIODevice::WriteOnly | QIODevice::Truncate); m_diagnosticsWindow->append(QString("Isolated header:\n") + header + QString("\n--Writing vessels to save--\n")); std::stringstream stringBuilder; for(int i = 0; i < savesList->count(); i++) { VesselListWidgetItem* item = (VesselListWidgetItem*)savesList->item(i); stringBuilder << item->GetVesselData()->AccessFullText()->toStdString(); } stringBuilder << "}\n}"; saveFile.write(header.toLocal8Bit()); saveFile.write(stringBuilder.str().c_str()); saveFile.close(); }
void Configurator::initUiFromSettings() { // load section from the file if( false == loadSettingsFile() ) return; // focus the right section int sectionIndex = 0; if( false == _startSectionName.isEmpty() ) { for( ; sectionIndex < _sections->count(); sectionIndex++ ) { QString sectionName = _sections->widget(sectionIndex)->objectName(); if( _startSectionName == sectionName ) break; } } _sections->setCurrentIndex( sectionIndex ); // focus the right sectionItem QListWidget* listWidget = qobject_cast<QListWidget*>( _sections->currentWidget() ); if( 0 != listWidget ) { int sectionItemIndex = 0; for( ; sectionItemIndex < listWidget->count(); sectionItemIndex++ ) { QString itemName = listWidget->item( sectionItemIndex )->data( Qt::UserRole ).toString(); if( _startSectionItemName == itemName ) break; } sectionItemIndex = (sectionItemIndex >= listWidget->count()) ? 0 : sectionItemIndex; listWidget->setCurrentRow( sectionItemIndex ); } }
void PageItem::slotSetFormData() { QTextEdit *textEdit = qobject_cast<QTextEdit*>(sender()); if (textEdit) // textEdit == 0 if the above cast fails { slotSetFormData(textEdit->toPlainText()); return; } QListWidget *listWidget = qobject_cast<QListWidget*>(sender()); if (listWidget) { QList<int> choices; for (int i = 0; i < listWidget->count(); ++i) { if (listWidget->item(i)->isSelected()) choices << i; } QString objectName = sender()->objectName(); if (!objectName.startsWith(QLatin1String("PageItem::formField"))) return; int which = objectName.remove(QLatin1String("PageItem::formField")).toInt(); Poppler::FormFieldChoice *formField = static_cast<Poppler::FormFieldChoice*>(m_formFields.at(which).field); formField->setCurrentChoices(choices); return; } }
XtConnectPage::XtConnectPage(QWidget *parent, QSettings &s, ImapPage *imapPage): QWidget(parent), imap(imapPage) { // Take care not to clash with the cache of the GUI QString cacheLocation = Common::writablePath(Common::LOCATION_CACHE) + QString::fromAscii("xtconnect-trojita"); QFormLayout *layout = new QFormLayout(this); cacheDir = new QLineEdit(s.value(Common::SettingsNames::xtConnectCacheDirectory, cacheLocation).toString(), this); layout->addRow(tr("Cache Directory"), cacheDir); QGroupBox *box = new QGroupBox(tr("Mailboxes to synchronize"), this); QVBoxLayout *boxLayout = new QVBoxLayout(box); QListWidget *mailboxes = new QListWidget(box); mailboxes->addItems(s.value(Common::SettingsNames::xtSyncMailboxList).toStringList()); for (int i = 0; i < mailboxes->count(); ++i) { mailboxes->item(i)->setFlags(Qt::ItemIsEnabled); } mailboxes->setToolTip(tr("Please use context menu inside the main application to select mailboxes to synchronize")); boxLayout->addWidget(mailboxes); layout->addRow(box); QString optionHost = s.value(Common::SettingsNames::xtDbHost).toString(); int optionPort = s.value(Common::SettingsNames::xtDbPort, QVariant(5432)).toInt(); QString optionDbname = s.value(Common::SettingsNames::xtDbDbName).toString(); QString optionUsername = s.value(Common::SettingsNames::xtDbUser).toString(); QStringList args = QCoreApplication::arguments(); for (int i = 1; i < args.length(); i++) { if (args.at(i) == "-h" && args.length() > i) optionHost = args.at(++i); else if (args.at(i) == "-d" && args.length() > i) optionDbname = args.at(++i); else if (args.at(i) == "-p" && args.length() > i) optionPort = args.at(++i).toInt(); else if (args.at(i) == "-U" && args.length() > i) optionUsername = args.at(++i); } hostName = new QLineEdit(optionHost); layout->addRow(tr("DB Hostname"), hostName); port = new QSpinBox(); port->setRange(1, 65535); port->setValue(optionPort); layout->addRow(tr("DB Port"), port); dbName = new QLineEdit(optionDbname); layout->addRow(tr("DB Name"), dbName); username = new QLineEdit(optionUsername); layout->addRow(tr("DB Username"), username); imapPasswordWarning = new QLabel(tr("Please fill in all IMAP options, including the password, at the IMAP page. " "If you do not save the password, background synchronization will not run."), this); imapPasswordWarning->setWordWrap(true); imapPasswordWarning->setStyleSheet(SettingsDialog::warningStyleSheet); layout->addRow(imapPasswordWarning); debugLog = new QCheckBox(); layout->addRow(tr("Debugging"), debugLog); QPushButton *btn = new QPushButton(tr("Run xTuple Synchronization")); connect(btn, SIGNAL(clicked()), this, SLOT(runXtConnect())); layout->addRow(btn); }
void ItemViewSettup::slotOk() { kDebug(planDbg()); QListWidget *lst = selector->availableListWidget(); for ( int r = 0; r < lst->count(); ++r ) { int c = static_cast<Item*>( lst->item( r ) )->column(); m_view->hideColumn( c ); } lst = selector->selectedListWidget(); for ( int r = 0; r < lst->count(); ++r ) { int c = static_cast<Item*>( lst->item( r ) )->column(); m_view->mapToSection( c, r ); m_view->showColumn( c ); } m_view->setStretchLastSection( stretchLastSection->isChecked() ); }
void PreferencesDialog::saveCommonList(QListWidget &from, QStringList &to) { to.clear(); for (auto row = 0, numRows = from.count(); row < numRows; ++row) to << from.item(row)->data(Qt::UserRole).toString(); }
QString Configurator::getActiveSectionItem() { QListWidget* listWidget = qobject_cast<QListWidget*>( _sections->currentWidget() ); if( 0 != listWidget ) return listWidget->objectName() +"/"+ listWidget->item( listWidget->currentRow() )->data( Qt::UserRole ).toString(); return QString(); }
bool KFFOpt_scenery::getOptions( QStringList & list ) { QListWidget* selected = ui_widget.selector_scenarii->selectedListWidget(); QListWidgetItem* item; QString buffer; uint i = 0; item = selected->item( i ); while ( item ) { buffer.clear(); buffer = buffer.setNum(i, 10); list << "--prop:sim/ai/scenario[" + buffer + "]=" + item->text(); item = selected->item( ++i ); } return true; }
void KFFOpt_scenery::saveSettings() { QListWidget* listWidget = ui_widget.selector_scenarii->selectedListWidget(); QListWidgetItem* item; QStringList list; int i = 0; item = listWidget->item( i ); while ( item ) { list << item->text(); item = listWidget->item( ++i ); } Settings::setScenarii_selected( list ); Settings::self()->writeConfig(); }
/* * When the timer (started in onDisplayMessage) fires, we update lst_debug with the * contents of debugListMessages. * * This happens in the timer event in order to rate limit it to a number of redraws per second * (redrawing, and especially scrolling the list view, can be quite resource intensive.) */ void MainWindow::refreshDebugList() { QListWidget *lst = ui->lst_debug; while(lst->count() + debugListMessages.size() - scrollbackSize > 0 && lst->count() > 0) { delete lst->item(0); } lst->addItems(debugListMessages); debugListMessages.clear(); lst->scrollToBottom(); }
void AnimationDialog::updateKfi(bool loop) { m_kfi->deletePath(); QListWidget *list = m_ui->listWidget; for(int i = 0; i < list->count(); i++) { AnimationListItem *item = static_cast<AnimationListItem*>(list->item(i)); m_kfi->addKeyFrame(item->frame(), item->time()); } m_kfi->setLoopInterpolation(loop); }
void MultiDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QVariant value; QString className = editor->metaObject()->className(); if (className == "QTimeEdit") { QTimeEdit* ed = qobject_cast<QTimeEdit*>(editor); Q_ASSERT( ed); value = QVariant( ed->time()); } else if (className == "QDateEdit") { QDateEdit* ed = qobject_cast<QDateEdit*>(editor); Q_ASSERT( ed); value = QVariant( ed->date()); } else if (className == "QDateTimeEdit") { QDateTimeEdit* ed = qobject_cast<QDateTimeEdit*>(editor); Q_ASSERT( ed); value = QVariant( ed->dateTime()); } else if (className == "IconViewer") { return; } else if (className == "QComboBox") { QComboBox* ed = qobject_cast<QComboBox*>(editor); Q_ASSERT( ed); value = QVariant( ed->currentText()); } else if (className == "QListWidget") { QListWidget* ed = qobject_cast<QListWidget*>(editor); Q_ASSERT( ed); QStringList valList; int itemCount = ed->count(); for (int i = 0; i < itemCount; ++i) { QListWidgetItem* bitItem = ed->item(i); bool isChecked = (bitItem->checkState() == Qt::Checked); if (isChecked) valList += bitItem->text(); } value = QVariant( valList); } else if (className == "QCheckBox") { QCheckBox* ed = qobject_cast<QCheckBox*>(editor); Q_ASSERT( ed); value = QVariant( ed->isChecked()); } else { QItemDelegate::setModelData( editor, model, index); return; } model->setData(index, value, Qt::EditRole); }
void CQReportDefinition::btnDeleteClicked() { QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage()); QListWidgetItem * pNewSelection = NULL; int i, multipleSelection; for (i = pList->count() - 1, multipleSelection = 0; 0 <= i; i--) if (pList->item(i)->isSelected()) { delete pList->takeItem(i); if (!pNewSelection && i < pList->count()) { pNewSelection = pList->item(i); // We select the next. } multipleSelection++; } if (multipleSelection == 0) return; // Nothing selected, mChanged = true; pList->clearSelection(); if (multipleSelection > 1) return; // Only one item was select and we move the selection to the next if (!pNewSelection && pList->count()) // We have removed item at the end. pNewSelection = pList->item(pList->count() - 1); // pNewSelection is NULL if the list is empty if (pNewSelection) { pNewSelection->setSelected(true); } return; }
inline OBSSource OBSBasicFilters::GetFilter(int row, bool async) { if (row == -1) return OBSSource(); QListWidget *list = async ? ui->asyncFilters : ui->effectFilters; QListWidgetItem *item = list->item(row); if (!item) return OBSSource(); QVariant v = item->data(Qt::UserRole); return v.value<OBSSource>(); }
/** * Adds a Peer to the list of contacts, if it doesnt exist from before. * @brief MainWindow::addLocalContact * @param peer Peer to add * @return false if Peer already is in contact list, else true */ bool MainWindow::addLocalContact(Peer* peer) { QListWidget* list = ui->lstContacts; QString str(peer->getName() + "/" + peer->getIp()); for (int i = 0; i < list->count(); ++i) { if (list->item(i)->data(Qt::DisplayRole).toString().compare(str) == 0) return false; } list->addItem(str); return true; }
void CQReportDefinition::btnUpClicked() { QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage()); int i, to, multipleSelection; QListWidgetItem * pMove; for (i = pList->count() - 1, to = -1, multipleSelection = 0; i >= 0; i--) if (pList->item(i)->isSelected()) { if (multipleSelection == 0) { to = i; } multipleSelection++; } else if (multipleSelection > 0) { pMove = pList->takeItem(i); if (pMove) { pList->insertItem(to, pMove); multipleSelection = 0; mChanged = true; } } // Unselect things we can not move. for (i = 0; i < multipleSelection; i++) pList->item(i)->setSelected(false); return; }
void AnimationDialog::selectNext() { m_kfi->stopInterpolation(); QListWidget* list = m_ui->listWidget; int next = list->row(m_item) + 1; if(next > list->count() - 1) { next = list->count() - 1; } AnimationListItem* item = static_cast<AnimationListItem*>(list->item(next)); list->setCurrentItem(item); m_item = item; m_parent->camera()->interpolateTo(m_item->frame(), 0.5); }
void AddPluginDialog::timerEvent(QTimerEvent* event) { if (event->timerId() == mTimerId) { killTimer(mTimerId); QListWidget* pluginList = ui->pluginList; QString s = ui->searchEdit->text(); for (int i=0; i < pluginList->count(); ++i) { QListWidgetItem* item = pluginList->item(i); item->setHidden(! item->data(SEARCH_ROLE).toString().contains(s, Qt::CaseInsensitive)); } } }
void AnimationDialog::selectPrev() { m_kfi->stopInterpolation(); QListWidget* list = m_ui->listWidget; int prev = list->row(m_item) - 1; if( !(prev >= 0 && list->count()) ) { prev = 0; } AnimationListItem* item = static_cast<AnimationListItem*>(list->item(prev)); list->setCurrentItem(item); m_item = item; m_parent->camera()->interpolateTo(m_item->frame(), 0.5); }
/** * Removes a peer from the list of contacts. * @brief MainWindow::removeLocalContact * @param p Peer to remove * @return true if found and deleted */ bool MainWindow::removeLocalContact(Peer* p) { QListWidget* list = ui->lstContacts; QString str(p->getName() + "/" + p->getIp()); for (int i = 0; i < list->count(); ++i) { if (list->item(i)->data(Qt::DisplayRole).toString().compare(str) == 0) { delete (list->takeItem(i)); return true; } } return false; }
//============================================================================= void DialogMeteotableOptions::slotChangeVisibleItems() { // copy visible items order from widget for (int i=0; i<listVisibleData->count(); i++) { QListWidgetItem *widgitem = listVisibleData->item(i); MeteotableOptionItem *item = getOptionItemByCode (widgitem->type()); item->pos = i; } // change visibility of selected items QListWidget *listWidgetSource; if (sender() == btAddVisibleItem) { listWidgetSource = listHiddenData; } else { listWidgetSource = listVisibleData; } for (int i=0; i<listWidgetSource->count(); i++) { QListWidgetItem *widgitem = listWidgetSource->item(i); if (widgitem->isSelected()) { // put all selected items at the end of the other list MeteotableOptionItem *item = getOptionItemByCode (widgitem->type()); if (item) { item->visible = ! item->visible; // reverse visibility item->pos = nbOptionItems(item->visible)-1; // to the end of his category } } } // update positions after movings (numerate from 0) qSort (listAllOptionItems.begin(), listAllOptionItems.end(), MeteotableOptionItem::lessThan_byPos); int posVis = 0; int posNotVis = 0; for (int i = 0; i < listAllOptionItems.size(); ++i) { MeteotableOptionItem *item = listAllOptionItems.at(i); if (item->visible) { item->pos = posVis++; } else { item->pos = posNotVis++; } } updateListWidgetsItems (); }
QListWidgetItem* MainWindow::GetProcessItem(Process* _process) { QListWidgetItem* target = NULL; QListWidget* list = this->ui.procListWidget; QString id = QString::number(_process->id); for (int index = 0x00; index < list->count(); ++index) { QListWidgetItem* item = list->item(index); if(item != NULL && item->text() == id) { target = item; break; } } return target; }
void GuiSpellchecker::updateSuggestions(docstring_list & words) { QString const suggestion = toqstr(d->word_.word()); d->ui.wordED->setText(suggestion); QListWidget * lw = d->ui.suggestionsLW; lw->clear(); if (words.empty()) { on_suggestionsLW_itemClicked(new QListWidgetItem(suggestion)); return; } for (size_t i = 0; i != words.size(); ++i) lw->addItem(toqstr(words[i])); on_suggestionsLW_itemClicked(lw->item(0)); lw->setCurrentRow(0); }
bool MapEditor::selectMapItem(const QModelIndex& index) { QListWidget* lwid = static_cast<QListWidget*>(this->sender()); if(lwid == 0) return true; QListWidgetItem* it=lwid->item(index.row()); if(it == 0) return true; bool ok=false; int ind = it->data(Qt::UserRole).toInt(&ok); if(!ok) return true; return selectMapItem(ind); }
void FormMain::setFolders( const QListWidget & cur, const QListWidget & exc ) { qApp->setOverrideCursor( Qt::WaitCursor ); for ( int i = 0; i < cur.count(); ++i ) { qint64 commonSize = 0; QTreeWidgetItem * rootItem = processPath( cur.item( i )->text(), commonSize, exc ); if ( rootItem ) tree->addTopLevelItem( rootItem ); } qApp->restoreOverrideCursor(); statusBar()->showMessage( "Finished", 3000 ); // 3 seconds }
void OBSBasicFilters::RemoveFilter(OBSSource filter) { uint32_t flags = obs_source_get_output_flags(filter); bool async = (flags & OBS_SOURCE_ASYNC) != 0; QListWidget *list = async ? ui->asyncFilters : ui->effectFilters; for (int i = 0; i < list->count(); i++) { QListWidgetItem *item = list->item(i); QVariant v = item->data(Qt::UserRole); OBSSource curFilter = v.value<OBSSource>(); if (filter == curFilter) { DeleteListItem(list, item); break; } } main->SaveProject(); }