]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiLyXFiles.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiLyXFiles.cpp
index bcb2dcd839c850263c83f883a53480230033aa77..98c43419fdc29c3e4cfcb5e2e4bbcb4aceb6d907 100644 (file)
@@ -42,8 +42,8 @@ namespace {
 
 QString const guiString(QString in)
 {
-       // recode specially encoded chars in file names
-       return in.replace('_', ' ').replace("%26", "&").replace("%28", "(").replace("%29", ")");
+       // recode specially encoded chars in file names (URL encoding and underbar)
+       return QString(QByteArray::fromPercentEncoding(in.toUtf8())).replace('_', ' ');
 }
 
 } // namespace anon
@@ -430,7 +430,10 @@ void GuiLyXFiles::updateContents()
                QTreeWidgetItem * item = new QTreeWidgetItem();
                QString const filename = info.fileName();
                QString guiname = filename.left(filename.lastIndexOf(getSuffix())).replace('_', ' ');
-               if (translateName())
+               // Special case: defaults.lyx
+               if (type_ == "templates" && guiname == "defaults")
+                       guiname = qt_("Default Template");
+               else if (translateName())
                        guiname = toqstr(translateIfPossible(qstring_to_ucs4(guiString(guiname))));
                QIcon file_icon = (realpath.startsWith(toqstr(package().user_support().absFileName()))) ?
                                user_icon : system_icon;
@@ -550,7 +553,12 @@ void GuiLyXFiles::passParams(string const & data)
 
 void GuiLyXFiles::selectItem(QString const item)
 {
-       QList<QTreeWidgetItem *> twi = filesLW->findItems(item, Qt::MatchExactly|Qt::MatchRecursive);
+       /* Using an intermediary variable flags is needed up to at least
+        * Qt 5.5 because of a subtle namespace issue. See:
+        *   https://stackoverflow.com/questions/10755058/qflags-enum-type-conversion-fails-all-of-a-sudden
+        * for details.*/
+       Qt::MatchFlags const flags(Qt::MatchExactly|Qt::MatchRecursive);
+       QList<QTreeWidgetItem *> twi = filesLW->findItems(item, flags);
        if (!twi.isEmpty())
                twi.first()->setSelected(true);
 }