COPASI API  4.16.103
SensWidgetComboBox.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 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) 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 #include <QtCore/QVariant>
12 #include <QtGui/QCheckBox>
13 #include <QtGui/QLabel>
14 #include <QtGui/QLineEdit>
15 #include <QtGui/QPushButton>
16 #include <QtGui/QRadioButton>
17 #include <QtGui/QLayout>
18 #include <QtGui/QToolTip>
19 #include <QtGui/QWhatsThis>
20 #include <QtGui/QMessageBox>
21 #include <QtGui/QToolButton>
22 #include <QtGui/QImage>
23 
24 #include <QtGui/QFrame>
25 #include <QtGui/QFileDialog>
26 #include <QtGui/QTableWidget>
27 
28 #include <algorithm>
29 
30 #include "SensWidgetComboBox.h"
31 #include "qtUtilities.h"
32 
33 SensWidgetComboBox::SensWidgetComboBox(QWidget * parent, const char * name)
34  : QComboBox(parent)
35 {
36  setObjectName(QString::fromUtf8(name));
37 }
38 
39 void SensWidgetComboBox::fillFromList(const std::vector<CObjectLists::ListType> & list)
40 {
41  //store old selection
43 
44  mIndexTable = list;
45 
46  //fill combobox
47  clear();
48  std::vector<CObjectLists::ListType>::const_iterator it, itEnd = mIndexTable.end();
49 
50  for (it = mIndexTable.begin(); it != itEnd; ++it)
51  insertItem(this->count(), FROM_UTF8(CObjectLists::ListTypeName[*it]));
52 
53  //restore old selection, if possible
54  if (!setCurrentObjectList(oldItem))
55  setCurrentIndex(0);
56 }
57 
59 {
60  unsigned int index = currentIndex();
61 
62  if (index < mIndexTable.size())
63  return mIndexTable[currentIndex()];
64  else
66 }
67 
69 {
70  std::vector<CObjectLists::ListType>::const_iterator it;
71  it = std::find(mIndexTable.begin(),
72  mIndexTable.end(),
73  lt);
74 
75  if (it == mIndexTable.end()) return false;
76 
77  setCurrentIndex(it - mIndexTable.begin());
78  return true;
79 }
std::vector< CObjectLists::ListType > mIndexTable
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CObjectLists::ListType getCurrentObjectList() const
static const std::string ListTypeName[]
Definition: CObjectLists.h:98
void fillFromList(const std::vector< CObjectLists::ListType > &list)
bool setCurrentObjectList(CObjectLists::ListType lt)
SensWidgetComboBox(QWidget *parent=0, const char *name=0)