/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * QtMoleculeView.cpp * * Created on: Mar 4, 2010 * Author: crueger */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "Views/Qt4/QtMoleculeView.hpp" #include #include "CodePatterns/MemDebug.hpp" #include "molecule.hpp" using namespace std; /***************** Basic structure for tab layout ***********/ QtMoleculeView::QtMoleculeView() : QTabWidget(), page_mol(NULL), page_atom(NULL) { /*allPage = new QTAllMoleculePage(); addTab(allPage,QString("All Molecules")); connect(this,SIGNAL(addMolecule(molecule*)),allPage,SLOT(addMolecule(molecule*))); connect(this,SIGNAL(removeMolecule(molecule*)),allPage,SLOT(removeMolecule(molecule*)));*/ } QtMoleculeView::~QtMoleculeView() {} /*void QtMoleculeView::moleculeSelected(molecule *mol){ if(!pages.count(mol)){ string molName = mol->name; QTMoleculePage *molPage = new QTMoleculePage(mol,molName); addTab(molPage,QString(molName.c_str())); pages[mol] = molPage; connect(molPage,SIGNAL(nameChanged(QTMoleculePage*,std::string)),this,SLOT(nameChanged(QTMoleculePage*,std::string))); emit addMolecule(mol); } } void QtMoleculeView::moleculeUnSelected(molecule *mol){ if(pages.count(mol)){ QTMoleculePage *molPage = pages[mol]; removeTab(indexOf(molPage)); pages.erase(mol); delete molPage; emit removeMolecule(mol); } } void QtMoleculeView::nameChanged(QTMoleculePage *page, std::string name){ setTabText(indexOf(page),QString(name.c_str())); }*/ void QtMoleculeView::nameChanged(QTMoleculePage *page, std::string name){} void QtMoleculeView::atomHover(const atom *_atom) { // Remove old tabs. if (page_atom){ removeTab(indexOf(page_atom)); delete(page_atom); page_atom = NULL; } if (page_mol){ removeTab(indexOf(page_mol)); delete(page_mol); page_mol = NULL; } // Show new tabs. if (_atom){ page_atom = new QTAtomPage(_atom, "test"); addTab(page_atom, "atom..."); } } /************************ Tab for single Atoms ********************/ QTAtomPage::QTAtomPage(const atom *_atom,std::string _name) : Observer("QTAtomPage"), atomRef(_atom), name(_name) { atomRef->signOn(this); } QTAtomPage::~QTAtomPage() { atomRef->signOff(this); } void QTAtomPage::update(Observable *subject){ /*if(name != atomRef->name){ name = atomRef->name; emit nameChanged(this,name); }*/ } void QTAtomPage::subjectKilled(Observable *subject){} /************************ Tab for single Molecules *****************/ QTMoleculePage::QTMoleculePage(const molecule *_mol, std::string _name) : Observer("QTMoleculePage"), mol(_mol), name(_name) { mol->signOn(this); } QTMoleculePage::~QTMoleculePage(){ mol->signOff(this); } void QTMoleculePage::update(Observable *subject){ if(name != mol->name){ name = mol->name; emit nameChanged(this,name); } } void QTMoleculePage::subjectKilled(Observable *subject){}