void VorbitalDlg::SaveSettings() { qDebug() << "SaveSettings."; QSettings* configData = new QSettings("Zeta Centauri", "Vorbital Player"); configData->setValue("randomize", _randomize); configData->setValue("volume", _volumeSlider->value()); QSize wsize = size(); configData->setValue("sizex", wsize.width()); configData->setValue("sizey", wsize.height()); QString playlistItems; for( int i = 0; i < _lstPlaylist->count(); i++ ) { QListWidgetItem* item = _lstPlaylist->item(i); QVariant variant = item->data(Qt::UserRole); QString filename = variant.toString(); qDebug() << "Saving Playlist Item: " << filename << "'."; if( i > 0 ) { playlistItems += ";"; } playlistItems += filename; } configData->setValue("playlist", playlistItems); configData->sync(); qDebug() << "Saved Settings: Randomize =" << _randomize << ", Volume =" << _volumeSlider->value() << ", Width =" << wsize.width() << ", Height =" << wsize.height() << ", Playlist =" << _lstPlaylist->count() << " items."; delete configData; }
void TodoDialog::on_newItemEdit_textChanged(const QString &arg1) { // search notes when at least 2 characters were entered if (arg1.count() >= 2) { QList<QString> noteNameList = CalendarItem::searchAsUidList( arg1, ui->todoListSelector->currentText()); firstVisibleTodoListRow = -1; for (int i = 0; i < ui->todoList->count(); ++i) { QListWidgetItem *item = ui->todoList->item(i); if (noteNameList.indexOf(item->data(Qt::UserRole).toString()) < 0) { item->setHidden(true); } else { if (firstVisibleTodoListRow < 0) { firstVisibleTodoListRow = i; } item->setHidden(false); } } } else { // show all items otherwise firstVisibleTodoListRow = 0; for (int i = 0; i < ui->todoList->count(); ++i) { QListWidgetItem *item = ui->todoList->item(i); item->setHidden(false); } } // let's highlight the text from the search line edit searchForSearchLineTextInNoteTextEdit(); }
Settings OptionsDialog::settingsFromUi() { Settings settings; if (ui->scanInCurrentFileRadioButton->isChecked()) settings.scanningScope = ScanningScopeCurrentFile; else if (ui->scanInSubprojectRadioButton->isChecked()) settings.scanningScope = ScanningScopeSubProject; else settings.scanningScope = ScanningScopeProject; settings.keywords.clear(); for (int i = 0; i < ui->keywordsList->count(); ++i) { QListWidgetItem *item = ui->keywordsList->item(i); Keyword keyword; keyword.name = item->text(); keyword.iconResource = item->data(Qt::UserRole).toString(); keyword.color = item->backgroundColor(); settings.keywords << keyword; } return settings; }
void ResourceListWidget::startDrag(Qt::DropActions supportedActions) { if (supportedActions == Qt::MoveAction) return; QListWidgetItem *item = currentItem(); if (!item) return; const QString filePath = item->data(Qt::UserRole).toString(); const QIcon icon = item->icon(); QMimeData *mimeData = new QMimeData; const QtResourceView::ResourceType type = icon.isNull() ? QtResourceView::ResourceOther : QtResourceView::ResourceImage; mimeData->setText(QtResourceView::encodeMimeData(type , filePath)); QDrag *drag = new QDrag(this); if (!icon.isNull()) { const QSize size = icon.actualSize(iconSize()); drag->setPixmap(icon.pixmap(size)); drag->setHotSpot(QPoint(size.width() / 2, size.height() / 2)); } drag->setMimeData(mimeData); drag->exec(Qt::CopyAction); }
void QgsAttributeTypeDialog::setWidgetV2Type( const QString& type ) { for( int i = 0; i < selectionListWidget->count(); i++ ) { QListWidgetItem* item = selectionListWidget->item( i ); if ( item->data( Qt::UserRole ).toString() == type ) { selectionListWidget->setCurrentItem( item ); break; } } if ( mEditorConfigWidgets.contains( type ) ) { stackedWidget->setCurrentWidget( mEditorConfigWidgets[type] ); } else { QgsEditorConfigWidget* cfgWdg = QgsEditorWidgetRegistry::instance()->createConfigWidget( type, mLayer, mFieldIdx, this ); if ( cfgWdg ) { cfgWdg->setConfig( mWidgetV2Config ); stackedWidget->addWidget( cfgWdg ); stackedWidget->setCurrentWidget( cfgWdg ); mEditorConfigWidgets.insert( type, cfgWdg ); } else { QgsDebugMsg( "Oops, couldn't create editor widget config dialog..." ); } } }
void ezQtEnginePluginConfigDlg::on_ButtonOK_clicked() { ezPluginSet& Plugins = ezQtEditorApp::GetSingleton()->GetEnginePlugins(); bool bChange = false; for (int i = 0; i < ListPlugins->count(); ++i) { QListWidgetItem* pItem = ListPlugins->item(i); const bool bLoad = pItem->checkState() == Qt::CheckState::Checked; bool& ToBeLoaded = Plugins.m_Plugins[pItem->data(Qt::UserRole + 1).toString().toUtf8().data()].m_bToBeLoaded; if (ToBeLoaded != bLoad) { ToBeLoaded = bLoad; bChange = true; } } if (bChange) { ezQtEditorApp::GetSingleton()->StoreEnginePluginsToBeLoaded(); } accept(); }
int CSelectType::selectedItem() const { QListWidgetItem* item = m_ui->m_typeList->currentItem(); if (!item) return -1; return item->data(Qt::UserRole).toInt(); }
void KeywordDialog::setupListWidget(const QString &selectedIcon) { ui->listWidget->setViewMode(QListWidget::IconMode); ui->listWidget->setDragEnabled(false); const QString infoIconName = QLatin1String(Core::Constants::ICON_INFO); QListWidgetItem *item = new QListWidgetItem(Utils::ThemeHelper::themedIcon(infoIconName), QLatin1String("information")); item->setData(Qt::UserRole, infoIconName); ui->listWidget->addItem(item); const QString warningIconName = QLatin1String(Core::Constants::ICON_WARNING); item = new QListWidgetItem(Utils::ThemeHelper::themedIcon(warningIconName), QLatin1String("warning")); item->setData(Qt::UserRole, warningIconName); ui->listWidget->addItem(item); const QString errorIconName = QLatin1String(Core::Constants::ICON_ERROR); item = new QListWidgetItem(Utils::ThemeHelper::themedIcon(errorIconName), QLatin1String("error")); item->setData(Qt::UserRole, errorIconName); ui->listWidget->addItem(item); for (int i = 0; i < ui->listWidget->count(); ++i) { item = ui->listWidget->item(i); if (item->data(Qt::UserRole).toString() == selectedIcon) { ui->listWidget->setCurrentItem(item); break; } } }
QStringList MainWindow::do_save_color_ranges(QString &base) { QMap<QString, rc_map> jobs; const QString& palId = current_pal_name(); const QList<QRgb>& palData = current_pal_data(); QStringList needOverwriteFiles; for(int k = 0; k < ui->listRanges->count(); ++k) { QListWidgetItem* itemw = ui->listRanges->item(k); Q_ASSERT(itemw); if(itemw->checkState() == Qt::Checked) { const QString& rangeId = itemw->data(Qt::UserRole).toString(); const QString& filePath = base + "/" + QFileInfo(img_path_).completeBaseName() + "-RC-" + palId + "-" + QString::number(k + 1) + "-" + rangeId + ".png"; jobs[filePath] = recolor_range(color_ranges_.value(rangeId), palData); if(QFileInfo(filePath).exists()) { needOverwriteFiles.push_back(filePath); } } } if(!needOverwriteFiles.isEmpty() && !confirm_existing_files(needOverwriteFiles)) { throw canceled_job(); } return do_run_jobs(jobs); }
QString SelectKeyboardLayoutDialog::selectedLayout() { QListWidgetItem* layoutItem = ui.layouts->currentItem(); if(layoutItem) { return layoutItem->data(Qt::UserRole).toString(); } return QString(); }
QString RecentProjectsDialogPage::selectedItem() const { QListWidgetItem* item = d->widget->currentItem(); if( item ) return item->data( Qt::UserRole ).toString(); return QString(); }
QmitkMultiNodeSelectionWidget::NodeList QmitkMultiNodeSelectionWidget::CompileEmitSelection() const { NodeList result; for (int i = 0; i < m_Controls.list->count(); ++i) { QListWidgetItem* item = m_Controls.list->item(i); auto node = item->data(Qt::UserRole).value<mitk::DataNode::Pointer>(); result.append(node); } if (!m_SelectOnlyVisibleNodes) { for (auto node : m_CurrentSelection) { if (!result.contains(node)) { result.append(node); } } } return result; }
void SettingsPage::updateButtonStates() { QListWidgetItem *item = m_ui.filterList->currentItem(); ILocatorFilter *filter = (item ? item->data(Qt::UserRole).value<ILocatorFilter *>() : 0); m_ui.editButton->setEnabled(filter && filter->isConfigurable()); m_ui.removeButton->setEnabled(filter && m_customFilters.contains(filter)); }
/** * Shows file details for a playlist item. */ void VorbitalDlg::ShowFileInfo(int index) { QListWidgetItem* item = _lstPlaylist->item(index); QVariant variant = item->data(Qt::UserRole); QString filename = variant.toString(); QMessageBox(QMessageBox::Information, filename, "File Location", QMessageBox::Ok); }
void CharacterListDialog::accept() { QListWidgetItem* character = mCharacterList->currentItem(); if(character) { QDialog::accept(); emit characterChosen(character->text(),character->data(Qt::UserRole).toString(),mCharacterList->currentRow()); } }
void AutoRunDialog::accept() { QListWidgetItem* item = ui.listWidget->selectedItems().first(); if(item) { GFile* gf = g_mount_get_root(mount_); void* p = qVariantValue<void*>(item->data(Qt::UserRole)); if(p) { // runt the selected application GAppInfo* app = G_APP_INFO(p); GList* filelist = g_list_prepend(NULL, gf); g_app_info_launch(app, filelist, NULL, NULL); g_list_free(filelist); } else { // the default action, open the mounted folder in the file manager Application* app = static_cast<Application*>(qApp); Settings& settings = app->settings(); FmPath* path = fm_path_new_for_gfile(gf); // open the path in a new window // FIXME: or should we open it in a new tab? Make this optional later MainWindow* win = new MainWindow(path); fm_path_unref(path); win->resize(settings.windowWidth(), settings.windowHeight()); win->show(); } g_object_unref(gf); } QDialog::accept(); }
void ImHistoryBrowser::historyChanged(uint msgId, int type) { if (type == NOTIFY_TYPE_ADD) { /* history message added */ HistoryMsg msg; if (rsHistory->getMessage(msgId, msg) == false) { return; } historyAdd(msg); return; } if (type == NOTIFY_TYPE_DEL) { /* history message removed */ int count = ui.listWidget->count(); for (int i = 0; i < count; ++i) { QListWidgetItem *itemWidget = ui.listWidget->item(i); if (itemWidget->data(ROLE_MSGID).toString().toUInt() == msgId) { delete(ui.listWidget->takeItem(i)); break; } } return; } if (type == NOTIFY_TYPE_MOD) { /* clear history */ ui.listWidget->clear(); return; } }
/* * Add highlighted entries into main data store */ void UploadImpl::add() { // checked rather than selected seems more intuitive // QList<QListWidgetItem *> items; // items = listWidget->selectedItems(); for (int n=0; n< listWidget->count(); ++n) { QListWidgetItem* i = listWidget->item(n); if ( (i->checkState() == Qt::Checked) && (i->flags() & Qt::ItemIsEnabled) ) { // userrole data contains location exercise list unsigned int pos = i->data(Qt::UserRole).toInt(); //Disable once uploaded i->setFlags(0); i->setCheckState(Qt::Checked); // TODO add session ids to remove this date grouping hack. QDateTime initial(exdata[pos].date, exdata[pos].time); std::vector<ExerciseSet> sets; while (pos < exdata.size() && QDateTime(exdata[pos].date, exdata[pos].time) == initial) { sets.push_back(exdata[pos++]); } if (sets.size()) ds->add(sets); } } close(); }
void MainForm::startStream() { // Warn if not setup if (strcmp(options->get_hoster()->get_name(), "dummy") == 0) { QMessageBox::warning(this, "Hoster", "Please setup a hoster", QMessageBox::Ok); return; } streamThread = new StreamThread(options); connect(streamThread, &StreamThread::streamCompleted, this, &MainForm::completeStream); connect(streamThread, &StreamThread::cacheFailed, this, &MainForm::cacheFailed); connect(streamThread, &StreamThread::downloadFinished, this, &MainForm::finishDownload); connect(streamThread, &StreamThread::rarCallback, this, &MainForm::handleRarCallback); connect(streamThread, &StreamThread::rarProgressed, this, &MainForm::updateRarProgress); connect(streamThread, &StreamThread::mpvCallback, this, &MainForm::handlempvCallback); for (int i = 0; i < play_list->count(); ++i) { QListWidgetItem *item = play_list->item(i); streamThread->add_link(item->data(Qt::ItemDataRole::UserRole).toString().toStdString().c_str()); } if (streamThread->isEmpty()) { QMessageBox::information(this, "Links", "Please add links and select them in the list.", QMessageBox::Ok); delete streamThread; streamThread = nullptr; } else { tabs->setCurrentIndex(Tabs::STREAM); enable_window(false); streamThread->start(); } }
void MarketListWidget::on_addButton_clicked() { if(!ui->listWidget->currentIndex().isValid()){ QMessageBox::critical(this,"Nada seleccionado","Seleccione un item de la lista para modificar",QMessageBox::Ok); return; } QListWidgetItem *item = ui->listWidget->currentItem(); int amount = ui->spinBox->value(); QSqlQuery query; int id = item->data(Qt::UserRole).toInt(); if(ui->spinBox->value()>0){ query.prepare("UPDATE MarketList SET amount=? WHERE food_id=?"); query.addBindValue(amount); query.addBindValue(id); if(query.exec()){ qDebug()<<"updated market list item properly"; FillList(); }else{ qDebug()<<"failed to update market list item"; } }else{ query.prepare("DELETE FROM MarketList WHERE food_id=?"); query.addBindValue(id); if(query.exec()){ qDebug()<<"deleted market list item properly"; FillList(); }else{ qDebug()<<"failed to delete market list item"; } } }
void PluginsManager::save() { if (!m_loaded) { return; } QStringList allowedPlugins; for (int i = 0; i < ui->list->count(); i++) { QListWidgetItem* item = ui->list->item(i); if (item->checkState() == Qt::Checked) { const Plugins::Plugin plugin = item->data(Qt::UserRole + 10).value<Plugins::Plugin>(); // Save plugins with relative path in portable mode if (mApp->isPortable()) allowedPlugins.append(plugin.fileName); else allowedPlugins.append(plugin.fullPath); } } Settings settings; settings.beginGroup("Plugin-Settings"); settings.setValue("EnablePlugins", ui->allowAppPlugins->isChecked()); settings.setValue("AllowedPlugins", allowedPlugins); settings.endGroup(); }
void SkinTestWindow::ReloadSkins(bool init) { int ROW= ui->SkinsList->currentRow(); if(init)times.clear(); ui->SkinsList->clear(); QDir d("themes"); QStringList sl = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot); sl.sort(); foreach(QString theme,sl) { //determine the SKIN NAME? Subskins? QDir dd("themes/"+theme); QStringList themefiles = dd.entryList(QStringList("*.css")); foreach(QString tf,themefiles) { QListWidgetItem* a = new QListWidgetItem; QString name; QFile f(QDir::currentPath()+ "/themes/"+theme+"/"+tf); if(f.open(QIODevice::ReadOnly)) { a->setText(theme+"/"+tf); a->setData(TIDATA,QDir::currentPath()+ "/themes/"+theme+"/"+tf); //file ui->SkinsList->addItem(a); QString fn = a->data(TIDATA).toString(); QFileInfo fi(fn); times[fn]=fi.lastModified(); } else gcprint("Unable to read file: "+QDir::currentPath()+ "/themes/"+theme+"/"+tf); }
void InlinePalette::handleContextMenue(QPoint p) { QListWidgetItem *item = InlineViewWidget->itemAt(p); if (item) { actItem = item->data(Qt::UserRole).toInt(); bool txFrame = false; if (!currDoc->m_Selection->isEmpty()) { PageItem* selItem = currDoc->m_Selection->itemAt(0); if ((selItem->isTextFrame() || selItem->isTable())) txFrame = true; } QMenu *pmenu = new QMenu(); if (txFrame) { QAction* pasteAct = pmenu->addAction( tr("Paste to Item")); connect(pasteAct, SIGNAL(triggered()), this, SLOT(handlePasteToItem())); } if ((currDoc->appMode != modeEdit) && (currDoc->appMode != modeEditTable)) { QAction* editAct = pmenu->addAction( tr("Edit Item")); connect(editAct, SIGNAL(triggered()), this, SLOT(handleEditItem())); } pmenu->exec(QCursor::pos()); delete pmenu; actItem = -1; } }
void CompletionBox::finishCompletion(){ QListWidgetItem *item = listwidget->currentItem(); if (!item) return; QString s = item->data(Qt::UserRole).toString().mid(searchString.length()); editor->insertPlainText(s); }
void WidgetListing::startDrag( Qt::DropActions /*supportedActions*/ ) { QListWidgetItem *item = currentItem(); QByteArray itemData; QDataStream dataStream( &itemData, QIODevice::WriteOnly ); int i_type = item->data( Qt::UserRole ).toInt(); int i_option = parent->getOptions(); dataStream << i_type << i_option; /* Create a new dragging event */ QDrag *drag = new QDrag( this ); /* With correct mimedata */ QMimeData *mimeData = new QMimeData; mimeData->setData( "vlc/button-bar", itemData ); drag->setMimeData( mimeData ); /* And correct pixmap */ QPixmap aPixmap = item->icon().pixmap( QSize( 22, 22 ) ); drag->setPixmap( aPixmap ); drag->setHotSpot( QPoint( 20, 20 ) ); /* We want to keep a copy */ drag->exec( Qt::CopyAction | Qt::MoveAction ); }
void OBSBasicFilters::ReorderFilter(QListWidget *list, obs_source_t *filter, size_t idx) { int count = list->count(); for (int i = 0; i < count; i++) { QListWidgetItem *listItem = list->item(i); QVariant v = listItem->data(Qt::UserRole); OBSSource filterItem = v.value<OBSSource>(); if (filterItem == filter) { if ((int)idx != i) { bool sel = (list->currentRow() == i); listItem = TakeListItem(list, i); if (listItem) { list->insertItem((int)idx, listItem); SetupVisibilityItem(list, listItem, filterItem); if (sel) list->setCurrentRow((int)idx); } } break; } } }
void QgsComposerPictureWidget::on_mRemoveDirectoryButton_clicked() { QString directoryToRemove = mSearchDirectoriesComboBox->currentText(); if ( directoryToRemove.isEmpty() ) { return; } mSearchDirectoriesComboBox->removeItem( mSearchDirectoriesComboBox->currentIndex() ); //remove entries from back to front (to have the indices of existing items constant) for ( int i = ( mPreviewListWidget->count() - 1 ); i >= 0; --i ) { QListWidgetItem* currentItem = mPreviewListWidget->item( i ); if ( currentItem && currentItem->data( Qt::UserRole ).toString().startsWith( directoryToRemove ) ) { delete( mPreviewListWidget->takeItem( i ) ); } } //update the image directory list in the settings QSettings s; QStringList userDirList = s.value( "/Composer/PictureWidgetDirectories" ).toStringList(); userDirList.removeOne( directoryToRemove ); s.setValue( "/Composer/PictureWidgetDirectories", userDirList ); }
void Radio::openLink() { QListWidgetItem *lWI = lW->currentItem(); if (lWI) { if (lWI == nowaStacjaLWI) { const QString newStation = tr("Adding a new radio station"); QString nazwa, adres; bool ok; nazwa = QInputDialog::getText(this, newStation, tr("Name"), QLineEdit::Normal, QString(), &ok); if (ok && !nazwa.isEmpty()) { adres = QInputDialog::getText(this, newStation, tr("Address"), QLineEdit::Normal, "http://", &ok); if (ok && !adres.isEmpty() && adres != "http://") addStation(nazwa, adres, wlasneStacje); } } else { const QString url = lWI->data(Qt::UserRole).toString(); if (!url.isEmpty()) emit QMPlay2Core.processParam("open", url); } } }
void ChangelogWindow::revertButtonClicked() { QList<QListWidgetItem *> list = ui->listWidget->selectedItems(); if (list.count() == 0) return; QMessageBox box; box.setText(QString("Are you sure you want to revert %1 changes?").arg(list.count())); box.setStandardButtons(QMessageBox::Yes|QMessageBox::No); if (box.exec() == QMessageBox::Yes) { for (int i = 0; i < list.count(); ++i) { QListWidgetItem *item = list.at(i); QStringList idList = item->data(Qt::UserRole).toString().split(":"); if (idList.at(0) == "bug") { SqlUtilities::simpleDelete(idList.at(1), idList.at(3)); } else { SqlUtilities::simpleDelete(idList.at(1),"shadow_comments"); } ui->listWidget->takeItem(ui->listWidget->row(item)); delete item; } } }
void SharedConnectionsDialog::sl_editClicked() { const QString dbiUrl = ui->lwConnections->currentItem()->data(UrlRole).toString(); const QString userName = ui->lwConnections->currentItem()->data(LoginRole).toString(); const QString connectionName = ui->lwConnections->currentItem()->text(); QObjectScopedPointer<EditConnectionDialog> editDialog = new EditConnectionDialog(this, dbiUrl, userName, connectionName); editDialog->setReadOnly(U2DbiUtils::PUBLIC_DATABASE_URL == U2DbiUtils::createFullDbiUrl(userName, dbiUrl)); const int dialogResult = editDialog->exec(); CHECK(!editDialog.isNull(), ); if (QDialog::Accepted == dialogResult) { QListWidgetItem* item = ui->lwConnections->currentItem(); const QString login = editDialog->getUserName(); const QString shortDbUrl = editDialog->getShortDbiUrl(); checkDbConnectionDuplicate(shortDbUrl, login, item->data(Qt::DisplayRole).toString()); if (connectionName != editDialog->getName()) { removeRecentConnection(item); } item->setText(editDialog->getName()); item->setData(UrlRole, shortDbUrl); item->setData(LoginRole, login); connectionTasks.remove(item); findUpgradeTasks(); saveRecentConnection(item); updateState(); } }