2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011-2012 Philipp Spitzer, gregor herrmann, Stefan Stahl
5 * This file is part of ConfClerk.
7 * ConfClerk is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation, either version 2 of the License, or (at your option)
12 * ConfClerk is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * ConfClerk. If not, see <http://www.gnu.org/licenses/>.
21 #include "searchtabcontainer.h"
22 #include "searchhead.h"
23 #include <QMessageBox>
25 SearchTabContainer::SearchTabContainer(QWidget *aParent) : TabContainer( aParent )
27 header = new SearchHead(this);
28 header->setObjectName(QString::fromUtf8("header"));
29 QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
30 sizePolicy.setHorizontalStretch(0);
31 sizePolicy.setVerticalStretch(0);
32 //sizePolicy.setHeightForWidth(TabContainer::sizePolicy().hasHeightForWidth());
33 sizePolicy.setHeightForWidth(header->sizePolicy().hasHeightForWidth());
34 header->setSizePolicy(sizePolicy);
35 header->setMinimumSize(QSize(10, 10));
36 verticalLayout->insertWidget(0,header);
37 connect(header, SIGNAL(searchClicked()), SLOT(searchButtonClicked()));
42 bool SearchTabContainer::searchDialogIsVisible() const {
43 return header->isVisible();
47 int SearchTabContainer::searchResultCount(const QDate& date) const {
48 int confId = Conference::activeConference();
49 if (confId == -1) return 0;
50 return Event::getSearchResultByDate(date, confId, "start, duration").count();
54 void SearchTabContainer::showSearchDialog(bool show) {
55 header->setVisible(show);
56 treeView->setVisible(!show);
60 void SearchTabContainer::searchButtonClicked() {
61 QHash<QString,QString> columns;
63 SearchHead *searchHeader = static_cast<SearchHead*>(header);
64 if( searchHeader->searchTitle->isChecked() )
65 columns.insertMulti("EVENT", "title");
66 if( searchHeader->searchAbstract->isChecked() )
67 columns.insertMulti("EVENT", "abstract");
68 if( searchHeader->searchTag->isChecked() )
69 columns.insertMulti("EVENT", "tag");
70 if( searchHeader->searchSpeaker->isChecked() )
71 columns["PERSON"] = "name";
72 if( searchHeader->searchRoom->isChecked() )
73 columns["ROOM"] = "name";
75 QString keyword = searchHeader->searchEdit->text();
77 int confId = Conference::activeConference();
78 if (confId == -1) return;
79 Conference conf = Conference::getById(confId);
81 SqlEngine::searchEvent( confId, columns, keyword );
84 for (QDate d = conf.start(); d <= conf.end(); d = d.addDays(1))
85 nrofFounds += Event::getSearchResultByDate(d, confId, "start, duration").count();
90 QMessageBox::information(
92 QString("Keyword '%1' not found!").arg(keyword),
93 QString("No events containing '%1' found!").arg(keyword),
99 emit searchResultChanged();
104 void SearchTabContainer::loadEvents( const QDate &aDate, const int aConferenceId )
106 static_cast<EventModel*>(treeView->model())->loadSearchResultEvents( aDate, aConferenceId );