COPASI API  4.16.103
listviews.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2002 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /****************************************************************************
16  ** $ CopasiUI/listviews.cpp
17  ** $ Author : Ankur Gupta
18  ** $ Author : Mudita Singhal
19  ** $ Author : Mrinmayee Kulkarni
20  **
21  ** This file contains the definition of the routines declared in listviews.h header
22  ** file.
23  **
24  ** This file is used to create the visual tree based on the information obtained from the data
25  ** model about the tree
26  **********************************************************************/
27 #include <QtCore/QObject>
28 #include <QtGui/QImage>
29 #include <QtCore/QMap>
30 #include <QtGui/QSortFilterProxyModel>
31 
32 #include "DataModelGUI.h"
33 #include "CQMessageBox.h"
34 #include "CQBrowserPane.h"
35 #include "CQBrowserPaneDM.h"
36 
37 #include "CQModelWidget.h"
38 #include "CQCompartmentsWidget.h"
39 #include "CQCompartment.h"
40 #include "CQEventsWidget.h"
41 #include "CQEventWidget1.h"
42 #include "CQFunctionsWidget.h"
43 #include "FunctionWidget1.h"
44 #ifdef HAVE_MML
45 # include "CQDifferentialEquations.h"
46 #endif // HAVE_MML
47 #include "CQLyapWidget.h"
48 #include "CQLyapResultWidget.h"
49 #include "CQSpeciesWidget.h"
50 #include "CQSpeciesDetail.h"
52 #include "CQModelValue.h"
53 #include "CQParameterSetsWidget.h"
54 #include "CQEFMWidget.h"
55 #include "CQEFMResultWidget.h"
56 #include "CQMoietiesTaskResult.h"
57 #include "CQMoietiesTaskWidget.h"
59 #include "CQReactionsWidget.h"
60 #include "ReactionsWidget1.h"
61 #include "SteadyStateWidget.h"
62 #include "CQSteadyStateResult.h"
63 #include "ScanWidget.h"
64 #include "SensitivitiesWidget.h"
65 #include "CQSensResultWidget.h"
66 #include "CQOptimizationWidget.h"
67 #include "CQOptimizationResult.h"
68 #include "CQReportsWidget.h"
69 #include "CQSplashWidget.h"
70 #include "CQTrajectoryWidget.h"
71 #include "CQTimeSeriesWidget.h"
72 #include "CQTSSAWidget.h"
73 #include "CQTSSAResultWidget.h"
74 #ifdef COPASI_DEBUG
75 #include "CQUpdatesWidget.h"
76 #endif //COPASI_DEBUG
77 #undef DELETE
78 #include "listviews.h"
79 #include "qtUtilities.h"
80 #include "CQFittingWidget.h"
81 #include "CQFittingResult.h"
82 #include "CQMCAWidget.h"
83 #include "CMCAResultWidget.h"
84 #include "CQLNAWidget.h"
85 #include "CLNAResultWidget.h"
86 #include "CQReportDefinition.h"
87 #include "CQPlotsWidget.h"
88 #include "CQMathMatrixWidget.h"
90 
91 #include "CQTabWidget.h"
92 
93 #include "UI/CQLayoutsWidget.h"
94 
95 #include "copasi.h"
96 
101 #include "plotUI/CQPlotSubwidget.h"
102 #include "model/CModel.h"
104 
105 #ifdef COPASI_NONLIN_DYN_OSCILLATION
106 #include "CQOscillationTaskWidget.h"
107 #endif
108 
109 // static
110 const std::string ListViews::ObjectTypeName[] =
111 {
112  "Species", // METABOLITE
113  "Compartment", // COMPARTMENT
114  "Reaction", // REACTION
115  "Function", // FUNCTION
116  "Model", // MODEL
117  "State", // STATE
118  "Report", // REPORT
119  "Plot", // PLOT
120  "Global Quantity", // MODELVALUE
121  "Event", // EVENT
122  "Annotation", // MIRIAM
123  "Layout", // LAYOUT
124  "Parameter Overview", // PARAMETEROVERVIEW
125  "Parameter Set", // MODELPARAMETERSET
126  ""
127 };
128 
129 // -----------------------------------------------------------------
130 //////////////////////////////////////////////////////////////////////////
131 // Definitions of the ListViews class as declared in listviews.h
132 /////////////////////////////////////////////////////////////////////////
133 
134 /*********ListViews::ListViews(QWidget *parent, const char *name)************
135  **
136  ** Parameters:- 1. QWidget* :- The parameter needed by the base class i.e QSplitter
137  ** 2. char* :- The name parameter needed by the base class, i.e., QSplitter
138  ** Returns :- It does not return anything size its 2 argument constructor
139  ** Description:- This is the constructor of the ListViews and is used to
140  ** set up all the requirement and initialization of the
141  ** components in the code.
142  ************************************************************/
143 ListViews::ListViews(QWidget *parent, const char *name):
144 
145  QSplitter(Qt::Horizontal, parent),
146  mpDataModelGUI(NULL),
147  mpTreeDM(NULL),
148  mpTreeSortDM(NULL),
149  mpMathModel(NULL),
150  mpCurrentWidget(NULL),
151  mCurrentItemKey(),
152  mpCMCAResultWidget(NULL),
153  mpCQMCAWidget(NULL),
154  mpCQLNAWidget(NULL),
155  mpCLNAResultWidget(NULL),
156  mpCompartmentsWidget(NULL),
157  compartmentsWidget1(NULL),
158  defaultWidget(NULL),
159  differentialEquations(NULL),
160  eventsWidget(NULL),
161  eventWidget1(NULL),
162  mpFunctionsWidget(NULL),
163  functionWidget1(NULL),
164  lyapWidget(NULL),
165  lyapResultWidget(NULL),
166  mpSpeciesWidget(NULL),
167  metabolitesWidget1(NULL),
168  modelWidget(NULL),
169  mpGlobalQuantitiesWidget(NULL),
170  mpModelValueWidget(NULL),
171  mpEFMWidget(NULL),
172  mpEFMResultWidget(NULL),
173  mpMoietiesTaskResult(NULL),
174  mpMoietiesTaskWidget(NULL),
175  optimizationWidget(NULL),
176  optResultWidget(NULL),
177  paramFittingWidget(NULL),
178  mpFittingResultWidget(NULL),
179  mpParameterOverviewWidget(NULL),
180  mpParameterSetsWidget(NULL),
181  mpParameterSetWidget(NULL),
182  mpPlotsWidget(NULL),
183  mpPlotSubwidget(NULL),
184  mpReactionsWidget(NULL),
185  reactionsWidget1(NULL),
186  scanWidget(NULL),
187  sensWidget(NULL),
188  sensResultWidget(NULL),
189  stateWidget(NULL),
190  steadystateWidget(NULL),
191  mpReportsWidget(NULL),
192  tableDefinition1(NULL),
193  timeSeriesWidget(NULL),
194  trajectoryWidget(NULL),
195  tssaWidget(NULL),
196  tssaResultWidget(NULL),
197  crossSectionTaskWidget(NULL),
198  crossSectionTimeSeriesWidget(NULL),
199 #ifdef COPASI_NONLIN_DYN_OSCILLATION
200  oscillationTaskWidget(NULL),
201 #endif
202 #ifdef COPASI_DEBUG
203  mpUpdatesWidget(NULL),
204 #endif
205  mpLayoutsWidget(NULL),
206  mpMathMatrixWidget(NULL)
207 {
208  // Qt3 support to Qt4 reference states . . .
209  // "Use the QSizePolicy() constructor and call the setHorizontalStretch(), setVerticalStretch(), and setHeightForWidth() functions instead."
210  // The stretch was set at "1 ,1", before, but maybe it doesn't need to be explicitly set now.
211  this->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
212 
213  setChildrenCollapsible(false);
214 
215  // create a new QListview to be displayed on the screen..and set its property
216  mpTreeView = new CQBrowserPane(this);
217  mpTreeDM = new CQBrowserPaneDM(this);
218  mpTreeSortDM = new QSortFilterProxyModel(this);
219 
220  mpTreeSortDM->setSourceModel(mpTreeDM);
221  mpTreeSortDM->setSortRole(Qt::EditRole);
222  mpTreeSortDM->setSortCaseSensitivity(Qt::CaseInsensitive);
223  // pSortModel->sort(0, Qt::AscendingOrder);
224 
225  mpTreeView->setModel(mpTreeSortDM);
226  mpTreeView->sortByColumn(0, Qt::AscendingOrder);
227 
228  mpStackedWidget = new QStackedWidget(this);
229  addWidget(mpTreeView);
230  addWidget(mpStackedWidget);
231 
232  if (!opaqueResize())
233  setOpaqueResize();
234 
235  defaultWidget = new CQSplashWidget(this);
236  mpStackedWidget->addWidget(defaultWidget);
237 
238  mpCurrentWidget = defaultWidget; // keeps track of the mpCurrentWidget in use
239  mCurrentItemKey = "";
240  mpStackedWidget->setCurrentWidget(defaultWidget);
241 
242  QList<int> Sizes = sizes();
243  Sizes[0] = 240;
244  Sizes[1] = 560;
245  setSizes(Sizes);
246 
247  // establishes the communication between the mpTreeView clicked and the routine called....
248  connect(mpTreeDM, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
249  this, SLOT(slotSort(const QModelIndex &, const QModelIndex &)));
250 }
251 
253 {
254  //TODO clean up
255  if (mpLayoutsWidget != NULL)
257 }
258 
259 /************************ListViews::setDataModel(DataModel<Folder>* dm)----------->
260  **
261  ** Parameters:- DataModel<Folder>* :- pointer to the data model to be used by all the
262  ** views
263  ** Returns :- void(Nothing)
264  ** Description:-This method is used to set the datamodel to be used by the
265  ** listview class to extract the data from the data-model
266  ************************************************************************************/
268 {
269  //First Disconnect updateCompleteView() and notifyView() from DataModelGUI
270  if (mpDataModelGUI)
271  {
272  disconnect(mpDataModelGUI, SIGNAL(notifyView(ListViews::ObjectType, ListViews::Action, std::string)),
273  this, SLOT(slotNotify(ListViews::ObjectType, ListViews::Action, std::string)));
274  }
275 
276  mpDataModelGUI = pDM;
278 
280  assert(pDataModel != NULL);
281 
282  //Set Model for the TableView
283  mpTreeDM->setCopasiDM(pDataModel);
284  mpTreeView->expand(mpTreeSortDM->mapFromSource(mpTreeDM->index(0, 0, QModelIndex())));
285 
286  if (mpDataModelGUI)
287  {
288  connect(mpDataModelGUI, SIGNAL(notifyView(ListViews::ObjectType, ListViews::Action, const std::string &)),
289  this, SLOT(slotNotify(ListViews::ObjectType, ListViews::Action, const std::string &)));
290  }
291 
293 }
294 
295 /***********ListViews::ConstructNodeWidgets()---------------------------->
296  ** Description:-This method is used to construct all the node widgets
297  *************************************************************************/
299 {
300 
301  // create the model widgets
303  {
306  }
307 
308  if (!compartmentsWidget1)
309  {
312  }
313 
314 #ifdef HAVE_MML
315 
317  {
320  }
321 
322 #endif // HAVE_MML
323 
324  if (!eventsWidget)
325  {
326  eventsWidget = new CQEventsWidget(this);
327  mpStackedWidget->addWidget(eventsWidget);
328  }
329 
330  if (!eventWidget1)
331  {
333  mpStackedWidget->addWidget(eventWidget1);
334  }
335 
336  if (!mpFunctionsWidget)
337  {
340  }
341 
342  if (!functionWidget1)
343  {
345  mpStackedWidget->addWidget(functionWidget1);
346  }
347 
348  if (!lyapWidget)
349  {
350  lyapWidget = new CQLyapWidget(this);
351  mpStackedWidget->addWidget(lyapWidget);
352  }
353 
354  if (!lyapResultWidget)
355  {
357  mpStackedWidget->addWidget(lyapResultWidget);
358  }
359 
360  if (!mpSpeciesWidget)
361  {
362  mpSpeciesWidget = new CQSpeciesWidget(this);
363  mpStackedWidget->addWidget(mpSpeciesWidget);
364  }
365 
366  if (!metabolitesWidget1)
367  {
370  }
371 
372  if (!modelWidget)
373  {
374  modelWidget = new CQTabWidget(ListViews::MODEL, new CQModelWidget(this), this);
375  mpStackedWidget->addWidget(modelWidget);
376  }
377 
378  if (!mpModelValueWidget)
379  {
382  }
383 
385  {
388  }
389 
390  if (!mpEFMWidget)
391  {
392  mpEFMWidget = new CQEFMWidget(this);
393  mpStackedWidget->addWidget(mpEFMWidget);
394  }
395 
396  if (!mpEFMResultWidget)
397  {
400  }
401 
403  {
406  }
407 
409  {
412  }
413 
415  {
418  }
419 
421  {
424  }
425 
427  {
430  }
431 
432  if (!mpCMCAResultWidget)
433  {
436  }
437 
438  if (!mpCQMCAWidget)
439  {
440  mpCQMCAWidget = new CQMCAWidget(this);
441  mpStackedWidget->addWidget(mpCQMCAWidget);
442  }
443 
444  if (!mpCLNAResultWidget)
445  {
448  }
449 
450  if (!mpCQLNAWidget)
451  {
452  mpCQLNAWidget = new CQLNAWidget(this);
453  mpStackedWidget->addWidget(mpCQLNAWidget);
454  }
455 
456  if (!optimizationWidget)
457  {
460  }
461 
462  if (!optResultWidget)
463  {
465  mpStackedWidget->addWidget(optResultWidget);
466  }
467 
468  if (!paramFittingWidget)
469  {
472  }
473 
475  {
478  }
479 
480  if (!mpPlotsWidget)
481  {
482  mpPlotsWidget = new CQPlotsWidget(this);
483  mpStackedWidget->addWidget(mpPlotsWidget);
484  }
485 
486  if (!mpPlotSubwidget)
487  {
488  mpPlotSubwidget = new CQPlotSubwidget(this);
489  mpStackedWidget->addWidget(mpPlotSubwidget);
490  }
491 
492  if (!mpReactionsWidget)
493  {
496  }
497 
498  if (!reactionsWidget1)
499  {
501  mpStackedWidget->addWidget(reactionsWidget1);
502  }
503 
504  if (!scanWidget)
505  {
506  scanWidget = new ScanWidget(this);
507  mpStackedWidget->addWidget(scanWidget);
508  }
509 
510  if (!stateWidget)
511  {
512  stateWidget = new CQSteadyStateResult(this);
513  mpStackedWidget->addWidget(stateWidget);
514  }
515 
516  if (!steadystateWidget)
517  {
520  }
521 
522  if (!mpReportsWidget)
523  {
524  mpReportsWidget = new CQReportsWidget(this);
525  mpStackedWidget->addWidget(mpReportsWidget);
526  }
527 
528  if (!tableDefinition1)
529  {
531  mpStackedWidget->addWidget(tableDefinition1);
532  }
533 
534  if (!sensWidget)
535  {
536  sensWidget = new SensitivitiesWidget(this);
537  mpStackedWidget->addWidget(sensWidget);
538  }
539 
540  if (!sensResultWidget)
541  {
543  mpStackedWidget->addWidget(sensResultWidget);
544  }
545 
546  if (!timeSeriesWidget)
547  {
549  mpStackedWidget->addWidget(timeSeriesWidget);
550  }
551 
552  if (!trajectoryWidget)
553  {
555  mpStackedWidget->addWidget(trajectoryWidget);
556  }
557 
558  if (!tssaWidget)
559  {
560  tssaWidget = new CQTSSAWidget(this);
561  mpStackedWidget->addWidget(tssaWidget);
562  }
563 
564  if (!tssaResultWidget)
565  {
567  mpStackedWidget->addWidget(tssaResultWidget);
568  }
569 
571  {
574  }
575 
577  {
580  }
581 
582 #ifdef COPASI_NONLIN_DYN_OSCILLATION
583 
584  if (!oscillationTaskWidget)
585  {
586  oscillationTaskWidget = new CQOscillationTaskWidget(this);
587  mpStackedWidget->addWidget(oscillationTaskWidget);
588  }
589 
590 #endif
591 
592 #ifdef COPASI_DEBUG
593 
594  if (!mpUpdatesWidget)
595  {
596  mpUpdatesWidget = new CQUpdatesWidget(this);
597  mpStackedWidget->addWidget(mpUpdatesWidget);
598  }
599 
600 #endif // COPASI_DEBUG
601 
602  if (!mpMathMatrixWidget)
603  {
606  }
607 
608  if (!mpLayoutsWidget)
609  {
610  mpLayoutsWidget = new CQLayoutsWidget(this);
611  mpStackedWidget->addWidget(mpLayoutsWidget);
612  }
613 }
614 
615 /**
616  * tries to find the right hand side widget that belongs to an item of the tree view
617  */
618 CopasiWidget* ListViews::findWidgetFromIndex(const QModelIndex & index) const
619 {
620  if (!index.isValid() || !mpDataModelGUI)
621  return NULL;
622 
623  // first try ID
624  size_t id = mpTreeDM->getIdFromIndex(index);
625 
626  if (id != C_INVALID_INDEX)
627  {
628 
629  return findWidgetFromId(id);
630  }
631 
632  // then try parent id:
633  id = mpTreeDM->getIdFromIndex(mpTreeDM->parent(index));
634 
635  switch (id)
636  {
637  case 111:
638  return compartmentsWidget1;
639  break;
640 
641  case 112:
642  return metabolitesWidget1;
643  break;
644 
645  case 114:
646  return reactionsWidget1;
647  break;
648 
649  case 115:
650  return mpModelValueWidget;
651  break;
652 
653  case 116:
654  return eventWidget1;
655  break;
656 
657  case 119:
658  return mpParameterSetWidget;
659  break;
660 
661  case 43:
662  return tableDefinition1;
663  break;
664 
665  case 42:
666  return mpPlotSubwidget;
667  break;
668 
669  case 5:
670  return functionWidget1;
671  break;
672  }
673 
674  //give up
675  return NULL;
676 }
677 
678 CopasiWidget* ListViews::findWidgetFromId(const size_t & id) const
679 {
680  switch (id)
681  {
682  case static_cast<size_t>(-1):
683  break; //continue with parent id
684 
685  case 0:
686  return defaultWidget;
687  break;
688 
689  case 1:
690  return modelWidget;
691  break;
692 
693  case 111:
694  return mpCompartmentsWidget;
695  break;
696 
697  case 112:
698  return mpSpeciesWidget;
699  break;
700 
701  case 114:
702  return mpReactionsWidget;
703  break;
704 
705  case 115:
707  break;
708 
709  case 116:
710  return eventsWidget;
711  break;
712 
713  case 118:
715  break;
716 
717  case 119:
718  return mpParameterSetsWidget;
719  break;
720 
721  //case 122:
722  // return functionSymbols;
723  // break;
724 #ifdef HAVE_MML
725 
726  case 126:
727  return differentialEquations;
728  break;
729 #endif // HAVE_MML
730 
731  case 127:
732  return mpMathMatrixWidget;
733  break;
734 #ifdef COPASI_DEBUG
735 
736  case 128:
737  return mpUpdatesWidget;
738  break;
739 #endif
740 
741  case 13:
742  return mpLayoutsWidget;
743  break;
744 
745  case 21:
746  return steadystateWidget;
747  break;
748 
749  case 211:
750  return stateWidget;
751  break;
752 
753  case 221:
754  return mpEFMWidget;
755  break;
756 
757  case 2211:
758  return mpEFMResultWidget;
759  break;
760 
761  case 222:
762  return mpMoietiesTaskWidget;
763  break;
764 
765  case 2221:
766  return mpMoietiesTaskResult;
767  break;
768 
769  case 23:
770  return trajectoryWidget;
771  break;
772 
773  case 231:
774  return timeSeriesWidget;
775  break;
776 
777  case 24:
778  return mpCQMCAWidget;
779  break;
780 
781  case 241:
782  return mpCMCAResultWidget;
783  break;
784 
785  case 26:
786  return lyapWidget;
787  break;
788 
789  case 261:
790  return lyapResultWidget;
791  break;
792 
793  case 27:
794  return tssaWidget;
795  break;
796 
797  case 271:
798  return tssaResultWidget;
799  break;
800 
801  case 28:
802  return crossSectionTaskWidget;
803  break;
804 
805  case 281:
807 
808 #ifdef COPASI_NONLIN_DYN_OSCILLATION
809 
810  case 29:
811  return oscillationTaskWidget;
812  break;
813 #endif
814 
815  case 31:
816  return scanWidget;
817  break;
818 
819  case 32:
820  return optimizationWidget;
821  break;
822 
823  case 321:
824  return optResultWidget;
825  break;
826 
827  case 33:
828  return paramFittingWidget;
829  break;
830 
831  case 331:
832  return mpFittingResultWidget;
833  break;
834 
835  case 34:
836  return sensWidget;
837  break;
838 
839  case 341:
840  return sensResultWidget;
841  break;
842 
843  case 35:
844  return mpCQLNAWidget;
845  break;
846 
847  case 351:
848  return mpCLNAResultWidget;
849  break;
850 
851  case 43: //Report
852  return mpReportsWidget;
853  break;
854 
855  case 42:
856  return mpPlotsWidget;
857  break;
858 
859  case 5:
860  return mpFunctionsWidget;
861  break;
862  }
863 
864  return NULL;
865 }
866 
867 /************************ListViews::slotFolderChanged(QListViewItem *i)----------->
868  **
869  ** Parameters:- index :- pointer to the node that was selected by the user
870  **
871  ** Returns :- void(Nothing)
872  ** Description:-This method is called whenever the user clicks on one of the
873  ** tree view items...
874  *************************************************************************************/
875 void ListViews::slotFolderChanged(const QModelIndex & index)
876 {
877  bool changeWidget = true;
878 
879  if (!index.isValid() || !mpDataModelGUI) return;
880 
881  // find the widget
882  CopasiWidget* newWidget = findWidgetFromIndex(index);
883 
884  if (!newWidget) return; //do nothing
885 
886  std::string itemKey = mpTreeDM->getKeyFromIndex(index);
887 
888  if (newWidget == mpCurrentWidget)
889  if (itemKey == mCurrentItemKey) return; //do nothing
890 
891  // leave old widget
892  if (mpCurrentWidget)
893  {
894  //item may point to an invalid ListViewItem now
895  QModelIndex newIndex = mpTreeView->currentIndex();
896 
897  // find the widget again (it may have changed)
898  newWidget = findWidgetFromIndex(newIndex);
899 
900  changeWidget = mpCurrentWidget->leave();
901 
902  if (!changeWidget) return;
903  }
904 
905  if (!newWidget) newWidget = defaultWidget; //should never happen
906 
907  // enter new widget
908  if (newWidget)
909  ((CopasiWidget*)newWidget)->enter(itemKey);
910 
911  // fall back
912  if (!newWidget)
913  {newWidget = defaultWidget;}
914 
915  // we emit the signal after the old widget has saved
916  // the changes
917  emit signalFolderChanged(index);
918 
919  mpCurrentWidget = newWidget;
920  mpStackedWidget->setCurrentWidget(mpCurrentWidget);
921  mCurrentItemKey = itemKey;
922 
923  mpTreeView->scrollTo(index);
924 }
925 
926 void ListViews::switchToOtherWidget(const size_t & id, const std::string & key)
927 {
928  if (!mpDataModelGUI) return;
929 
930  QModelIndex Index = mpTreeDM->index(id, key);
931  QModelIndex SortIndex = mpTreeSortDM->mapFromSource(Index);
932 
933  mpTreeView->setCurrentIndex(SortIndex);
934 }
935 
936 //********** some methods to store and restore the state of the listview ****
937 
939 {
940  QModelIndex index = mpTreeView->currentIndex();
941 
942  if (!index.isValid() || !mpDataModelGUI)
943  return C_INVALID_INDEX;
944 
945  return mpTreeDM->getIdFromIndex(index);
946 }
947 
948 //**************************************************************************************+***
949 
950 //static members **************************
951 
952 bool ListViews::slotNotify(ObjectType objectType, Action action, std::string key)
953 {
954  if (objectType != MODEL &&
955  objectType != STATE &&
956  action != ADD)
957  {
958  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
959  (*CCopasiRootContainer::getDatamodelList())[0]->changed();
960  }
961 
962  bool success = true;
963 
964  // delete the layout windows when the current model is added
965  // actually it would have been better to do this when a model is deleted, but
966  // the deletion notification is only sent to the listviews if the deleted
967  // model had been changed.
968  if (objectType == MODEL && action == DELETE)
969  {
971  }
972 
973  if (!updateCurrentWidget(objectType, action, key)) success = false;
974 
975  notifyChildWidgets(objectType, action, key);
976 
977  return success;
978 }
979 
980 void ListViews::slotSort(const QModelIndex & /* index1 */, const QModelIndex & /* index2 */)
981 {
982  mpTreeView->sortByColumn(0, Qt::AscendingOrder);
983 }
984 
985 bool ListViews::updateCurrentWidget(ObjectType objectType, Action action, const std::string & key)
986 {
987  bool success = true;
988 
989  if (mpCurrentWidget)
990  mpCurrentWidget->update(objectType, action, key);
991 
992  return success;
993 }
994 
996 {return this->mpCurrentWidget;}
997 
999 {
1000  if (mpCurrentWidget != NULL)
1002 }
1003 
1005  Action action,
1006  const std::string & key)
1007 {
1008  QList <CopasiWidget *> widgets = findChildren<CopasiWidget *>();
1009  QListIterator<CopasiWidget *> it(widgets); // iterate over the CopasiWidgets
1010  CopasiWidget * pCopasiWidget;
1011 
1012  while (it.hasNext())
1013  {
1014  if ((pCopasiWidget = it.next()) != NULL)
1015  {
1016  pCopasiWidget->update(objectType, action, key);
1017  }
1018  }
1019 }
1020 
1022 {
1023  QList <CQMiriamWidget *> widgets = findChildren<CQMiriamWidget *>();
1024  QListIterator<CQMiriamWidget *> it(widgets); // iterate over the CQMiriamWidgets
1025  CQMiriamWidget * pWidget;
1026 
1027  while (it.hasNext())
1028  {
1029  pWidget = it.next();
1030 
1031  if (dynamic_cast<CQMiriamWidget* >(pWidget))
1032  dynamic_cast<CQMiriamWidget* >(pWidget)->updateResourcesList();
1033  }
1034 }
1035 
1036 void ListViews::setFramework(int framework)
1037 {
1038  QList <CopasiWidget *> widgets = findChildren<CopasiWidget *>();
1039  QListIterator<CopasiWidget *> it(widgets); // iterate over the CopasiWidgets
1040  CopasiWidget * pCopasiWidget;
1041 
1042  while (it.hasNext())
1043  {
1044  if ((pCopasiWidget = it.next()) != NULL)
1045  pCopasiWidget->setFramework(framework);
1046  }
1047 }
1048 
1050 {
1051  return trajectoryWidget;
1052 }
1053 
1055 {
1056  return steadystateWidget;
1057 }
1058 
1060 {
1061  return scanWidget;
1062 }
1063 
1065 {
1066  return mpCQMCAWidget;
1067 }
1068 
1070 {
1071  return mpCQLNAWidget;
1072 }
1073 
1075 {
1076  return paramFittingWidget;
1077 }
1078 
1080 {
1081  return optimizationWidget;
1082 }
1083 
1085 {
1086  return crossSectionTaskWidget;
1087 }
ScanWidget * scanWidget
Definition: listviews.h:227
CQTabWidget * modelWidget
Definition: listviews.h:209
virtual QModelIndex parent(const QModelIndex &index) const
SteadyStateWidget * getSteadyStateWidget()
Definition: listviews.cpp:1054
CMCAResultWidget * mpCMCAResultWidget
Definition: listviews.h:193
DataModelGUI * mpDataModelGUI
Definition: listviews.h:182
CQOptimizationResult * optResultWidget
Definition: listviews.h:217
CQLNAWidget * getLNAWidget()
Definition: listviews.cpp:1069
CQBrowserPane * mpTreeView
Definition: listviews.h:190
CQOptimizationWidget * optimizationWidget
Definition: listviews.h:216
objectType
CQReportsWidget * mpReportsWidget
Definition: listviews.h:232
A widget class for Functions branch.
CopasiWidget * getCurrentWidget()
Definition: listviews.cpp:995
SensitivitiesWidget * sensWidget
Definition: listviews.h:228
void switchToOtherWidget(const size_t &id, const std::string &key)
Definition: listviews.cpp:926
CQFittingWidget * getFittingWidget()
Definition: listviews.cpp:1074
CLNAResultWidget * mpCLNAResultWidget
Definition: listviews.h:196
CQMathMatrixWidget * mpMathMatrixWidget
Definition: listviews.h:250
CopasiWidget * findWidgetFromIndex(const QModelIndex &index) const
Definition: listviews.cpp:618
CQMCAWidget * getMCAWidget()
Definition: listviews.cpp:1064
void setDataModel(DataModelGUI *pDM)
Definition: listviews.cpp:267
CQLNAWidget * mpCQLNAWidget
Definition: listviews.h:195
CQMCAWidget * mpCQMCAWidget
Definition: listviews.h:194
bool updateCurrentWidget(ObjectType objectType, Action action, const std::string &key="")
Definition: listviews.cpp:985
void setCopasiDM(const CCopasiDataModel *pDataModel)
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
CQLyapWidget * lyapWidget
Definition: listviews.h:205
CQBrowserPaneDM * mpTreeDM
Definition: listviews.h:183
void ConstructNodeWidgets()
Definition: listviews.cpp:298
CQPlotsWidget * mpPlotsWidget
Definition: listviews.h:223
void commit()
Definition: listviews.cpp:998
#define C_INVALID_INDEX
Definition: copasi.h:222
CQParameterSetsWidget * mpParameterSetsWidget
Definition: listviews.h:221
CQTrajectoryWidget * trajectoryWidget
Definition: listviews.h:235
CQSensResultWidget * sensResultWidget
Definition: listviews.h:229
CQLayoutsWidget * mpLayoutsWidget
Definition: listviews.h:249
void setFramework(int framework)
Definition: listviews.cpp:1036
CQTabWidget * eventWidget1
Definition: listviews.h:202
void notifyChildWidgets(ObjectType objectType, Action action, const std::string &key)
Definition: listviews.cpp:1004
CQPlotSubwidget * mpPlotSubwidget
Definition: listviews.h:224
virtual ~ListViews()
Definition: listviews.cpp:252
CQEFMWidget * mpEFMWidget
Definition: listviews.h:212
CQTabWidget * reactionsWidget1
Definition: listviews.h:226
CQReactionsWidget * mpReactionsWidget
Definition: listviews.h:225
CQTSSAResultWidget * tssaResultWidget
Definition: listviews.h:237
CQTabWidget * mpParameterSetWidget
Definition: listviews.h:222
CQTSSAWidget * tssaWidget
Definition: listviews.h:236
void slotFolderChanged(const QModelIndex &index)
Definition: listviews.cpp:875
CQEventsWidget * eventsWidget
Definition: listviews.h:201
CopasiWidget * findWidgetFromId(const size_t &id) const
Definition: listviews.cpp:678
CQSpeciesWidget * mpSpeciesWidget
Definition: listviews.h:207
QSortFilterProxyModel * mpTreeSortDM
Definition: listviews.h:184
CQCrossSectionTaskWidget * crossSectionTaskWidget
Definition: listviews.h:238
virtual bool leave()
CQGlobalQuantitiesWidget * mpGlobalQuantitiesWidget
Definition: listviews.h:210
virtual bool update(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
CQEFMResultWidget * mpEFMResultWidget
Definition: listviews.h:213
CQTabWidget * functionWidget1
Definition: listviews.h:204
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
CopasiWidget * mpCurrentWidget
Definition: listviews.h:186
CQFittingWidget * paramFittingWidget
Definition: listviews.h:218
CQCompartmentsWidget * mpCompartmentsWidget
Definition: listviews.h:197
CQCrossSectionTaskWidget * getCrossSectionWidget()
Definition: listviews.cpp:1084
CQSplashWidget * defaultWidget
Definition: listviews.h:199
void updateMIRIAMResourceContents()
Definition: listviews.cpp:1021
size_t getIdFromIndex(const QModelIndex &index) const
CQDifferentialEquations * differentialEquations
Definition: listviews.h:200
ListViews(QWidget *parent=0, const char *name=0)
Definition: listviews.cpp:143
CQFittingResult * mpFittingResultWidget
Definition: listviews.h:219
CQTrajectoryWidget * getTrajectoryWidget()
Definition: listviews.cpp:1049
void slotSort(const QModelIndex &index1, const QModelIndex &index2)
Definition: listviews.cpp:980
CQLyapResultWidget * lyapResultWidget
Definition: listviews.h:206
CQSteadyStateResult * stateWidget
Definition: listviews.h:230
CQTabWidget * compartmentsWidget1
Definition: listviews.h:198
CQFunctionsWidget * mpFunctionsWidget
Definition: listviews.h:203
std::string mCurrentItemKey
Definition: listviews.h:187
CQReportDefinition * tableDefinition1
Definition: listviews.h:233
CQMoietiesTaskWidget * mpMoietiesTaskWidget
Definition: listviews.h:215
void setGuiDM(const DataModelGUI *pDataModel)
CQMoietiesTaskResult * mpMoietiesTaskResult
Definition: listviews.h:214
CQParameterOverviewWidget * mpParameterOverviewWidget
Definition: listviews.h:220
QStackedWidget * mpStackedWidget
Definition: listviews.h:191
CQOptimizationWidget * getOptimizationWidget()
Definition: listviews.cpp:1079
std::string getKeyFromIndex(const QModelIndex &index) const
static const std::string ObjectTypeName[]
Definition: listviews.h:107
CQTabWidget * mpModelValueWidget
Definition: listviews.h:211
virtual void setFramework(int framework)
CQTabWidget * metabolitesWidget1
Definition: listviews.h:208
ScanWidget * getScanWidget()
Definition: listviews.cpp:1059
void signalFolderChanged(const QModelIndex &index)
SteadyStateWidget * steadystateWidget
Definition: listviews.h:231
CQTimeSeriesWidget * crossSectionTimeSeriesWidget
Definition: listviews.h:239
size_t getCurrentItemId()
Definition: listviews.cpp:938
bool slotNotify(ListViews::ObjectType objectType, ListViews::Action action, std::string key="")
Definition: listviews.cpp:952
CQTimeSeriesWidget * timeSeriesWidget
Definition: listviews.h:234
bool enter(const std::string &key)