source: src/gui/searchtabcontainer.cpp @ c9fa699

qt5
Last change on this file since c9fa699 was ea638ef, checked in by pavelpa <pavelpa@…>, 12 years ago

implemented 'conflicts' dialog

  • displays rooms instead of conflicts for now
    • needs to implement additional methods in Event, ...
  • Property mode set to 100644
File size: 3.4 KB
Line 
1
2#include "searchtabcontainer.h"
3#include "searchhead.h"
4
5
6SearchTabContainer::SearchTabContainer(QWidget *aParent) : TabContainer( aParent )
7{
8    header = new SearchHead(this);
9    header->setObjectName(QString::fromUtf8("header"));
10    QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, 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->hide();
36    treeView->hide();
37
38    connect( header, SIGNAL(searchClicked()), SLOT(searchButtonClicked()));
39    connect( searchAgainButton, SIGNAL(clicked()), SLOT(searchAgainClicked()));
40}
41
42SearchTabContainer::~SearchTabContainer()
43{
44}
45
46void SearchTabContainer::searchButtonClicked()
47{
48    QHash<QString,QString> columns;
49
50    SearchHead *searchHeader = static_cast<SearchHead*>(header);
51    if( searchHeader->searchTitle->isChecked() )
52        columns.insertMulti("EVENT", "title");
53    if( searchHeader->searchAbstract->isChecked() )
54        columns.insertMulti("EVENT", "abstract");
55    if( searchHeader->searchTag->isChecked() )
56        columns.insertMulti("EVENT", "tag");
57    if( searchHeader->searchSpeaker->isChecked() )
58        columns["PERSON"] = "name";
59    if( searchHeader->searchRoom->isChecked() )
60        columns["ROOM"] = "name";
61
62    QString keyword = searchHeader->searchEdit->text().replace( QString("%"), QString("\\%") );
63    qDebug() << "\nKeyword to search: " << keyword;
64
65    int confId = Conference::activeConference();
66    SqlEngine::searchEvent( confId, columns, keyword );
67
68    QDate startDate = Conference::getById(confId).start();
69    QDate endDate = Conference::getById(confId).end();
70    dayNavigator->setDates(startDate, endDate);
71    updateTreeView( Conference::getById(confId).start() );
72}
73
74void SearchTabContainer::searchAgainClicked()
75{
76    qDebug() << "SearchTab::searchAgainClicked()";
77    header->show();
78    searchAgainButton->hide();
79    dayNavigator->hide();
80    treeView->hide();
81}
82
83void SearchTabContainer::loadEvents( const QDate &aDate, const int aConferenceId )
84{
85    int eventsCount = static_cast<EventModel*>(treeView->model())->loadSearchResultEvents( aDate, aConferenceId );
86    if( eventsCount ||
87            //TODO: this is not good test
88            dayNavigator->getCurrentDate() != Conference::getById( aConferenceId ).start()
89            ){
90        searchAgainButton->show();
91        dayNavigator->show();
92        treeView->show();
93        header->hide();
94    }
95    else{
96        treeView->hide();
97        searchAgainButton->hide();
98        dayNavigator->hide();
99        header->show();
100    }
101}
Note: See TracBrowser for help on using the repository browser.