Mercurial > hg > easaier-soundaccess
view widgets/QueryResultsWidget.cpp @ 126:c26c73ca6d37
the result list is better now.
it's not the final version.
the final version.... is coming soon
author | benoitrigolleau |
---|---|
date | Tue, 23 Oct 2007 15:24:06 +0000 |
parents | 87495ac7710a |
children | f3dce7a985cf |
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* Sound Access EASAIER client application. Silogic 2007. Laure Bajard. This program 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. See the file COPYING included with this distribution for more information. */ #include "QueryResultsWidget.h" #include <QLabel> #include <QApplication> #include <iostream> #include "sv/main/MainWindow.h" #include "widgets/ListResultGeneralItemWidget.h" QueryResultsWidget::QueryResultsWidget() : QWidget(), m_ndResults(0) { m_resultsLayout = new QGridLayout; QWidget *resultsWidget = new QWidget; resultsWidget->setLayout(m_resultsLayout); m_scrollArea = new QScrollArea; m_scrollArea->setWidget(resultsWidget); m_scrollArea->setWidgetResizable(true); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(m_scrollArea); setLayout(mainLayout); } QueryResultsWidget::~QueryResultsWidget() {} void QueryResultsWidget::reset() { m_ndResults = 0; QLayoutItem *child; while ((child = m_resultsLayout->takeAt(0)) != 0) { delete child->widget(); } } void QueryResultsWidget::newResult() { m_curResult.clear(); } void QueryResultsWidget::addInfo(const QString& name, const QString& value) { Info info; info.name = name; info.value = value; m_curResult.push_back(info); } void QueryResultsWidget::displayResult() { std::vector<Info>::iterator iter; QString author = ""; QString title = ""; QString uri = ""; ListResultGeneralItemWidget *itemResult = new ListResultGeneralItemWidget(); itemResult->setRank(m_ndResults); itemResult->setType(0); for (iter = m_curResult.begin(); iter != m_curResult.end(); iter++) { if ((*iter).name == "identification") { uri = (*iter).value; uri = uri.right(uri.length() - uri.lastIndexOf("#") - 1); } } for (iter = m_curResult.begin(); iter != m_curResult.end(); iter++) { if ((*iter).name != "identification") { if((*iter).name == "author"){ author = (*iter).value; } if ((*iter).name == "title") { title += (*iter).value; } } } itemResult->setTitleAndAuthorName(author,title,uri ); itemResult->addConfidence(100,"contains"); connect(itemResult, SIGNAL(linkActivated(QString)), MainWindow::instance(), SLOT(importEasaierFile(QString))); m_resultsLayout->addWidget(itemResult,m_ndResults,0); m_resultsLayout->setSpacing(0); m_ndResults++; }