void UISettingsDialog::sltRevalidate(QIWidgetValidator *pValidator) { /* Get related settings page: */ UISettingsPage *pSettingsPage = qobject_cast<UISettingsPage*>(pValidator->widget()); AssertMsg(pSettingsPage, ("Validator should corresponds a page!\n")); /* Prepare empty warning & title: */ QString strWarning; QString strTitle = m_pSelector->itemTextByPage(pSettingsPage); /* Recorrelate page with others before revalidation: */ recorrelate(pSettingsPage); /* Revalidate the page: */ bool fValid = pSettingsPage->revalidate(strWarning, strTitle); /* Compose a message: */ strWarning = strWarning.isEmpty() ? QString() : tr("On the <b>%1</b> page, %2").arg(strTitle, strWarning); pValidator->setLastWarning(strWarning); fValid ? setWarning(strWarning) : setError(strWarning); /* Remember validation status: */ pValidator->setOtherValid(fValid); }
void LDLQuadLine::reportBadVertexOrder(int index1, int index2, int index3, int index4) { UCCHAR oldBuf[4][64]; UCCHAR newBuf[4][64]; int indices[4]; int i; indices[0] = index1; indices[1] = index2; indices[2] = index3; indices[3] = index4; for (i = 0; i < 4; i++) { printPoint(i, oldBuf[i]); printPoint(indices[i], newBuf[i]); } if (m_actionFlags.bfcClip) { setError(LDLEVertexOrder, TCLocalStrings::get(_UC("LDLQuadLineBfcBadVertSeq")), oldBuf[0], oldBuf[1], oldBuf[2], oldBuf[3], newBuf[0], newBuf[1], newBuf[2], newBuf[3]); } else { setWarning(LDLEVertexOrder, TCLocalStrings::get(_UC("LDLQuadLineBadVertSeq")), oldBuf[0], oldBuf[1], oldBuf[2], oldBuf[3], newBuf[0], newBuf[1], newBuf[2], newBuf[3]); } }
void LDLQuadLine::reportQuadSplit(bool flat, const int q1, const int q2, const int q3, const int q4, const int t1, const int t2, const int t3, const int t4, const int t5, const int t6) { UCCHAR q1Buf[64], q2Buf[64], q3Buf[64], q4Buf[64]; UCCHAR t1Buf[64], t2Buf[64], t3Buf[64], t4Buf[64], t5Buf[64], t6Buf[64]; CUCSTR errorTypeString = TCLocalStrings::get(_UC("LDLQuadLineConcave")); LDLErrorType errorType = LDLEConcaveQuad; if (!flat) { errorTypeString = TCLocalStrings::get(_UC("LDLQuadLineNonFlat")); errorType = LDLENonFlatQuad; } printPoint(q1, q1Buf); printPoint(q2, q2Buf); printPoint(q3, q3Buf); printPoint(q4, q4Buf); printPoint(t1, t1Buf); printPoint(t2, t2Buf); printPoint(t3, t3Buf); printPoint(t4, t4Buf); printPoint(t5, t5Buf); printPoint(t6, t6Buf); setWarning(errorType, TCLocalStrings::get(_UC("LDLQuadLineSpit")), errorTypeString, q1Buf, q2Buf, q3Buf, q4Buf, t1Buf, t2Buf, t3Buf, t4Buf, t5Buf, t6Buf); }
void LDLQuadLine::reportQuadSplit(bool flat, const int q1, const int q2, const int q3, const int q4, const int t1, const int t2, const int t3, const int t4, const int t5, const int t6) { UCSTRING q1Str, q2Str, q3Str, q4Str; UCSTRING t1Str, t2Str, t3Str, t4Str, t5Str, t6Str; CUCSTR errorTypeString = TCLocalStrings::get(_UC("LDLQuadLineConcave")); LDLErrorType errorType = LDLEConcaveQuad; if (!flat) { errorTypeString = TCLocalStrings::get(_UC("LDLQuadLineNonFlat")); errorType = LDLENonFlatQuad; } q1Str = printPoint(q1); q2Str = printPoint(q2); q3Str = printPoint(q3); q4Str = printPoint(q4); t1Str = printPoint(t1); t2Str = printPoint(t2); t3Str = printPoint(t3); t4Str = printPoint(t4); t5Str = printPoint(t5); t6Str = printPoint(t6); setWarning(errorType, TCLocalStrings::get(_UC("LDLQuadLineSpit")), errorTypeString, q1Str.c_str(), q2Str.c_str(), q3Str.c_str(), q4Str.c_str(), t1Str.c_str(), t2Str.c_str(), t3Str.c_str(), t4Str.c_str(), t5Str.c_str(), t6Str.c_str()); }
void LDLQuadLine::reportBadVertexOrder(int index1, int index2, int index3, int index4) { UCSTRING oldStr[4]; UCSTRING newStr[4]; int indices[4]; int i; indices[0] = index1; indices[1] = index2; indices[2] = index3; indices[3] = index4; for (i = 0; i < 4; i++) { oldStr[i] = printPoint(i); newStr[i] = printPoint(indices[i]); } if (m_actionFlags.bfcClip) { setError(LDLEVertexOrder, TCLocalStrings::get(_UC("LDLQuadLineBfcBadVertSeq")), oldStr[0].c_str(), oldStr[1].c_str(), oldStr[2].c_str(), oldStr[3].c_str(), newStr[0].c_str(), newStr[1].c_str(), newStr[2].c_str(), newStr[3].c_str()); } else { setWarning(LDLEVertexOrder, TCLocalStrings::get(_UC("LDLQuadLineBadVertSeq")), oldStr[0].c_str(), oldStr[1].c_str(), oldStr[2].c_str(), oldStr[3].c_str(), newStr[0].c_str(), newStr[1].c_str(), newStr[2].c_str(), newStr[3].c_str()); } }
void QtUserSearchWindow::show() { clear(); if (type_ == AddContact) { setWarning(boost::optional<std::string>()); } QWidget::show(); raise(); }
void InputGeneratorWidget::updatePreviewTextImmediately() { // If the dialog is not shown, delay the update in case we need to prompt the // user to overwrite changes. Set the m_updatePending flag to true so we'll // know to update in the show event. if (!isVisible()) { m_updatePending = true; return; } // Reset the update throttling m_updatePending = false; // Have any buffers been modified? if (!m_dirtyTextEdits.isEmpty()) { QStringList buffers; foreach (QTextEdit* edit, m_dirtyTextEdits) buffers << m_textEdits.key(edit, tr("Unknown")); QString message = tr("The following file(s) have been modified:\n\n%1\n\n" "Would you like to overwrite your changes to reflect " "the new geometry or job options?", "", buffers.size()) .arg(buffers.join("\n")); int response = QMessageBox::question( this, tr("Overwrite modified input files?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (static_cast<QMessageBox::StandardButton>(response) != QMessageBox::Yes) { // Prevent updates while restoring the option cache: bool oldUpdatePending = m_updatePending; m_updatePending = true; // Restore cached options. applyOptions(m_optionCache); m_updatePending = oldUpdatePending; return; } } if (!m_molecule) return; // Generate the input files QJsonObject inputOptions; inputOptions["options"] = collectOptions(); bool success = m_inputGenerator.generateInput(inputOptions, *m_molecule); if (!m_inputGenerator.warningList().isEmpty()) { QString warningHtml; warningHtml += "<style>li{color:red;}h3{font-weight:bold;}</style>"; warningHtml += "<h3>" + tr("Problems occured during input generation:") + "</h3>"; warningHtml += "<ul>"; foreach (const QString& warning, m_inputGenerator.warningList()) warningHtml += QString("<li>%1</li>").arg(warning); warningHtml += "</ul>"; setWarning(warningHtml); } else {
void WorksheetWidget::fetchWorksheet(const QDate& startDate, const QDate& endDate) { disconnect(ui->startDate, SIGNAL(dateChanged(QDate)), m_fetchTimer, SLOT(start())); disconnect(ui->endDate, SIGNAL(dateChanged(QDate)), m_fetchTimer, SLOT(start())); ui->startDate->setDate(startDate); ui->endDate->setDate(endDate); connect(ui->startDate, SIGNAL(dateChanged(QDate)), m_fetchTimer, SLOT(start())); connect(ui->endDate, SIGNAL(dateChanged(QDate)), m_fetchTimer, SLOT(start())); m_fetcher->fetchWorksheet(startDate, endDate); if(startDate > endDate) setWarning("Start date is greater than end date"); else setWarning(QString::null); }
void WorksheetWidget::finished() { if(WorksheetModel* model = qobject_cast<WorksheetModel*>(ui->tableView->model())) model->setWorkLog(m_fetcher->workLog()); if(!m_fetcher->lastError().isNull()) setWarning(m_fetcher->lastError()); ui->totalTimeLabel->setText("Total time spent: " + Entry::formatTimeSpent(total())); }
LDLFileLineArray *LDLQuadLine::removeColinearPoint(void) { LDLFileLineArray *fileLineArray = NULL; LDLTriangleLine *triangleLine1 = NULL; LDLTriangleLine *triangleLine2 = NULL; switch (m_colinearIndex) { case 0: triangleLine1 = newTriangleLine(0, 1, 2); triangleLine2 = newTriangleLine(2, 3, 0); break; case 1: triangleLine1 = newTriangleLine(1, 2, 3); triangleLine2 = newTriangleLine(3, 0, 1); break; case 2: triangleLine1 = newTriangleLine(2, 3, 0); triangleLine2 = newTriangleLine(0, 1, 2); break; case 3: triangleLine1 = newTriangleLine(3, 0, 1); triangleLine2 = newTriangleLine(1, 2, 3); break; default: break; } if (triangleLine1 != NULL && triangleLine2 != NULL) { fileLineArray = new LDLFileLineArray(2); fileLineArray->addObject(triangleLine1); fileLineArray->addObject(triangleLine2); triangleLine1->release(); triangleLine2->release(); } if (fileLineArray != NULL) { setWarning(LDLEColinear, ls(_UC("LDLQuadLineCoLinear")), m_colinearIndex + 1); } else { setError(LDLEGeneral, ls(_UC("LDLQuadLineCoLinearError"))); } return fileLineArray; }
LDLFileLineArray *LDLQuadLine::removeMatchingPoint(void) { LDLFileLineArray *fileLineArray = removePoint(m_matchingIndex); if (fileLineArray) { UCCHAR pointBuf[64] = _UC(""); printPoint(m_matchingIndex, pointBuf); setWarning(LDLEMatchingPoints, TCLocalStrings::get(_UC("LDLQuadLineIdentical")), m_matchingIndex + 1, pointBuf); } else { setError(LDLEGeneral, TCLocalStrings::get(_UC("LDLQuadLineIdenticalError"))); } return fileLineArray; }
LDLFileLineArray *LDLQuadLine::removeMatchingPoint(void) { LDLFileLineArray *fileLineArray = removePoint(m_matchingIndex); if (fileLineArray) { UCSTRING pointStr; pointStr = printPoint(m_matchingIndex); setWarning(LDLEMatchingPoints, TCLocalStrings::get(_UC("LDLQuadLineIdentical")), m_matchingIndex + 1, pointStr.c_str()); } else { setError(LDLEGeneral, TCLocalStrings::get(_UC("LDLQuadLineIdenticalError"))); } return fileLineArray; }
/* Wenn Aktiv, dann werden an die Verbrucher am Output die von ihnen benötigten Energien gesendet. Die Energie die zum aufladen am Input benötigt wird, wird nur teilweise in elektrische Energie umgesetzt, der rest wird als Wärme an die Radiatoren abgegeben. */ void Battery::calculateStep() { std::vector<Port*> inputEnergy = collectAllActiveSubSystemsWithClassifier(inputStreams_,"Energy[J]"); std::vector<Port*> outputEnergy = collectAllActiveSubSystemsWithClassifier(outputStreams_,"Energy[J]"); std::vector<Port*> inputHeat = collectAllActiveSubSystemsWithClassifier(inputStreams_,"Heat[J]"); std::vector<Port*> outputHeat = collectAllActiveSubSystemsWithClassifier(outputStreams_,"Heat[J]"); double inE = getPortValuesSum(inputEnergy); double outE = getPortValuesSum(outputEnergy); double inH = getPortValuesSum(inputHeat); double outH = getPortValuesSum(outputHeat); if(isActive()) { //Neue Ladung der Batterie. Auf- und Entladung sind verlustbehaftet. double elecE = inE * eff_ - outE * (1/eff_); c_ = c_ + elecE; //Energie die als Wärme beim Auf- und Entladen entsteht. double heat = elecE * (1 - eff_); //Temperaturdiffernz durch Wärme, Heater und Radiatoren double deltaT = (heat - (outH) + inH) / (m_ * heatCap_); //Daraus ergibt sich die Temperatur t_ = t_ + deltaT; //Wenn diese Temperatur größer oder kleiner ist als die Maximalwerte, //dann soll die Batterie keine Energie mehr liefern und auch nicht mehr //aufladen können, was im else Teil der Abfrage geregelt wird. if( (t_<maxT_) && (t_>minT_) ){ //Energie Anforderung an die Input-Energieströme senden. if(c_<mc_){ writePortValuesEqual(inputEnergy,cr_*(*simTime_)); }else{ writePortValuesEqual(inputEnergy,0.0); } //Energie entsprechend der entladerate an die Verbraucher senden, wenn noch if(c_>outE){ std::vector<Port*>::iterator it; for (it = outputEnergy.begin(); it!=outputEnergy.end(); ++it){ double v = (*it)->getValue(); (*it)->setValue(v*dcr_*(*simTime_)); } }else{ writePortValuesEqual(outputEnergy,0.0); } }else{ //Die Batterie soll nicht aufgeladen werden, wenn sie nicht nominell funktioniert writePortValuesEqual(inputEnergy,0.0); //Es soll keine Energie an die Verbruacher gesendet werden, wenn der //Betrieb nicht nominell ist. writePortValuesEqual(outputEnergy,0.0); } //Wärme Anforderung an die Heater senden sobald Abweichung -3 Kelvin beträgt if(t_<tOperating_-3){ double heatDemand = (tOperating_-t_) * m_ * heatCap_; writePortValuesEqual(inputHeat,heatDemand); //Radiation auf Null sezten writePortValuesEqual(outputHeat,0.0); } //Wärme-Abgabe Anforderung an die Radiatoren senden sobald Abweichung von +3 Kelvin if(t_>tOperating_+3){ double radDemand = (t_-tOperating_) * m_ * heatCap_; writePortValuesEqual(outputHeat,radDemand); //Heat auf Null setzen writePortValuesEqual(inputHeat,0.0); } if((t_<tOperating_+3) && (t_>tOperating_-3)){ //Heat und Radiation auf Null setzen writePortValuesEqual(inputHeat,0.0); writePortValuesEqual(outputHeat,0.0); } } if(!isActive()) { writePortValuesEqual(inputEnergy,0.0); writePortValuesEqual(outputEnergy,0.0); writePortValuesEqual(inputHeat,0.0); writePortValuesEqual(outputHeat,0.0); } //Nominal if(((c_/mc_) > 0.15 ) && (t_<maxT_) && (t_>minT_)) setNominal(); //Anzeige von Warnungen if( ((c_/mc_) < 0.15 ) || (t_>(tOperating_+3)) || (t_<(tOperating_-3))) setWarning(); //Anzeige von Fehlern if(((c_/mc_) < 0.00001 ) || (t_>maxT_) || (t_<minT_)) setError(); }
void UISettingsDialog::sltHandleValidityChanged(const QIWidgetValidator * /* pValidator */) { /* Get validators list: */ QList<QIWidgetValidator*> validatorsList(findChildren<QIWidgetValidator*>()); /* Detect ERROR presence: */ { setError(QString()); QString strError; bool fNewValid = true; for (int i = 0; i < validatorsList.size(); ++i) { QIWidgetValidator *pValidator = validatorsList[i]; fNewValid = pValidator->isValid(); if (!fNewValid) { strError = pValidator->warningText(); if (strError.isNull()) strError = pValidator->lastWarning(); break; } } /* Try to set the generic error message when invalid * but no specific message is provided: */ if (m_strErrorString.isNull() && !strError.isNull()) setError(strError); m_fValid = fNewValid; m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_fValid); m_pWarningPane->setWarningPixmap(m_errorIcon); m_pWarningPane->setWarningText(m_strErrorHint); #ifdef Q_WS_MAC m_pWarningPane->setToolTip(m_strErrorString); #endif /* Q_WS_MAC */ if (m_fValid && m_pStatusBar->currentWidget() == m_pWarningPane) m_pStatusBar->setCurrentIndex(0); else if (!m_fValid && m_pStatusBar->currentIndex() == 0) m_pStatusBar->setCurrentWidget(m_pWarningPane); if (!m_fValid) return; } /* Detect WARNING presence: */ { setWarning(QString()); QString strWarning; bool fNewSilent = true; for (int i = 0; i < validatorsList.size(); ++i) { QIWidgetValidator *pValidator = validatorsList[i]; if (!pValidator->warningText().isNull() || !pValidator->lastWarning().isNull()) { fNewSilent = false; strWarning = pValidator->warningText(); if (strWarning.isNull()) strWarning = pValidator->lastWarning(); break; } } /* Try to set the generic error message when invalid * but no specific message is provided: */ if (m_strWarningString.isNull() && !strWarning.isNull()) setWarning(strWarning); m_fSilent = fNewSilent; m_pWarningPane->setWarningPixmap(m_warningIcon); m_pWarningPane->setWarningText(m_strWarningHint); #ifdef Q_WS_MAC m_pWarningPane->setToolTip(m_strWarningString); #endif /* Q_WS_MAC */ if (m_fSilent && m_pStatusBar->currentWidget() == m_pWarningPane) m_pStatusBar->setCurrentIndex(0); else if (!m_fSilent && m_pStatusBar->currentIndex() == 0) m_pStatusBar->setCurrentWidget(m_pWarningPane); } }
bool LDLQuadLine::swapNeeded(int index1, int index2, int index3, int index4) { TCVector &p1 = m_points[index1]; TCVector &p2 = m_points[index2]; TCVector &p3 = m_points[index3]; TCVector &p4 = m_points[index4]; TCVector normal1 = (p1 - p4) * (p1 - p2); TCVector normal2 = (p2 - p1) * (p2 - p3); TCVector normal3 = (p3 - p2) * (p3 - p4); TCVector normal4 = (p4 - p3) * (p4 - p1); TCFloat length1 = normal1.length(); TCFloat length2 = normal2.length(); TCFloat length3 = normal3.length(); TCFloat length4 = normal4.length(); TCFloat dotProduct; bool nonFlat = false; if (fEq(length1, 0.0) || fEq(length2, 0.0) || fEq(length3, 0.0) || fEq(length4, 0.0)) { return false; } normal1 /= length1; normal2 /= length2; normal3 /= length3; normal4 /= length4; if ((dotProduct = normal1.dot(normal2)) <= 0.0) { return true; } if (dotProduct <= 0.9) { nonFlat = true; } if ((dotProduct = normal1.dot(normal3)) <= 0.0) { return true; } if (dotProduct <= 0.9) { nonFlat = true; } if ((dotProduct = normal1.dot(normal4)) <= 0.0) { return true; } if (dotProduct <= 0.9) { nonFlat = true; } if ((dotProduct = normal2.dot(normal3)) <= 0.0) { return true; } if (dotProduct <= 0.9) { nonFlat = true; } if ((dotProduct = normal2.dot(normal4)) <= 0.0) { return true; } if (dotProduct <= 0.9) { nonFlat = true; } if ((dotProduct = normal3.dot(normal4)) <= 0.0) { return true; } if (dotProduct <= 0.9) { nonFlat = true; } if (nonFlat) { setWarning(LDLENonFlatQuad, TCLocalStrings::get(_UC("LDLQuadLineNonFlatError"))); } return false; }
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) : m_buildConfiguration(bc), m_configModel(new ConfigModel(this)), m_configFilterModel(new Utils::CategorySortFilterModel), m_configTextFilterModel(new Utils::CategorySortFilterModel) { QTC_CHECK(bc); setDisplayName(tr("CMake")); auto vbox = new QVBoxLayout(this); vbox->setMargin(0); auto container = new Utils::DetailsWidget; container->setState(Utils::DetailsWidget::NoSummary); vbox->addWidget(container); auto details = new QWidget(container); container->setWidget(details); auto mainLayout = new QGridLayout(details); mainLayout->setMargin(0); mainLayout->setColumnStretch(1, 10); auto project = static_cast<CMakeProject *>(bc->project()); auto buildDirChooser = new Utils::PathChooser; buildDirChooser->setBaseFileName(project->projectDirectory()); buildDirChooser->setFileName(bc->buildDirectory()); connect(buildDirChooser, &Utils::PathChooser::rawPathChanged, this, [this](const QString &path) { m_configModel->flush(); // clear out config cache... m_buildConfiguration->setBuildDirectory(Utils::FileName::fromString(path)); }); int row = 0; mainLayout->addWidget(new QLabel(tr("Build directory:")), row, 0); mainLayout->addWidget(buildDirChooser->lineEdit(), row, 1); mainLayout->addWidget(buildDirChooser->buttonAtIndex(0), row, 2); ++row; mainLayout->addItem(new QSpacerItem(20, 10), row, 0); ++row; m_errorLabel = new QLabel; m_errorLabel->setPixmap(Utils::Icons::CRITICAL.pixmap()); m_errorLabel->setVisible(false); m_errorMessageLabel = new QLabel; m_errorMessageLabel->setVisible(false); auto boxLayout = new QHBoxLayout; boxLayout->addWidget(m_errorLabel); boxLayout->addWidget(m_errorMessageLabel); mainLayout->addLayout(boxLayout, row, 0, 1, 3, Qt::AlignHCenter); ++row; m_warningLabel = new QLabel; m_warningLabel->setPixmap(Utils::Icons::WARNING.pixmap()); m_warningLabel->setVisible(false); m_warningMessageLabel = new QLabel; m_warningMessageLabel->setVisible(false); auto boxLayout2 = new QHBoxLayout; boxLayout2->addWidget(m_warningLabel); boxLayout2->addWidget(m_warningMessageLabel); mainLayout->addLayout(boxLayout2, row, 0, 1, 3, Qt::AlignHCenter); ++row; mainLayout->addItem(new QSpacerItem(20, 10), row, 0); ++row; m_filterEdit = new Utils::FancyLineEdit; m_filterEdit->setPlaceholderText(tr("Filter")); m_filterEdit->setFiltering(true); mainLayout->addWidget(m_filterEdit, row, 0, 1, 2); ++row; auto tree = new Utils::TreeView; connect(tree, &Utils::TreeView::activated, tree, [tree](const QModelIndex &idx) { tree->edit(idx); }); m_configView = tree; m_configView->viewport()->installEventFilter(this); m_configFilterModel->setSourceModel(m_configModel); m_configFilterModel->setFilterKeyColumn(0); m_configFilterModel->setFilterRole(ConfigModel::ItemIsAdvancedRole); m_configFilterModel->setFilterFixedString("0"); m_configTextFilterModel->setSourceModel(m_configFilterModel); m_configTextFilterModel->setSortRole(Qt::DisplayRole); m_configTextFilterModel->setFilterKeyColumn(-1); m_configTextFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); connect(m_configTextFilterModel, &QAbstractItemModel::layoutChanged, this, [this]() { QModelIndex selectedIdx = m_configView->currentIndex(); if (selectedIdx.isValid()) m_configView->scrollTo(selectedIdx); }); m_configView->setModel(m_configTextFilterModel); m_configView->setMinimumHeight(300); m_configView->setUniformRowHeights(true); m_configView->setSortingEnabled(true); m_configView->sortByColumn(0, Qt::AscendingOrder); auto stretcher = new Utils::HeaderViewStretcher(m_configView->header(), 0); m_configView->setSelectionMode(QAbstractItemView::SingleSelection); m_configView->setSelectionBehavior(QAbstractItemView::SelectItems); m_configView->setFrameShape(QFrame::NoFrame); m_configView->setItemDelegate(new ConfigModelItemDelegate(m_buildConfiguration->project()->projectDirectory(), m_configView)); QFrame *findWrapper = Core::ItemViewFind::createSearchableWrapper(m_configView, Core::ItemViewFind::LightColored); findWrapper->setFrameStyle(QFrame::StyledPanel); m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicatorSize::Large, findWrapper); m_progressIndicator->attachToWidget(findWrapper); m_progressIndicator->raise(); m_progressIndicator->hide(); m_showProgressTimer.setSingleShot(true); m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks connect(&m_showProgressTimer, &QTimer::timeout, [this]() { m_progressIndicator->show(); }); mainLayout->addWidget(findWrapper, row, 0, 1, 2); auto buttonLayout = new QVBoxLayout; m_addButton = new QPushButton(tr("&Add")); m_addButton->setToolTip(tr("Add a new configuration value.")); buttonLayout->addWidget(m_addButton); { m_addButtonMenu = new QMenu; m_addButtonMenu->addAction(tr("&Boolean"))->setData( QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::BOOLEAN))); m_addButtonMenu->addAction(tr("&String"))->setData( QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::STRING))); m_addButtonMenu->addAction(tr("&Directory"))->setData( QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::DIRECTORY))); m_addButtonMenu->addAction(tr("&File"))->setData( QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::FILE))); m_addButton->setMenu(m_addButtonMenu); } m_editButton = new QPushButton(tr("&Edit")); m_editButton->setToolTip(tr("Edit the current CMake configuration value.")); buttonLayout->addWidget(m_editButton); m_unsetButton = new QPushButton(tr("&Unset")); m_unsetButton->setToolTip(tr("Unset a value in the CMake configuration.")); buttonLayout->addWidget(m_unsetButton); m_resetButton = new QPushButton(tr("&Reset")); m_resetButton->setToolTip(tr("Reset all unapplied changes.")); m_resetButton->setEnabled(false); buttonLayout->addWidget(m_resetButton); buttonLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::Fixed)); m_showAdvancedCheckBox = new QCheckBox(tr("Advanced")); buttonLayout->addWidget(m_showAdvancedCheckBox); buttonLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding)); mainLayout->addLayout(buttonLayout, row, 2); connect(m_configView->selectionModel(), &QItemSelectionModel::currentChanged, this, &CMakeBuildSettingsWidget::updateSelection); ++row; m_reconfigureButton = new QPushButton(tr("Apply Configuration Changes")); m_reconfigureButton->setEnabled(false); mainLayout->addWidget(m_reconfigureButton, row, 0, 1, 3); updateAdvancedCheckBox(); setError(bc->error()); setWarning(bc->warning()); connect(project, &ProjectExplorer::Project::parsingStarted, this, [this]() { updateButtonState(); m_configView->setEnabled(false); m_showProgressTimer.start(); }); if (m_buildConfiguration->isParsing()) m_showProgressTimer.start(); else { m_configModel->setConfiguration(m_buildConfiguration->configurationFromCMake()); m_configView->expandAll(); } connect(project, &ProjectExplorer::Project::parsingFinished, this, [this, buildDirChooser, stretcher]() { m_configModel->setConfiguration(m_buildConfiguration->configurationFromCMake()); m_configView->expandAll(); m_configView->setEnabled(true); stretcher->stretch(); updateButtonState(); buildDirChooser->triggerChanged(); // refresh valid state... m_showProgressTimer.stop(); m_progressIndicator->hide(); }); connect(m_buildConfiguration, &CMakeBuildConfiguration::errorOccured, this, [this]() { m_showProgressTimer.stop(); m_progressIndicator->hide(); }); connect(m_configTextFilterModel, &QAbstractItemModel::modelReset, this, [this, stretcher]() { m_configView->expandAll(); stretcher->stretch(); }); connect(m_configModel, &QAbstractItemModel::dataChanged, this, &CMakeBuildSettingsWidget::updateButtonState); connect(m_configModel, &QAbstractItemModel::modelReset, this, &CMakeBuildSettingsWidget::updateButtonState); connect(m_showAdvancedCheckBox, &QCheckBox::stateChanged, this, &CMakeBuildSettingsWidget::updateAdvancedCheckBox); connect(m_filterEdit, &QLineEdit::textChanged, m_configTextFilterModel, &QSortFilterProxyModel::setFilterFixedString); connect(m_resetButton, &QPushButton::clicked, m_configModel, &ConfigModel::resetAllChanges); connect(m_reconfigureButton, &QPushButton::clicked, this, [this]() { m_buildConfiguration->setConfigurationForCMake(m_configModel->configurationForCMake()); }); connect(m_unsetButton, &QPushButton::clicked, this, [this]() { m_configModel->toggleUnsetFlag(mapToSource(m_configView, m_configView->currentIndex())); }); connect(m_editButton, &QPushButton::clicked, this, [this]() { QModelIndex idx = m_configView->currentIndex(); if (idx.column() != 1) idx = idx.sibling(idx.row(), 1); m_configView->setCurrentIndex(idx); m_configView->edit(idx); }); connect(m_addButtonMenu, &QMenu::triggered, this, [this](QAction *action) { ConfigModel::DataItem::Type type = static_cast<ConfigModel::DataItem::Type>(action->data().value<int>()); QString value = tr("<UNSET>"); if (type == ConfigModel::DataItem::BOOLEAN) value = QString::fromLatin1("OFF"); m_configModel->appendConfiguration(tr("<UNSET>"), value, type); const Utils::TreeItem *item = m_configModel->findNonRootItem([&value, type](Utils::TreeItem *item) { ConfigModel::DataItem dataItem = ConfigModel::dataItemFromIndex(item->index()); return dataItem.key == tr("<UNSET>") && dataItem.type == type && dataItem.value == value; }); QModelIndex idx = m_configModel->indexForItem(item); idx = m_configTextFilterModel->mapFromSource(m_configFilterModel->mapFromSource(idx)); m_configView->scrollTo(idx); m_configView->setCurrentIndex(idx); m_configView->edit(idx); }); connect(bc, &CMakeBuildConfiguration::errorOccured, this, &CMakeBuildSettingsWidget::setError); connect(bc, &CMakeBuildConfiguration::warningOccured, this, &CMakeBuildSettingsWidget::setWarning); updateFromKit(); connect(m_buildConfiguration->target(), &ProjectExplorer::Target::kitChanged, this, &CMakeBuildSettingsWidget::updateFromKit); connect(m_buildConfiguration, &CMakeBuildConfiguration::enabledChanged, this, [this]() { setError(m_buildConfiguration->disabledReason()); setConfigurationForCMake(); }); connect(m_buildConfiguration, &CMakeBuildConfiguration::configurationForCMakeChanged, this, [this]() { setConfigurationForCMake(); }); updateSelection(QModelIndex(), QModelIndex()); }