Changeset 6116df for src/UIElements
- Timestamp:
- Jun 19, 2017, 8:24:17 AM (8 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChangeBugEmailaddress, ChemicalSpaceEvaluator, EmpiricalPotential_contain_HomologyGraph_documentation, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_oldresults, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps
- Children:
- be848d
- Parents:
- 5776cb
- git-author:
- Frederik Heber <heber@…> (04/01/17 07:03:30)
- git-committer:
- Frederik Heber <frederik.heber@…> (06/19/17 08:24:17)
- Location:
- src/UIElements/Views/Qt4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/QtGeometryList.cpp
r5776cb r6116df 45 45 46 46 #include <QAbstractItemView> 47 #include <QCoreApplication> 47 48 48 49 using namespace std; … … 56 57 { 57 58 setColumnCount(COLUMNCOUNT); 58 setSelectionMode(QAbstractItemView::NoSelection); 59 setSelectionMode(QAbstractItemView::SingleSelection); 60 setSortingEnabled(true); 59 61 60 62 QStringList header; … … 62 64 header << COLUMNNAMES[i]; 63 65 setHeaderLabels(header); 66 sortByColumn(0); 67 68 setStyleSheet("QTreeView::item:hover{background-color:#999966;}"); 64 69 65 70 refill(NULL); … … 68 73 GeometryRegistry::getInstance().signOn(this, GeometryRegistry::GeometryInserted); 69 74 GeometryRegistry::getInstance().signOn(this, GeometryRegistry::GeometryRemoved); 75 76 QCoreApplication::instance()->installEventFilter(this); 70 77 } 71 78 … … 129 136 void QtGeometryList::subjectKilled(Observable *publisher) { 130 137 } 138 139 bool QtGeometryList::eventFilter(QObject* object, QEvent* event) 140 { 141 if(event->type() == QEvent::MouseMove) 142 { 143 mouseMoveFunction(static_cast<QMouseEvent*>(event)); 144 } 145 // Repeat for other mouse events 146 147 // returning true blocks event returning false doesnt so if you want to block all mouse events except what your handling then return true inside each of your ifs 148 return false; 149 } 150 151 void QtGeometryList::mouseMoveFunction(QMouseEvent * event) 152 { 153 if (event->type() == QEvent::MouseMove) { 154 QTreeWidgetItem* current = itemAt(event->pos()); 155 if (current == NULL) 156 return; 157 // reset all tooltips 158 bool NoneSelected = true; 159 for (int i=0;i<topLevelItemCount();i++){ 160 QTreeWidgetItem *item = topLevelItem(i); 161 item->setToolTip(NAME, tr("")); 162 item->setToolTip(VECTOR, tr("")); 163 NoneSelected &= !item->isSelected(); 164 } 165 const std::string name = current->text(NAME).toStdString(); 166 GeometryObject *v = GeometryRegistry::getInstance().getByName(name); 167 const Vector currentVec = v->getVector(); 168 if ((NoneSelected) || (current->isSelected())) { 169 // show norm 170 std::string tooltiptext("Length:"); 171 tooltiptext += toString<double>(currentVec.Norm()); 172 tooltiptext += std::string(" Angström"); 173 current->setToolTip(NAME, trUtf8(tooltiptext.c_str())); 174 current->setToolTip(VECTOR, trUtf8(tooltiptext.c_str())); 175 } else { 176 for (int i=0;i<topLevelItemCount();i++){ 177 QTreeWidgetItem *item = topLevelItem(i); 178 if (item->isSelected()) { 179 // show angle 180 const std::string othername = item->text(NAME).toStdString(); 181 GeometryObject *otherv = GeometryRegistry::getInstance().getByName(othername); 182 const Vector otherVec = otherv->getVector(); 183 std::string tooltiptext("Angle:"); 184 tooltiptext += toString<double>(currentVec.Angle(otherVec)*180/M_PI); 185 tooltiptext += std::string(" deg"); 186 current->setToolTip(NAME, trUtf8(tooltiptext.c_str())); 187 current->setToolTip(VECTOR, trUtf8(tooltiptext.c_str())); 188 break; 189 } 190 } 191 } 192 } 193 } -
src/UIElements/Views/Qt4/QtGeometryList.hpp
r5776cb r6116df 16 16 17 17 #include <QtGui/QTreeWidget> 18 #include <QMouseEvent> 19 18 20 #include "CodePatterns/Observer/Observer.hpp" 19 21 … … 27 29 QtGeometryList(QWidget * _parent=0); 28 30 virtual ~QtGeometryList(); 31 32 protected: 33 bool eventFilter(QObject* object, QEvent* event); 34 void mouseMoveFunction(QMouseEvent * event); 29 35 30 36 protected:
Note:
See TracChangeset
for help on using the changeset viewer.