Changeset 7cd6e7 for src/UIElements/QT4
- Timestamp:
- Jul 25, 2010, 3:07:42 PM (14 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:
- e2f3114
- Parents:
- 0ff6b5
- Location:
- src/UIElements/QT4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/QT4/QTDialog.cpp
r0ff6b5 r7cd6e7 17 17 #include <QtGui/QDoubleSpinBox> 18 18 #include <Qt/qlineedit.h> 19 #include <Qt/qlistwidget.h> 19 20 #include <Qt/qdialogbuttonbox.h> 20 21 #include <Qt/qpushbutton.h> … … 28 29 #include "element.hpp" 29 30 #include "molecule.hpp" 31 #include "Descriptors/AtomIdDescriptor.hpp" 30 32 #include "Descriptors/MoleculeIdDescriptor.hpp" 31 33 #include "Matrix.hpp" … … 95 97 } 96 98 99 void QTDialog::queryAtoms(char const*, string){ 100 // TODO 101 ASSERT(false, "Not implemented yet"); 102 } 103 97 104 void QTDialog::queryBox(char const*, string){ 98 105 // TODO … … 106 113 } 107 114 115 void QTDialog::queryInts(const char *title,string) 116 { 117 registerQuery(new IntsQTQuery(title,inputLayout,this)); 118 } 119 108 120 void QTDialog::queryDouble(const char* title,string){ 109 121 registerQuery(new DoubleQTQuery(title,inputLayout,this)); 110 122 } 111 123 124 void QTDialog::queryDoubles(const char* title,string){ 125 registerQuery(new DoublesQTQuery(title,inputLayout,this)); 126 } 127 112 128 void QTDialog::queryString(const char* title,string) 113 129 { … … 123 139 { 124 140 registerQuery(new MoleculeQTQuery(title,inputLayout,this)); 141 } 142 143 void QTDialog::queryMolecules(const char *title,string) 144 { 145 // TODO 146 ASSERT(false, "Not implemented yet"); 125 147 } 126 148 … … 129 151 } 130 152 153 void QTDialog::queryVectors(const char* title, bool check,string) { 154 // TODO 155 ASSERT(false, "Not implemented yet"); 156 } 157 131 158 void QTDialog::queryElement(const char* title, string){ 132 159 registerQuery(new ElementQTQuery(title,inputLayout,this)); 160 } 161 162 void QTDialog::queryElements(const char* title, string){ 163 // TODO 164 ASSERT(false, "Not implemented yet"); 133 165 } 134 166 … … 157 189 } 158 190 159 // Handling is easy since the GUI makes it impossible to enter invalid values 160 bool QTDialog::IntQTQuery::handle() 161 { 162 return true; 163 } 191 bool QTDialog::IntQTQuery::handle() { 192 return true; 193 } 194 195 196 QTDialog::IntsQTQuery::IntsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) : 197 Dialog::IntsQuery(_title), 198 parent(_parent) 199 { 200 QHBoxLayout * thisHLayout = new QHBoxLayout(); 201 QVBoxLayout * thisV1Layout = new QVBoxLayout(); 202 QVBoxLayout * thisV2Layout = new QVBoxLayout(); 203 204 QLabel *titleLabel = new QLabel(QString(getTitle().c_str())); 205 QLabel *inputLabel = new QLabel("Enter to add"); 206 QListWidget* inputList = new QListWidget(); 207 inputList->setSelectionMode(QAbstractItemView::ExtendedSelection); 208 QLineEdit* inputBox = new QLineEdit(); 209 inputLabel->setBuddy(inputBox); 210 titleLabel->setBuddy(inputList); 211 QPushButton* AddButton = new QPushButton("Add"); 212 AddButton->setEnabled(false); 213 QPushButton* RemoveButton = new QPushButton("Remove"); 214 RemoveButton->setEnabled(false); 215 216 thisV1Layout->addWidget(titleLabel); 217 thisV1Layout->addWidget(inputList); 218 thisV2Layout->addWidget(inputLabel); 219 thisV2Layout->addWidget(inputBox); 220 thisV2Layout->addWidget(AddButton); 221 thisV2Layout->addWidget(RemoveButton); 222 parent->addLayout(thisHLayout); 223 thisHLayout->addLayout(thisV1Layout); 224 thisHLayout->addLayout(thisV2Layout); 225 226 pipe = new QTQueryListPipe<int>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton); 227 connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&))); 228 connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected())); 229 connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue())); 230 connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow())); 231 } 232 233 QTDialog::IntsQTQuery::~IntsQTQuery() 234 { 235 delete pipe; 236 } 237 238 bool QTDialog::IntsQTQuery::handle() { 239 return true; 240 } 241 164 242 165 243 QTDialog::DoubleQTQuery::DoubleQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) : … … 192 270 193 271 272 QTDialog::DoublesQTQuery::DoublesQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) : 273 Dialog::DoublesQuery(title), 274 parent(_parent) 275 { 276 QHBoxLayout * thisHLayout = new QHBoxLayout(); 277 QVBoxLayout * thisV1Layout = new QVBoxLayout(); 278 QVBoxLayout * thisV2Layout = new QVBoxLayout(); 279 280 QLabel *titleLabel = new QLabel(QString(getTitle().c_str())); 281 QLabel *inputLabel = new QLabel("Enter to add"); 282 QListWidget* inputList = new QListWidget(); 283 inputList->setSelectionMode(QAbstractItemView::ExtendedSelection); 284 QLineEdit* inputBox = new QLineEdit(); 285 inputLabel->setBuddy(inputBox); 286 titleLabel->setBuddy(inputList); 287 QPushButton* AddButton = new QPushButton("Add"); 288 AddButton->setEnabled(false); 289 QPushButton* RemoveButton = new QPushButton("Remove"); 290 RemoveButton->setEnabled(false); 291 292 thisV1Layout->addWidget(titleLabel); 293 thisV1Layout->addWidget(inputList); 294 thisV2Layout->addWidget(inputLabel); 295 thisV2Layout->addWidget(inputBox); 296 thisV2Layout->addWidget(AddButton); 297 thisV2Layout->addWidget(RemoveButton); 298 parent->addLayout(thisHLayout); 299 thisHLayout->addLayout(thisV1Layout); 300 thisHLayout->addLayout(thisV2Layout); 301 302 pipe = new QTQueryListPipe<double>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton); 303 connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&))); 304 connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected())); 305 connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue())); 306 connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));} 307 308 QTDialog::DoublesQTQuery::~DoublesQTQuery() 309 { 310 delete pipe; 311 } 312 313 bool QTDialog::DoublesQTQuery::handle() { 314 return true; 315 } 316 317 194 318 QTDialog::StringQTQuery::StringQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) : 195 319 Dialog::StringQuery(_title), … … 223 347 parent(_parent) 224 348 { 225 thisLayout = new QHBoxLayout(); 226 titleLabel = new QLabel(QString(getTitle().c_str())); 227 inputBox = new QLineEdit(); 228 parent->addLayout(thisLayout); 229 thisLayout->addWidget(titleLabel); 230 thisLayout->addWidget(inputBox); 231 232 pipe = new StringQTQueryPipe(&temp,_dialog); 233 pipe->update(inputBox->text()); 234 connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(update(const QString&))); 235 } 349 QHBoxLayout * thisHLayout = new QHBoxLayout(); 350 QVBoxLayout * thisV1Layout = new QVBoxLayout(); 351 QVBoxLayout * thisV2Layout = new QVBoxLayout(); 352 353 QLabel *titleLabel = new QLabel(QString(getTitle().c_str())); 354 QLabel *inputLabel = new QLabel("Enter to add"); 355 QListWidget* inputList = new QListWidget(); 356 inputList->setSelectionMode(QAbstractItemView::ExtendedSelection); 357 QLineEdit* inputBox = new QLineEdit(); 358 inputLabel->setBuddy(inputBox); 359 titleLabel->setBuddy(inputList); 360 QPushButton* AddButton = new QPushButton("Add"); 361 AddButton->setEnabled(false); 362 QPushButton* RemoveButton = new QPushButton("Remove"); 363 RemoveButton->setEnabled(false); 364 365 thisV1Layout->addWidget(titleLabel); 366 thisV1Layout->addWidget(inputList); 367 thisV2Layout->addWidget(inputLabel); 368 thisV2Layout->addWidget(inputBox); 369 thisV2Layout->addWidget(AddButton); 370 thisV2Layout->addWidget(RemoveButton); 371 parent->addLayout(thisHLayout); 372 thisHLayout->addLayout(thisV1Layout); 373 thisHLayout->addLayout(thisV2Layout); 374 375 pipe = new QTQueryListPipe<std::string>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton); 376 connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&))); 377 connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected())); 378 connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue())); 379 connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));} 236 380 237 381 QTDialog::StringsQTQuery::~StringsQTQuery() … … 293 437 } 294 438 439 QTDialog::MoleculesQTQuery::MoleculesQTQuery(string _title, QBoxLayout *_parent,QTDialog *_dialog) : 440 Dialog::MoleculesQuery(_title), 441 parent(_parent) 442 { 443 thisLayout = new QHBoxLayout(); 444 titleLabel = new QLabel(QString(getTitle().c_str())); 445 inputBox = new QComboBox(); 446 // add all molecules to the combo box 447 vector<molecule*> molecules = World::getInstance().getAllMolecules(); 448 for(vector<molecule*>::iterator iter = molecules.begin(); 449 iter != molecules.end(); 450 ++iter) { 451 stringstream sstr; 452 sstr << (*iter)->IndexNr << "\t" << (*iter)->getName(); 453 inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr)); 454 } 455 parent->addLayout(thisLayout); 456 thisLayout->addWidget(titleLabel); 457 thisLayout->addWidget(inputBox); 458 459 pipe = new MoleculesQTQueryPipe(&tmp,_dialog,inputBox); 460 pipe->update(inputBox->currentIndex()); 461 connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); 462 } 463 464 QTDialog::MoleculesQTQuery::~MoleculesQTQuery() 465 { 466 delete pipe; 467 } 468 469 // Handling is easy, since the GUI makes it impossible to select invalid values 470 bool QTDialog::MoleculesQTQuery::handle() 471 { 472 return true; 473 } 474 295 475 QTDialog::VectorQTQuery::VectorQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) : 296 476 Dialog::VectorQuery(title,_check), … … 304 484 subLayout = new QVBoxLayout(); 305 485 mainLayout->addLayout(subLayout); 306 for(int i=0; i<3; i++) { 307 coordLayout[i] = new QHBoxLayout(); 308 subLayout->addLayout(coordLayout[i]); 309 coordLabel[i] = new QLabel(QString(coords[i])); 310 coordLayout[i]->addWidget(coordLabel[i]); 311 coordInput[i] = new QDoubleSpinBox(); 312 coordInput[i]->setRange(0,M.at(i,i)); 313 coordInput[i]->setDecimals(3); 314 coordLayout[i]->addWidget(coordInput[i]); 315 pipe[i] = new DoubleQTQueryPipe(&((*tmp)[i]),_dialog); 316 pipe[i]->update(coordInput[i]->value()); 317 connect(coordInput[i],SIGNAL(valueChanged(double)),pipe[i],SLOT(update(double))); 318 319 } 486 QComboBox* inputBox = new QComboBox(); 487 coordLayout = new QHBoxLayout(); 488 subLayout->addLayout(coordLayout); 489 coordLabel = new QLabel(QString("x,y,z")); 490 coordLayout->addWidget(coordLabel); 491 coordInput = new QDoubleSpinBox(); 492 // coordInput->setRange(0,M.at(i,i)); 493 coordInput->setDecimals(3); 494 coordLayout->addWidget(coordInput); 495 pipe = new VectorQTQueryPipe(&(tmp),_dialog,inputBox); 496 //pipe->update(coordInput->value()); 497 connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double))); 320 498 parent->addLayout(mainLayout); 321 499 } … … 325 503 326 504 bool QTDialog::VectorQTQuery::handle() { 505 return true; 506 } 507 508 509 QTDialog::VectorsQTQuery::VectorsQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) : 510 Dialog::VectorsQuery(title,_check), 511 parent(_parent) 512 { 513 const Matrix& M = World::getInstance().getDomain().getM(); 514 const char *coords[3] = {"x:","y:","z:"}; 515 mainLayout= new QHBoxLayout(); 516 titleLabel = new QLabel(QString(getTitle().c_str())); 517 mainLayout->addWidget(titleLabel); 518 subLayout = new QVBoxLayout(); 519 mainLayout->addLayout(subLayout); 520 QComboBox* inputBox = new QComboBox(); 521 coordLayout = new QHBoxLayout(); 522 subLayout->addLayout(coordLayout); 523 coordLabel = new QLabel(QString("x,y,z")); 524 coordLayout->addWidget(coordLabel); 525 coordInput = new QDoubleSpinBox(); 526 // coordInput->setRange(0,M.at(i,i)); 527 coordInput->setDecimals(3); 528 coordLayout->addWidget(coordInput); 529 pipe = new VectorsQTQueryPipe(&(tmp),_dialog,inputBox); 530 //pipe->update(coordInput->value()); 531 connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double))); 532 parent->addLayout(mainLayout); 533 } 534 535 QTDialog::VectorsQTQuery::~VectorsQTQuery() 536 {} 537 538 bool QTDialog::VectorsQTQuery::handle() { 327 539 return true; 328 540 } … … 363 575 } 364 576 577 578 QTDialog::ElementsQTQuery::ElementsQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog) : 579 Dialog::ElementsQuery(_title), 580 parent(_parent) 581 { 582 periodentafel *periode = World::getInstance().getPeriode(); 583 thisLayout = new QHBoxLayout(); 584 titleLabel = new QLabel(QString(getTitle().c_str())); 585 inputBox = new QComboBox(); 586 for(periodentafel::const_iterator iter = periode->begin(); 587 iter!=periode->end(); 588 ++iter) 589 { 590 stringstream sstr; 591 sstr << (*iter).first << "\t" << (*iter).second->name; 592 inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first)); 593 } 594 parent->addLayout(thisLayout); 595 thisLayout->addWidget(titleLabel); 596 thisLayout->addWidget(inputBox); 597 598 pipe = new ElementsQTQueryPipe(&tmp,_dialog,inputBox); 599 pipe->update(inputBox->currentIndex()); 600 connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); 601 } 602 603 QTDialog::ElementsQTQuery::~ElementsQTQuery() 604 { 605 delete pipe; 606 } 607 608 bool QTDialog::ElementsQTQuery::handle(){ 609 return true; 610 } 611 365 612 /*************************** Plumbing *******************************/ 613 614 615 template<typename T> QTQueryListPipe<T>::QTQueryListPipe(std::vector<T> *_content, QTDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton) : 616 content(_content), 617 dialog(_dialog), 618 inputBox(_inputBox), 619 inputList(_inputList), 620 AddButton(_AddButton), 621 RemoveButton(_RemoveButton) 622 {} 623 624 template<typename T> QTQueryListPipe<T>::~QTQueryListPipe() 625 {} 626 627 template<typename T> void QTQueryListPipe<T>::IntegerEntered(const QString&) 628 { 629 AddButton->setEnabled(true); 630 } 631 632 template<typename T> void QTQueryListPipe<T>::IntegerSelected() 633 { 634 if (inputList->selectedItems().empty()) 635 RemoveButton->setEnabled(false); 636 else 637 RemoveButton->setEnabled(true); 638 } 639 640 template<typename T> void QTQueryListPipe<T>::AddInteger() { 641 // type-check 642 std::string text = inputBox->text().toStdString(); 643 int number = 0; 644 try { 645 number = boost::lexical_cast<int>(text); 646 } catch (boost::bad_lexical_cast&) { 647 return; 648 }; 649 // add item to both 650 inputList->addItem(QString(number)); 651 AddValue(number); 652 } 653 654 template<typename T> void QTQueryListPipe<T>::AddValue(T item) { 655 content->push_back(item); 656 657 dialog->update(); 658 } 659 660 template<typename T> void QTQueryListPipe<T>::RemoveInteger() { 661 QList<QListWidgetItem *> items = inputList->selectedItems(); 662 for (QList<QListWidgetItem *>::iterator iter = items.begin(); !items.empty(); iter = items.begin()) { 663 // obtain which position item has (by making it current item) 664 inputList->setCurrentItem(*iter); 665 // remove 666 QTQueryListPipe<T>::RemoteRow(inputList->currentRow()); // template parameters needs to be known, such that compiler knows which to call 667 inputList->removeItemWidget(*iter); 668 } 669 } 670 671 template<typename T> void QTQueryListPipe<T>::RemoveRow(int row) { 672 int counter = 0; 673 typename std::vector<T>::iterator iter = content->begin(); 674 for (; iter != content->end(); ++iter) 675 if (counter++ == row) 676 break; 677 if (iter != content->end()) 678 content->erase(iter); 679 } 680 366 681 367 682 StringQTQueryPipe::StringQTQueryPipe(string *_content, QTDialog *_dialog) : … … 403 718 dialog->update(); 404 719 } 720 721 VectorQTQueryPipe::VectorQTQueryPipe(Vector *_content, QTDialog *_dialog, QComboBox *_theBox) : 722 content(_content), 723 dialog(_dialog), 724 theBox(_theBox) 725 {} 726 727 VectorQTQueryPipe::~VectorQTQueryPipe() 728 {} 729 730 void VectorQTQueryPipe::update() { 731 dialog->update(); 732 } 733 734 VectorsQTQueryPipe::VectorsQTQueryPipe(std::vector<Vector> *_content, QTDialog *_dialog, QComboBox *_theBox) : 735 content(_content), 736 dialog(_dialog), 737 theBox(_theBox) 738 {} 739 740 VectorsQTQueryPipe::~VectorsQTQueryPipe() 741 {} 742 743 void VectorsQTQueryPipe::update() { 744 dialog->update(); 745 } 746 747 AtomQTQueryPipe::AtomQTQueryPipe(atom **_content, QTDialog *_dialog, QComboBox *_theBox) : 748 content(_content), 749 dialog(_dialog), 750 theBox(_theBox) 751 {} 752 753 AtomQTQueryPipe::~AtomQTQueryPipe() 754 {} 755 756 void AtomQTQueryPipe::update(int newIndex) { 757 QVariant data = theBox->itemData(newIndex); 758 int idx = data.toInt(); 759 (*content) = World::getInstance().getAtom(AtomById(idx)); 760 dialog->update(); 761 } 762 763 764 AtomsQTQueryPipe::AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QComboBox *_theBox) : 765 content(_content), 766 dialog(_dialog), 767 theBox(_theBox) 768 {} 769 770 AtomsQTQueryPipe::~AtomsQTQueryPipe() 771 {} 772 773 void AtomsQTQueryPipe::update(int newIndex) { 774 QVariant data = theBox->itemData(newIndex); 775 int idx = data.toInt(); 776 atom *Walker = World::getInstance().getAtom(AtomById(idx)); 777 if (Walker) 778 (*content).push_back(Walker) ; 779 dialog->update(); 780 } 781 405 782 406 783 MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox) : … … 420 797 } 421 798 422 ElementQTQueryPipe::ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox) : 799 800 MoleculesQTQueryPipe::MoleculesQTQueryPipe(std::vector<molecule *>*_content, QTDialog *_dialog, QComboBox *_theBox) : 423 801 content(_content), 424 802 dialog(_dialog), 425 803 theBox(_theBox) 426 { 427 content->resize(1); 428 } 804 {} 805 806 MoleculesQTQueryPipe::~MoleculesQTQueryPipe() 807 {} 808 809 void MoleculesQTQueryPipe::update(int newIndex) { 810 QVariant data = theBox->itemData(newIndex); 811 int idx = data.toInt(); 812 molecule *mol = World::getInstance().getMolecule(MoleculeById(idx)); 813 if (mol) 814 (*content).push_back(mol); 815 dialog->update(); 816 } 817 818 ElementQTQueryPipe::ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox) : 819 content(_content), 820 dialog(_dialog), 821 theBox(_theBox) 822 {} 429 823 430 824 ElementQTQueryPipe::~ElementQTQueryPipe() … … 434 828 QVariant data = theBox->itemData(newIndex); 435 829 int idx = data.toInt(); 436 (*content)[0] = World::getInstance().getPeriode()->FindElement(idx); 437 dialog->update(); 438 } 439 830 *content = World::getInstance().getPeriode()->FindElement(idx); 831 dialog->update(); 832 } 833 834 ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox) : 835 content(_content), 836 dialog(_dialog), 837 theBox(_theBox) 838 {} 839 840 ElementsQTQueryPipe::~ElementsQTQueryPipe() 841 {} 842 843 void ElementsQTQueryPipe::update(int newIndex) { 844 QVariant data = theBox->itemData(newIndex); 845 int idx = data.toInt(); 846 element *elemental = World::getInstance().getPeriode()->FindElement(idx); 847 if(elemental) 848 (*content).push_back(elemental); 849 dialog->update(); 850 } 851 852 -
src/UIElements/QT4/QTDialog.hpp
r0ff6b5 r7cd6e7 17 17 class QDoubleSpinBox; 18 18 class QLineEdit; 19 class QListWidget; 19 20 class QComboBox; 20 21 class QDialogButtonBox; … … 22 23 23 24 // Forward declarations for plumbing 25 template<typename T> class QTQueryListPipe; 24 26 class StringQTQueryPipe; 27 class StringsQTQueryPipe; 25 28 class IntQTQueryPipe; 26 29 class DoubleQTQueryPipe; 30 class DoublesQTQueryPipe; 31 class AtomQTQueryPipe; 32 class AtomsQTQueryPipe; 27 33 class MoleculeQTQueryPipe; 34 class MoleculesQTQueryPipe; 28 35 class ElementQTQueryPipe; 36 class ElementsQTQueryPipe; 37 class VectorQTQueryPipe; 38 class VectorsQTQueryPipe; 29 39 30 40 class QTDialog : public QDialog, public Dialog … … 38 48 virtual void queryBoolean(const char *, std::string = ""); 39 49 virtual void queryInt(const char *,std::string = ""); 50 virtual void queryInts(const char *,std::string = ""); 40 51 virtual void queryDouble(const char*,std::string = ""); 52 virtual void queryDoubles(const char*,std::string = ""); 41 53 virtual void queryString(const char*,std::string = ""); 42 54 virtual void queryStrings(const char*,std::string = ""); 43 55 virtual void queryAtom(const char*,std::string = ""); 56 virtual void queryAtoms(const char*,std::string = ""); 44 57 virtual void queryMolecule(const char*,std::string = ""); 58 virtual void queryMolecules(const char*,std::string = ""); 45 59 virtual void queryVector(const char*,bool,std::string = ""); 60 virtual void queryVectors(const char*,bool,std::string = ""); 46 61 virtual void queryBox(const char*, std::string = ""); 47 62 virtual void queryElement(const char*,std::string = ""); 63 virtual void queryElements(const char*,std::string = ""); 48 64 49 65 virtual bool display(); … … 66 82 }; 67 83 84 class IntsQTQuery : public Dialog::IntsQuery { 85 public: 86 IntsQTQuery(std::string _title,QBoxLayout *_parent,QTDialog *_dialog); 87 virtual ~IntsQTQuery(); 88 virtual bool handle(); 89 void IntegerEntered(const QString&); 90 void IntegerSelected(); 91 void AddInteger(); 92 void RemoveInteger(); 93 private: 94 QBoxLayout *parent; 95 QBoxLayout *thisLayout; 96 QLabel *titleLabel; 97 98 QTQueryListPipe<int> *pipe; 99 }; 100 68 101 class DoubleQTQuery : public Dialog::DoubleQuery { 69 102 public: … … 80 113 }; 81 114 115 class DoublesQTQuery : public Dialog::DoublesQuery { 116 public: 117 DoublesQTQuery(std::string title,QBoxLayout *_parent,QTDialog *_dialog); 118 virtual ~DoublesQTQuery(); 119 virtual bool handle(); 120 private: 121 QBoxLayout *parent; 122 QBoxLayout *thisLayout; 123 QLabel *titleLabel; 124 QDoubleSpinBox *inputBox; 125 126 QTQueryListPipe<double> *pipe; 127 }; 128 82 129 class StringQTQuery : public Dialog::StringQuery { 83 130 public: … … 105 152 QLineEdit *inputBox; 106 153 107 StringQTQueryPipe *pipe; 154 QTQueryListPipe<std::string> *pipe; 155 }; 156 157 class AtomQTQuery : public Dialog::AtomQuery { 158 public: 159 AtomQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog); 160 virtual ~AtomQTQuery(); 161 virtual bool handle(); 162 private: 163 QBoxLayout *parent; 164 QBoxLayout *thisLayout; 165 QLabel *titleLabel; 166 QComboBox *inputBox; 167 168 AtomQTQueryPipe *pipe; 169 }; 170 171 class AtomsQTQuery : public Dialog::AtomsQuery { 172 public: 173 AtomsQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog); 174 virtual ~AtomsQTQuery(); 175 virtual bool handle(); 176 private: 177 QBoxLayout *parent; 178 QBoxLayout *thisLayout; 179 QLabel *titleLabel; 180 QComboBox *inputBox; 181 182 AtomsQTQueryPipe *pipe; 108 183 }; 109 184 … … 122 197 }; 123 198 199 class MoleculesQTQuery : public Dialog::MoleculesQuery { 200 public: 201 MoleculesQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog); 202 virtual ~MoleculesQTQuery(); 203 virtual bool handle(); 204 private: 205 QBoxLayout *parent; 206 QBoxLayout *thisLayout; 207 QLabel *titleLabel; 208 QComboBox *inputBox; 209 210 MoleculesQTQueryPipe *pipe; 211 }; 212 124 213 class VectorQTQuery : public Dialog::VectorQuery { 125 214 public: … … 132 221 QLabel *titleLabel; 133 222 QBoxLayout *subLayout; 134 QBoxLayout *coordLayout[3]; 135 QLabel *coordLabel[3]; 136 QDoubleSpinBox *coordInput[3]; 137 138 DoubleQTQueryPipe *pipe[3]; 223 QBoxLayout *coordLayout; 224 QLabel *coordLabel; 225 QDoubleSpinBox *coordInput; 226 227 VectorQTQueryPipe *pipe; 228 }; 229 230 class VectorsQTQuery : public Dialog::VectorsQuery { 231 public: 232 VectorsQTQuery(std::string title,bool _check,QBoxLayout *,QTDialog *); 233 virtual ~VectorsQTQuery(); 234 virtual bool handle(); 235 private: 236 QBoxLayout *parent; 237 QBoxLayout *mainLayout; 238 QLabel *titleLabel; 239 QBoxLayout *subLayout; 240 QBoxLayout *coordLayout; 241 QLabel *coordLabel; 242 QDoubleSpinBox *coordInput; 243 244 VectorsQTQueryPipe *pipe; 139 245 }; 140 246 … … 151 257 152 258 ElementQTQueryPipe *pipe; 259 }; 260 261 class ElementsQTQuery : public Dialog::ElementsQuery { 262 public: 263 ElementsQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog); 264 virtual ~ElementsQTQuery(); 265 virtual bool handle(); 266 private: 267 QBoxLayout *parent; 268 QBoxLayout *thisLayout; 269 QLabel *titleLabel; 270 QComboBox *inputBox; 271 272 ElementsQTQueryPipe *pipe; 153 273 }; 154 274 … … 164 284 // since MOC doesn't like nested classes 165 285 286 287 template<typename T> class QTQueryListPipe : public QWidget { 288 public: 289 QTQueryListPipe(std::vector<T> *_content, QTDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton); 290 virtual ~QTQueryListPipe(); 291 void AddInteger(); 292 void RemoveInteger(); 293 void IntegerSelected(); 294 void IntegerEntered(const QString&); 295 296 private: 297 void AddValue(T item); 298 void RemoveRow(int row); 299 300 std::vector<T> *content; 301 QTDialog *dialog; 302 QLineEdit *inputBox; 303 QListWidget *inputList; 304 QPushButton *AddButton; 305 QPushButton *RemoveButton; 306 }; 307 308 166 309 class StringQTQueryPipe : public QWidget { 167 310 Q_OBJECT … … 194 337 }; 195 338 339 196 340 class DoubleQTQueryPipe : public QWidget { 197 341 Q_OBJECT … … 209 353 }; 210 354 355 class AtomQTQueryPipe : public QWidget { 356 Q_OBJECT 357 public: 358 AtomQTQueryPipe(atom **_content, QTDialog *_dialog, QComboBox *_theBox); 359 virtual ~AtomQTQueryPipe(); 360 361 public slots: 362 void update(int); 363 364 private: 365 atom **content; 366 QTDialog *dialog; 367 QComboBox *theBox; 368 369 }; 370 371 372 class AtomsQTQueryPipe : public QWidget { 373 Q_OBJECT 374 public: 375 AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QComboBox *_theBox); 376 virtual ~AtomsQTQueryPipe(); 377 378 public slots: 379 void update(int); 380 381 private: 382 std::vector<atom *>*content; 383 QTDialog *dialog; 384 QComboBox *theBox; 385 386 }; 387 211 388 class MoleculeQTQueryPipe : public QWidget { 212 389 Q_OBJECT … … 225 402 }; 226 403 404 class MoleculesQTQueryPipe : public QWidget { 405 Q_OBJECT 406 public: 407 MoleculesQTQueryPipe(std::vector<molecule *>*_content, QTDialog *_dialog, QComboBox *_theBox); 408 virtual ~MoleculesQTQueryPipe(); 409 410 public slots: 411 void update(int); 412 413 private: 414 std::vector<molecule *>*content; 415 QTDialog *dialog; 416 QComboBox *theBox; 417 418 }; 419 420 class VectorQTQueryPipe : public QWidget { 421 Q_OBJECT 422 public: 423 VectorQTQueryPipe(Vector *_content, QTDialog *_dialog, QComboBox *_theBox); 424 virtual ~VectorQTQueryPipe(); 425 426 public slots: 427 void update(); 428 429 private: 430 Vector *content; 431 QTDialog *dialog; 432 QComboBox *theBox; 433 }; 434 435 class VectorsQTQueryPipe : public QWidget { 436 Q_OBJECT 437 public: 438 VectorsQTQueryPipe(std::vector<Vector>*_content, QTDialog *_dialog, QComboBox *_theBox); 439 virtual ~VectorsQTQueryPipe(); 440 441 public slots: 442 void update(); 443 444 private: 445 std::vector<Vector> *content; 446 QTDialog *dialog; 447 QComboBox *theBox; 448 }; 449 227 450 class ElementQTQueryPipe : public QWidget { 228 451 Q_OBJECT 229 452 public: 230 ElementQTQueryPipe( std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox);453 ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox); 231 454 virtual ~ElementQTQueryPipe(); 232 455 … … 235 458 236 459 private: 237 std::vector<element *> *content; 460 element **content; 461 QTDialog *dialog; 462 QComboBox *theBox; 463 }; 464 465 class ElementsQTQueryPipe : public QWidget { 466 Q_OBJECT 467 public: 468 ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox); 469 virtual ~ElementsQTQueryPipe(); 470 471 public slots: 472 void update(int); 473 474 private: 475 std::vector<element *>*content; 238 476 QTDialog *dialog; 239 477 QComboBox *theBox;
Note:
See TracChangeset
for help on using the changeset viewer.