- Timestamp:
- Aug 5, 2015, 5:32:11 PM (9 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:
- 5b61e5
- Parents:
- a39d72
- git-author:
- Frederik Heber <heber@…> (07/19/15 12:01:14)
- git-committer:
- Frederik Heber <heber@…> (08/05/15 17:32:11)
- Location:
- src/UIElements/Views/Qt4/MoleculeList
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.cpp
ra39d72 r07b800 51 51 52 52 #include "Atom/atom.hpp" 53 #include "Actions/MoleculeAction/ChangeNameAction.hpp" 54 #include "Actions/SelectionAction/Molecules/PopMoleculesAction.hpp" 55 #include "Actions/SelectionAction/Molecules/PushMoleculesAction.hpp" 56 #include "Actions/SelectionAction/Molecules/MoleculeByIdAction.hpp" 57 #include "Actions/ActionQueue.hpp" 58 #include "Actions/ActionSequence.hpp" 59 #include "Actions/ActionTrait.hpp" 60 #include "Actions/MakroAction.hpp" 53 61 #include "Descriptors/MoleculeIdDescriptor.hpp" 54 62 #include "Formula.hpp" … … 73 81 refill(); 74 82 75 // qRegisterMetaType<QItemSelection>("QItemSelection"); 76 //connect(this,SIGNAL(cellChanged(int,int)),this,SLOT(moleculeChanged(int,int))); 77 // connect(selectionModel(),SIGNAL(selectionChanged(QItemSelection, QItemSelection)),this,SLOT(rowsSelected(QItemSelection, QItemSelection))); 83 connect(this,SIGNAL(itemChanged(QStandardItem*)),this,SLOT(moleculeNameChanged(QStandardItem*))); 78 84 connect(this, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(checkForVisibilityChange(QStandardItem*)), Qt::DirectConnection); 79 85 } … … 507 513 } 508 514 509 510 void QtMoleculeList::moleculeChanged() { 511 /*int idx = verticalHeaderItem(row)->data(Qt::UserRole).toInt(); 512 molecule *mol = molecules->ReturnIndex(idx); 513 string cellValue = item(row,QtMoleculeItem::NAME)->text().toStdString(); 514 if(mol->getName() != cellValue && cellValue !="") { 515 mol->setName(cellValue); 516 } 517 else if(cellValue==""){ 518 item(row,QtMoleculeItem::NAME)->setText(QString(mol->getName().c_str())); 519 }*/ 515 static 516 MoleCuilder::MakroAction *constructMakroRenameAction( 517 MoleCuilder::ActionSequence &sequence, 518 const std::string &_new_name, 519 const moleculeId_t _molid 520 ) 521 { 522 MoleCuilder::ActionQueue &AQ = MoleCuilder::ActionQueue::getInstance(); 523 MoleCuilder::ActionTrait trait("change-single-molecule-name"); 524 sequence.addAction(AQ.getActionByName("push-molecule-selection").clone(MoleCuilder::Action::NonInteractive)); 525 MoleCuilder::Action * const selectaction = 526 AQ.getActionByName("select-molecule-by-id").clone(MoleCuilder::Action::NonInteractive); 527 { 528 std::stringstream molid_string; 529 molid_string << toString(_molid); 530 selectaction->setOptionValue("select-molecule-by-id", molid_string.str()); 531 } 532 sequence.addAction(selectaction); 533 MoleCuilder::Action * const changeaction = 534 AQ.getActionByName("change-molname").clone(MoleCuilder::Action::NonInteractive); 535 changeaction->setOptionValue("change-molname", _new_name); 536 sequence.addAction(changeaction); 537 sequence.addAction(AQ.getActionByName("pop-molecule-selection").clone(MoleCuilder::Action::NonInteractive)); 538 539 MoleCuilder::MakroAction* makroaction = 540 new MoleCuilder::MakroAction(trait, sequence); 541 return makroaction; 542 } 543 544 void QtMoleculeList::moleculeNameChanged(QStandardItem* item) 545 { 546 boost::recursive_mutex::scoped_lock lock(refill_mutex); 547 // obtain molecule id 548 if ( item->index().column() == QtMoleculeItem::NAME) { 549 QtMoleculeItem *molitem = assert_cast<QtMoleculeItem *>(item); 550 MoleculeItemBiMap_t::right_const_iterator iter = MoleculeItemBiMap.right.find(molitem); 551 ASSERT( iter != MoleculeItemBiMap.right.end(), 552 "QtMoleculeList::moleculeChanged() - name of unknown molecule changed."); 553 const moleculeId_t molid = iter->second; 554 // change the name 555 molecule * const mol = World::getInstance().getMolecule(MoleculeById(molid)); 556 std::string cellValue = item->text().toStdString(); 557 if ((mol->getName() != cellValue) && (!cellValue.empty())) { 558 // create actions such that we may undo 559 static MoleCuilder::ActionSequence sequence; 560 MoleCuilder::MakroAction *makroaction = 561 constructMakroRenameAction(sequence, cellValue, molid); 562 MoleCuilder::ActionQueue &AQ = MoleCuilder::ActionQueue::getInstance(); 563 AQ.registerAction(makroaction); 564 AQ.queueAction("change-single-molecule-name", MoleCuilder::Action::NonInteractive); 565 } else if(cellValue=="") { 566 item->setText(QString(mol->getName().c_str())); 567 } 568 } 520 569 } 521 570 -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp
ra39d72 r07b800 54 54 55 55 private slots: 56 void moleculeChanged(); 57 // void visibilityChanged(QStandardItem*, int); 56 void moleculeNameChanged(QStandardItem*); 58 57 void checkForVisibilityChange(QStandardItem*); 59 58 void checkState();
Note:
See TracChangeset
for help on using the changeset viewer.