]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiExternal.cpp
Handle correctly zero table special arguments.
[lyx.git] / src / frontends / qt4 / GuiExternal.cpp
index 65790327bb88b7f20b7886074d31743620c3d8fc..ba1c171ebfca116f6a5377217b03b351f9614520 100644 (file)
@@ -80,7 +80,7 @@ char const * const origin_gui_strs[] = {
        N_("Top right"), N_("Bottom right"), N_("Baseline right")
 };
 
-} // namespace anon
+} // namespace
 
 
 GuiExternal::GuiExternal(GuiView & lv)
@@ -202,10 +202,16 @@ GuiExternal::GuiExternal(GuiView & lv)
        external::TemplateManager::Templates::const_iterator i1, i2;
        i1 = external::TemplateManager::get().getTemplates().begin();
        i2 = external::TemplateManager::get().getTemplates().end();
+       QMap<QString, QString> localizedTemplates;
        for (; i1 != i2; ++i1)
-               externalCO->addItem(qt_(i1->second.guiName), toqstr(i1->second.lyxName));
-       // Sort alphabetically by(localized) GUI name
-       externalCO->model()->sort(0);
+               localizedTemplates.insert(qt_(i1->second.guiName), toqstr(i1->second.lyxName));
+       // Sort alphabetically by (localized) GUI name
+       QStringList keys = localizedTemplates.keys();
+       qSort(keys.begin(), keys.end(), SortLocaleAware);
+       for (QString & key : keys) {
+               QString const value = localizedTemplates[key];
+               externalCO->addItem(key, value);
+       }
 
        // Fill the origins combo
        for (size_t i = 0; i != sizeof(origins) / sizeof(origins[0]); ++i)
@@ -487,6 +493,9 @@ static void getCrop(external::ClipData & data,
 
 void GuiExternal::updateContents()
 {
+       if (params_.filename.empty())
+               tab->setCurrentIndex(0);
+
        string const name =
                params_.filename.outputFileName(fromqstr(bufferFilePath()));
        fileED->setText(toqstr(name));
@@ -525,7 +534,10 @@ void GuiExternal::updateTemplate()
                external::TemplateManager::get();
        external::Template const * const templ = etm.getTemplateByName(
                fromqstr(externalCO->itemData(externalCO->currentIndex()).toString()));
-       externalTB->setPlainText(toqstr(translateIfPossible(templ->helpText)));
+       externalTB->setPlainText(toqstr(translateIfPossible(
+                               templ ? templ->helpText : docstring())));
+       if (!templ)
+               return;
 
        // Ascertain which (if any) transformations the template supports
        // and disable tabs and Group Boxes hosting unsupported transforms.