comparison 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
comparison
equal deleted inserted replaced
125:66af7c1b10d9 126:c26c73ca6d37
11 COPYING included with this distribution for more information. 11 COPYING included with this distribution for more information.
12 */ 12 */
13 13
14 #include "QueryResultsWidget.h" 14 #include "QueryResultsWidget.h"
15 15
16 #include <QScrollArea>
17 #include <QLabel> 16 #include <QLabel>
18 #include <QApplication> 17 #include <QApplication>
19 18
20 #include <iostream> 19 #include <iostream>
21 20
22 #include "sv/main/MainWindow.h" 21 #include "sv/main/MainWindow.h"
22 #include "widgets/ListResultGeneralItemWidget.h"
23 23
24 QueryResultsWidget::QueryResultsWidget() : QWidget(), 24 QueryResultsWidget::QueryResultsWidget() : QWidget(),
25 m_ndResults(0) 25 m_ndResults(0)
26 { 26 {
27 m_resultsLayout = new QGridLayout; 27 m_resultsLayout = new QGridLayout;
28 28
29 QWidget *resultsWidget = new QWidget; 29 QWidget *resultsWidget = new QWidget;
30 resultsWidget->setLayout(m_resultsLayout); 30 resultsWidget->setLayout(m_resultsLayout);
31 31
32 QScrollArea * scrollArea = new QScrollArea; 32 m_scrollArea = new QScrollArea;
33 scrollArea->setWidget(resultsWidget); 33 m_scrollArea->setWidget(resultsWidget);
34 scrollArea->setWidgetResizable(true); 34 m_scrollArea->setWidgetResizable(true);
35 35
36 QVBoxLayout *mainLayout = new QVBoxLayout; 36 QVBoxLayout *mainLayout = new QVBoxLayout;
37 mainLayout->addWidget(scrollArea); 37 mainLayout->addWidget(m_scrollArea);
38 38
39 setLayout(mainLayout); 39 setLayout(mainLayout);
40 } 40 }
41 41
42 QueryResultsWidget::~QueryResultsWidget() 42 QueryResultsWidget::~QueryResultsWidget()
68 68
69 void QueryResultsWidget::displayResult() 69 void QueryResultsWidget::displayResult()
70 { 70 {
71 std::vector<Info>::iterator iter; 71 std::vector<Info>::iterator iter;
72 72
73 QLabel* result = new QLabel(); 73 QString author = "";
74 QString title = "";
75 QString uri = "";
74 76
75 QString text; 77 ListResultGeneralItemWidget *itemResult = new ListResultGeneralItemWidget();
76 QString uri = ""; 78 itemResult->setRank(m_ndResults);
79 itemResult->setType(0);
77 80
78 for (iter = m_curResult.begin(); iter != m_curResult.end(); iter++) 81 for (iter = m_curResult.begin(); iter != m_curResult.end(); iter++)
79 { 82 {
80 if ((*iter).name == "identification") 83 if ((*iter).name == "identification")
81 { 84 {
86 89
87 for (iter = m_curResult.begin(); iter != m_curResult.end(); iter++) 90 for (iter = m_curResult.begin(); iter != m_curResult.end(); iter++)
88 { 91 {
89 if ((*iter).name != "identification") 92 if ((*iter).name != "identification")
90 { 93 {
91 text += "<br>" ; 94 if((*iter).name == "author"){
92 text += (*iter).name; 95 author = (*iter).value;
93 text += " : " ; 96 }
94 if ((*iter).name == "title") 97 if ((*iter).name == "title")
95 { 98 {
96 text += "<a href=\""; 99 title += (*iter).value;
97 text += uri;
98 text += "\">";
99 text += (*iter).value;
100 text += "</a>";
101 } else
102 {
103 text += (*iter).value;
104 } 100 }
105 text += "</br>" ;
106 } 101 }
107 } 102 }
108 103 itemResult->setTitleAndAuthorName(author,title,uri );
109 connect(result, SIGNAL(linkActivated(QString)), MainWindow::instance(), SLOT(importEasaierFile(QString))); 104 itemResult->addConfidence(100,"contains");
110 105
111 result->setText(text); 106 connect(itemResult, SIGNAL(linkActivated(QString)), MainWindow::instance(), SLOT(importEasaierFile(QString)));
112 107
113 m_resultsLayout->addWidget(result,m_ndResults,0); 108
109 m_resultsLayout->addWidget(itemResult,m_ndResults,0);
110 m_resultsLayout->setSpacing(0);
114 m_ndResults++; 111 m_ndResults++;
115 112
116 } 113 }