COPASI API  4.16.103
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
CQMessageBox Class Reference

#include <CQMessageBox.h>

Inheritance diagram for CQMessageBox:
Inheritance graph
[legend]
Collaboration diagram for CQMessageBox:
Collaboration graph
[legend]

Public Member Functions

 CQMessageBox (Icon icon, const QString &title, const QString &text, StandardButtons buttons=NoButton, QWidget *parent=0, Qt::WindowFlags f=Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint)
 
void setFilteredText (const QString &text)
 
void setText (const QString &text)
 
 ~CQMessageBox ()
 

Static Public Member Functions

static StandardButton confirmDelete (QWidget *parent, const QString &objectType, const QString &objects, const std::set< const CCopasiObject * > &deletedObjects)
 
static StandardButton critical (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
 
static StandardButton information (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
 
static StandardButton question (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
 
static StandardButton warning (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
 

Protected Attributes

QWidget * mpPage1
 
QWidget * mpPage2
 
QTabWidget * mpTabWidget
 
QTextEdit * mpText1
 
QTextEdit * mpText2
 
QVBoxLayout * mpVerticalLayoutPage1
 
QVBoxLayout * mpVerticalLayoutPage2
 

Detailed Description

Definition at line 27 of file CQMessageBox.h.

Constructor & Destructor Documentation

CQMessageBox::CQMessageBox ( Icon  icon,
const QString &  title,
const QString &  text,
StandardButtons  buttons = NoButton,
QWidget *  parent = 0,
Qt::WindowFlags  f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint 
)

Definition at line 35 of file CQMessageBox.cpp.

References CopasiUI3Window::getMainWindow(), mpPage1, mpTabWidget, mpText1, mpVerticalLayoutPage1, and CopasiUI3Window::setMessageShown().

Referenced by critical(), information(), question(), and warning().

37  :
38  QMessageBox(icon, title, QString(), buttons, parent, f),
39  mpTabWidget(NULL),
40  mpPage1(NULL),
42  mpText1(NULL),
43  mpPage2(NULL),
45  mpText2(NULL)
46 {
47  if (CopasiUI3Window::getMainWindow() != NULL)
48  {
50  }
51 
52  mpTabWidget = new QTabWidget(this);
53  mpTabWidget->setObjectName(QString::fromUtf8("mpTabWidget"));
54  mpTabWidget->setMinimumSize(QSize(400, 200));
55 
56  mpPage1 = new QWidget();
57  mpPage1->setObjectName(QString::fromUtf8("mpPage1"));
58 
59  mpVerticalLayoutPage1 = new QVBoxLayout(mpPage1);
60  mpVerticalLayoutPage1->setMargin(2);
61  mpVerticalLayoutPage1->setObjectName(QString::fromUtf8("mpVerticalLayoutPage1"));
62 
63  mpText1 = new QTextEdit(mpPage1);
64  mpText1->setObjectName(QString::fromUtf8("mpText1"));
65  mpText1->setReadOnly(true);
66  mpText1->setText(text);
67  mpVerticalLayoutPage1->addWidget(mpText1);
68 
69  mpTabWidget->addTab(mpPage1, QString("Messages"));
70 
71  // The code below is derived from qt-4.4.3/src/gui/dialogs/qmessagebox.cpp
72  static_cast<QGridLayout *>(layout())->addWidget(mpTabWidget, 0, 1, 1, 1);
73  QLabel * pLabel = findChild<QLabel *>("qt_msgbox_label");
74 
75  if (pLabel != NULL)
76  pLabel->hide();
77 }
QVBoxLayout * mpVerticalLayoutPage2
Definition: CQMessageBox.h:68
QWidget * mpPage1
Definition: CQMessageBox.h:64
static CopasiUI3Window * getMainWindow()
QVBoxLayout * mpVerticalLayoutPage1
Definition: CQMessageBox.h:65
QTabWidget * mpTabWidget
Definition: CQMessageBox.h:63
QTextEdit * mpText1
Definition: CQMessageBox.h:66
QTextEdit * mpText2
Definition: CQMessageBox.h:69
void setMessageShown(const bool &shown)
QWidget * mpPage2
Definition: CQMessageBox.h:67
CQMessageBox::~CQMessageBox ( )

Definition at line 79 of file CQMessageBox.cpp.

References CopasiUI3Window::getMainWindow(), and CopasiUI3Window::setMessageShown().

80 {
81  if (CopasiUI3Window::getMainWindow() != NULL)
82  {
84  }
85 }
static CopasiUI3Window * getMainWindow()
void setMessageShown(const bool &shown)

Member Function Documentation

QMessageBox::StandardButton CQMessageBox::confirmDelete ( QWidget *  parent,
const QString &  objectType,
const QString &  objects,
const std::set< const CCopasiObject * > &  deletedObjects 
)
static

Definition at line 151 of file CQMessageBox.cpp.

References CFunctionDB::appendDependentFunctions(), CModel::appendDependentModelObjects(), CCopasiDataModel::appendDependentTasks(), FROM_UTF8, CCopasiRootContainer::getDatamodelList(), CCopasiRootContainer::getFunctionList(), CCopasiDataModel::getModel(), and question().

Referenced by CQReportDefinition::btnDeleteReportClicked(), CQParameterSetsDM::removeRows(), CQReportDM::removeRows(), CQLayoutsDM::removeRows(), CQReactionDM::removeRows(), CQFunctionDM::removeRows(), CQEventDM::removeRows(), CQGlobalQuantityDM::removeRows(), CQCompartmentDM::removeRows(), CQSpecieDM::removeRows(), ReactionsWidget1::saveToReaction(), CQReactionDM::setEquation(), FunctionWidget1::slotBtnDelete(), ReactionsWidget1::slotBtnDelete(), CQSpeciesDetail::slotBtnDelete(), CQCompartment::slotBtnDelete(), and CQModelValue::slotBtnDelete().

154 {
155  if (deletedObjects.size() == 0)
156  return QMessageBox::Ok;
157 
158  // Determine the affected data model
159  const CCopasiDataModel * pDataModel = (*deletedObjects.begin())->getObjectDataModel();
160 
161  // Determine the affected function DB
162  CFunctionDB * pFunctionDB =
163  dynamic_cast< CFunctionDB * >((*deletedObjects.begin())->getObjectAncestor("FunctionDB"));
164 
165  if (pDataModel == NULL &&
166  pFunctionDB == NULL)
167  return QMessageBox::Ok;
168 
169  if (pFunctionDB != NULL)
170  {
171  // TODO In case a function is deleted we need to loop through all data models
172  pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
173  }
174  else
175  {
177  }
178 
179  QString msg =
180  QString("Do you want to delete the listed %1?\n %2\n").arg(objectType, objects);
181 
182  std::set< const CCopasiObject * > Functions;
183  std::set< const CCopasiObject * > Reactions;
184  std::set< const CCopasiObject * > Metabolites;
185  std::set< const CCopasiObject * > Values;
186  std::set< const CCopasiObject * > Compartments;
187  std::set< const CCopasiObject * > Events;
188  std::set< const CCopasiObject * > Tasks;
189 
190  bool Used = false;
191 
192  if (pFunctionDB != NULL)
193  {
194  Used |= pFunctionDB->appendDependentFunctions(deletedObjects, Functions);
195 
196  if (Functions.size() > 0)
197  {
198  msg.append("Following functions(s) reference above and will be deleted:\n ");
199 
200  std::set< const CCopasiObject * >::const_iterator it = Functions.begin();
201  std::set< const CCopasiObject * >::const_iterator end = Functions.end();
202 
203  for (; it != end; ++it)
204  {
205  msg.append(FROM_UTF8((*it)->getObjectName()));
206  msg.append("\n ");
207  }
208 
209  msg.remove(msg.length() - 2, 2);
210  }
211  }
212 
213  const CModel * pModel = NULL;
214 
215  if (pDataModel != NULL)
216  {
217  pModel = pDataModel->getModel();
218 
219  // We need to check the tasks
220  Used |= pDataModel->appendDependentTasks(deletedObjects, Tasks);
221 
222  if (Tasks.size() > 0)
223  {
224  msg.append("Following task(s) reference above and will be modified:\n ");
225 
226  std::set< const CCopasiObject * >::const_iterator it = Tasks.begin();
227  std::set< const CCopasiObject * >::const_iterator end = Tasks.end();
228 
229  for (; it != end; ++it)
230  {
231  msg.append(FROM_UTF8((*it)->getObjectName()));
232  msg.append("\n ");
233  }
234 
235  msg.remove(msg.length() - 2, 2);
236  }
237  }
238 
239  if (pModel != NULL)
240  {
241  Used |= pModel->appendDependentModelObjects(deletedObjects, Reactions, Metabolites,
242  Compartments, Values, Events);
243 
244  if (Reactions.size() > 0)
245  {
246  msg.append("Following reactions(s) reference above and will be deleted:\n ");
247 
248  std::set< const CCopasiObject * >::const_iterator it = Reactions.begin();
249  std::set< const CCopasiObject * >::const_iterator end = Reactions.end();
250 
251  for (; it != end; ++it)
252  {
253  msg.append(FROM_UTF8((*it)->getObjectName()));
254  msg.append("\n ");
255  }
256 
257  msg.remove(msg.length() - 2, 2);
258  }
259 
260  if (Metabolites.size() > 0)
261  {
262  msg.append("Following species reference above and will be deleted:\n ");
263 
264  std::set< const CCopasiObject * >::const_iterator it = Metabolites.begin();
265  std::set< const CCopasiObject * >::const_iterator end = Metabolites.end();
266 
267  for (; it != end; ++it)
268  {
269  msg.append(FROM_UTF8((*it)->getObjectName()));
270  msg.append("\n ");
271  }
272 
273  msg.remove(msg.length() - 2, 2);
274  }
275 
276  if (Values.size() > 0)
277  {
278  msg.append("Following global quantities reference above and will be deleted:\n ");
279 
280  std::set< const CCopasiObject * >::const_iterator it = Values.begin();
281  std::set< const CCopasiObject * >::const_iterator end = Values.end();
282 
283  for (; it != end; ++it)
284  {
285  msg.append(FROM_UTF8((*it)->getObjectName()));
286  msg.append("\n ");
287  }
288 
289  msg.remove(msg.length() - 2, 2);
290  }
291 
292  if (Compartments.size() > 0)
293  {
294  msg.append("Following compartment(s) reference above and will be deleted:\n ");
295 
296  std::set< const CCopasiObject * >::const_iterator it = Compartments.begin();
297  std::set< const CCopasiObject * >::const_iterator end = Compartments.end();
298 
299  for (; it != end; ++it)
300  {
301  msg.append(FROM_UTF8((*it)->getObjectName()));
302  msg.append("\n ");
303  }
304 
305  msg.remove(msg.length() - 2, 2);
306  }
307 
308  if (Events.size() > 0)
309  {
310  msg.append("Following event(s) reference above and will be deleted:\n ");
311 
312  std::set< const CCopasiObject * >::const_iterator it = Events.begin();
313  std::set< const CCopasiObject * >::const_iterator end = Events.end();
314 
315  for (; it != end; ++it)
316  {
317  msg.append(FROM_UTF8((*it)->getObjectName()));
318  msg.append("\n ");
319  }
320 
321  msg.remove(msg.length() - 2, 2);
322  }
323  }
324 
325  StandardButton choice = QMessageBox::Ok;
326 
327  if (Used)
328  {
329  choice = CQMessageBox::question(parent, "CONFIRM DELETE", msg,
330  QMessageBox::Ok | QMessageBox::Cancel,
331  QMessageBox::Cancel);
332  }
333 
334  return choice;
335 }
objectType
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
bool appendDependentTasks(std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependentTasks) const
bool appendDependentModelObjects(const std::set< const CCopasiObject * > &candidates, std::set< const CCopasiObject * > &dependentReactions, std::set< const CCopasiObject * > &dependentMetabolites, std::set< const CCopasiObject * > &dependentCompartments, std::set< const CCopasiObject * > &dependentModelValues, std::set< const CCopasiObject * > &dependentEvents) const
Definition: CModel.cpp:2364
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
bool appendDependentFunctions(std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependentFunctions) const
static CFunctionDB * getFunctionList()
Definition: CModel.h:50
static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
QMessageBox::StandardButton CQMessageBox::critical ( QWidget *  parent,
const QString &  title,
const QString &  text,
StandardButtons  buttons = Ok,
StandardButton  defaultButton = NoButton 
)
static

Definition at line 135 of file CQMessageBox.cpp.

References CQMessageBox(), and CopasiUI3Window::isMainThread().

Referenced by DataModelGUI::buildChangedObjects(), TaskWidget::commonBeforeRunTask(), TaskWidget::commonRunTask(), CQGLLayoutPainter::draw(), CQGLLayoutPainter::draw_bitmap(), CQNewMainWindow::export_bitmap(), CQGLLayoutPainter::export_bitmap(), TaskWidget::finishTask(), CQFittingWidget::loadTask(), main(), CQBarChart::saveDataToFile(), CQMiriamWidget::showEvent(), CQPreferenceDialog::slotBtnOk(), CopasiUI3Window::slotExportMathModelFinished(), CopasiUI3Window::slotExportSBMLToStringFinished(), FunctionWidget1::slotFcnDescriptionChanged(), CopasiUI3Window::slotFileOpenFinished(), CopasiUI3Window::slotFileSaveFinished(), TaskWidget::slotFinishThread(), CopasiUI3Window::slotImportSBMLFinished(), CopasiUI3Window::slotImportSBMLFromStringFinished(), CQTimeSeriesWidget::slotSave(), PlotWindow::slotSaveData(), CQExpressionWidget::slotSelectObject(), and CopasiUI3Window::slotUpdateMIRIAMFinished().

138 {
140  return defaultButton;
141 
142  CQMessageBox * pMessageBox = new CQMessageBox(QMessageBox::Critical, title, text, buttons, parent);
143  pMessageBox->setDefaultButton(defaultButton);
144  StandardButton choice = (StandardButton) pMessageBox->exec();
145  delete pMessageBox;
146 
147  return choice;
148 }
CQMessageBox(Icon icon, const QString &title, const QString &text, StandardButtons buttons=NoButton, QWidget *parent=0, Qt::WindowFlags f=Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint)
static bool isMainThread()
QMessageBox::StandardButton CQMessageBox::information ( QWidget *  parent,
const QString &  title,
const QString &  text,
StandardButtons  buttons = Ok,
StandardButton  defaultButton = NoButton 
)
static

Definition at line 88 of file CQMessageBox.cpp.

References CQMessageBox(), and CopasiUI3Window::isMainThread().

Referenced by SliderSettingsDialog::browseButtonPressed(), CopasiUI3Window::checkPendingMessages(), checkSelection(), CProgressBar::closeEvent(), SliderDialog::createNewSlider(), SliderDialog::createSlidersForFolder(), SliderDialog::deleteInvalidSliders(), TaskWidget::finishTask(), SliderDialog::getCSlidersForObject(), CopasiFileDialog::getSaveFileName(), CQBarChart::hotKeysMessage(), FunctionWidget1::leave(), SliderSettingsDialog::logCheckBoxToggled(), SliderSettingsDialog::minValueChanged(), CopasiFileDialog::openExampleDir(), CQTabWidget::save(), CQReportDefinition::save(), CQSpeciesDetail::save(), CQFunctionDM::setData(), CQSpecieDM::setData(), CopasiUI3Window::slotConvertToIrreversible(), CQTSSAWidget::slotDuration(), CQTrajectoryWidget::slotDuration(), CQExperimentData::slotExperimentChanged(), TaskWidget::slotFinishThread(), CQTSSAWidget::slotIntervals(), CQTrajectoryWidget::slotIntervals(), CQTSSAWidget::slotIntervalSize(), CQTrajectoryWidget::slotIntervalSize(), CQCrossSectionTaskWidget::slotOutputConvergence(), CQCrossSectionTaskWidget::slotOutputCrossings(), CQCrossSectionTaskWidget::slotOutputDelay(), CopasiUI3Window::slotQuit(), CQCrossSectionTaskWidget::slotUpdateConvergence(), CQCrossSectionTaskWidget::slotUpdateCrossings(), and WizardDialog::textBrowser_anchorClicked().

91 {
93  return defaultButton;
94 
95  CQMessageBox * pMessageBox = new CQMessageBox(QMessageBox::Information, title, text, buttons, parent);
96  pMessageBox->setDefaultButton(defaultButton);
97  StandardButton choice = (StandardButton) pMessageBox->exec();
98  delete pMessageBox;
99 
100  return choice;
101 }
CQMessageBox(Icon icon, const QString &title, const QString &text, StandardButtons buttons=NoButton, QWidget *parent=0, Qt::WindowFlags f=Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint)
static bool isMainThread()
QMessageBox::StandardButton CQMessageBox::question ( QWidget *  parent,
const QString &  title,
const QString &  text,
StandardButtons  buttons = Ok,
StandardButton  defaultButton = NoButton 
)
static

Definition at line 103 of file CQMessageBox.cpp.

References CQMessageBox(), and CopasiUI3Window::isMainThread().

Referenced by CQReportDefinition::btnAdvancedClicked(), checkSelection(), TaskWidget::commonRunTask(), confirmDelete(), DataModelGUI::importCellDesigner(), CopasiUI3Window::importSBMLFromString(), CQReportDefinitionSelect::loadReportDefinitionVector(), SliderSettingsDialog::maxValueChanged(), SliderSettingsDialog::minValueChanged(), CopasiUI3Window::newDoc(), CQModifiedDM::removeRows(), CQBiologicalDescriptionDM::removeRows(), CQReferenceDM::removeRows(), CQCreatorDM::removeRows(), CQParameterSetsWidget::slotBtnClearClicked(), CQPlotsWidget::slotBtnClearClicked(), CQEventsWidget::slotBtnClearClicked(), CQReactionsWidget::slotBtnClearClicked(), CQReportsWidget::slotBtnClearClicked(), CQCompartmentsWidget::slotBtnClearClicked(), CQFunctionsWidget::slotBtnClearClicked(), CQGlobalQuantitiesWidget::slotBtnClearClicked(), CQSpeciesWidget::slotBtnClearClicked(), CQLayoutsWidget::slotBtnClearClicked(), CQMiriamWidget::slotBtnClearClicked(), CQParameterOverviewWidget::slotBtnNew(), CopasiUI3Window::slotFileOpen(), CopasiUI3Window::slotFileOpenFinished(), CopasiUI3Window::slotImportSBML(), CCopasiPlotSelectionDialog::slotOKButtonClicked(), and CopasiUI3Window::slotQuit().

106 {
108  return defaultButton;
109 
110  CQMessageBox * pMessageBox = new CQMessageBox(QMessageBox::Question, title, text, buttons, parent);
111  pMessageBox->setDefaultButton(defaultButton);
112  StandardButton choice = (StandardButton) pMessageBox->exec();
113  delete pMessageBox;
114 
115  return choice;
116 }
CQMessageBox(Icon icon, const QString &title, const QString &text, StandardButtons buttons=NoButton, QWidget *parent=0, Qt::WindowFlags f=Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint)
static bool isMainThread()
void CQMessageBox::setFilteredText ( const QString &  text)

Definition at line 342 of file CQMessageBox.cpp.

References mpPage2, mpTabWidget, mpText2, and mpVerticalLayoutPage2.

Referenced by CopasiUI3Window::checkPendingMessages().

343 {
344  if (!text.isEmpty() && mpPage2 == NULL)
345  {
346  mpPage2 = new QWidget();
347  mpPage2->setObjectName(QString::fromUtf8("mpPage2"));
348 
349  mpVerticalLayoutPage2 = new QVBoxLayout(mpPage2);
350  mpVerticalLayoutPage2->setMargin(2);
351  mpVerticalLayoutPage2->setObjectName(QString::fromUtf8("mpVerticalLayoutPage2"));
352 
353  mpText2 = new QTextEdit(mpPage2);
354  mpText2->setObjectName(QString::fromUtf8("mpText2"));
355  mpText2->setReadOnly(true);
356  mpVerticalLayoutPage2->addWidget(mpText2);
357  mpTabWidget->addTab(mpPage2, QString("Minor Issues"));
358  }
359 
360  mpText2->setText(text);
361 }
QVBoxLayout * mpVerticalLayoutPage2
Definition: CQMessageBox.h:68
QTabWidget * mpTabWidget
Definition: CQMessageBox.h:63
QTextEdit * mpText2
Definition: CQMessageBox.h:69
QWidget * mpPage2
Definition: CQMessageBox.h:67
void CQMessageBox::setText ( const QString &  text)

Definition at line 337 of file CQMessageBox.cpp.

References mpText1.

Referenced by CopasiUI3Window::slotFileSave().

338 {
339  mpText1->setText(text);
340 }
QTextEdit * mpText1
Definition: CQMessageBox.h:66
QMessageBox::StandardButton CQMessageBox::warning ( QWidget *  parent,
const QString &  title,
const QString &  text,
StandardButtons  buttons = Ok,
StandardButton  defaultButton = NoButton 
)
static

Definition at line 119 of file CQMessageBox.cpp.

References CQMessageBox(), and CopasiUI3Window::isMainThread().

Referenced by CCopasiSelectionDialog::chooseCellMatrix(), CQRDFTreeView::enterProtected(), CQGLLayoutPainter::export_bitmap(), CQLayoutMainWindow::saveImage(), CopasiUI3Window::slotFileOpenFinished(), CopasiUI3Window::slotFileSaveFinished(), and CQLayoutMainWindow::startAnimation().

122 {
124  return defaultButton;
125 
126  CQMessageBox * pMessageBox = new CQMessageBox(QMessageBox::Warning, title, text, buttons, parent);
127  pMessageBox->setDefaultButton(defaultButton);
128  StandardButton choice = (StandardButton) pMessageBox->exec();
129  delete pMessageBox;
130 
131  return choice;
132 }
CQMessageBox(Icon icon, const QString &title, const QString &text, StandardButtons buttons=NoButton, QWidget *parent=0, Qt::WindowFlags f=Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint)
static bool isMainThread()

Member Data Documentation

QWidget* CQMessageBox::mpPage1
protected

Definition at line 64 of file CQMessageBox.h.

Referenced by CQMessageBox().

QWidget* CQMessageBox::mpPage2
protected

Definition at line 67 of file CQMessageBox.h.

Referenced by setFilteredText().

QTabWidget* CQMessageBox::mpTabWidget
protected

Definition at line 63 of file CQMessageBox.h.

Referenced by CQMessageBox(), and setFilteredText().

QTextEdit* CQMessageBox::mpText1
protected

Definition at line 66 of file CQMessageBox.h.

Referenced by CQMessageBox(), and setText().

QTextEdit* CQMessageBox::mpText2
protected

Definition at line 69 of file CQMessageBox.h.

Referenced by setFilteredText().

QVBoxLayout* CQMessageBox::mpVerticalLayoutPage1
protected

Definition at line 65 of file CQMessageBox.h.

Referenced by CQMessageBox().

QVBoxLayout* CQMessageBox::mpVerticalLayoutPage2
protected

Definition at line 68 of file CQMessageBox.h.

Referenced by setFilteredText().


The documentation for this class was generated from the following files: