diff -r 41300fa6a67c -r 2f34d5167611 tools/assistant/lib/qhelpsearchquerywidget.cpp --- a/tools/assistant/lib/qhelpsearchquerywidget.cpp Tue Feb 02 00:43:10 2010 +0200 +++ b/tools/assistant/lib/qhelpsearchquerywidget.cpp Fri Apr 16 15:50:13 2010 +0300 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -120,6 +120,22 @@ // nothing todo } + void retranslate() + { + simpleSearchLabel->setText(QHelpSearchQueryWidget::tr("Search for:")); + prevQueryButton->setToolTip(QHelpSearchQueryWidget::tr("Previous search")); + nextQueryButton->setToolTip(QHelpSearchQueryWidget::tr("Next search")); + searchButton->setText(QHelpSearchQueryWidget::tr("Search")); +#ifdef QT_CLUCENE_SUPPORT + advancedSearchLabel->setText(QHelpSearchQueryWidget::tr("Advanced search")); + similarLabel->setText(QHelpSearchQueryWidget::tr("words similar to:")); + withoutLabel->setText(QHelpSearchQueryWidget::tr("without the words:")); + exactLabel->setText(QHelpSearchQueryWidget::tr("with exact phrase:")); + allLabel->setText(QHelpSearchQueryWidget::tr("with all of the words:")); + atLeastLabel->setText(QHelpSearchQueryWidget::tr("with at least one of the words:")); +#endif + } + QString escapeString(const QString &text) { QString retValue = text; @@ -132,15 +148,15 @@ << QLatin1String("}") << QLatin1String("~"); // make sure we won't end up with an empty string - foreach (const QString escapeChar, escapableCharsList) { + foreach (const QString &escapeChar, escapableCharsList) { if (retValue.contains(escapeChar)) retValue.replace(escapeChar, QLatin1String("")); } if (retValue.trimmed().isEmpty()) return retValue; - retValue = text; // now realy escape the string... - foreach (const QString escapeChar, escapableCharsList) { + retValue = text; // now really escape the string... + foreach (const QString &escapeChar, escapableCharsList) { if (retValue.contains(escapeChar)) retValue.replace(escapeChar, escape + escapeChar); } @@ -301,7 +317,7 @@ QStringList lst = similarQuery->text().split(exp, QString::SkipEmptyParts); if (!lst.isEmpty()) { QStringList fuzzy; - foreach (const QString term, lst) + foreach (const QString &term, lst) fuzzy += buildTermList(escapeString(term)); queryList.append(QHelpSearchQuery(QHelpSearchQuery::FUZZY, fuzzy)); } @@ -309,7 +325,7 @@ lst = withoutQuery->text().split(exp, QString::SkipEmptyParts); if (!lst.isEmpty()) { QStringList without; - foreach (const QString term, lst) + foreach (const QString &term, lst) without.append(escapeString(term)); queryList.append(QHelpSearchQuery(QHelpSearchQuery::WITHOUT, without)); } @@ -323,7 +339,7 @@ lst = allQuery->text().split(exp, QString::SkipEmptyParts); if (!lst.isEmpty()) { QStringList all; - foreach (const QString term, lst) + foreach (const QString &term, lst) all.append(escapeString(term)); queryList.append(QHelpSearchQuery(QHelpSearchQuery::ALL, all)); } @@ -331,7 +347,7 @@ lst = atLeastQuery->text().split(exp, QString::SkipEmptyParts); if (!lst.isEmpty()) { QStringList atLeast; - foreach (const QString term, lst) + foreach (const QString &term, lst) atLeast += buildTermList(escapeString(term)); queryList.append(QHelpSearchQuery(QHelpSearchQuery::ATLEAST, atLeast)); } @@ -360,6 +376,13 @@ friend class QHelpSearchQueryWidget; bool simpleSearch; + QLabel *simpleSearchLabel; + QLabel *advancedSearchLabel; + QLabel *similarLabel; + QLabel *withoutLabel; + QLabel *exactLabel; + QLabel *allLabel; + QLabel *atLeastLabel; QPushButton *searchButton; QWidget* advancedSearchWidget; QToolButton *showHideAdvancedSearchButton; @@ -408,19 +431,17 @@ vLayout->setMargin(0); QHBoxLayout* hBoxLayout = new QHBoxLayout(); - QLabel *label = new QLabel(tr("Search for:"), this); + d->simpleSearchLabel = new QLabel(this); d->defaultQuery = new QLineEdit(this); d->defaultQuery->setCompleter(&d->searchCompleter); d->prevQueryButton = new QToolButton(this); d->prevQueryButton->setArrowType(Qt::LeftArrow); - d->prevQueryButton->setToolTip(tr("Previous search")); d->prevQueryButton->setEnabled(false); d->nextQueryButton = new QToolButton(this); d->nextQueryButton->setArrowType(Qt::RightArrow); - d->nextQueryButton->setToolTip(tr("Next search")); d->nextQueryButton->setEnabled(false); - d->searchButton = new QPushButton(tr("Search"), this); - hBoxLayout->addWidget(label); + d->searchButton = new QPushButton(this); + hBoxLayout->addWidget(d->simpleSearchLabel); hBoxLayout->addWidget(d->defaultQuery); hBoxLayout->addWidget(d->prevQueryButton); hBoxLayout->addWidget(d->nextQueryButton); @@ -439,15 +460,15 @@ d->showHideAdvancedSearchButton->setText(QLatin1String("+")); d->showHideAdvancedSearchButton->setMinimumSize(25, 20); - label = new QLabel(tr("Advanced search"), this); + d->advancedSearchLabel = new QLabel(this); QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); - sizePolicy.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); - label->setSizePolicy(sizePolicy); + sizePolicy.setHeightForWidth(d->advancedSearchLabel->sizePolicy().hasHeightForWidth()); + d->advancedSearchLabel->setSizePolicy(sizePolicy); QFrame* hLine = new QFrame(this); hLine->setFrameStyle(QFrame::HLine); hBoxLayout->addWidget(d->showHideAdvancedSearchButton); - hBoxLayout->addWidget(label); + hBoxLayout->addWidget(d->advancedSearchLabel); hBoxLayout->addWidget(hLine); vLayout->addLayout(hBoxLayout); @@ -457,32 +478,32 @@ QGridLayout *gLayout = new QGridLayout(d->advancedSearchWidget); gLayout->setMargin(0); - label = new QLabel(tr("words similar to:"), this); - gLayout->addWidget(label, 0, 0); + d->similarLabel = new QLabel(this); + gLayout->addWidget(d->similarLabel, 0, 0); d->similarQuery = new QLineEdit(this); d->similarQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->similarQuery, 0, 1); - label = new QLabel(tr("without the words:"), this); - gLayout->addWidget(label, 1, 0); + d->withoutLabel = new QLabel(this); + gLayout->addWidget(d->withoutLabel, 1, 0); d->withoutQuery = new QLineEdit(this); d->withoutQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->withoutQuery, 1, 1); - label = new QLabel(tr("with exact phrase:"), this); - gLayout->addWidget(label, 2, 0); + d->exactLabel = new QLabel(this); + gLayout->addWidget(d->exactLabel, 2, 0); d->exactQuery = new QLineEdit(this); d->exactQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->exactQuery, 2, 1); - label = new QLabel(tr("with all of the words:"), this); - gLayout->addWidget(label, 3, 0); + d->allLabel = new QLabel(this); + gLayout->addWidget(d->allLabel, 3, 0); d->allQuery = new QLineEdit(this); d->allQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->allQuery, 3, 1); - label = new QLabel(tr("with at least one of the words:"), this); - gLayout->addWidget(label, 4, 0); + d->atLeastLabel = new QLabel(this); + gLayout->addWidget(d->atLeastLabel, 4, 0); d->atLeastQuery = new QLineEdit(this); d->atLeastQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->atLeastQuery, 4, 1); @@ -490,6 +511,8 @@ vLayout->addWidget(d->advancedSearchWidget); d->advancedSearchWidget->hide(); + d->retranslate(); + connect(d->exactQuery, SIGNAL(returnPressed()), this, SIGNAL(search())); connect(d->similarQuery, SIGNAL(returnPressed()), this, SIGNAL(search())); connect(d->withoutQuery, SIGNAL(returnPressed()), this, SIGNAL(search())); @@ -510,7 +533,7 @@ } /*! - Returns a list of querys to use in combination with the search engines + Returns a list of queries to use in combination with the search engines search(QList &query) function. */ QList QHelpSearchQueryWidget::query() const @@ -531,4 +554,14 @@ } } +/*! \reimp +*/ +void QHelpSearchQueryWidget::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) + d->retranslate(); + else + QWidget::changeEvent(event); +} + QT_END_NAMESPACE