X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgui%2Fsearchdialog.cpp;h=ea412a9c0654405b2b4a08936fb98a7e03f82e96;hb=6965c4495bce1459eaba90b34569830c95aff5e3;hp=58dd94fa5c0179babb162bf7ab13d177324f34bb;hpb=d187495fd3566da1ee1eb94cc313c2f561a0fac5;p=jenirok diff --git a/src/gui/searchdialog.cpp b/src/gui/searchdialog.cpp index 58dd94f..ea412a9 100644 --- a/src/gui/searchdialog.cpp +++ b/src/gui/searchdialog.cpp @@ -23,6 +23,7 @@ #include #include #include "searchdialog.h" +#include "settings.h" SearchDialog::SearchDialog(QWidget* parent): QDialog(parent), numberInput_(0), locationInput_(0), selector_(0) @@ -42,8 +43,7 @@ numberInput_(0), locationInput_(0), selector_(0) locationLayout->addWidget(locationInput_); selector_ = new ButtonSelector(tr("Type"), this); - selector_->addItem(tr("Persons")); - selector_->addItem(tr("Companies")); + loadSearchTypes(); QVBoxLayout* leftLayout = new QVBoxLayout; leftLayout->addLayout(numberLayout); @@ -75,7 +75,16 @@ void SearchDialog::searchPressed() } details.location = locationInput_->text(); - details.type = selector_->currentIndex(); + + int type = 0; + + if(selector_->isVisible()) + { + type = selector_->value().toInt(); + } + + details.type = static_cast(type); + emit search(details); hide(); } @@ -89,3 +98,45 @@ void SearchDialog::setVisible(bool visible) numberInput_->setFocus(); } } + +void SearchDialog::setSearchString(QString const& string) +{ + numberInput_->setText(string); +} + +void SearchDialog::loadSearchTypes() +{ + selector_->clear(); + + Source* source = Source::getSource(Source::stringToId(Settings::instance()->get("source"))); + + QList types; + source->getSearchTypes(types); + + if(types.size() > 1) + { + for(int i = 0; i < types.size(); i++) + { + switch(types.at(i)) + { + case Source::PERSONS: + selector_->addItem(tr("Persons"), static_cast(Source::PERSONS)); + break; + case Source::YELLOW_PAGES: + selector_->addItem(tr("Companies"), static_cast(Source::YELLOW_PAGES)); + break; + case Source::BOTH: + break; + } + } + + if(!selector_->isVisible()) + { + selector_->show(); + } + } + else + { + selector_->hide(); + } +}