void VegetationWidget::buildList() { QStringList extList; extList << ".png" << ".tga" << ".osgb"; std::string plantDir = g_SystemContext._workContextDir; plantDir.append(CONTEXT_DIR); plantDir.append("/Plant/"); QString grassDir = chineseTextUTF8ToQString(plantDir + "Grass"); QStringList returnList; findAllFilesByExt(grassDir, extList, returnList); QStandardItemModel* grassModel = qobject_cast<QStandardItemModel*>(_grassListView->model()); grassModel->clear(); for (int i = 0; i < returnList.size(); ++i) { QFileInfo fileInfo = returnList.at(i); QStandardItem* newItem = new QStandardItem(fileInfo.fileName()); setupIcon(newItem, "grass"); newItem->setCheckable(true); grassModel->appendRow(newItem); } QString treeDir = chineseTextUTF8ToQString(plantDir + "Tree"); returnList.clear(); findAllFilesByExt(treeDir, extList, returnList); QStandardItemModel* treeModel = qobject_cast<QStandardItemModel*>(_treeListView->model()); treeModel->clear(); for (int i = 0; i < returnList.size(); ++i) { QFileInfo fileInfo = returnList.at(i); QStandardItem* newItem = new QStandardItem(fileInfo.fileName()); setupIcon(newItem, "tree"); newItem->setCheckable(true); treeModel->appendRow(newItem); } }
void Read::engine() { QElapsedTimer timer; timer.start(); qDebug() << "Engine CreateTable" << myParent->name(); //qDebug() << "Myparent->getParent() - " << myParent->getParent(); QStandardItemModel *model = getTableModel();// myParent->getParent()->getTableData(); QGraphicsScene *scene = getScene2D(); model->clear(); scene->clear(); qDebug() << "Got data: " << model; QFile file(_file); //qDebug() << "File exists: " << file.exists() << &_file2 << _file2; if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); int row = 0; QStandardItem *newItem = 0; if (!in.atEnd() && _headers) { QString line = in.readLine(); QStringList list = line.simplified().split(_delimiter); model->setHorizontalHeaderLabels(list); } while ( !in.atEnd() ) { QString line = in.readLine(); QStringList list = line.simplified().split(_delimiter); if (!line.startsWith("#") && line.contains(_delimiter)) { list = line.simplified().split(_delimiter); for (int col = 0; col < list.length(); ++col){ if (list.at(col).length() > 0) { newItem = new QStandardItem(list.at(col)); } else { newItem = new QStandardItem(""); } model->setItem(row, col, newItem); } row++; } } qDebug() << "Lugesin ridu: " << row; } else { model->clear(); scene->clear(); } file.close(); qDebug() << "Read Node took: " << timer.elapsed() << "milliseconds"; }
void QgsStyleManagerDialog::populateSymbols( const QStringList& symbolNames, bool check ) { QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() ); model->clear(); int type = currentItemType(); for ( int i = 0; i < symbolNames.count(); ++i ) { QString name = symbolNames[i]; QgsSymbol* symbol = mStyle->symbol( name ); if ( symbol && symbol->type() == type ) { QStandardItem* item = new QStandardItem( name ); QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( symbol, listItems->iconSize() ); item->setIcon( icon ); item->setData( name ); // used to find out original name when user edited the name item->setCheckable( check ); item->setToolTip( name ); // add to model model->appendRow( item ); } delete symbol; } selectedSymbolsChanged( QItemSelection(), QItemSelection() ); symbolSelected( listItems->currentIndex() ); }
void QgsSymbolV2SelectorDialog::populateSymbolView() { QSize previewSize = viewSymbols->iconSize(); QPixmap p( previewSize ); QPainter painter; QStandardItemModel* model = qobject_cast<QStandardItemModel*>( viewSymbols->model() ); if ( !model ) { return; } model->clear(); QStringList names = mStyle->symbolNames(); for ( int i = 0; i < names.count(); i++ ) { QgsSymbolV2* s = mStyle->symbol( names[i] ); if ( s->type() != mSymbol->type() ) { delete s; continue; } QStandardItem* item = new QStandardItem( names[i] ); item->setData( names[i], Qt::UserRole ); //so we can show a label when it is clicked item->setText( "" ); //set the text to nothing and show in label when clicked rather item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable ); // create preview icon QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( s, previewSize ); item->setIcon( icon ); // add to model model->appendRow( item ); delete s; } }
bool SourcesOnRequestEngine::updateSourceEvent(const QString &source) { // Whenever a visualization has requested an update, such as when passing // an update interval to DataEngine::connectSource, this method will be called. // When this method is called we can assume that: // * the source exists // * it hasn't been updated more frequently than the minimum update interval // // If not data is set in this method, then the update is skipped for the visualiation // and that is just fine. // // We can also set data for other sources here if we wish, but as with // sourceRequestEvent this may not be what the visualization expects. Unlike in // sourceRequestEvent, however, this will result in expected behavior: visualizations // connected to the sources which have setData called for them will be notified // of these changes. const int updateCount = containerForSource(source)->data().value("Update Count").toInt() + 1; setData(source, "Update Count", updateCount); QStandardItemModel *m = qobject_cast<QStandardItemModel *>(modelForSource(source)); if (m) { m->clear(); m->appendRow(new QStandardItem(QString("Item1, update %1").arg(updateCount))); m->appendRow(new QStandardItem(QString("Item2, update %1").arg(updateCount))); m->appendRow(new QStandardItem(QString("Item3, update %1").arg(updateCount))); } // Since we updated the source immediately here, we need to return true so the DataEngine // knows to continue with the update notification for visualizations. return true; }
void MainWidget::setIconWidgetPath(QString path) { QStandardItemModel* fModel = qobject_cast<QStandardItemModel*>(iView->model()); if(!fModel) { fModel = new QStandardItemModel; iView->setModel(fModel); } fModel->clear(); QStringList filter; filter<<QString("*.jpeg")<<QString("*.jpg")<<QString("*.png")<<QString("*.gif")<<QString("*.bmp"); QDirIterator dir_iter(path, filter, QDir::Files | QDir::NoSymLinks, QDirIterator::NoIteratorFlags); if(dir_iter.hasNext()){ while(dir_iter.hasNext()){ dir_iter.next(); QString file = dir_iter.fileInfo().absoluteFilePath(); QImage img(file); if(!img.isNull()){ QPixmap pix = QPixmap::fromImage(img); if(pix.size().width() > 300 || pix.size().height()>300){ pix = pix.scaled(200,200, Qt::KeepAspectRatio); //,Qt::SmoothTransformation) } QStandardItem* item = new QStandardItem(QIcon(pix),file.mid(file.lastIndexOf("/")+1)); item->setData(QVariant(file),Qt::WhatsThisRole); fModel->appendRow(item); } } } }
void BAbstractFileType::showAutocompletionMenu(BAbstractCodeEditorDocument *doc, QTextCursor cursor, const QPoint &) { if (cursor.isNull()) return; QCompleter *completer = doc->findChild<QCompleter *>("beqt/completer"); cursor.select(QTextCursor::WordUnderCursor); if (!cursor.hasSelection()) { if (completer) completer->popup()->hide(); return; } QList<AutocompletionItem> list = createAutocompletionItemList(doc, cursor); if (list.isEmpty()) { if (completer) completer->popup()->hide(); return; } QStandardItemModel *model = doc->findChild<QStandardItemModel *>("beqt/completion_model"); if (!model) { model = new QStandardItemModel(doc); model->setObjectName("beqt/completion_model"); model->setColumnCount(1); } model->clear(); foreach (const AutocompletionItem &item, list) { QStandardItem *si = new QStandardItem(item.actionIcon, item.actionText); si->setData(item.actionToolTip, Qt::ToolTipRole); si->setData(item.text, Qt::UserRole); model->appendRow(si); }
void StitcherWorkspace::initConstraintsTree() { /* This is a prefix to distinguish Hawk Geometry properties from the normal widget properties */ QStandardItemModel * model = qobject_cast<QStandardItemModel *>(constraintsTree->model()); model->clear(); model->setHorizontalHeaderLabels(QStringList() << "Constraint" << "Error"); constraintsTree->setColumnWidth(0,20); }
void QgsStyleExportImportDialog::doExportImport() { QModelIndexList selection = listItems->selectionModel()->selectedIndexes(); if ( selection.isEmpty() ) { QMessageBox::warning( this, tr( "Export/import error" ), tr( "You should select at least one symbol/color ramp." ) ); return; } if ( mDialogMode == Export ) { QString fileName = QFileDialog::getSaveFileName( this, tr( "Save styles" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; } // ensure the user never omitted the extension from the file name if ( !fileName.endsWith( QLatin1String( ".xml" ), Qt::CaseInsensitive ) ) { fileName += QLatin1String( ".xml" ); } mFileName = fileName; moveStyles( &selection, mStyle, mTempStyle ); if ( !mTempStyle->exportXml( mFileName ) ) { QMessageBox::warning( this, tr( "Export/import error" ), tr( "Error when saving selected symbols to file:\n%1" ) .arg( mTempStyle->errorString() ) ); return; } else { QMessageBox::information( this, tr( "Export successful" ), tr( "The selected symbols were successfully exported to file:\n%1" ) .arg( mFileName ) ); } } else // import { moveStyles( &selection, mTempStyle, mStyle ); // clear model QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() ); model->clear(); accept(); } mFileName = QLatin1String( "" ); mTempStyle->clear(); }
void Configure::setHardwareConfiguration(QDomDocument* doc) { // print out the element names of all elements that are direct children // of the outermost element. QStandardItemModel *model = new QStandardItemModel(); model->clear(); printTree(doc->documentElement(),""); qDebug()<<"Configure::printTree: "<<serverType<<","<<sampleRate<<","<<minFrequency<<","<<maxFrequency; }
bool QgsStyleExportImportDialog::populateStyles( QgsStyle *style ) { // load symbols and color ramps from file if ( mDialogMode == Import ) { // NOTE mTempStyle is style here if ( !style->importXml( mFileName ) ) { QMessageBox::warning( this, tr( "Import error" ), tr( "An error occurred during import:\n%1" ).arg( style->errorString() ) ); return false; } } QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() ); model->clear(); // populate symbols QStringList styleNames = style->symbolNames(); QString name; for ( int i = 0; i < styleNames.count(); ++i ) { name = styleNames[i]; QStringList tags = style->tagsOfSymbol( QgsStyle::SymbolEntity, name ); QgsSymbol *symbol = style->symbol( name ); QStandardItem *item = new QStandardItem( name ); QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( symbol, listItems->iconSize(), 15 ); item->setIcon( icon ); item->setToolTip( QString( "<b>%1</b><br><i>%2</i>" ).arg( name, tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) ); // Set font to 10points to show reasonable text QFont itemFont = item->font(); itemFont.setPointSize( 10 ); item->setFont( itemFont ); model->appendRow( item ); delete symbol; } // and color ramps styleNames = style->colorRampNames(); for ( int i = 0; i < styleNames.count(); ++i ) { name = styleNames[i]; std::unique_ptr< QgsColorRamp > ramp( style->colorRamp( name ) ); QStandardItem *item = new QStandardItem( name ); QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), listItems->iconSize(), 15 ); item->setIcon( icon ); model->appendRow( item ); } return true; }
bool CodeEditor::save() { QFile file(windowFilePath()); if(!file.open(QIODevice::WriteOnly| QIODevice::Truncate) ) return false; const QString text = edit->toPlainText(); file.write(text.toLocal8Bit()); file.close(); CppObjList objList; CppReader reader(text); objList << reader; objList.readDescription(text); if(!objList.isEmpty()) { QFileInfo info(windowFilePath()); if( Editor1::source().contains(info.fileName())) { QStandardItemModel *objModel = Editor1::source().value(info.fileName()); objModel->clear(); foreach (QStandardItem *it, objList) objModel->appendRow( it); objModel->setHorizontalHeaderLabels(QStringList(info.fileName())); model->clear(); select(model->invisibleRootItem(),objModel->invisibleRootItem()); view->expandAll(); view->resizeColumnToContents(0); } else { QStandardItemModel *objModel = new QStandardItemModel; foreach (QStandardItem *it, objList) objModel->appendRow( it); objModel->setHorizontalHeaderLabels(QStringList(info.fileName())); Editor1::source().insert(info.fileName(),objModel); model->clear(); select(model->invisibleRootItem(),objModel->invisibleRootItem()); view->expandAll(); view->resizeColumnToContents(0); } } edit->document()->setModified(false); return true; }
void EncodeDock::loadPresets() { QStandardItemModel* sourceModel = (QStandardItemModel*) m_presetsModel.sourceModel(); sourceModel->clear(); QStandardItem* parentItem = new QStandardItem(tr("Custom")); sourceModel->invisibleRootItem()->appendRow(parentItem); QDir dir(QStandardPaths::standardLocations(QStandardPaths::DataLocation).first()); if (dir.cd("presets") && dir.cd("encode")) { QStringList entries = dir.entryList(QDir::Files | QDir::NoDotAndDotDot | QDir::Readable); foreach (QString name, entries) { QStandardItem* item = new QStandardItem(name); item->setData(name); parentItem->appendRow(item); }
void EditProfileDialog::updateKeyBindingsList(bool selectCurrentTranslator) { if (!_ui->keyBindingList->model()) _ui->keyBindingList->setModel(new QStandardItemModel(this)); KeyboardTranslatorManager* keyManager = KeyboardTranslatorManager::instance(); const QString& name = lookupProfile() ->property<QString>(Profile::KeyBindings); const KeyboardTranslator* currentTranslator = keyManager->findTranslator(name); QStandardItemModel* model = qobject_cast<QStandardItemModel*>(_ui->keyBindingList->model()); Q_ASSERT(model); model->clear(); QStandardItem* selectedItem = 0; QList<QString> translatorNames = keyManager->allTranslators(); QListIterator<QString> iter(translatorNames); while (iter.hasNext()) { const QString& name = iter.next(); const KeyboardTranslator* translator = keyManager->findTranslator(name); QStandardItem* item = new QStandardItem(translator->description()); item->setData(QVariant::fromValue(translator),Qt::UserRole+1); item->setIcon( KIcon("preferences-desktop-keyboard") ); if ( translator == currentTranslator ) selectedItem = item; model->appendRow(item); } model->sort(0); if ( selectCurrentTranslator && selectedItem ) { _ui->keyBindingList->selectionModel()->setCurrentIndex( selectedItem->index() , QItemSelectionModel::Select ); } }
void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme) { if (!_ui->colorSchemeList->model()) _ui->colorSchemeList->setModel(new QStandardItemModel(this)); const QString& name = lookupProfile()->colorScheme(); const ColorScheme* currentScheme = ColorSchemeManager::instance()->findColorScheme(name); QStandardItemModel* model = qobject_cast<QStandardItemModel*>(_ui->colorSchemeList->model()); Q_ASSERT(model); model->clear(); QList<const ColorScheme*> schemeList = ColorSchemeManager::instance()->allColorSchemes(); QListIterator<const ColorScheme*> schemeIter(schemeList); QStandardItem* selectedItem = 0; while (schemeIter.hasNext()) { const ColorScheme* colors = schemeIter.next(); QStandardItem* item = new QStandardItem(colors->description()); item->setData( QVariant::fromValue(colors) , Qt::UserRole + 1); item->setFlags( item->flags() ); if ( currentScheme == colors ) selectedItem = item; model->appendRow(item); } model->sort(0); if ( selectCurrentScheme && selectedItem ) { _ui->colorSchemeList->updateGeometry(); _ui->colorSchemeList->selectionModel()->setCurrentIndex( selectedItem->index() , QItemSelectionModel::Select ); // update transparency warning label updateTransparencyWarning(); } }
void QgsStyleV2ManagerDialog::populateColorRamps( const QStringList& colorRamps, bool check ) { QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() ); model->clear(); for ( int i = 0; i < colorRamps.count(); ++i ) { QString name = colorRamps[i]; QgsVectorColorRampV2* ramp = mStyle->colorRamp( name ); QStandardItem* item = new QStandardItem( name ); QIcon icon = QgsSymbolLayerV2Utils::colorRampPreviewIcon( ramp, listItems->iconSize() ); item->setIcon( icon ); item->setData( name ); // used to find out original name when user edited the name item->setCheckable( check ); item->setToolTip( name ); model->appendRow( item ); delete ramp; } }
void QgsStyleManagerDialog::populateColorRamps( const QStringList& colorRamps, bool check ) { QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() ); model->clear(); for ( int i = 0; i < colorRamps.count(); ++i ) { QString name = colorRamps[i]; QScopedPointer< QgsColorRamp > ramp( mStyle->colorRamp( name ) ); QStandardItem* item = new QStandardItem( name ); QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.data(), listItems->iconSize() ); item->setIcon( icon ); item->setData( name ); // used to find out original name when user edited the name item->setCheckable( check ); item->setToolTip( name ); model->appendRow( item ); } selectedSymbolsChanged( QItemSelection(), QItemSelection() ); symbolSelected( listItems->currentIndex() ); }
void CSVSettings::View::setSelectedValues (const QStringList &list, bool doViewUpdate, bool signalUpdate) const { QItemSelection selection; if (stringListsMatch (list, selectedValues())) return; if (!mHasFixedValues) { QStandardItemModel *model = static_cast <QStandardItemModel *>(mDataModel); model->clear(); model->appendColumn (toStandardItemList (list)); for (int i = 0; i < model->rowCount(); i++) { QModelIndex idx = model->index(i, 0); selection.append (QItemSelectionRange (idx, idx)); } } else { for (int i = 0; i < mDataModel->rowCount(); i++) { if (list.contains(value(i))) { QModelIndex idx = mDataModel->index(i, 0); selection.append(QItemSelectionRange (idx, idx)); } } } select (selection); //update the view if the selection was set from the model side, not by the //user if (doViewUpdate) updateView (signalUpdate); }
void QgsCategorizedSymbolRendererV2Widget::populateCategories() { QStandardItemModel* m = qobject_cast<QStandardItemModel*>( viewCategories->model() ); m->clear(); QStringList labels; labels << tr( "Symbol" ) << tr( "Value" ) << tr( "Label" ); m->setHorizontalHeaderLabels( labels ); int i, count = mRenderer->categories().count(); // TODO: sort?? utils.sortVariantList(keys); for ( i = 0; i < count; i++ ) { const QgsRendererCategoryV2 &cat = mRenderer->categories()[i]; addCategory( cat ); } viewCategories->resizeColumnToContents( 0 ); viewCategories->resizeColumnToContents( 1 ); viewCategories->resizeColumnToContents( 2 ); }
void QgsGraduatedSymbolRendererV2Widget::populateRanges() { QStandardItemModel* m = qobject_cast<QStandardItemModel*>( viewGraduated->model() ); m->clear(); mRowSelected = -1; QStringList labels; labels << tr( "Symbol" ) << tr( "Range" ) << tr( "Label" ); m->setHorizontalHeaderLabels( labels ); QSize iconSize( 16, 16 ); int i, count = mRenderer->ranges().count(); for ( i = 0; i < count; i++ ) { const QgsRendererRangeV2& range = mRenderer->ranges()[i]; QString rangeStr = QString::number( range.lowerValue(), 'f', 4 ) + " - " + QString::number( range.upperValue(), 'f', 4 ); QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( range.symbol(), iconSize ); QStandardItem* item = new QStandardItem( icon, "" ); //item->setData(k); // set attribute value as user role item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); QStandardItem* item2 = new QStandardItem( rangeStr ); item2->setEditable( 0 ); QList<QStandardItem *> list; list << item << item2 << new QStandardItem( range.label() ); m->appendRow( list ); } // make sure that the "range" column has visible context viewGraduated->resizeColumnToContents( 0 ); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void DataContainerReaderWidget::on_filePath_fileDropped(const QString& text) { DataContainerArrayProxy proxy; setOpenDialogLastDirectory(text); // Set/Remove the red outline if the file does exist if (verifyPathExists(text, filePath) == true) { if(getFilter() != NULL) { if(m_Filter->getLastFileRead().compare(text) != 0) { QStandardItemModel* model = qobject_cast<QStandardItemModel*>(dcaProxyView->model()); if(NULL != model) { model->clear(); } if (m_Filter->getInputFileDataContainerArrayProxy().dataContainers.size() > 0 && (text == m_Filter->getLastFileRead() || m_Filter->getLastFileRead().isEmpty())) { proxy = m_Filter->getInputFileDataContainerArrayProxy(); } else { proxy = m_Filter->readDataContainerArrayStructure(text); m_Filter->setLastRead(QDateTime::currentDateTime()); } m_Filter->setLastFileRead(text); // Update the cached file path in the filter } updateModelFromProxy(proxy); } emit parametersChanged(); // This should force the preflight to run because we are emitting a signal } }
ModelBuilder(QStandardItemModel &model, int numCols = 1 /* TODO bug for greater than one */) : col(0), row(0), numCols(numCols), model(model) { model.clear(); model.setColumnCount(numCols); }
void SheepLoopWidget::xformIdxBoxIndexChanged(int idx) { int genome_idx = qMax(0, m_genomeIdxBox->currentIndex()); flam3_genome* genome = genomes->data() + genome_idx; if (!genome || idx >= genome->num_xforms || genome_idx < 0 || genome_idx >= genomes->size()) { logWarn("SheepLoopWidget::xformIdxBoxIndexChanged : no xform %d in genome %d", idx, genome_idx); return; } QStandardItemModel* model = qobject_cast<QStandardItemModel*>(m_motionElementsView->model()); disconnect(model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(motionItemChanged(QStandardItem*))); flam3_xform* xform = genome->xform + idx; m_animateButton->setChecked(xform->animate); model->clear(); model->setHorizontalHeaderLabels(QStringList() << QString("element") << QString("value") << QString("function") << QString("frequency")); connect(model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(motionItemChanged(QStandardItem*))); for (int n = 0 ; n < xform->num_motion ; n++) { int m_idx = n; flam3_xform* motion = xform->motion + m_idx; int var_idx = -1; for (int i = 0 ; i < flam3_nvariations ; i++) if (motion->var[i] != 0.0) { var_idx = i; break; } if (var_idx != -1) { model->setItem(n, 0, new QStandardItem(QString("var: ") + Util::variation_names().at(var_idx))); model->setItem(n, 1, new QStandardItem(QString::number(motion->var[var_idx]))); } else { bool found_val = false; foreach(QString s, Util::get_variable_names()) { double val = Util::get_xform_variable(motion, s); if (val != 0.0) { model->setItem(n, 0, new QStandardItem(QString("par: ") + s)); model->setItem(n, 1, new QStandardItem(QString::number(val))); found_val = true; break; } } if (!found_val) { if (motion->animate != 0.0) { model->setItem(n, 0, new QStandardItem(QString("animate"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->animate))); } else if (motion->color != 0.0) { model->setItem(n, 0, new QStandardItem(QString("color"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->color))); } else if (motion->color_speed != 0.0) { model->setItem(n, 0, new QStandardItem(QString("color_speed"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->color_speed))); } else if (motion->density != 0.0) { model->setItem(n, 0, new QStandardItem(QString("density"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->density))); } else if (motion->opacity != 0.0) { model->setItem(n, 0, new QStandardItem(QString("opacity"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->opacity))); } else if (motion->c[0][0] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("xform: a"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->c[0][0]))); } else if (motion->c[1][0] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("xform: b"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->c[1][0]))); } else if (motion->c[2][0] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("xform: c"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->c[2][0]))); } else if (motion->c[0][1] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("xform: d"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->c[0][1]))); } else if (motion->c[1][1] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("xform: e"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->c[1][1]))); } else if (motion->c[2][1] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("xform: f"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->c[2][1]))); } else if (motion->post[0][0] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("post: a"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->post[0][0]))); } else if (motion->post[1][0] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("post: b"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->post[1][0]))); } else if (motion->post[2][0] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("post: c"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->post[2][0]))); } else if (motion->post[0][1] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("post: d"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->post[0][1]))); } else if (motion->post[1][1] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("post: e"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->post[1][1]))); } else if (motion->post[2][1] != 0.0) { model->setItem(n, 0, new QStandardItem(QString("post: f"))); model->setItem(n, 1, new QStandardItem(QString::number(motion->post[2][1]))); } } } if (motion->motion_func == MOTION_SIN) model->setItem(n, 2, new QStandardItem("sin")); else if (motion->motion_func == MOTION_HILL) model->setItem(n, 2, new QStandardItem("hill")); else model->setItem(n, 2, new QStandardItem("triangle")); model->setItem(n, 3, new QStandardItem(QString::number(motion->motion_freq))); }
void StitcherWorkspace::loadGeometry() { /* This is a prefix to distinguish Hawk Geometry properties from the normal widget properties */ const QString tag("HawkGeometry_"); QList<QGraphicsItem *> ii = _stitcherView->items(); QMap<QString,ImageItem *> sortMap; for(int i = 0; i<ii.size(); i++) { if(ImageItem * imageItem = qgraphicsitem_cast<ImageItem *>(ii[i])) { if(imageItem->isVisible()) { sortMap.insert(imageItem->identifier(),imageItem); } } } QList<ImageItem *>sortedItems = sortMap.values(); QStandardItemModel * model = qobject_cast<QStandardItemModel *>(geometryTree->model()); model->clear(); model->setHorizontalHeaderLabels(QStringList() << "Parameter" << "Value" << "Locked"); for(int i = 0; i<sortedItems.size(); i++) { ImageItem * imageItem = sortedItems[i]; const QMetaObject *metaobject = imageItem->metaObject(); int count = metaobject->propertyCount(); QStandardItem * itemName = new QStandardItem(imageItem->identifier()); QStandardItem * itemValue = new QStandardItem(); QStandardItem * itemLocked = new QStandardItem(); itemLocked->setFlags(itemLocked->flags() & ~Qt::ItemIsEditable); QStandardItem *parentItem = model->invisibleRootItem(); itemName->setFlags(itemName->flags() & ~Qt::ItemIsEditable); itemValue->setFlags(itemValue->flags() & ~Qt::ItemIsEditable); if(model->findItems(itemName->text()).empty()) { parentItem->appendRow(QList<QStandardItem *>() << itemName << itemValue << itemLocked); parentItem = itemName; } else { parentItem = model->findItems(itemName->text()).first(); } for (int j=0; j<count; ++j) { QMetaProperty metaproperty = metaobject->property(j); const char *name = metaproperty.name(); if(!QString(name).startsWith(tag)) { continue; } QVariant var = imageItem->property(name); Qt::ItemFlags itemValueFlags = Qt::ItemIsSelectable|Qt::ItemIsEnabled; if(metaproperty.isWritable()) { itemValueFlags |= Qt::ItemIsEditable; } if(var.type() == QVariant::Double) { double value = var.toDouble(); if(QString(name).endsWith("_theta") || QString(name).endsWith("_alpha")) { /* convert to degrees */ value *= 180/M_PI; } if(QString(name).endsWith("_dy")) { /* swap axis */ value = -value; } QStandardItem * itemName = new QStandardItem(_stitcherView->propertyNameToDisplayName(name,tag)); QStandardItem * itemValue = new QStandardItem(QString("%0").arg(value)); itemValue->setData(value,Qt::UserRole + 1); itemValue->setData(QString(name),Qt::UserRole + 2); itemValue->setData(QVariant::fromValue(imageItem),Qt::UserRole + 3); itemName->setFlags(itemName->flags() & ~Qt::ItemIsEditable); itemValue->setFlags(itemValueFlags); QStandardItem * itemLocked = new QStandardItem(); itemLocked->setFlags(itemLocked->flags() & ~Qt::ItemIsEditable); /* check for lock property */ QString lockedPropertyName = name + QString("_locked"); if(imageItem->property(lockedPropertyName.toAscii().data()).isValid()) { bool locked = imageItem->property(lockedPropertyName.toAscii().data()).toBool(); itemLocked->setCheckable(true); itemLocked->setData(locked,Qt::UserRole + 1); itemLocked->setData(QString(lockedPropertyName),Qt::UserRole + 2); itemLocked->setData(QVariant::fromValue(imageItem),Qt::UserRole + 3); if(locked) { itemLocked->setCheckState(Qt::Checked); itemValue->setEnabled(false); } } /* Temporarily disable Dz and Alpha */ if(itemName->text() == "Dz" || itemName->text() == "Alpha") { itemLocked->setCheckState(Qt::Checked); itemName->setEnabled(false); itemValue->setEnabled(false); itemLocked->setEnabled(false); itemName->setToolTip("Currently disabled"); itemValue->setToolTip("Currently disabled"); itemLocked->setToolTip("Currently disabled"); } parentItem->appendRow(QList<QStandardItem *>() << itemName << itemValue << itemLocked); } } } geometryTree->expandAll(); geometryTree->resizeColumnToContents(0); geometryTree->sortByColumn(0,Qt::AscendingOrder); }
void MpcImportWindow::populateCandidateObjects(QList<SsoElements> objects) { candidatesForAddition.clear(); //Get a list of the current objects QHash<QString,QString> defaultSsoIdentifiers = ssoManager->getDefaultSsoIdentifiers(); QHash<QString,QString> loadedSsoIdentifiers = ssoManager->listAllLoadedSsoIdentifiers(); //Separating the objects into visual groups in the list int newDefaultSsoIndex = 0; int newLoadedSsoIndex = 0; int newNovelSsoIndex = 0; int insertionIndex = 0; QStandardItemModel * model = candidateObjectsModel; model->clear(); model->setColumnCount(1); foreach (SsoElements object, objects) { QString name = object.value("name").toString(); if (name.isEmpty()) continue; QString group = object.value("section_name").toString(); if (group.isEmpty()) continue; //Prevent name conflicts between asteroids and moons if (loadedSsoIdentifiers.contains(name)) { if (loadedSsoIdentifiers.value(name) != group) { name.append('*'); object.insert("name", name); } } QStandardItem * item = new QStandardItem(); item->setText(name); item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); item->setCheckState(Qt::Unchecked); if (defaultSsoIdentifiers.contains(name)) { //Duplicate of a default solar system object QFont itemFont(item->font()); itemFont.setBold(true); item->setFont(itemFont); candidatesForUpdate.append(object); insertionIndex = newDefaultSsoIndex; newDefaultSsoIndex++; newLoadedSsoIndex++; newNovelSsoIndex++; } else if (loadedSsoIdentifiers.contains(name)) { //Duplicate of another existing object QFont itemFont(item->font()); itemFont.setItalic(true); item->setFont(itemFont); candidatesForUpdate.append(object); insertionIndex = newLoadedSsoIndex; newLoadedSsoIndex++; newNovelSsoIndex++; } else { candidatesForAddition.append(object); insertionIndex = newNovelSsoIndex; newNovelSsoIndex++; } model->insertRow(insertionIndex, item); }