/*
* Project: MoleCuilder
* Description: creates and alters molecular systems
* Copyright (C) 2017 Frederik Heber. All rights reserved.
*
*
* This file is part of MoleCuilder.
*
* MoleCuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* MoleCuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MoleCuilder. If not, see .
*/
/*
* QtGeometryList.cpp
*
* Created on: Mar 25, 2017
* Author: heber
*/
// include config.h
#ifdef HAVE_CONFIG_H
#include
#endif
#include "Views/Qt4/QtGeometryList.hpp"
#include
//#include "CodePatterns/MemDebug.hpp"
#include "CodePatterns/Observer/Notification.hpp"
#include "CodePatterns/toString.hpp"
#include "Geometry/GeometryRegistry.hpp"
#include
using namespace std;
const int QtGeometryList::COLUMNCOUNT = COLUMNTYPES_MAX;
const char *QtGeometryList::COLUMNNAMES[QtGeometryList::COLUMNCOUNT]={"Name","Vector"};
QtGeometryList::QtGeometryList(QWidget * _parent) :
QTreeWidget (_parent),
Observer("QtGeometryList")
{
setColumnCount(COLUMNCOUNT);
setSelectionMode(QAbstractItemView::NoSelection);
QStringList header;
for(int i=0; i(publisher) == GeometryRegistry::getPointer()) {
switch (notification->getChannelNo()) {
case GeometryRegistry::GeometryInserted:
{
refill(NULL);
break;
}
case GeometryRegistry::GeometryRemoved:
{
refill(GeometryRegistry::getInstance().lastChanged());
break;
}
default:
ASSERT(0, "QtGeometryList::recieveNotification() - we cannot get here.");
break;
}
}
}
void QtGeometryList::refill(::GeometryObject *ignore)
{
clear();
GeometryRegistry ® = GeometryRegistry::getInstance();
GeometryRegistry::const_iterator iter;
for (iter = reg.getBeginIter(); iter != reg.getEndIter(); iter ++){
::GeometryObject *v = iter->second;
if (v == ignore)
continue;
QTreeWidgetItem *treeItem = new QTreeWidgetItem(this);
treeItem->setText(NAME, QString(v->getName().c_str()));
treeItem->setText(VECTOR, QString(toString(v->getVector()).c_str()));
}
}
#if 0
void QtGeometryList::paintEvent(QPaintEvent * event)
{
/*if (dirty)
refill(NULL);*/
QtGeometryList::paintEvent(event);
}
#endif
void QtGeometryList::subjectKilled(Observable *publisher) {
}