source: confclerk_git/src/gui/searchtabcontainer.cpp @ ac2b0b2

qt5
Last change on this file since ac2b0b2 was ac2b0b2, checked in by Philipp Spitzer <philipp@…>, 11 years ago

The search result is now synced with the daynavigator.
When the search result is not on the current date, the date is changed.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
4 *
5 * This file is part of ConfClerk.
6 *
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)
10 * any later version.
11 *
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
15 * more details.
16 *
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/>.
19 */
20
21#include "searchtabcontainer.h"
22#include "searchhead.h"
23#include <QMessageBox>
24
25SearchTabContainer::SearchTabContainer(QWidget *aParent) : TabContainer( aParent )
26{
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()));
38    showSearchDialog();
39}
40
41
42int SearchTabContainer::searchResultCount(const QDate& date) const {
43    int confId = Conference::activeConference();
44    if (confId == -1) return 0;
45    return Event::getSearchResultByDate(date, confId, "start, duration").count();
46}
47
48
49void SearchTabContainer::showSearchDialog() {
50    header->show();
51    treeView->hide();
52}
53
54
55void SearchTabContainer::searchButtonClicked() {
56    QHash<QString,QString> columns;
57
58    SearchHead *searchHeader = static_cast<SearchHead*>(header);
59    if( searchHeader->searchTitle->isChecked() )
60        columns.insertMulti("EVENT", "title");
61    if( searchHeader->searchAbstract->isChecked() )
62        columns.insertMulti("EVENT", "abstract");
63    if( searchHeader->searchTag->isChecked() )
64        columns.insertMulti("EVENT", "tag");
65    if( searchHeader->searchSpeaker->isChecked() )
66        columns["PERSON"] = "name";
67    if( searchHeader->searchRoom->isChecked() )
68        columns["ROOM"] = "name";
69
70    QString keyword = searchHeader->searchEdit->text();
71
72    int confId = Conference::activeConference();
73    if (confId == -1) return;
74    Conference conf = Conference::getById(confId);
75
76    SqlEngine::searchEvent( confId, columns, keyword );
77
78    int nrofFounds = 0;
79    for (QDate d = conf.start(); d <= conf.end(); d = d.addDays(1))
80        nrofFounds += Event::getSearchResultByDate(d, confId, "start, duration").count();
81
82    if (!nrofFounds) {
83        treeView->hide();
84        header->show();
85        QMessageBox::information(
86                this,
87                QString("Keyword '%1' not found!").arg(keyword),
88                QString("No events containing '%1' found!").arg(keyword),
89                QMessageBox::Ok);
90    } else {
91        treeView->show();
92        header->hide();
93
94        emit searchResultChanged();
95    }
96}
97
98
99void SearchTabContainer::loadEvents( const QDate &aDate, const int aConferenceId )
100{
101    static_cast<EventModel*>(treeView->model())->loadSearchResultEvents( aDate, aConferenceId );
102}
103
Note: See TracBrowser for help on using the repository browser.