Moved warnings to another function
This commit is contained in:
parent
ba80b6b861
commit
8d757e96be
2 changed files with 16 additions and 8 deletions
|
|
@ -52,19 +52,15 @@ void MainWindow::onGridUpdated()
|
||||||
{
|
{
|
||||||
if (iter->size() > 1)
|
if (iter->size() > 1)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *topItem = new QTreeWidgetItem(ui->treeWarnings, QStringList{
|
QString warningTitle = QString("Color \"%1\" is used by several lines:").arg(iter.key());
|
||||||
QString("Color \"%1\" is used by several lines:").arg(iter.key())
|
QStringList warningDescription{};
|
||||||
});
|
|
||||||
|
|
||||||
for(int i = 0; i < iter->size(); i++)
|
for(int i = 0; i < iter->size(); i++)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *innerItem = new QTreeWidgetItem(topItem, QStringList {
|
warningDescription.push_back(QString("Line #%1").arg(iter->at(i)));
|
||||||
QString("Line #%1").arg(iter->at(i))
|
|
||||||
});
|
|
||||||
topItem->addChild(innerItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->treeWarnings->addTopLevelItem(topItem);
|
throwWarning(warningTitle, warningDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui->treeWarnings->expandAll();
|
ui->treeWarnings->expandAll();
|
||||||
|
|
@ -122,6 +118,17 @@ bool MainWindow::isSelectedLineCorrect(int line)
|
||||||
return line >= 0 && line < size && size > 0;
|
return line >= 0 && line < size && size > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::throwWarning(const QString &title, const QStringList &description)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *titleItem = new QTreeWidgetItem(ui->treeWarnings, QStringList{ title });
|
||||||
|
for (auto iter = description.begin(); iter != description.end(); iter++)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *descriptionItem = new QTreeWidgetItem(titleItem, QStringList{ *iter });
|
||||||
|
titleItem->addChild(descriptionItem);
|
||||||
|
}
|
||||||
|
ui->treeWarnings->addTopLevelItem(titleItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_buttonSave_clicked()
|
void MainWindow::on_buttonSave_clicked()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,6 @@ private:
|
||||||
int lastEditedLine = -1;
|
int lastEditedLine = -1;
|
||||||
|
|
||||||
bool isSelectedLineCorrect(int line);
|
bool isSelectedLineCorrect(int line);
|
||||||
|
void throwWarning(const QString &title, const QStringList &description);
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue