Ignore:
Timestamp:
Apr 6, 2012, 11:57:20 AM (13 years ago)
Author:
Frederik Heber <heber@…>
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:
1de61e
Parents:
613f8c
git-author:
Michael Ankele <ankele@…> (03/13/12 12:58:50)
git-committer:
Frederik Heber <heber@…> (04/06/12 11:57:20)
Message:

QtWorldView: selection in widget calls actions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/QtWorldView.cpp

    r613f8c rb14efe  
    2828#include "molecule.hpp"
    2929#include "MoleculeListClass.hpp"
     30#include "Actions/SelectionAction/Molecules/MoleculeByIdAction.hpp"
     31#include "Actions/SelectionAction/Molecules/NotMoleculeByIdAction.hpp"
    3032
    3133using namespace std;
     
    103105    const int index = (*iter)->IndexNr;
    104106    molItem->setData(0, Qt::UserRole, QVariant(index));
     107    molItem->setSelected(World::getInstance().isSelected(*iter));
    105108
    106109
     
    130133
    131134void QtWorldView::rowSelected(){
    132   //std::cout << "Selection in (" << row << "," << column << "): " << item(row,column) << std::endl;
    133   /*bool state = item(row,column)->isSelected();
    134   for(int i = 0; i<COLUMNCOUNT; i++){
    135     //std::cout << "Setting " << i << "-th item " << item(row,i) << " in row " << row << " to state selected." << std::endl;
    136     item(row,i)->setSelected(state);
     135
     136  // lookup all molecules in the treeWidget
     137  for (int i=0;i<topLevelItemCount();i++){
     138    QTreeWidgetItem *top = topLevelItem(i);
     139    for (int j=0;j<top->childCount();j++){
     140
     141      // molecules are 1 level below the top
     142      QTreeWidgetItem *molItem = top->child(j);
     143
     144      // molecule index stored as user data
     145      int index = molItem->data(0, Qt::UserRole).toInt();
     146      molecule *mol = molecules->ReturnIndex(index);
     147      ASSERT(mol, "QtWorldView::rowSelected()");
     148
     149      // selection changed by user?
     150      bool molSelectedWorld = World::getInstance().isSelected(mol);
     151      bool molSelectedList = molItem->isSelected();
     152      //std::cout << molSelectedWorld << " " << molSelectedList << std::endl;
     153
     154      if (molSelectedWorld != molSelectedList){
     155
     156        // apply new selection state
     157        if (molSelectedList){
     158          //std::cout << "select molecule" << std::endl;
     159          MoleCuilder::SelectionMoleculeById(mol->getId());
     160        }else{
     161          //std::cout << "unselect molecule" << std::endl;
     162          MoleCuilder::SelectionNotMoleculeById(mol->getId());
     163        }
     164      }
     165    }
    137166  }
    138   // figure out which rows have changed
    139   for(int i=0; i<rowCount();++i){
    140     state = item(i,0)->isSelected();
    141     if(molSelection[i]!=state){
    142       int idx = verticalHeaderItem(i)->data(Qt::UserRole).toInt();
    143       molecule *mol = molecules->ReturnIndex(idx);
    144       if(state){
    145         emit moleculeSelected(mol);
    146       }
    147       else{
    148         emit moleculeUnSelected(mol);
    149       }
    150       molSelection[i]=state;
    151     }
    152   }*/
    153167}
Note: See TracChangeset for help on using the changeset viewer.