bool Variables::runOnModule(Module &module) { errs() << "Running Variables\n"; doInitialization(module); vector<Change*>::iterator it; for(it = changes[GLOBALVAR].begin(); it != changes[GLOBALVAR].end(); it++) { changeGlobal(*it, module); // TODO: return value and metadata } for(it = changes[LOCALVAR].begin(); it != changes[LOCALVAR].end(); it++) { AllocaInst* newTarget = changeLocal(*it); if (newTarget) { errs() << "\tProcessed local variable: " << newTarget->getName() << "\n"; updateMetadata(module, (*it)->getValue(), newTarget, (*it)->getType()[0]); #ifdef DEBUG verifyModule(module, AbortProcessAction); errs() << "**** MODULE VERIFIES after a single change ****\n"; #endif } } return true; }
void EditMetadataCommon::showSaveMenu() { updateMetadata(); if (!hasMetadataChanged()) { Close(); return; } QString label = tr("Save Changes?"); MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythDialogBox *menu = new MythDialogBox(label, popupStack, "savechangesmenu"); if (!menu->Create()) { delete menu; return; } menu->SetReturnEvent(this, "savechangesmenu"); if (metadataOnly) menu->AddButton(tr("Save Changes"), SLOT(saveToMetadata())); else menu->AddButton(tr("Save Changes"), SLOT(saveAll())); menu->AddButton(tr("Exit/Do Not Save"), SLOT(cleanupAndClose())); menu->AddButton(tr("Cancel")); popupStack->AddScreen(menu); }
void QgsMeshRendererActiveDatasetWidget::onActiveDatasetChanged( int value ) { int groupIndex = mDatasetGroupTreeView->activeGroup(); mActiveScalarDataset = QgsMeshDatasetIndex(); mActiveVectorDataset = QgsMeshDatasetIndex(); QgsMeshDatasetIndex datasetIndex( groupIndex, value ); if ( mMeshLayer && mMeshLayer->dataProvider() && datasetIndex.isValid() && mMeshLayer->dataProvider()->datasetCount( groupIndex ) > value ) { const QgsMeshDatasetGroupMetadata meta = mMeshLayer->dataProvider()->datasetGroupMetadata( datasetIndex ); mActiveScalarDataset = datasetIndex; if ( meta.isVector() ) mActiveVectorDataset = datasetIndex; } updateMetadata( datasetIndex ); emit activeScalarDatasetChanged( activeScalarDataset() ); emit activeVectorDatasetChanged( activeVectorDataset() ); emit widgetChanged(); }
ccSNECloud::ccSNECloud(ccPointCloud* obj) : ccPointCloud() { //copy points, normals and scalar fields from obj. *this += obj; //update metadata updateMetadata(); }
NowPlaying::NowPlaying(QObject *parent, const QVariantList &args) : Plasma::Applet(parent, args), m_controller(0), m_state(NoPlayer), m_currentLayout(NoLayout), m_volume(0), m_length(0), m_textPanel(new InfoPanel) { resize(300, 200); // ideal planar size connect(this, SIGNAL(metadataChanged(QMap<QString,QString>)), m_textPanel, SLOT(updateMetadata(QMap<QString,QString>))); connect(this, SIGNAL(coverChanged(QPixmap)), m_textPanel, SLOT(updateArtwork(QPixmap))); }
void EditMetadataDialog::switchToAlbumArt() { updateMetadata(); MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); EditAlbumartDialog *editDialog = new EditAlbumartDialog(mainStack); if (!editDialog->Create()) { delete editDialog; return; } mainStack->AddScreen(editDialog); Close(); }
void InterpolatingGraph::onNewData(qint64 timestamp) { auto const& data = series.getData(lastUpdate, timestamp); for (auto i = data.constBegin(); i != data.constEnd(); ++i) { updateMetadata(i.value()); switch (currentScalingMode) { case PlotSettings::NOSCALING: graph->addData(i.key(), i.value()); break; case PlotSettings::MINMAXSCALING: scaleToRange(0.0, 1.0, currentScaleType); break; } } lastUpdate = timestamp; updatePlot(currentScalingMode); }
QString ComponentEditorWidget::commitMetadata() noexcept { try { QScopedPointer<CmdComponentEdit> cmd(new CmdComponentEdit(*mComponent)); try { // throws on invalid name cmd->setName("", ElementName(mUi->edtName->text().trimmed())); } catch (const Exception& e) { } cmd->setDescription("", mUi->edtDescription->toPlainText().trimmed()); cmd->setKeywords("", mUi->edtKeywords->text().trimmed()); try { // throws on invalid version cmd->setVersion(Version::fromString(mUi->edtVersion->text().trimmed())); } catch (const Exception& e) { } cmd->setAuthor(mUi->edtAuthor->text().trimmed()); cmd->setDeprecated(mUi->cbxDeprecated->isChecked()); cmd->setCategories(mCategoriesEditorWidget->getUuids()); cmd->setIsSchematicOnly(mUi->cbxSchematicOnly->isChecked()); try { // throws on invalid prefix cmd->setPrefix("", ComponentPrefix(mUi->edtPrefix->text().trimmed())); } catch (const Exception& e) { } cmd->setDefaultValue(mUi->edtDefaultValue->toPlainText().trimmed()); cmd->setAttributes(mUi->attributesEditorWidget->getAttributeList()); // Commit all changes. mUndoStack->execCmd(cmd.take()); // can throw // Reload metadata into widgets to discard invalid input. updateMetadata(); } catch (const Exception& e) { return e.getMsg(); } return QString(); }
//pass ctors straight to ccPointCloud ccSNECloud::ccSNECloud() : ccPointCloud() { updateMetadata(); }
void EditMetadataDialog::customEvent(QEvent *event) { if (event->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = (DialogCompletionEvent*)(event); // make sure the user didn't ESCAPE out of the menu if (dce->GetResult() < 0) return; QString resultid = dce->GetId(); QString resulttext = dce->GetResultText(); if (resultid == "optionsmenu") { if (resulttext == tr("Edit Albumart Images")) switchToAlbumArt(); else if (resulttext == tr("Search Internet For Genre Image")) { updateMetadata(); searchForGenreImages(); } else if (resulttext == tr("Search Internet For Artist Image")) { updateMetadata(); searchForArtistImages(); } else if (resulttext == tr("Search Internet For Album Image")) { updateMetadata(); searchForAlbumImages(); } else if (resulttext == tr("Check Track Length")) { int length = calcTrackLength(m_metadata->Filename()); if (length != m_metadata->Length() / 1000) { int oldLength = m_metadata->Length() / 1000; // save the new length to our working copy of the metadata m_metadata->setLength(length * 1000); // save the new length to the source copy of the metadata m_sourceMetadata->setLength(length * 1000); m_sourceMetadata->dumpToDatabase(); // this will update any track lengths displayed on screen gPlayer->sendMetadataChangedEvent(m_sourceMetadata->ID()); // this will force the playlist stats to update MusicPlayerEvent me(MusicPlayerEvent::TrackChangeEvent, gPlayer->getCurrentTrackPos()); gPlayer->dispatch(me); ShowOkPopup(QString("Updated track length to %1 seconds\nwas %2 seconds").arg(length).arg(oldLength)); } } } } else if (event->type() == MythEvent::MythEventMessage) { MythEvent *me = (MythEvent *)event; QStringList tokens = me->Message().split(" ", QString::SkipEmptyParts); if (!tokens.isEmpty()) { if (tokens[0] == "BROWSER_DOWNLOAD_FINISHED") { scanForImages(); // force the icons to update updateAlbumImage(); updateArtistImage(); updateGenreImage(); m_metadata->getAlbumArtImages()->dumpToDatabase(); // force a reload of the images for any tracks affected MetadataPtrList *allMusic = gMusicData->all_music->getAllMetadata(); for (int x = 0; x < allMusic->count(); x++) { if ((allMusic->at(x)->ID() == m_sourceMetadata->ID()) || (allMusic->at(x)->getDirectoryId() == m_sourceMetadata->getDirectoryId())) { allMusic->at(x)->reloadAlbumArtImages(); gPlayer->sendAlbumArtChangedEvent(allMusic->at(x)->ID()); } } } } } }
bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri) { if (!magnetUri.isValid()) { MessageBoxRaised::critical(0, tr("Invalid magnet link"), tr("This magnet link was not recognized")); return false; } m_hash = magnetUri.hash(); // Prevent showing the dialog if download is already present if (BitTorrent::Session::instance()->isKnownTorrent(m_hash)) { BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash); if (torrent) { if (torrent->isPrivate()) { MessageBoxRaised::critical(0, tr("Already in download list"), tr("Torrent is already in download list. Trackers weren't merged because it is a private torrent."), QMessageBox::Ok); } else { torrent->addTrackers(magnetUri.trackers()); torrent->addUrlSeeds(magnetUri.urlSeeds()); MessageBoxRaised::information(0, tr("Already in download list"), tr("Magnet link is already in download list. Trackers were merged."), QMessageBox::Ok); } } else { MessageBoxRaised::critical(0, tr("Cannot add torrent"), tr("Cannot add this torrent. Perhaps it is already in adding."), QMessageBox::Ok); } return false; } connect(BitTorrent::Session::instance(), SIGNAL(metadataLoaded(BitTorrent::TorrentInfo)), SLOT(updateMetadata(BitTorrent::TorrentInfo))); // Set dialog title QString torrent_name = magnetUri.name(); setWindowTitle(torrent_name.isEmpty() ? tr("Magnet link") : torrent_name); setupTreeview(); // Set dialog position setdialogPosition(); BitTorrent::Session::instance()->loadMetadata(magnetUri); setMetadataProgressIndicator(true, tr("Retrieving metadata...")); ui->lblhash->setText(m_hash); return true; }
bool JpegRotator::exifTransform(const MetaEngineRotation& matrix) { FileWriteLocker lock(m_destFile); QFileInfo fi(m_file); if (!fi.exists()) { qCDebug(DIGIKAM_GENERAL_LOG) << "ExifRotate: file does not exist: " << m_file; return false; } if (!isJpegImage(m_file)) { // Not a jpeg image. qCDebug(DIGIKAM_GENERAL_LOG) << "ExifRotate: not a JPEG file: " << m_file; return false; } QList<TransformAction> actions = matrix.transformations(); if (actions.isEmpty()) { if (m_file != m_destFile) { copyFile(m_file, m_destFile); } return true; } QString dest = m_destFile; QString src = m_file; QString dir = fi.absolutePath(); QStringList unlinkLater; for (int i=0; i<actions.size(); i++) { SafeTemporaryFile* const temp = new SafeTemporaryFile(dir + QLatin1String("/JpegRotator-XXXXXX.digikamtempfile.jpg")); temp->setAutoRemove(false); temp->open(); QString tempFile = temp->fileName(); // Crash fix: a QTemporaryFile is not properly closed until its destructor is called. delete temp; if (!performJpegTransform(actions[i], src, tempFile)) { qCDebug(DIGIKAM_GENERAL_LOG) << "JPEG lossless transform failed for" << src; // See bug 320107 : if lossless transform cannot be achieve, do lossy transform. DImg srcImg; qCDebug(DIGIKAM_GENERAL_LOG) << "Trying lossy transform for " << src; if (!srcImg.load(src)) { ::unlink(QFile::encodeName(tempFile).constData()); return false; } if (actions[i] != MetaEngineRotation::NoTransformation) { srcImg.transform(actions[i]); } srcImg.setAttribute(QLatin1String("quality"), getJpegQuality(src)); if (!srcImg.save(tempFile, DImg::JPEG)) { qCDebug(DIGIKAM_GENERAL_LOG) << "Lossy transform failed for" << src; ::unlink(QFile::encodeName(tempFile).constData()); return false; } qCDebug(DIGIKAM_GENERAL_LOG) << "Lossy transform done for " << src; } if (i+1 != actions.size()) { // another round src = tempFile; unlinkLater << tempFile; continue; } // finalize updateMetadata(tempFile, matrix); // atomic rename if (DMetadata::hasSidecar(tempFile)) { QString sidecarTemp = DMetadata::sidecarPath(tempFile); QString sidecarDest = DMetadata::sidecarPath(dest); #ifdef Q_OS_WIN if (::MoveFileEx((LPCWSTR)sidecarTemp.utf16(), (LPCWSTR)sidecarDest.utf16(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH) == 0) #else if (::rename(QFile::encodeName(sidecarTemp).constData(), QFile::encodeName(sidecarDest).constData()) != 0) #endif { qCDebug(DIGIKAM_GENERAL_LOG) << "Renaming sidecar file" << sidecarTemp << "to" << sidecarDest << "failed"; unlinkLater << sidecarTemp; break; } } #ifdef Q_OS_WIN if (::MoveFileEx((LPCWSTR)tempFile.utf16(), (LPCWSTR)dest.utf16(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH) == 0) #else if (::rename(QFile::encodeName(tempFile).constData(), QFile::encodeName(dest).constData()) != 0) #endif { qCDebug(DIGIKAM_GENERAL_LOG) << "Renaming" << tempFile << "to" << dest << "failed"; unlinkLater << tempFile; break; } } foreach (const QString& tempFile, unlinkLater) { ::unlink(QFile::encodeName(tempFile).constData()); }
void InterpolatingGraph::updateMetadata(QMap<qint64, double> data) { for (QMap<qint64, double>::const_iterator i = data.constBegin(); i != data.constEnd(); i++) { updateMetadata(i.value()); } }
void VisualNavbar::fetchData() { // TODO: This code is quite verbose but very readable. The goal is to // experiment until we know what we want and then start to optimize. sections = Core()->getAllSections(); // Sort sections so we don't have to filter for overlaps afterwards qSort(sections.begin(), sections.end(), sortSectionLessThan); mappedSegments.clear(); for (SectionDescription section : sections) { bool segment_found = false; for (int i = 0; i < mappedSegments.count(); i++) { MappedSegment &mappedSegment = mappedSegments[i]; // Check if the segment contains the section bool segment_contains_section_start = false; if ((mappedSegment.address_from <= section.vaddr) && (section.vaddr <= mappedSegment.address_to)) { segment_contains_section_start = true; } bool segment_contains_section_end = false; if ((mappedSegment.address_from <= section.vaddr + section.vsize) && (section.vaddr + section.vsize <= mappedSegment.address_to)) { segment_contains_section_end = true; } // Check if the section contains the segment bool section_contains_segment_start = false; bool section_contains_segment_end = false; if ((section.vaddr <= mappedSegment.address_from) && (mappedSegment.address_from <= section.vaddr + section.vsize)) { section_contains_segment_start = true; } if ((section.vaddr <= mappedSegment.address_to) && (mappedSegment.address_to <= section.vaddr + section.vsize)) { section_contains_segment_end = true; } if (segment_contains_section_start | segment_contains_section_end | section_contains_segment_start | section_contains_segment_end) { if (section.vaddr < mappedSegment.address_from) { mappedSegment.address_from = section.vaddr; } if (mappedSegment.address_to < section.vaddr + section.vsize) { mappedSegment.address_to = section.vaddr + section.vsize; } segment_found = true; mappedSegment.sectionDescriptions.append(section); break; } } if (!segment_found) { MappedSegment mappedSegment; mappedSegment.address_from = section.vaddr; mappedSegment.address_to = section.vaddr + section.vsize; mappedSegment.sectionDescriptions.append(section); mappedSegments.append(mappedSegment); } } // If the file does not contain any sections we get the segments // from the memory maps instead. // It treats each map on its own, so overlapping maps will be shown // seperated. if (sections.count() == 0) { QJsonArray maps = Core()->cmdj("omj").array(); for (QJsonValue mapValue : maps) { QJsonObject map = mapValue.toObject(); MappedSegment mappedSegment; mappedSegment.address_from = map["from"].toVariant().toULongLong(); mappedSegment.address_to = map["to"].toVariant().toULongLong(); mappedSegments.append(mappedSegment); } } totalMappedSize = 0; for (auto &mappedSegment : mappedSegments) { totalMappedSize += mappedSegment.address_to - mappedSegment.address_from; } updateMetadata(); }
ComponentEditorWidget::ComponentEditorWidget(const Context& context, const FilePath& fp, QWidget* parent) : EditorWidgetBase(context, fp, parent), mUi(new Ui::ComponentEditorWidget) { mUi->setupUi(this); mUi->lstMessages->setHandler(this); setupErrorNotificationWidget(*mUi->errorNotificationWidget); setWindowIcon(QIcon(":/img/library/component.png")); // Insert category list editor widget. mCategoriesEditorWidget.reset( new ComponentCategoryListEditorWidget(mContext.workspace, this)); mCategoriesEditorWidget->setRequiresMinimumOneEntry(true); int row; QFormLayout::ItemRole role; mUi->formLayout->getWidgetPosition(mUi->lblCategories, &row, &role); mUi->formLayout->setWidget(row, QFormLayout::FieldRole, mCategoriesEditorWidget.data()); // Load element. mComponent.reset(new Component(std::unique_ptr<TransactionalDirectory>( new TransactionalDirectory(mFileSystem)))); // can throw mUi->signalEditorWidget->setReferences(mUndoStack.data(), &mComponent->getSignals()); mUi->symbolVariantsEditorWidget->setReferences( mUndoStack.data(), &mComponent->getSymbolVariants(), this); updateMetadata(); // Show "interface broken" warning when related properties are modified. memorizeComponentInterface(); setupInterfaceBrokenWarningWidget(*mUi->interfaceBrokenWarningWidget); connect(mUi->cbxSchematicOnly, &QCheckBox::toggled, this, &ComponentEditorWidget::undoStackStateModified); // Reload metadata on undo stack state changes. connect(mUndoStack.data(), &UndoStack::stateModified, this, &ComponentEditorWidget::updateMetadata); // Handle changes of metadata. connect(mUi->edtName, &QLineEdit::editingFinished, this, &ComponentEditorWidget::commitMetadata); connect(mUi->edtDescription, &PlainTextEdit::editingFinished, this, &ComponentEditorWidget::commitMetadata); connect(mUi->edtKeywords, &QLineEdit::editingFinished, this, &ComponentEditorWidget::commitMetadata); connect(mUi->edtAuthor, &QLineEdit::editingFinished, this, &ComponentEditorWidget::commitMetadata); connect(mUi->edtVersion, &QLineEdit::editingFinished, this, &ComponentEditorWidget::commitMetadata); connect(mUi->cbxDeprecated, &QCheckBox::clicked, this, &ComponentEditorWidget::commitMetadata); connect(mCategoriesEditorWidget.data(), &ComponentCategoryListEditorWidget::edited, this, &ComponentEditorWidget::commitMetadata); connect(mUi->cbxSchematicOnly, &QCheckBox::clicked, this, &ComponentEditorWidget::commitMetadata); connect(mUi->edtPrefix, &QLineEdit::editingFinished, this, &ComponentEditorWidget::commitMetadata); connect(mUi->edtDefaultValue, &PlainTextEdit::editingFinished, this, &ComponentEditorWidget::commitMetadata); connect(mUi->attributesEditorWidget, &AttributeListEditorWidget::edited, this, &ComponentEditorWidget::commitMetadata); }
void VisualNavbar::updateMetadataAndPaint() { qWarning() << "Update metadata & paint"; updateMetadata(); fillData(); }
void InterpolatingGraph::scaleToRange(double lower, double upper, PlotSettings::ScaleType scaleType) { if (scaleType == PlotSettings::NOT_SCALABLE) { // nothing to be done here return; } if (lower > upper) { // not a valid range return; } graph->clearData(); auto const& data = series.getData(); if (data.keys().takeLast() != lastUpdate) { updateMetadata(series.getData(lastUpdate, data.keys().takeLast())); } // rescale to new range for (auto i = data.constBegin(); i != data.constEnd(); ++i) { double scaledValue = i.value(); switch (scaleType) { case PlotSettings::LINSCALE: scaledValue = ((i.value() - currentMin) / (currentMax - currentMin)) * (upper - lower) + lower; break; case PlotSettings::LOGSCALE: { double log10 = qLn(10); double rangeFac = 1e-3; if (std::abs(currentMin) > currentMax) { // negative interval is wider // The log scale boundaries may never be zero or carry the wrong sign. // Cut off above rangeFac or currentMax, whichever is closer to zero (while still negative). double logScaleMin = std::min(-rangeFac, currentMin); double logScaleMax = std::min(-rangeFac, currentMax); if (i.value() > logScaleMax) { // invalid value. Draw outside visible area. scaledValue = upper + (upper - lower)*0.75; } else { scaledValue = upper - ((qLn(i.value()/logScaleMax)/log10) / (qLn(logScaleMin/logScaleMax)/log10)) * (upper - lower); } } else { // positive interval is wider // The log scale boundaries may never be zero or carry the wrong sign. // Cut off below rangeFac or currentMin, whichever is closer to zero (while still positive). double logScaleMin = std::max(rangeFac, currentMin); double logScaleMax = std::max(rangeFac, currentMax); if (i.value() < logScaleMin) { // invalid value. Draw outside visible area. scaledValue = lower - (upper - lower)*0.75; } else { scaledValue = lower + ((qLn(i.value()/logScaleMin)/log10) / (qLn(logScaleMax/logScaleMin)/log10)) * (upper - lower); } } break; } default: // unknown or unscalable scale type break; } graph->addData(i.key(), scaledValue); } }