summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-01-21 12:47:41 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-01-21 12:47:41 (GMT)
commit2ae6b44e4242c60bd882661e104bb53fa6670556 (patch)
tree024f8e72fcafda1698d5929de52b92f6f4d94279
parentbd4cbc57ee6b3d2721a51932f4eaea8d8b07f04f (diff)
parentaf30aeb6a1ebb7307f06c122c0c93d152f4d958c (diff)
downloadQt-2ae6b44e4242c60bd882661e104bb53fa6670556.zip
Qt-2ae6b44e4242c60bd882661e104bb53fa6670556.tar.gz
Qt-2ae6b44e4242c60bd882661e104bb53fa6670556.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/berlin-staging-1 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/berlin-staging-1: QtHelp: Enable dynamic translation. Designer: Fixed a crash when previewing in a non-existent style. uic3: Introduced option to preserve layout object names of Designer 3.
-rw-r--r--src/tools/uic3/converter.cpp20
-rw-r--r--src/tools/uic3/form.cpp8
-rw-r--r--src/tools/uic3/main.cpp18
-rw-r--r--src/tools/uic3/ui3reader.cpp22
-rw-r--r--src/tools/uic3/ui3reader.h16
-rw-r--r--tools/assistant/lib/qhelpsearchquerywidget.cpp71
-rw-r--r--tools/assistant/lib/qhelpsearchquerywidget.h3
-rw-r--r--tools/assistant/lib/qhelpsearchresultwidget.cpp8
-rw-r--r--tools/assistant/lib/qhelpsearchresultwidget.h1
-rw-r--r--tools/designer/src/lib/shared/widgetfactory.cpp2
10 files changed, 107 insertions, 62 deletions
diff --git a/src/tools/uic3/converter.cpp b/src/tools/uic3/converter.cpp
index 8fe2a24..2bf293d 100644
--- a/src/tools/uic3/converter.cpp
+++ b/src/tools/uic3/converter.cpp
@@ -121,7 +121,7 @@ static inline bool isKDEClass(const QString &className)
return className.at(1) .isUpper() && className.at(2).isLower();
}
-DomUI *Ui3Reader::generateUi4(const QDomElement &widget, bool implicitIncludes)
+DomUI *Ui3Reader::generateUi4(const QDomElement &widget)
{
QDomNodeList nl;
candidateCustomWidgets.clear();
@@ -474,7 +474,7 @@ DomUI *Ui3Reader::generateUi4(const QDomElement &widget, bool implicitIncludes)
// Magic header generation feature for legacy KDE forms
// (for example, filesharing/advanced/kcm_sambaconf/share.ui)
- if (implicitIncludes && isKDEClass(customClass)) {
+ if ((m_options & ImplicitIncludes) && isKDEClass(customClass)) {
QString header = customClass.toLower();
header += QLatin1String(".h");
DomHeader *domHeader = new DomHeader;
@@ -710,10 +710,13 @@ DomWidget *Ui3Reader::createWidget(const QDomElement &w, const QString &widgetCl
ui_action_list.append(a);
} else if (t == QLatin1String("property")) {
// skip the property it is already handled by createProperties
-
- QString name = e.attribute(QLatin1String("name")); // change the varname this widget
- if (name == QLatin1String("name"))
- ui_widget->setAttributeName(DomTool::readProperty(w, QLatin1String("name"), QVariant()).toString());
+ const QString name = e.attribute(QLatin1String("name")); // change the varname this widget
+ if (name == QLatin1String("name")) {
+ // Do not name QLayoutWidget if layout names are to be used.
+ const bool applyName = !(m_options & PreserveLayoutNames) || className != QLatin1String("QLayoutWidget");
+ if (applyName)
+ ui_widget->setAttributeName(DomTool::readProperty(w, QLatin1String("name"), QVariant()).toString());
+ }
} else if (t == QLatin1String("row")) {
DomRow *row = new DomRow();
row->read(e);
@@ -797,6 +800,11 @@ DomLayout *Ui3Reader::createLayout(const QDomElement &w)
createProperties(w, &ui_property_list, className);
createAttributes(w, &ui_attribute_list, className);
+ if (m_options & PreserveLayoutNames) {
+ const QString layoutName = getLayoutName(w);
+ if (!layoutName.isEmpty())
+ lay->setAttributeName(layoutName);
+ }
QDomElement e = w.firstChild().toElement();
while (!e.isNull()) {
diff --git a/src/tools/uic3/form.cpp b/src/tools/uic3/form.cpp
index ac2668b..df1314f 100644
--- a/src/tools/uic3/form.cpp
+++ b/src/tools/uic3/form.cpp
@@ -100,7 +100,7 @@ QByteArray combinePath(const char *infile, const char *outfile)
\sa createFormImpl()
*/
-void Ui3Reader::createFormDecl(const QDomElement &e, bool implicitIncludes)
+void Ui3Reader::createFormDecl(const QDomElement &e)
{
QDomElement body = e;
@@ -138,7 +138,7 @@ void Ui3Reader::createFormDecl(const QDomElement &e, bool implicitIncludes)
QString tagName = n3.tagName().toLower();
if (tagName == QLatin1String("class")) {
cl = n3.firstChild().toText().data();
- if (!nofwd)
+ if (m_options & CustomWidgetForwardDeclarations)
forwardDecl << cl;
customWidgets.insert(cl, 0);
} else if (tagName == QLatin1String("header")) {
@@ -257,10 +257,10 @@ void Ui3Reader::createFormDecl(const QDomElement &e, bool implicitIncludes)
d.option().copyrightHeader = false;
d.option().extractImages = m_extractImages;
d.option().qrcOutputFile = m_qrcOutputFile;
- d.option().implicitIncludes = implicitIncludes;
+ d.option().implicitIncludes = (m_options & ImplicitIncludes) ? 1 : 0;
if (trmacro.size())
d.option().translateFunction = trmacro;
- DomUI *ui = generateUi4(e, implicitIncludes);
+ DomUI *ui = generateUi4(e);
d.uic(fileName, ui, &out);
delete ui;
diff --git a/src/tools/uic3/main.cpp b/src/tools/uic3/main.cpp
index ecc345e..6acc94f 100644
--- a/src/tools/uic3/main.cpp
+++ b/src/tools/uic3/main.cpp
@@ -78,13 +78,11 @@ int runUic3(int argc, char * argv[])
QByteArray image_tmpfile;
const char* projectName = 0;
const char* trmacro = 0;
- bool nofwd = false;
bool fix = false;
bool deps = false;
- bool implicitIncludes = true;
+ unsigned readerOptions = Ui3Reader::ImplicitIncludes|Ui3Reader::CustomWidgetForwardDeclarations;
QByteArray pchFile;
-
QApplication app(argc, argv, false);
for (int n = 1; n < argc && error == 0; n++) {
@@ -146,9 +144,11 @@ int runUic3(int argc, char * argv[])
} else if (opt == "d") {
deps = true;
} else if (opt == "no-implicit-includes") {
- implicitIncludes = false;
+ readerOptions &= ~Ui3Reader::ImplicitIncludes;
} else if (opt == "nofwd") {
- nofwd = true;
+ readerOptions &= ~Ui3Reader::CustomWidgetForwardDeclarations;
+ } else if (opt == "layout-names") {
+ readerOptions |= Ui3Reader::PreserveLayoutNames;
} else if (opt == "nounload") {
// skip
} else if (opt == "convert") {
@@ -253,6 +253,7 @@ int runUic3(int argc, char * argv[])
"\t-extract qrcFile Create resource file and extract embedded images into \"image\" dir\n"
"\t-pch file Add #include \"file\" as the first statement in implementation\n"
"\t-nofwd Omit forward declarations of custom classes\n"
+ "\t-layout-names Preserve layout names of Qt Designer 3\n"
"\t-no-implicit-includes Do not generate #include-directives for custom classes\n"
"\t-nounload Do not unload plugins after processing\n"
"\t-tr func Use func() instead of tr() for i18n\n"
@@ -289,9 +290,8 @@ int runUic3(int argc, char * argv[])
QTextStream out(&fileOut);
- Ui3Reader ui3(out);
+ Ui3Reader ui3(out, readerOptions);
ui3.setExtractImages(extract, qrcOutputFile);
-
if (projectName && imagecollection) {
out.setEncoding(QTextStream::Latin1);
ui3.embed(projectName, images);
@@ -349,7 +349,7 @@ int runUic3(int argc, char * argv[])
return 0;
} else if (convert) {
- ui3.generateUi4(QFile::decodeName(fileName), QFile::decodeName(outputFile), doc, implicitIncludes);
+ ui3.generateUi4(QFile::decodeName(fileName), QFile::decodeName(outputFile), doc);
return 0;
}
@@ -388,8 +388,6 @@ int runUic3(int argc, char * argv[])
subcl,
QString::fromUtf8(trmacro),
QString::fromUtf8(className),
- nofwd,
- implicitIncludes,
convertedUi);
if (!protector.isEmpty()) {
diff --git a/src/tools/uic3/ui3reader.cpp b/src/tools/uic3/ui3reader.cpp
index 6c5bda3..fd50a19 100644
--- a/src/tools/uic3/ui3reader.cpp
+++ b/src/tools/uic3/ui3reader.cpp
@@ -176,7 +176,6 @@ void Ui3Reader::init()
{
outputFileName.clear();
trmacro.clear();
- nofwd = false;
fileName.clear();
writeFunctImpl = true;
@@ -241,11 +240,10 @@ QDomElement Ui3Reader::parse(const QDomDocument &doc)
return widget;
}
-Ui3Reader::Ui3Reader(QTextStream &outStream)
- : out(outStream), trout(&languageChangeBody)
+Ui3Reader::Ui3Reader(QTextStream &outStream, unsigned options) :
+ m_options(options), out(outStream), trout(&languageChangeBody),
+ m_porting(new Porting), m_extractImages(false)
{
- m_porting = new Porting();
- m_extractImages = false;
}
Ui3Reader::~Ui3Reader()
@@ -255,14 +253,13 @@ Ui3Reader::~Ui3Reader()
void Ui3Reader::generate(const QString &fn, const QString &outputFn,
QDomDocument doc, bool decl, bool subcl, const QString &trm,
- const QString& subClass, bool omitForwardDecls, bool implicitIncludes, const QString &convertedUiFile)
+ const QString& subClass, const QString &convertedUiFile)
{
init();
fileName = fn;
outputFileName = outputFn;
trmacro = trm;
- nofwd = omitForwardDecls;
QDomElement e = parse(doc);
@@ -281,21 +278,21 @@ void Ui3Reader::generate(const QString &fn, const QString &outputFn,
createSubImpl(e, subClass);
} else {
if (decl)
- createFormDecl(e, implicitIncludes);
+ createFormDecl(e);
else
createFormImpl(e);
}
}
-void Ui3Reader::generateUi4(const QString &fn, const QString &outputFn, QDomDocument doc, bool implicitIncludes)
+void Ui3Reader::generateUi4(const QString &fn, const QString &outputFn, QDomDocument doc)
{
init();
fileName = fn;
outputFileName = outputFn;
- DomUI *ui = generateUi4(parse(doc), implicitIncludes);
+ DomUI *ui = generateUi4(parse(doc));
if (!ui)
return;
@@ -317,11 +314,6 @@ void Ui3Reader::setTrMacro(const QString &trmacro)
this->trmacro = trmacro;
}
-void Ui3Reader::setForwardDeclarationsEnabled(bool b)
-{
- nofwd = !b;
-}
-
void Ui3Reader::setOutputFileName(const QString &fileName)
{
outputFileName = fileName;
diff --git a/src/tools/uic3/ui3reader.h b/src/tools/uic3/ui3reader.h
index cd17835..144ef05 100644
--- a/src/tools/uic3/ui3reader.h
+++ b/src/tools/uic3/ui3reader.h
@@ -68,23 +68,24 @@ typedef QList<QPair<int, Color> > ColorGroup;
class Ui3Reader
{
public:
- Ui3Reader(QTextStream &stream);
+ enum Options { CustomWidgetForwardDeclarations = 0x1, ImplicitIncludes = 0x2, PreserveLayoutNames = 0x4 };
+
+ explicit Ui3Reader(QTextStream &stream, unsigned options);
~Ui3Reader();
void computeDeps(const QDomElement &e, QStringList &globalIncludes, QStringList &localIncludes, bool impl = false);
- void generateUi4(const QString &fn, const QString &outputFn, QDomDocument doc, bool implicitIncludes);
+ void generateUi4(const QString &fn, const QString &outputFn, QDomDocument doc);
void generate(const QString &fn, const QString &outputFn,
QDomDocument doc, bool decl, bool subcl, const QString &trm,
- const QString& subclname, bool omitForwardDecls, bool implicitIncludes, const QString &convertedUiFile);
+ const QString& subclname, const QString &convertedUiFile);
void embed(const char *project, const QStringList &images);
void setTrMacro(const QString &trmacro);
- void setForwardDeclarationsEnabled(bool b);
void setOutputFileName(const QString &fileName);
- void createFormDecl(const QDomElement &e, bool implicitIncludes);
+ void createFormDecl(const QDomElement &e);
void createFormImpl(const QDomElement &e);
void createWrapperDecl(const QDomElement &e, const QString &convertedUiFile);
@@ -125,7 +126,7 @@ private:
void errorInvalidSlot(const QString &slot, const QString &widgetName, const QString &widgetClass,
int line, int col);
- DomUI *generateUi4(const QDomElement &e, bool implicitIncludes);
+ DomUI *generateUi4(const QDomElement &e);
DomWidget *createWidget(const QDomElement &w, const QString &widgetClass = QString());
void createProperties(const QDomElement &e, QList<DomProperty*> *properties, const QString &className);
void createAttributes(const QDomElement &e, QList<DomProperty*> *properties, const QString &className);
@@ -145,6 +146,8 @@ private:
void fixLayoutMargin(DomLayout *ui_layout);
+ const unsigned m_options;
+
QTextStream &out;
QTextOStream trout;
QString languageChangeBody;
@@ -157,7 +160,6 @@ private:
QString formName;
QString lastItem;
QString trmacro;
- bool nofwd;
struct Buddy
{
diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp
index a2b3ca2..b614cb4 100644
--- a/tools/assistant/lib/qhelpsearchquerywidget.cpp
+++ b/tools/assistant/lib/qhelpsearchquerywidget.cpp
@@ -120,6 +120,22 @@ private:
// nothing todo
}
+ void retranslate()
+ {
+ simpleSearchLabel->setText(tr("Search for:"));
+ prevQueryButton->setToolTip(tr("Previous search"));
+ nextQueryButton->setToolTip(tr("Next search"));
+ searchButton->setText(tr("Search"));
+#ifdef QT_CLUCENE_SUPPORT
+ advancedSearchLabel->setText(tr("Advanced search"));
+ similarLabel->setText(tr("words <B>similar</B> to:"));
+ withoutLabel->setText(tr("<B>without</B> the words:"));
+ exactLabel->setText(tr("with <B>exact phrase</B>:"));
+ allLabel->setText(tr("with <B>all</B> of the words:"));
+ atLeastLabel->setText(tr("with <B>at least one</B> of the words:"));
+#endif
+ }
+
QString escapeString(const QString &text)
{
QString retValue = text;
@@ -360,6 +376,13 @@ private:
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 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent)
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 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent)
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 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent)
QGridLayout *gLayout = new QGridLayout(d->advancedSearchWidget);
gLayout->setMargin(0);
- label = new QLabel(tr("words <B>similar</B> 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("<B>without</B> 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 <B>exact phrase</B>:"), 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 <B>all</B> 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 <B>at least one</B> 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 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent)
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()));
@@ -531,4 +554,14 @@ void QHelpSearchQueryWidget::focusInEvent(QFocusEvent *focusEvent)
}
}
+/*! \reimp
+*/
+void QHelpSearchQueryWidget::changeEvent(QEvent *event)
+{
+ if (event->type() == QEvent::LanguageChange)
+ d->retranslate();
+ else
+ QWidget::changeEvent(event);
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/lib/qhelpsearchquerywidget.h b/tools/assistant/lib/qhelpsearchquerywidget.h
index a99bae0..2afc4b4 100644
--- a/tools/assistant/lib/qhelpsearchquerywidget.h
+++ b/tools/assistant/lib/qhelpsearchquerywidget.h
@@ -74,7 +74,8 @@ Q_SIGNALS:
void search();
private:
- void focusInEvent(QFocusEvent *focusEvent);
+ virtual void focusInEvent(QFocusEvent *focusEvent);
+ virtual void changeEvent(QEvent *event);
private:
QHelpSearchQueryWidgetPrivate *d;
diff --git a/tools/assistant/lib/qhelpsearchresultwidget.cpp b/tools/assistant/lib/qhelpsearchresultwidget.cpp
index 3cac880..a3f5aed 100644
--- a/tools/assistant/lib/qhelpsearchresultwidget.cpp
+++ b/tools/assistant/lib/qhelpsearchresultwidget.cpp
@@ -408,6 +408,14 @@ QHelpSearchResultWidget::QHelpSearchResultWidget(QHelpSearchEngine *engine)
connect(engine, SIGNAL(searchingFinished(int)), d, SLOT(setResults(int)));
}
+/*! \reimp
+*/
+void QHelpSearchResultWidget::changeEvent(QEvent *event)
+{
+ if (event->type() == QEvent::LanguageChange)
+ d->setResults(d->searchEngine->hitCount());
+}
+
/*!
Destroys the search result widget.
*/
diff --git a/tools/assistant/lib/qhelpsearchresultwidget.h b/tools/assistant/lib/qhelpsearchresultwidget.h
index d078079..ff29adc 100644
--- a/tools/assistant/lib/qhelpsearchresultwidget.h
+++ b/tools/assistant/lib/qhelpsearchresultwidget.h
@@ -75,6 +75,7 @@ private:
QHelpSearchResultWidgetPrivate *d;
QHelpSearchResultWidget(QHelpSearchEngine *engine);
+ virtual void changeEvent(QEvent *event);
};
QT_END_NAMESPACE
diff --git a/tools/designer/src/lib/shared/widgetfactory.cpp b/tools/designer/src/lib/shared/widgetfactory.cpp
index eda551d..c7b13a1 100644
--- a/tools/designer/src/lib/shared/widgetfactory.cpp
+++ b/tools/designer/src/lib/shared/widgetfactory.cpp
@@ -774,6 +774,8 @@ void WidgetFactory::applyStyleTopLevel(const QString &styleName, QWidget *w)
void WidgetFactory::applyStyleToTopLevel(QStyle *style, QWidget *widget)
{
+ if (!style)
+ return;
const QPalette standardPalette = style->standardPalette();
if (widget->style() == style && widget->palette() == standardPalette)
return;