Changeset 8ccf3b for src/UIElements
- Timestamp:
- Jan 27, 2015, 5:18:30 PM (10 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 1c3390
- Parents:
- 6770fa
- git-author:
- Frederik Heber <heber@…> (01/14/15 22:32:34)
- git-committer:
- Frederik Heber <heber@…> (01/27/15 17:18:30)
- Location:
- src/UIElements
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/QtMainWindow.cpp
r6770fa r8ccf3b 95 95 QVBoxLayout *layout = new QVBoxLayout(layoutwidget); 96 96 97 moleculeList = new QtMoleculeList(worldTab); 97 QTreeView *moleculeListView = new QTreeView(worldTab); 98 moleculeList = new QtMoleculeList; 99 moleculeListView->setModel(moleculeList); 98 100 elementList = new QtElementList(worldTab); 99 101 homologyList = new QtHomologyList(worldTab); … … 129 131 layout->addWidget(worldTab); 130 132 splitter2->addWidget(layoutwidget); 131 worldTab->addTab(moleculeList , "Molecules");133 worldTab->addTab(moleculeListView, "Molecules"); 132 134 worldTab->addTab(elementList, "All Elements"); 133 135 worldTab->addTab(fragmentList, "All Fragments"); -
src/UIElements/Views/Qt4/QtMoleculeList.cpp
r6770fa r8ccf3b 59 59 const char *QtMoleculeList::COLUMNNAMES[QtMoleculeList::COLUMNCOUNT]={"Name","Visibility", "Atoms","Formula","Occurrence"/*,"Size"*/}; 60 60 61 QtMoleculeList::QtMoleculeList(QWidget * _parent) : 62 QTreeWidget (_parent), 61 QtMoleculeList::QtMoleculeList() : 63 62 Observer("QtMoleculeList") 64 63 { 65 64 setColumnCount(COLUMNCOUNT); 66 setSelectionMode(QAbstractItemView::MultiSelection);67 68 QStringList header;69 for(int i=0; i<COLUMNCOUNT;++i)70 header << COLUMNNAMES[i];71 setHeaderLabels(header);65 // setSelectionMode(QAbstractItemView::MultiSelection); 66 67 // QStringList header; 68 // for(int i=0; i<COLUMNCOUNT;++i) 69 // header << COLUMNNAMES[i]; 70 // setHeaderLabels(header); 72 71 73 72 World::getInstance().signOn(this, World::MoleculeInserted); 74 73 World::getInstance().signOn(this, World::MoleculeRemoved); 75 76 74 77 75 dirty = true; … … 82 80 refill(); 83 81 84 qRegisterMetaType<QItemSelection>("QItemSelection");82 // qRegisterMetaType<QItemSelection>("QItemSelection"); 85 83 //connect(this,SIGNAL(cellChanged(int,int)),this,SLOT(moleculeChanged(int,int))); 86 connect(selectionModel(),SIGNAL(selectionChanged(QItemSelection, QItemSelection)),this,SLOT(rowsSelected(QItemSelection, QItemSelection)));87 connect(this, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(visibilityChanged(QTreeWidgetItem*, int)));84 // connect(selectionModel(),SIGNAL(selectionChanged(QItemSelection, QItemSelection)),this,SLOT(rowsSelected(QItemSelection, QItemSelection))); 85 // connect(this, SIGNAL(itemChanged(QStandardItem*, int)), this, SLOT(visibilityChanged(QStandardItem*, int))); 88 86 } 89 87 … … 97 95 ASSERT(0, 98 96 "QtMoleculeList::update() - we did not sign up for any global updates."); 97 } 98 99 QStandardItem * QtMoleculeList::MoleculeToItem(const molecule * const _mol) 100 { 101 MoleculeItemBiMap_t::left_const_iterator iter = 102 MoleculeItemBiMap.left.find(_mol); 103 ASSERT( iter != MoleculeItemBiMap.left.end(), 104 "QtMoleculeList - could not find molecule "+_mol->getName()+" in my list."); 105 return iter->second; 99 106 } 100 107 … … 106 113 { 107 114 const molecule * const mol = World::getInstance().lastChanged<molecule>(); 108 addItem( mol);115 addItem( mol ); 109 116 break; 110 117 } … … 112 119 { 113 120 const molecule * const mol = World::getInstance().lastChanged<molecule>(); 114 removeItem( mol);121 removeItem( mol ); 115 122 break; 116 123 } … … 129 136 130 137 void QtMoleculeList::addGroupItem( 131 Q TreeWidgetItem *&_groupItem,138 QStandardItem *&mainitem, 132 139 const std::string &_molecule_formula) 133 140 { 134 _groupItem = new QTreeWidgetItem(this); 135 formula.insert( std::make_pair(_molecule_formula, _groupItem) ); 136 // fill item 137 _groupItem->setText(NAME, QString("default")); 138 _groupItem->setFlags((_groupItem->flags() | Qt::ItemIsUserCheckable) ^ Qt::ItemIsSelectable); 139 _groupItem->setCheckState(VISIBILITY, Qt::Unchecked); 140 _groupItem->setText(ATOMCOUNT, QString::number(0)); 141 _groupItem->setText(FORMULA, QString("")); 142 _groupItem->setText(OCCURRENCE, "0"); 143 _groupItem->setData(0, Qt::UserRole, QVariant(-1)); 141 QList<QStandardItem *> groupItems; 142 // fill item list 143 mainitem = new QStandardItem(QString("default")); 144 mainitem->setFlags(mainitem->flags() ^ Qt::ItemIsSelectable); 145 formula.insert( std::make_pair(_molecule_formula, mainitem) ); 146 groupItems << mainitem; 147 QStandardItem *visitem = new QStandardItem; 148 visitem->setCheckState(Qt::Unchecked); 149 visitem->setFlags(mainitem->flags() | Qt::ItemIsUserCheckable); 150 groupItems << visitem; 151 groupItems << new QStandardItem(QString::number(0)); 152 groupItems << new QStandardItem(QString("")); 153 groupItems << new QStandardItem(QString::number(0)); 154 invisibleRootItem()->appendRow(groupItems); 155 // _groupItem->setData(0, Qt::UserRole, QVariant(-1)); 144 156 } 145 157 146 158 void QtMoleculeList::addMoleculeItem( 147 Q TreeWidgetItem *&_groupItem,159 QStandardItem *_groupitem, 148 160 const molecule *_mol, 149 161 const std::string &_molecule_formula) 150 162 { 151 QTreeWidgetItem *molItem = new QTreeWidgetItem(_groupItem); 152 molItem->setText(NAME, QString(_mol->getName().c_str())); 153 molItem->setFlags(molItem->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable); 154 molItem->setCheckState(VISIBILITY, Qt::Unchecked); 155 molItem->setText(ATOMCOUNT, QString::number(_mol->getAtomCount())); 156 molItem->setText(FORMULA, QString(_molecule_formula.c_str())); 157 const int index = _mol->getId(); 158 molItem->setData(0, Qt::UserRole, QVariant(index)); 159 molItem->setSelected(World::getInstance().isSelected(_mol)); 163 QList<QStandardItem *> molItems; 164 QStandardItem *mainitem = new QStandardItem(QString(_mol->getName().c_str())); 165 mainitem->setFlags(mainitem->flags() | Qt::ItemIsSelectable); 166 // mainitem->setSelected(World::getInstance().isSelected(_mol)); 167 MoleculeItemBiMap.left.insert( std::make_pair(_mol, mainitem) ); 168 molItems << mainitem; 169 QStandardItem *visitem = new QStandardItem(); 170 visitem->setCheckState(Qt::Unchecked); 171 visitem->setFlags(mainitem->flags() | Qt::ItemIsUserCheckable); 172 molItems << visitem; 173 molItems << new QStandardItem(QString::number(_mol->getAtomCount())); 174 molItems << new QStandardItem(QString(_molecule_formula.c_str())); 175 molItems << new QStandardItem(QString::number(0)); 176 // const int index = _mol->getId(); 177 // molItem->setData(0, Qt::UserRole, QVariant(index)); 178 _groupitem->appendRow(molItems); 160 179 } 161 180 … … 166 185 changing = true; 167 186 // find group if already in list 168 Q TreeWidgetItem *groupItem = NULL;187 QStandardItem *groupItem = NULL; 169 188 170 189 const std::string &molecule_formula = _mol->getFormula().toString(); … … 197 216 198 217 // increase group occurrence 199 int count = groupItem->text(OCCURRENCE).toInt() + 1; 200 groupItem->setText(OCCURRENCE, QString::number(count)); 218 const int index = groupItem->index().row(); 219 QStandardItem *occ_item = invisibleRootItem()->child(index, OCCURRENCE); 220 int count = occ_item->text().toInt() + 1; 221 occ_item->setText(QString::number(count)); 201 222 202 223 changing = false; … … 225 246 formula.clear(); 226 247 FormulaVisibilityCountMap.clear(); 248 MoleculeItemBiMap.clear(); 227 249 228 250 for (std::vector<molecule*>::const_iterator iter = molecules.begin(); … … 236 258 } 237 259 260 /* 238 261 void QtMoleculeList::paintEvent(QPaintEvent * event) 239 262 { … … 242 265 QTreeWidget::paintEvent(event); 243 266 } 267 */ 244 268 245 269 void QtMoleculeList::subjectKilled(Observable *publisher) { 246 270 } 247 271 248 void QtMoleculeList::visibilityChanged(QTreeWidgetItem* item, int column) 272 /* 273 void QtMoleculeList::visibilityChanged(QStandardItem* item, int column) 249 274 { 250 275 if ((!changing) && (!clearing) && (!ChangingChildrensVisibility)) … … 313 338 } 314 339 } 340 */ 315 341 316 342 void QtMoleculeList::moleculeChanged() { … … 326 352 } 327 353 354 /* 328 355 void QtMoleculeList::rowsSelected(const QItemSelection & selected, const QItemSelection & deselected){ 329 356 … … 369 396 selecting = false; 370 397 } 398 399 */ -
src/UIElements/Views/Qt4/QtMoleculeList.hpp
r6770fa r8ccf3b 14 14 #endif 15 15 16 #include <QtGui/QTreeWidget> 16 #include <QtGui/QStandardItem> 17 #include <QtGui/QStandardItemModel> 17 18 19 #include <boost/bimap.hpp> 18 20 #include <map> 19 21 #include <string> … … 26 28 class MoleculeListClass; 27 29 28 class QtMoleculeList : public Q TreeWidget, public Observer30 class QtMoleculeList : public QStandardItemModel, public Observer 29 31 { 30 32 Q_OBJECT 31 33 32 34 public: 33 QtMoleculeList( QWidget * _parent=0);35 QtMoleculeList(); 34 36 virtual ~QtMoleculeList(); 35 37 … … 38 40 virtual void recieveNotification(Observable *publisher, Notification_ptr notification); 39 41 virtual void subjectKilled(Observable *publisher); 40 virtual void paintEvent(QPaintEvent * event);42 // virtual void paintEvent(QPaintEvent * event); 41 43 void refill(); 42 44 … … 47 49 private slots: 48 50 void moleculeChanged(); 49 void visibilityChanged(QTreeWidgetItem*, int);51 // void visibilityChanged(QStandardItem*, int); 50 52 51 void rowsSelected(const QItemSelection & selected, const QItemSelection & deselected); 53 // void rowsSelected(const QItemSelection & selected, const QItemSelection & deselected); 54 52 55 53 56 signals: … … 63 66 bool ChangingChildrensVisibility; 64 67 65 void addItem(const molecule *_mol); 66 void addGroupItem(QTreeWidgetItem *&_groupItem, const std::string &_molecule_formula); 67 void addMoleculeItem(QTreeWidgetItem *&_groupItem, const molecule *_mol, const std::string &molecule_formula); 68 void removeItem(const molecule *_mol); 68 QStandardItem * MoleculeToItem(const molecule * const _mol); 69 70 void addItem(const molecule * const _mol); 71 void addGroupItem(QStandardItem *&mainitem, const std::string &_molecule_formula); 72 void addMoleculeItem(QStandardItem *_groupitem, const molecule *_mol, const std::string &molecule_formula); 73 void removeItem(const molecule * const _mol); 69 74 70 75 typedef std::map<std::string, unsigned int> FormulaVisibilityCountMap_t; 71 76 FormulaVisibilityCountMap_t FormulaVisibilityCountMap; 72 77 73 typedef std::map<std::string, Q TreeWidgetItem*> FormulaTreeItemMap_t;78 typedef std::map<std::string, QStandardItem*> FormulaTreeItemMap_t; 74 79 //!> map of (unique) formulas in the world 75 80 FormulaTreeItemMap_t formula; 81 82 typedef boost::bimap<const molecule *, QStandardItem*> MoleculeItemBiMap_t; 83 MoleculeItemBiMap_t MoleculeItemBiMap; 76 84 }; 77 85
Note:
See TracChangeset
for help on using the changeset viewer.