feat(cpn): Identify new and changed models by italicising row (#3840)
* enh(cpn): identify new and changed models by italicising row * enh(cpn): identify drag n drop and new from template as changed
This commit is contained in:
@@ -129,6 +129,7 @@ class ModelData {
|
|||||||
char filename[16+1];
|
char filename[16+1];
|
||||||
char labels[100];
|
char labels[100];
|
||||||
int modelIndex; // Companion only, temporary index position managed by data model.
|
int modelIndex; // Companion only, temporary index position managed by data model.
|
||||||
|
bool modelUpdated; // Companion only, used to highlight if changed in models list
|
||||||
|
|
||||||
TimerData timers[CPN_MAX_TIMERS];
|
TimerData timers[CPN_MAX_TIMERS];
|
||||||
bool noGlobalFunctions;
|
bool noGlobalFunctions;
|
||||||
|
|||||||
@@ -739,7 +739,6 @@ void MdiChild::checkAndInitModel(int row)
|
|||||||
{
|
{
|
||||||
if (row < (int)radioData.models.size() && radioData.models[row].isEmpty()) {
|
if (row < (int)radioData.models.size() && radioData.models[row].isEmpty()) {
|
||||||
radioData.models[row].setDefaultValues(row, radioData.generalSettings);
|
radioData.models[row].setDefaultValues(row, radioData.generalSettings);
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -827,7 +826,7 @@ int MdiChild::newModel(int modelIndex)
|
|||||||
if (countUsedModels() == 1) {
|
if (countUsedModels() == 1) {
|
||||||
radioData.setCurrentModel(modelIndex);
|
radioData.setCurrentModel(modelIndex);
|
||||||
}
|
}
|
||||||
setModified();
|
setModelModified(modelIndex);
|
||||||
setSelectedModel(modelIndex);
|
setSelectedModel(modelIndex);
|
||||||
|
|
||||||
if (isNewModel) {
|
if (isNewModel) {
|
||||||
@@ -987,6 +986,7 @@ void MdiChild::pasteModelData(const QMimeData * mimeData, const QModelIndex row,
|
|||||||
strcpy(radioData.models[modelIdx].filename, radioData.getNextModelFilename().toStdString().c_str());
|
strcpy(radioData.models[modelIdx].filename, radioData.getNextModelFilename().toStdString().c_str());
|
||||||
lastSelectedModel = modelIdx; // after refresh the last pasted model will be selected
|
lastSelectedModel = modelIdx; // after refresh the last pasted model will be selected
|
||||||
modified = true;
|
modified = true;
|
||||||
|
setModelModified(modelIdx, false); // avoid unnecessary refreshes
|
||||||
if (doMove) {
|
if (doMove) {
|
||||||
deletesList.append(origMdlIdx);
|
deletesList.append(origMdlIdx);
|
||||||
removeModelFromCutList(origMdlIdx);
|
removeModelFromCutList(origMdlIdx);
|
||||||
@@ -1175,7 +1175,7 @@ void MdiChild::openModelWizard(int row)
|
|||||||
int res = wizard->exec();
|
int res = wizard->exec();
|
||||||
if (res == QDialog::Accepted && wizard->mix.complete /*TODO rather test the exec() result?*/) {
|
if (res == QDialog::Accepted && wizard->mix.complete /*TODO rather test the exec() result?*/) {
|
||||||
radioData.models[row] = wizard->mix;
|
radioData.models[row] = wizard->mix;
|
||||||
setModified();
|
setModelModified(row);
|
||||||
setSelectedModel(row);
|
setSelectedModel(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1200,7 +1200,7 @@ void MdiChild::openModelEditWindow(int row)
|
|||||||
ModelEdit * t = new ModelEdit(this, radioData, (row), firmware);
|
ModelEdit * t = new ModelEdit(this, radioData, (row), firmware);
|
||||||
gStopwatch.report("ModelEdit created");
|
gStopwatch.report("ModelEdit created");
|
||||||
t->setWindowTitle(tr("Editing model %1: ").arg(row+1) + QString(model.name) + QString(" (%1)").arg(userFriendlyCurrentFile()));
|
t->setWindowTitle(tr("Editing model %1: ").arg(row+1) + QString(model.name) + QString(" (%1)").arg(userFriendlyCurrentFile()));
|
||||||
connect(t, &ModelEdit::modified, this, &MdiChild::setModified);
|
connect(t, &ModelEdit::modified, this, &MdiChild::setCurrentModelModified);
|
||||||
gStopwatch.report("STARTING MODEL EDIT");
|
gStopwatch.report("STARTING MODEL EDIT");
|
||||||
t->show();
|
t->show();
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
@@ -1336,6 +1336,13 @@ bool MdiChild::saveFile(const QString & filename, bool setCurrent)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < (int)radioData.models.size(); i++) {
|
||||||
|
if (!radioData.models[i].isEmpty())
|
||||||
|
radioData.models[i].modelUpdated = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
|
||||||
if (setCurrent) {
|
if (setCurrent) {
|
||||||
setCurrentFile(filename);
|
setCurrentFile(filename);
|
||||||
}
|
}
|
||||||
@@ -1663,6 +1670,8 @@ void MdiChild::openModelTemplate(int row)
|
|||||||
for (int i = 0; i < CPN_MAX_MODULES; i++) {
|
for (int i = 0; i < CPN_MAX_MODULES; i++) {
|
||||||
radioData.models[row].moduleData[i].modelId = row + 1;
|
radioData.models[row].moduleData[i].modelId = row + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setModelModified(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MdiChild::openModelPrompt(int row)
|
void MdiChild::openModelPrompt(int row)
|
||||||
@@ -1818,3 +1827,17 @@ void MdiChild::exportSelectedModels()
|
|||||||
{
|
{
|
||||||
exportModels(getSelectedModels());
|
exportModels(getSelectedModels());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MdiChild::setCurrentModelModified()
|
||||||
|
{
|
||||||
|
setModelModified(getCurrentModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MdiChild::setModelModified(const int modelIndex, bool cascade)
|
||||||
|
{
|
||||||
|
if (modelIndex >= 0 && modelIndex < (int)radioData.models.size()) {
|
||||||
|
radioData.models[modelIndex].modelUpdated = true;
|
||||||
|
if (cascade)
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ class MdiChild : public QWidget
|
|||||||
void updateNavigation();
|
void updateNavigation();
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
void setModified();
|
void setModified();
|
||||||
|
void setCurrentModelModified();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void showModelsListContextMenu(const QPoint & pos);
|
void showModelsListContextMenu(const QPoint & pos);
|
||||||
void showLabelsContextMenu(const QPoint & pos);
|
void showLabelsContextMenu(const QPoint & pos);
|
||||||
@@ -228,6 +229,7 @@ class MdiChild : public QWidget
|
|||||||
const quint16 stateDataVersion;
|
const quint16 stateDataVersion;
|
||||||
AbstractStaticItemModel* modelSortOrderItemModel;
|
AbstractStaticItemModel* modelSortOrderItemModel;
|
||||||
QComboBox* cboModelSortOrder;
|
QComboBox* cboModelSortOrder;
|
||||||
|
void setModelModified(const int modelIndex, bool cascade = true);
|
||||||
};
|
};
|
||||||
|
|
||||||
// This will draw the drop indicator across all columns of a model View (vs. in just one column), and lets us make the indicator more obvious.
|
// This will draw the drop indicator across all columns of a model View (vs. in just one column), and lets us make the indicator more obvious.
|
||||||
|
|||||||
@@ -171,9 +171,12 @@ QVariant ModelsListModel::data(const QModelIndex & index, int role) const
|
|||||||
return item->data(index.column());
|
return item->data(index.column());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == Qt::FontRole && item->isModel() && item->getModelIndex() == (int)radioData->generalSettings.currModelIndex) {
|
if (role == Qt::FontRole && item->isModel()) {
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setBold(true);
|
if (item->getModelIndex() == (int)radioData->generalSettings.currModelIndex)
|
||||||
|
font.setBold(true);
|
||||||
|
if (radioData->models[item->getModelIndex()].modelUpdated)
|
||||||
|
font.setItalic(true);
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user