Ignore:
Timestamp:
Jun 23, 2015, 6:29:02 AM (10 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:
6b474e
Parents:
704d59
git-author:
Frederik Heber <heber@…> (05/22/15 21:14:50)
git-committer:
Frederik Heber <heber@…> (06/23/15 06:29:02)
Message:

QtMoleculeItem now uses moleculeId_t instead molecule*.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.cpp

    r704d59 r69b434  
    102102}
    103103
    104 QtMoleculeItem * QtMoleculeList::MoleculeToItem(const molecule * const _mol) const
     104QtMoleculeItem * QtMoleculeList::MoleculeIdToItem(const moleculeId_t _molid) const
    105105{
    106106  MoleculeItemBiMap_t::left_const_iterator iter =
    107       MoleculeItemBiMap.left.find(_mol);
     107      MoleculeItemBiMap.left.find(_molid);
    108108  if( iter != MoleculeItemBiMap.left.end())
    109109    return iter->second;
     
    112112}
    113113
    114 const molecule * const QtMoleculeList::ItemToMolecule(const QtMoleculeItem * const _item) const
     114const moleculeId_t QtMoleculeList::ItemToMoleculeId(const QtMoleculeItem * const _item) const
    115115{
    116116  const MoleculeItemBiMap_t::right_const_iterator iter =
     
    119119    return iter->second;
    120120  else
    121       return NULL;
    122 }
    123 
    124 const molecule * const QtMoleculeList::IndexToMolecule(const QModelIndex &_index) const
     121    return -1;
     122}
     123
     124const moleculeId_t QtMoleculeList::IndexToMoleculeId(const QModelIndex &_index) const
    125125{
    126126  QtMoleculeItem * const item = dynamic_cast<QtMoleculeItem *>(itemFromIndex(_index));
    127127  if (item == NULL)
    128     return NULL;
     128    return -1;
    129129  else
    130     return ItemToMolecule(item);
     130    return ItemToMoleculeId(item);
    131131}
    132132
     
    153153        list_accessing = false;
    154154
    155         const QtMoleculeItem *mol_item = MoleculeToItem(mol);
     155        const QtMoleculeItem *mol_item = MoleculeIdToItem(mol->getId());
    156156        if (mol_item != NULL) {
    157157          QStandardItem *parent_item = mol_item->parent();
     
    194194void QtMoleculeList::addMoleculeItem(
    195195    QStandardItem *_groupitem,
    196     const molecule * const _mol,
     196    const moleculeId_t _molid,
    197197    const std::string &_molecule_formula)
    198198{
    199199  QList<QStandardItem *> molItems =
    200       QtMoleculeItemFactory::getInstance().createMoleculeItems(_mol, callback_DirtyItems);
     200      QtMoleculeItemFactory::getInstance().createMoleculeItems(_molid, callback_DirtyItems);
    201201  QtMoleculeItem *mol_item = dynamic_cast<QtMoleculeItem *>(molItems.front());
    202202  ASSERT( mol_item != NULL,
    203203      "QtMoleculeList::addMoleculeItem() - item from factory was not a QtMoleculeItem?");
    204   MoleculeItemBiMap.left.insert( std::make_pair(_mol, mol_item) );
     204  MoleculeItemBiMap.left.insert( std::make_pair(_molid, mol_item) );
    205205//  LOG(1, "Inserting molecule " << _mol->getId() << ": " << _mol);
    206206  _groupitem->appendRow(molItems);
     
    242242
    243243  // add molecule
    244   addMoleculeItem(groupItem, _mol, molecule_formula);
     244  addMoleculeItem(groupItem, _mol->getId(), molecule_formula);
    245245}
    246246
     
    567567  for (std::vector<const molecule *>::iterator removeiter = toBeRemovedItems_copy.begin();
    568568      removeiter != toBeRemovedItems_copy.end(); ++removeiter) {
    569     QtMoleculeItem *item = MoleculeToItem(*removeiter);
     569    QtMoleculeItem *item = MoleculeIdToItem((*removeiter)->getId());
    570570    dirtyItems_copy.erase(item);
    571571    toBeMovedItems_copy.erase(item);
     
    577577            (*visiter)->index().row(),
    578578            QtMoleculeItemFactory::NAME));
    579     const molecule *mol = ItemToMolecule(_item);
     579    const moleculeId_t molid = ItemToMoleculeId(_item);
     580    const molecule *mol = World::getInstance().getMolecule(MoleculeById(molid));
    580581    if (std::binary_search(
    581582            toBeRemovedItems_copy.begin(), toBeRemovedItems_copy.end(),
     
    613614      removeiter != toBeRemovedItems_copy.end(); ++removeiter) {
    614615//    LOG(1, "Removing molecule " << *removeiter); // cannot access directly, molecule is gone
    615     QtMoleculeItem *item = MoleculeToItem(*removeiter);
     616    QtMoleculeItem *item = MoleculeIdToItem((*removeiter)->getId());
    616617    if (item != NULL)
    617618      removeItem(item);
Note: See TracChangeset for help on using the changeset viewer.