summaryrefslogtreecommitdiffstats
path: root/tools/linguist
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-30 22:58:06 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-30 22:58:06 (GMT)
commit27e55ed231f2afe5a775c3ea92f2ef4bf1f6a26d (patch)
tree4be868ec6a0a425044bee84f269cfee3bad7c0e6 /tools/linguist
parent50afd26a657da319bd6e3cff09ac6c8dd44405bf (diff)
parent61f2b450560887651b3350e63bdd75609e3b6752 (diff)
downloadQt-27e55ed231f2afe5a775c3ea92f2ef4bf1f6a26d.zip
Qt-27e55ed231f2afe5a775c3ea92f2ef4bf1f6a26d.tar.gz
Qt-27e55ed231f2afe5a775c3ea92f2ef4bf1f6a26d.tar.bz2
Merge branch '4.6' of git://scm.dev.nokia.troll.no/qt/qt into kinetic-declarativeui
Conflicts: src/corelib/animation/qabstractanimation.cpp
Diffstat (limited to 'tools/linguist')
-rw-r--r--tools/linguist/linguist/mainwindow.cpp29
-rw-r--r--tools/linguist/linguist/mainwindow.h1
-rw-r--r--tools/linguist/linguist/messagemodel.cpp7
-rw-r--r--tools/linguist/linguist/translationsettingsdialog.cpp33
-rw-r--r--tools/linguist/linguist/translationsettingsdialog.h2
-rw-r--r--tools/linguist/shared/qph.cpp30
-rw-r--r--tools/linguist/shared/translator.h6
7 files changed, 76 insertions, 32 deletions
diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp
index 5c3aaa1..383f5aa 100644
--- a/tools/linguist/linguist/mainwindow.cpp
+++ b/tools/linguist/linguist/mainwindow.cpp
@@ -305,8 +305,6 @@ MainWindow::MainWindow()
m_contextView->setModel(m_sortedContextsModel);
m_contextView->header()->setMovable(false);
m_contextView->setColumnHidden(0, true);
- m_contextView->header()->setResizeMode(1, QHeaderView::Stretch);
- m_contextView->header()->setResizeMode(2, QHeaderView::ResizeToContents);
m_contextView->header()->setStretchLastSection(false);
m_contextDock->setWidget(m_contextView);
@@ -335,8 +333,6 @@ MainWindow::MainWindow()
m_messageView->setModel(m_sortedMessagesModel);
m_messageView->header()->setMovable(false);
m_messageView->setColumnHidden(0, true);
- m_messageView->setColumnHidden(2, true);
- // last visible column auto-stretches
m_messagesDock->setWidget(m_messageView);
@@ -443,6 +439,7 @@ MainWindow::MainWindow()
statusBar()->addPermanentWidget(m_modifiedLabel);
modelCountChanged();
+ initViewHeaders();
resetSorting();
connect(m_dataModel, SIGNAL(modifiedChanged(bool)),
@@ -509,6 +506,14 @@ MainWindow::~MainWindow()
delete m_printer;
}
+void MainWindow::initViewHeaders()
+{
+ m_contextView->header()->setResizeMode(1, QHeaderView::Stretch);
+ m_contextView->header()->setResizeMode(2, QHeaderView::ResizeToContents);
+ m_messageView->setColumnHidden(2, true);
+ // last visible column auto-stretches
+}
+
void MainWindow::modelCountChanged()
{
int mc = m_dataModel->modelCount();
@@ -740,6 +745,7 @@ bool MainWindow::closeAll()
m_messageView->setUpdatesEnabled(false);
m_dataModel->closeAll();
modelCountChanged();
+ initViewHeaders();
recentFiles().closeGroup();
return true;
}
@@ -2348,6 +2354,17 @@ void MainWindow::updatePhraseDicts()
m_phraseView->update();
}
+static bool haveMnemonic(const QString &str)
+{
+ QString mnemonic = QKeySequence::mnemonic(str);
+ if (mnemonic == QLatin1String("Alt+Space")) {
+ // "Nobody" ever really uses these, and they are highly annoying
+ // because we get a lot of false positives.
+ return false;
+ }
+ return !mnemonic.isEmpty();
+}
+
void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose)
{
MultiDataIndex curIdx = index;
@@ -2379,10 +2396,10 @@ void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose)
}
if (m_ui.actionAccelerators->isChecked()) {
- bool sk = !QKeySequence::mnemonic(source).isEmpty();
+ bool sk = haveMnemonic(source);
bool tk = true;
for (int i = 0; i < translations.count() && tk; ++i) {
- tk &= !QKeySequence::mnemonic(translations[i]).isEmpty();
+ tk &= haveMnemonic(translations[i]);
}
if (!sk && tk) {
diff --git a/tools/linguist/linguist/mainwindow.h b/tools/linguist/linguist/mainwindow.h
index 8b46893..dc711d8 100644
--- a/tools/linguist/linguist/mainwindow.h
+++ b/tools/linguist/linguist/mainwindow.h
@@ -179,6 +179,7 @@ private:
bool prev(bool checkUnfinished);
void updateStatistics();
+ void initViewHeaders();
void modelCountChanged();
void setupMenuBar();
void setupToolBars();
diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp
index 024fd91..49cd382 100644
--- a/tools/linguist/linguist/messagemodel.cpp
+++ b/tools/linguist/linguist/messagemodel.cpp
@@ -786,16 +786,9 @@ void MultiDataModel::closeAll()
m_numFinished = 0;
m_numEditable = 0;
m_numMessages = 0;
- int delCol = m_dataModels.count();
- m_msgModel->beginRemoveColumns(QModelIndex(), 1, delCol);
- for (int i = m_multiContextList.size(); --i >= 0;) {
- m_msgModel->beginRemoveColumns(m_msgModel->createIndex(i, 0, 0), 1, delCol);
- m_msgModel->endRemoveColumns();
- }
qDeleteAll(m_dataModels);
m_dataModels.clear();
m_multiContextList.clear();
- m_msgModel->endRemoveColumns();
m_msgModel->reset();
emit allModelsDeleted();
onModifiedChanged();
diff --git a/tools/linguist/linguist/translationsettingsdialog.cpp b/tools/linguist/linguist/translationsettingsdialog.cpp
index 0d94c3a..562f14e 100644
--- a/tools/linguist/linguist/translationsettingsdialog.cpp
+++ b/tools/linguist/linguist/translationsettingsdialog.cpp
@@ -60,15 +60,7 @@ TranslationSettingsDialog::TranslationSettingsDialog(QWidget *parent)
m_ui.srcCbLanguageList->model()->sort(0, Qt::AscendingOrder);
m_ui.srcCbLanguageList->insertItem(0, QLatin1String("POSIX"), QVariant(QLocale::C));
- for (int i = QLocale::AnyCountry + 1; i < QLocale::LastCountry; ++i) {
- QString country = QLocale::countryToString(QLocale::Country(i));
- m_ui.srcCbCountryList->addItem(country, QVariant(i));
- }
- m_ui.srcCbCountryList->model()->sort(0, Qt::AscendingOrder);
- m_ui.srcCbCountryList->insertItem(0, tr("Any Country"), QVariant(QLocale::AnyCountry));
-
m_ui.tgtCbLanguageList->setModel(m_ui.srcCbLanguageList->model());
- m_ui.tgtCbCountryList->setModel(m_ui.srcCbCountryList->model());
}
void TranslationSettingsDialog::setDataModel(DataModel *dataModel)
@@ -87,6 +79,31 @@ void TranslationSettingsDialog::setPhraseBook(PhraseBook *phraseBook)
setWindowTitle(tr("Settings for '%1' - Qt Linguist").arg(fn));
}
+static void fillCountryCombo(const QVariant &lng, QComboBox *combo)
+{
+ combo->clear();
+ QLocale::Language lang = QLocale::Language(lng.toInt());
+ if (lang != QLocale::C) {
+ foreach (QLocale::Country cntr, QLocale::countriesForLanguage(lang)) {
+ QString country = QLocale::countryToString(cntr);
+ combo->addItem(country, QVariant(cntr));
+ }
+ combo->model()->sort(0, Qt::AscendingOrder);
+ }
+ combo->insertItem(0, TranslationSettingsDialog::tr("Any Country"), QVariant(QLocale::AnyCountry));
+ combo->setCurrentIndex(0);
+}
+
+void TranslationSettingsDialog::on_srcCbLanguageList_currentIndexChanged(int idx)
+{
+ fillCountryCombo(m_ui.srcCbLanguageList->itemData(idx), m_ui.srcCbCountryList);
+}
+
+void TranslationSettingsDialog::on_tgtCbLanguageList_currentIndexChanged(int idx)
+{
+ fillCountryCombo(m_ui.tgtCbLanguageList->itemData(idx), m_ui.tgtCbCountryList);
+}
+
void TranslationSettingsDialog::on_buttonBox_accepted()
{
int itemindex = m_ui.tgtCbLanguageList->currentIndex();
diff --git a/tools/linguist/linguist/translationsettingsdialog.h b/tools/linguist/linguist/translationsettingsdialog.h
index 2408add..7908cd7 100644
--- a/tools/linguist/linguist/translationsettingsdialog.h
+++ b/tools/linguist/linguist/translationsettingsdialog.h
@@ -66,6 +66,8 @@ private:
private slots:
void on_buttonBox_accepted();
+ void on_srcCbLanguageList_currentIndexChanged(int idx);
+ void on_tgtCbLanguageList_currentIndexChanged(int idx);
private:
Ui::TranslationSettingsDialog m_ui;
diff --git a/tools/linguist/shared/qph.cpp b/tools/linguist/shared/qph.cpp
index 788245c..32bdabb 100644
--- a/tools/linguist/shared/qph.cpp
+++ b/tools/linguist/shared/qph.cpp
@@ -81,14 +81,20 @@ bool QPHReader::read(Translator &translator)
while (!atEnd()) {
readNext();
if (isStartElement()) {
- if (name() == QLatin1String("source"))
+ if (name() == QLatin1String("source")) {
m_currentField = SourceField;
- else if (name() == QLatin1String("target"))
+ } else if (name() == QLatin1String("target")) {
m_currentField = TargetField;
- else if (name() == QLatin1String("definition"))
+ } else if (name() == QLatin1String("definition")) {
m_currentField = DefinitionField;
- else
+ } else {
m_currentField = NoField;
+ if (name() == QLatin1String("QPH")) {
+ QXmlStreamAttributes atts = attributes();
+ translator.setLanguageCode(atts.value(QLatin1String("language")).toString());
+ translator.setSourceLanguageCode(atts.value(QLatin1String("sourcelanguage")).toString());
+ }
+ }
} else if (isWhiteSpace()) {
// ignore these
} else if (isCharacters()) {
@@ -104,7 +110,7 @@ bool QPHReader::read(Translator &translator)
TranslatorMessage msg;
msg.setSourceText(m_currentSource);
msg.setTranslation(m_currentTarget);
- msg.setTranslatorComment(m_currentDefinition);
+ msg.setComment(m_currentDefinition);
translator.append(msg);
m_currentSource.clear();
m_currentTarget.clear();
@@ -157,7 +163,14 @@ static bool saveQPH(const Translator &translator, QIODevice &dev, ConversionData
{
QTextStream t(&dev);
t.setCodec(QTextCodec::codecForName("UTF-8"));
- t << "<!DOCTYPE QPH>\n<QPH>\n";
+ t << "<!DOCTYPE QPH>\n<QPH";
+ QString languageCode = translator.languageCode();
+ if (!languageCode.isEmpty() && languageCode != QLatin1String("C"))
+ t << " language=\"" << languageCode << "\"";
+ languageCode = translator.sourceLanguageCode();
+ if (!languageCode.isEmpty() && languageCode != QLatin1String("C"))
+ t << " sourcelanguage=\"" << languageCode << "\"";
+ t << ">\n";
foreach (const TranslatorMessage &msg, translator.messages()) {
t << "<phrase>\n";
t << " <source>" << protect(msg.sourceText()) << "</source>\n";
@@ -166,9 +179,8 @@ static bool saveQPH(const Translator &translator, QIODevice &dev, ConversionData
QChar(Translator::TextVariantSeparator));
t << " <target>" << protect(str)
<< "</target>\n";
- if (!msg.context().isEmpty() || !msg.comment().isEmpty())
- t << " <definition>" << msg.context() << msg.comment()
- << "</definition>\n";
+ if (!msg.comment().isEmpty())
+ t << " <definition>" << protect(msg.comment()) << "</definition>\n";
t << "</phrase>\n";
}
t << "</QPH>\n";
diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h
index 353cf9d..fa447a3 100644
--- a/tools/linguist/shared/translator.h
+++ b/tools/linguist/shared/translator.h
@@ -55,10 +55,12 @@
QT_BEGIN_NAMESPACE
#ifdef QT_BOOTSTRAPPED
-struct QObject {
+class QObject {
+public:
static QString tr(const char *sourceText, const char * = 0, int n = -1);
};
-struct QCoreApplication : public QObject {
+class QCoreApplication : public QObject {
+public:
enum Encoding { CodecForTr };
static QString translate(const char *, const char *sourceText, const char * = 0,
Encoding = CodecForTr, int n = -1)