21 #include <QGridLayout>
22 #include <QHeaderView>
24 #include <QPushButton>
25 #include <QTableWidget>
26 #include <QTableWidgetItem>
29 const int top_panel_height = 80;
34 const QString& documentVersion)
35 : QDialog(parent), m_messageService(messageService), m_projectDocumentVersion(documentVersion)
37 setMinimumSize(256, 256);
39 setWindowTitle(
"Problems encountered while loading project");
40 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
42 auto mainLayout =
new QVBoxLayout;
49 setLayout(mainLayout);
50 setAttribute(Qt::WA_DeleteOnClose,
true);
56 auto result =
new QWidget(
this);
57 auto layout =
new QHBoxLayout;
59 auto warningLabel =
new QLabel;
60 warningLabel->setPixmap(QPixmap(
":/images/warning_64x64.png"));
62 auto warningWidget =
new QWidget;
63 warningWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
64 warningWidget->resize(top_panel_height, top_panel_height);
65 auto warningWidgetLayout =
new QHBoxLayout;
66 warningWidgetLayout->addWidget(warningLabel);
67 warningWidget->setLayout(warningWidgetLayout);
71 titleFont.setBold(
true);
73 auto messageLabel =
new QLabel();
74 messageLabel->setFont(titleFont);
75 messageLabel->setText(
"Some parts of the project were not loaded correctly.");
76 messageLabel->setWordWrap(
true);
78 layout->addWidget(warningWidget);
79 layout->addWidget(messageLabel);
80 layout->setContentsMargins(0, 0, 0, 0);
81 result->setLayout(layout);
89 auto result =
new QWidget(
this);
90 auto layout =
new QHBoxLayout;
92 auto line =
new QFrame();
93 line->setFrameShape(QFrame::VLine);
94 line->setFrameShadow(QFrame::Sunken);
96 auto gridLayout =
new QGridLayout;
99 for (
int irow = 0; irow < names.size(); ++irow) {
100 gridLayout->addWidget(
new QLabel(names.at(irow)), irow, 0);
101 gridLayout->addWidget(
new QLabel(
"WARNINGS"), irow, 1);
104 layout->addWidget(line);
105 layout->addLayout(gridLayout);
106 layout->addWidget(
new QWidget);
108 layout->setContentsMargins(0, 0, 0, 0);
110 result->setLayout(layout);
117 auto result =
new QWidget(
this);
118 auto layout =
new QVBoxLayout;
122 titleFont.setBold(
true);
124 auto whyLabel =
new QLabel;
125 whyLabel->setFont(titleFont);
126 whyLabel->setText(
"Why did this happen to me?");
128 auto explanationLabel =
new QLabel;
130 explanationLabel->setWordWrap(
true);
132 auto whatLabel =
new QLabel;
133 whatLabel->setFont(titleFont);
134 whatLabel->setText(
"What to do?");
136 auto adviceLabel =
new QLabel;
137 QString adviceText(
"Check parameters of your items and re-enter uninitialized values. "
138 "Use detailed log below to get a hint what went wrong. "
139 "After that, save you project and work as normal.");
140 adviceLabel->setText(adviceText);
141 adviceLabel->setWordWrap(
true);
143 layout->addWidget(whyLabel);
144 layout->addWidget(explanationLabel);
145 layout->addWidget(whatLabel);
146 layout->addWidget(adviceLabel);
148 layout->setContentsMargins(0, 0, 0, 0);
150 result->setLayout(layout);
157 auto result =
new QWidget(
this);
158 auto layout =
new QVBoxLayout;
162 titleFont.setBold(
true);
164 auto detailsLabel =
new QLabel;
165 detailsLabel->setFont(titleFont);
166 detailsLabel->setText(
"Details");
168 layout->addWidget(detailsLabel);
171 layout->setContentsMargins(0, 0, 0, 0);
173 result->setLayout(layout);
180 auto result =
new QTableWidget;
181 result->setWordWrap(
true);
184 result->setStyleSheet(
185 "QToolTip { color: #ffffff; background-color: #fcfcfc; border: 1px solid black; }");
190 result->verticalHeader()->setVisible(
false);
191 result->horizontalHeader()->setStretchLastSection(
true);
197 result->setItem(rowCount, 2,
createTableItem(message->messageDescription()));
201 result->resizeRowsToContents();
208 auto result =
new QHBoxLayout;
210 auto button =
new QPushButton(
"Close",
this);
211 button->setAutoDefault(
false);
212 connect(button, &QPushButton::clicked,
this, &ProjectLoadWarningDialog::close);
214 result->addStretch(3);
215 result->setContentsMargins(0, 0, 0, 0);
216 result->addWidget(button);
230 return QStringList() <<
"Sender"
237 auto result =
new QTableWidgetItem(
name);
238 result->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
241 QString toolTip = QString(
"<font color=black>%1</font>").arg(
name);
242 result->setToolTip(toolTip);
253 QString(
"Given project was created using BornAgain version %1 "
254 " which is different from version %2 you are currently using. "
255 "At the moment we provide only limited support for import from older versions.")
260 QString(
"Given project was created using BornAgain version %1 "
261 "which is the same as the current version of the framework. "
262 "Strangely enough, some parts was not loaded correctly due to format mismatch. "
263 "Please contact developpers.")
Defines class DesignerHelper.
Defines class GUIHelpers functions.
Defines class GUIMessage.
Defines MessageService class.
Defines class ProjectLoadWarningDialog.
static int getSectionFontSize()
The service to collect messages from different senders.
const QList< GUIMessage * > messages() const
QStringList senderList() const
QWidget * createModelInfoPanel()
Info panel with summary over warnings in different models.
QStringList tableHeaderLabels() const
Returns labels for table header.
QWidget * createExplanationPanel()
Info panel with explanations what had happened and what to do.
QTableWidgetItem * createTableItem(const QString &name)
const MessageService * m_messageService
ProjectLoadWarningDialog(QWidget *parent, const MessageService *messageService=0, const QString &documentVersion="")
int numberOfTableRows() const
Returns number of rows in table with error messages, each row represents an error message.
QString explanationText() const
Returns explanations what went wrong.
QWidget * createDetailsPanel()
Info panel with table widget containing error messages.
QWidget * createTopPanel()
Top panel with warning icon and the header.
QTableWidget * createTableWidget()
Creates QTableWidget and fills it with error messages.
QString m_projectDocumentVersion
QString getBornAgainVersionString()
QString const & name(EShape k)