1 | /*
|
---|
2 | * Project: MoleCuilder
|
---|
3 | * Description: creates and alters molecular systems
|
---|
4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * QtMoleculeView.cpp
|
---|
10 | *
|
---|
11 | * Created on: Mar 4, 2010
|
---|
12 | * Author: crueger
|
---|
13 | */
|
---|
14 |
|
---|
15 | // include config.h
|
---|
16 | #ifdef HAVE_CONFIG_H
|
---|
17 | #include <config.h>
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #include "Views/Qt4/QtMoleculeView.hpp"
|
---|
21 |
|
---|
22 | #include <iostream>
|
---|
23 |
|
---|
24 | #include "CodePatterns/MemDebug.hpp"
|
---|
25 |
|
---|
26 | #include "molecule.hpp"
|
---|
27 |
|
---|
28 | using namespace std;
|
---|
29 |
|
---|
30 | /***************** Basic structure for tab layout ***********/
|
---|
31 |
|
---|
32 | QtMoleculeView::QtMoleculeView() :
|
---|
33 | QTabWidget(),
|
---|
34 | page_mol(NULL), page_atom(NULL)
|
---|
35 | {
|
---|
36 | /*allPage = new QTAllMoleculePage();
|
---|
37 | addTab(allPage,QString("All Molecules"));
|
---|
38 |
|
---|
39 | connect(this,SIGNAL(addMolecule(molecule*)),allPage,SLOT(addMolecule(molecule*)));
|
---|
40 | connect(this,SIGNAL(removeMolecule(molecule*)),allPage,SLOT(removeMolecule(molecule*)));*/
|
---|
41 | }
|
---|
42 |
|
---|
43 | QtMoleculeView::~QtMoleculeView()
|
---|
44 | {}
|
---|
45 |
|
---|
46 | /*void QtMoleculeView::moleculeSelected(molecule *mol){
|
---|
47 | if(!pages.count(mol)){
|
---|
48 | string molName = mol->name;
|
---|
49 | QTMoleculePage *molPage = new QTMoleculePage(mol,molName);
|
---|
50 | addTab(molPage,QString(molName.c_str()));
|
---|
51 | pages[mol] = molPage;
|
---|
52 |
|
---|
53 | connect(molPage,SIGNAL(nameChanged(QTMoleculePage*,std::string)),this,SLOT(nameChanged(QTMoleculePage*,std::string)));
|
---|
54 |
|
---|
55 | emit addMolecule(mol);
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | void QtMoleculeView::moleculeUnSelected(molecule *mol){
|
---|
60 | if(pages.count(mol)){
|
---|
61 | QTMoleculePage *molPage = pages[mol];
|
---|
62 | removeTab(indexOf(molPage));
|
---|
63 | pages.erase(mol);
|
---|
64 | delete molPage;
|
---|
65 | emit removeMolecule(mol);
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | void QtMoleculeView::nameChanged(QTMoleculePage *page, std::string name){
|
---|
70 | setTabText(indexOf(page),QString(name.c_str()));
|
---|
71 | }*/
|
---|
72 |
|
---|
73 | void QtMoleculeView::nameChanged(QTMoleculePage *page, std::string name){}
|
---|
74 |
|
---|
75 | void QtMoleculeView::atomHover(const atom *_atom)
|
---|
76 | {
|
---|
77 | // Remove old tabs.
|
---|
78 | if (page_atom){
|
---|
79 | removeTab(indexOf(page_atom));
|
---|
80 | delete(page_atom);
|
---|
81 | page_atom = NULL;
|
---|
82 | }
|
---|
83 | if (page_mol){
|
---|
84 | removeTab(indexOf(page_mol));
|
---|
85 | delete(page_mol);
|
---|
86 | page_mol = NULL;
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | // Show new tabs.
|
---|
91 | if (_atom){
|
---|
92 | page_atom = new QTAtomPage(_atom, "test");
|
---|
93 | addTab(page_atom, "atom...");
|
---|
94 | }
|
---|
95 | }
|
---|
96 |
|
---|
97 | /************************ Tab for single Atoms ********************/
|
---|
98 |
|
---|
99 | QTAtomPage::QTAtomPage(const atom *_atom,std::string _name) :
|
---|
100 | Observer("QTAtomPage"),
|
---|
101 | atomRef(_atom), name(_name)
|
---|
102 | {
|
---|
103 | atomRef->signOn(this);
|
---|
104 | }
|
---|
105 |
|
---|
106 | QTAtomPage::~QTAtomPage()
|
---|
107 | {
|
---|
108 | atomRef->signOff(this);
|
---|
109 | }
|
---|
110 |
|
---|
111 | void QTAtomPage::update(Observable *subject){
|
---|
112 | /*if(name != atomRef->name){
|
---|
113 | name = atomRef->name;
|
---|
114 | emit nameChanged(this,name);
|
---|
115 | }*/
|
---|
116 | }
|
---|
117 |
|
---|
118 | void QTAtomPage::subjectKilled(Observable *subject){}
|
---|
119 |
|
---|
120 | /************************ Tab for single Molecules *****************/
|
---|
121 |
|
---|
122 | QTMoleculePage::QTMoleculePage(const molecule *_mol, std::string _name) :
|
---|
123 | Observer("QTMoleculePage"),
|
---|
124 | mol(_mol), name(_name)
|
---|
125 | {
|
---|
126 | mol->signOn(this);
|
---|
127 | }
|
---|
128 |
|
---|
129 | QTMoleculePage::~QTMoleculePage(){
|
---|
130 | mol->signOff(this);
|
---|
131 | }
|
---|
132 |
|
---|
133 | void QTMoleculePage::update(Observable *subject){
|
---|
134 | if(name != mol->name){
|
---|
135 | name = mol->name;
|
---|
136 | emit nameChanged(this,name);
|
---|
137 | }
|
---|
138 | }
|
---|
139 |
|
---|
140 | void QTMoleculePage::subjectKilled(Observable *subject){}
|
---|