removed headers from *.h and *.cpp
[toast/confclerk.git] / src / gui / searchtabcontainer.cpp
1
2 #include "searchtabcontainer.h"
3 #include "searchhead.h"
4
5
6 SearchTabContainer::SearchTabContainer(QWidget *aParent) : TabContainer( aParent )
7 {
8     header = new SearchHead(this);
9     header->setObjectName(QString::fromUtf8("header"));
10     QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
11     sizePolicy.setHorizontalStretch(0);
12     sizePolicy.setVerticalStretch(0);
13     //sizePolicy.setHeightForWidth(TabContainer::sizePolicy().hasHeightForWidth());
14     sizePolicy.setHeightForWidth(header->sizePolicy().hasHeightForWidth());
15     header->setSizePolicy(sizePolicy);
16     header->setMinimumSize(QSize(10, 10));
17
18     verticalLayout->insertWidget(0,header);
19
20     header->show();
21
22     searchAgainButton = new QToolButton(this);
23     searchAgainButton->setObjectName(QString::fromUtf8("button"));
24     QIcon icon;
25     icon.addPixmap(QPixmap(QString::fromUtf8(":/icons/search.png")), QIcon::Normal, QIcon::Off);
26     searchAgainButton->setIcon(icon);
27     QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Minimum);
28     sizePolicy1.setHorizontalStretch(0);
29     sizePolicy1.setVerticalStretch(0);
30     sizePolicy1.setHeightForWidth(searchAgainButton->sizePolicy().hasHeightForWidth());
31     searchAgainButton->setSizePolicy(sizePolicy1);
32
33     verticalLayout_2->insertWidget(0,searchAgainButton);
34
35     searchAgainButton->show();
36
37     connect( header, SIGNAL(searchClicked()), SLOT(searchButtonClicked()));
38     connect( searchAgainButton, SIGNAL(clicked()), SLOT(searchAgainClicked()));
39 }
40
41 SearchTabContainer::~SearchTabContainer()
42 {
43 }
44
45 void SearchTabContainer::searchButtonClicked()
46 {
47     qDebug() << "SearchTab::searchButtonClicked()";
48
49     QHash<QString,QString> columns;
50
51     SearchHead *searchHeader = static_cast<SearchHead*>(header);
52     if( searchHeader->searchTitle->isChecked() )
53         columns.insertMulti("EVENT", "title");
54     if( searchHeader->searchAbstract->isChecked() )
55         columns.insertMulti("EVENT", "abstract");
56     if( searchHeader->searchTag->isChecked() )
57         columns.insertMulti("EVENT", "tag");
58     if( searchHeader->searchSpeaker->isChecked() )
59         columns["PERSON"] = "name";
60     if( searchHeader->searchRoom->isChecked() )
61         columns["ROOM"] = "name";
62
63     QString keyword = searchHeader->searchEdit->text().replace( QString("%"), QString("\\%") );
64     qDebug() << "\nKeyword to search: " << keyword;
65
66     int confId = Conference::activeConference();
67     SqlEngine::searchEvent( confId, columns, keyword );
68
69     QDate startDate = Conference::getById(confId).start();
70     QDate endDate = Conference::getById(confId).end();
71     dayNavigator->setDates(startDate, endDate);
72     updateTreeView( Conference::getById(confId).start() );
73 }
74
75 void SearchTabContainer::searchAgainClicked()
76 {
77     qDebug() << "SearchTab::searchAgainClicked()";
78     header->show();
79     searchAgainButton->hide();
80     dayNavigator->hide();
81     treeView->hide();
82 }
83
84 void SearchTabContainer::loadEvents( const QDate &aDate, const int aConferenceId )
85 {
86     int eventsCount = static_cast<EventModel*>(treeView->model())->loadSearchResultEvents( aDate, aConferenceId );
87     if( eventsCount ||
88             //TODO: this is not good test
89             dayNavigator->getCurrentDate() != Conference::getById( aConferenceId ).start()
90             ){
91         searchAgainButton->show();
92         dayNavigator->show();
93         treeView->show();
94         header->hide();
95     }
96     else{
97         treeView->hide();
98         searchAgainButton->hide();
99         dayNavigator->hide();
100         header->show();
101     }
102 }