/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2013 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 . */ /* * QtHomologyList.cpp * * Created on: Jun 24, 2014 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "Views/Qt4/QtHomologyList.hpp" #include #include #include #include "CodePatterns/MemDebug.hpp" #include "Fragmentation/Homology/HomologyContainer.hpp" #include "World.hpp" using namespace std; const int QtHomologyList::COLUMNCOUNT = COLUMNTYPES_MAX; const char *QtHomologyList::COLUMNNAMES[QtHomologyList::COLUMNCOUNT]={"Number","Nodes","Edges","Occurrence"}; QtHomologyList::QtHomologyList(QWidget * _parent) : QTreeWidget (_parent), Observer("QtHomologyList") { setColumnCount(COLUMNCOUNT); setSelectionMode(QAbstractItemView::MultiSelection); QStringList header; for(int i=0; ifirst; const size_t times = std::distance(occurences.first, occurences.second); QTreeWidgetItem *treeItem = new QTreeWidgetItem(this); treeItem->setText(NUMBER, QString::number(count)); { std::stringstream output; graph.printNodes(output); treeItem->setText(NODES, QString(output.str().c_str())); } { std::stringstream output; graph.printEdges(output); treeItem->setText(EDGES, QString(output.str().c_str())); } if (times > 0) { treeItem->setText(OCCURRENCE, QString::number(times)); } else { treeItem->setText(OCCURRENCE, "none"); treeItem->setDisabled(true); } HomologySelection.push_back(treeItem->isSelected()); } dirty = false; } void QtHomologyList::paintEvent(QPaintEvent * event) { if (dirty) refill(); QTreeWidget::paintEvent(event); } void QtHomologyList::subjectKilled(Observable *publisher) { // as a new instance should always already be present ... just sign on HomologyContainer &homologies = World::getInstance().getHomologies(); homologies.signOn(this); } void QtHomologyList::rowSelected() { //std::cout << "rowSelected\n"; for (int i=0;iisSelected(); if (newSelection != HomologySelection[i]){ HomologySelection[i] = newSelection; } } }