Changeset 79b59b for src/UIElements/Views
- Timestamp:
- Apr 6, 2012, 11:57:19 AM (13 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:
- 818201
- Parents:
- 575343
- git-author:
- Michael Ankele <ankele@…> (03/22/12 12:27:01)
- git-committer:
- Frederik Heber <heber@…> (04/06/12 11:57:19)
- Location:
- src/UIElements/Views/Qt4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/QtWorldView.cpp
r575343 r79b59b 36 36 // these attributes are skiped so far 37 37 const int QtWorldView::COLUMNCOUNT = COLUMNTYPES_MAX; 38 const char *QtWorldView::COLUMNNAMES[QtWorldView::COLUMNCOUNT]={"Name","Atoms","Formula" /*,"Size"*/};38 const char *QtWorldView::COLUMNNAMES[QtWorldView::COLUMNCOUNT]={"Name","Atoms","Formula","Occurrence"/*,"Size"*/}; 39 39 40 40 QtWorldView::QtWorldView(QWidget * _parent) : 41 QT ableWidget (_parent),41 QTreeWidget (_parent), 42 42 Observer("QtWorldView") 43 43 { 44 setRowCount(0);45 44 setColumnCount(COLUMNCOUNT); 45 setSelectionMode(QAbstractItemView::MultiSelection); 46 46 47 for(int i=0; i<COLUMNCOUNT;++i) { 48 QTableWidgetItem *heading = new QTableWidgetItem(); 49 std::cout << "Creating heading item " << heading << "." << std::endl; 50 heading->setText(QString(COLUMNNAMES[i])); 51 setHorizontalHeaderItem(i,heading); 52 } 47 QStringList header; 48 for(int i=0; i<COLUMNCOUNT;++i) 49 header << COLUMNNAMES[i]; 50 setHeaderLabels(header); 53 51 54 52 molecules = World::getInstance().getMolecules(); … … 56 54 update(molecules); 57 55 58 connect(this,SIGNAL(cellChanged(int,int)),this,SLOT(moleculeChanged(int,int)));59 connect(this,SIGNAL( cellClicked(int,int)),this,SLOT(cellSelected(int,int)));56 //connect(this,SIGNAL(cellChanged(int,int)),this,SLOT(moleculeChanged(int,int))); 57 connect(this,SIGNAL(itemSelectionChanged()),this,SLOT(rowSelected())); 60 58 61 59 } … … 68 66 void QtWorldView::update(Observable *publisher) { 69 67 int numMolecules = molecules->ListOfMolecules.size(); 70 setRowCount(numMolecules);68 clear(); 71 69 molSelection.resize(numMolecules); 70 71 // list of (unique) formulas in the world 72 std::vector<Formula> formula; 73 72 74 int i; 73 75 MoleculeList::iterator iter; … … 76 78 ++i,++iter) { 77 79 80 // find group if already in list 81 QTreeWidgetItem *groupItem = NULL; 82 for (unsigned int j=0;j<formula.size();j++) 83 if ((*iter)->getFormula() == formula[j]){ 84 groupItem = topLevelItem(j); 85 break; 86 } 87 88 // new molecule type -> create new group 89 if (!groupItem){ 90 formula.push_back((*iter)->getFormula()); 91 groupItem = new QTreeWidgetItem(this); 92 groupItem->setText(0, QString((*iter)->getName().c_str())); 93 groupItem->setText(1, QString::number((*iter)->getAtomCount())); 94 groupItem->setText(2, QString((*iter)->getFormula().toString().c_str())); 95 groupItem->setText(3, "0"); 96 } 97 98 // add molecule 99 QTreeWidgetItem *molItem = new QTreeWidgetItem(groupItem); 100 molItem->setText(0, QString((*iter)->getName().c_str())); 101 molItem->setText(1, QString::number((*iter)->getAtomCount())); 102 molItem->setText(2, QString((*iter)->getFormula().toString().c_str())); 78 103 const int index = (*iter)->IndexNr; 79 QTableWidgetItem *indexWidget = new QTableWidgetItem(); 80 //std::cout << "Creating index item " << indexWidget << "." << std::endl; 81 indexWidget->setText(QString::number(index)); 82 indexWidget->setData(Qt::UserRole,QVariant(index)); 83 setVerticalHeaderItem(i,indexWidget); 104 molItem->setData(0, Qt::UserRole, QVariant(index)); 84 105 85 const string name = (*iter)->getName();86 QTableWidgetItem *nameWidget = new QTableWidgetItem();87 //std::cout << "Creating name item " << nameWidget << " at " << i << "," << NAME << "." << std::endl;88 nameWidget->setText(QString(name.c_str()));89 setItem(i,NAME,nameWidget);90 106 91 const int atomCount = (*iter)->getAtomCount(); 92 QTableWidgetItem *countWidget= new QTableWidgetItem(); 93 //std::cout << "Creating count item " << countWidget << " at " << i << "," << ATOMCOUNT << "." << std::endl; 94 countWidget->setText(QString::number(atomCount)); 95 countWidget->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); 96 setItem(i,ATOMCOUNT,countWidget); 107 // increase group occurrence 108 int count = groupItem->text(3).toInt() + 1; 109 groupItem->setText(3, QString::number(count)); 97 110 98 const Formula formula = (*iter)->getFormula(); 99 QTableWidgetItem *formulaWidget= new QTableWidgetItem(); 100 //std::cout << "Creating formula item " << formulaWidget << " at " << i << "," << FORMULA << "." << std::endl; 101 formulaWidget->setText(QString(formula.toString().c_str())); 102 formulaWidget->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); 103 setItem(i,FORMULA,formulaWidget); 104 105 molSelection[i]=nameWidget->isSelected(); 111 //molSelection[i]=nameWidget->isSelected(); 106 112 } 107 113 } … … 110 116 } 111 117 112 void QtWorldView::moleculeChanged( int row, int column) {113 int idx = verticalHeaderItem(row)->data(Qt::UserRole).toInt();118 void QtWorldView::moleculeChanged() { 119 /*int idx = verticalHeaderItem(row)->data(Qt::UserRole).toInt(); 114 120 molecule *mol = molecules->ReturnIndex(idx); 115 121 string cellValue = item(row,NAME)->text().toStdString(); … … 119 125 else if(cellValue==""){ 120 126 item(row,NAME)->setText(QString(mol->getName().c_str())); 121 } 127 }*/ 122 128 } 123 129 124 130 125 void QtWorldView:: cellSelected(int row, int column){131 void QtWorldView::rowSelected(){ 126 132 //std::cout << "Selection in (" << row << "," << column << "): " << item(row,column) << std::endl; 127 bool state = item(row,column)->isSelected();133 /*bool state = item(row,column)->isSelected(); 128 134 for(int i = 0; i<COLUMNCOUNT; i++){ 129 135 //std::cout << "Setting " << i << "-th item " << item(row,i) << " in row " << row << " to state selected." << std::endl; … … 144 150 molSelection[i]=state; 145 151 } 146 } 152 }*/ 147 153 } -
src/UIElements/Views/Qt4/QtWorldView.hpp
r575343 r79b59b 15 15 16 16 17 #include <QtGui/QT ableWidget>17 #include <QtGui/QTreeWidget> 18 18 #include "CodePatterns/Observer/Observer.hpp" 19 19 … … 21 21 class MoleculeListClass; 22 22 23 class QtWorldView : public QT ableWidget, public Observer23 class QtWorldView : public QTreeWidget, public Observer 24 24 { 25 25 Q_OBJECT … … 34 34 35 35 static const int COLUMNCOUNT; 36 enum {NAME,ATOMCOUNT,FORMULA, COLUMNTYPES_MAX} COLUMNTYPES;36 enum {NAME,ATOMCOUNT,FORMULA,OCCURRENCE,COLUMNTYPES_MAX} COLUMNTYPES; 37 37 static const char *COLUMNNAMES[]; 38 38 39 39 private slots: 40 void moleculeChanged( int row, int column);40 void moleculeChanged(); 41 41 42 void cellSelected(int row, int column);42 void rowSelected(); 43 43 44 44 signals:
Note:
See TracChangeset
for help on using the changeset viewer.