]> git.lyx.org Git - features.git/commitdiff
Convert internal_path() to unicode (partially). Fix bug 3114:
authorAbdelrazak Younes <younes@lyx.org>
Thu, 18 Jan 2007 12:30:07 +0000 (12:30 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Thu, 18 Jan 2007 12:30:07 +0000 (12:30 +0000)
  http://bugzilla.lyx.org/show_bug.cgi?id=3114

* os.h
  - new docstring adapted internal_path()

* qt_helpers.[Ch]:
  - new QString adapted internal_path()

All other files: use that.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16744 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/QExternal.C
src/frontends/qt4/QGraphics.C
src/frontends/qt4/QInclude.C
src/frontends/qt4/QPrefsDialog.C
src/frontends/qt4/qt_helpers.C
src/frontends/qt4/qt_helpers.h
src/support/os.h
src/support/os_cygwin.C
src/support/os_unix.C
src/support/os_win32.C

index 8d7a131bf82760e0f0294e3826a024671291e3b5..7ed801317dde2898feb35f40c4cf87442e04ca68 100644 (file)
@@ -455,7 +455,8 @@ void QExternal::apply()
 {
        InsetExternalParams params = controller().params();
 
-       params.filename.set(internal_path(fromqstr(dialog_->fileED->text())),
+       // FIXME: UNICODE
+       params.filename.set(to_utf8(internal_path(dialog_->fileED->text())),
                            kernel().bufferFilepath());
 
        params.settemplate(controller().getTemplate(
index 5c3c7c53b1789188f95005a9865ab03f5e702b75..8f813ec946f8bd57a6d44d19bba849ade9c022d0 100644 (file)
@@ -270,7 +270,8 @@ void QGraphics::apply()
 {
        InsetGraphicsParams & igp = controller().params();
 
-       igp.filename.set(internal_path(fromqstr(dialog_->filename->text())),
+       // FIXME: UNICODE
+       igp.filename.set(to_utf8(internal_path(dialog_->filename->text())),
                         kernel().bufferFilepath());
 
        // the bb section
index 62a0fac90131ce31f3dd1e2122a331c96cc775ea..b58491ba43595b69ea5f98b40c3a1f69a72121b8 100644 (file)
@@ -103,7 +103,7 @@ void QInclude::apply()
 {
        InsetCommandParams params = controller().params();
 
-       params["filename"] = from_utf8(internal_path(fromqstr(dialog_->filenameED->text())));
+       params["filename"] = internal_path(dialog_->filenameED->text());
        params.preview(dialog_->previewCB->isChecked());
 
        int const item = dialog_->typeCO->currentIndex();
index 17dcf8d5c50e2fc1f7b6e4dc8b7beae8376198eb..39d95184f4528300f3cf5eff3458b123a2d8d85f 100644 (file)
@@ -176,12 +176,6 @@ QString const external_path_list(string const & input)
 }
 
 
-string const internal_path(QString const & input)
-{
-       return lyx::support::os::internal_path(fromqstr(input));
-}
-
-
 string const internal_path_list(QString const & input)
 {
        return lyx::support::os::internal_path_list(fromqstr(input));
@@ -254,8 +248,10 @@ void PrefKeyboard::apply(LyXRC & rc) const
 {
        // FIXME: can derive CB from the two EDs
        rc.use_kbmap = keymapCB->isChecked();
-       rc.primary_kbmap = internal_path(firstKeymapED->text());
-       rc.secondary_kbmap = internal_path(secondKeymapED->text());
+
+       // FIXME: UNICODE
+       rc.primary_kbmap = to_utf8(internal_path(firstKeymapED->text()));
+       rc.secondary_kbmap = to_utf8(internal_path(secondKeymapED->text()));
 }
 
 
@@ -683,13 +679,14 @@ PrefPaths::PrefPaths(QPrefs * form, QWidget * parent)
 
 void PrefPaths::apply(LyXRC & rc) const
 {
-       rc.document_path = internal_path(workingDirED->text());
-       rc.template_path = internal_path(templateDirED->text());
-       rc.backupdir_path = internal_path(backupDirED->text());
-       rc.tempdir_path = internal_path(tempDirED->text());
+       // FIXME: UNICODE
+       rc.document_path = to_utf8(internal_path(workingDirED->text()));
+       rc.template_path = to_utf8(internal_path(templateDirED->text()));
+       rc.backupdir_path = to_utf8(internal_path(backupDirED->text()));
+       rc.tempdir_path = to_utf8(internal_path(tempDirED->text()));
        rc.path_prefix = internal_path_list(pathPrefixED->text());
        // FIXME: should be a checkbox only
-       rc.lyxpipes = internal_path(lyxserverDirED->text());
+       rc.lyxpipes = to_utf8(internal_path(lyxserverDirED->text()));
 }
 
 
@@ -707,7 +704,7 @@ void PrefPaths::update(LyXRC const & rc)
 void PrefPaths::select_templatedir()
 {
        docstring file(form_->controller().browsedir(
-               qstring_to_ucs4(templateDirED->text()),
+               internal_path(templateDirED->text()),
                _("Select a document templates directory")));
        if (!file.empty())
                templateDirED->setText(toqstr(file));
@@ -717,7 +714,7 @@ void PrefPaths::select_templatedir()
 void PrefPaths::select_tempdir()
 {
        docstring file(form_->controller().browsedir(
-               qstring_to_ucs4(tempDirED->text()),
+               internal_path(tempDirED->text()),
                _("Select a temporary directory")));
        if (!file.empty())
                tempDirED->setText(toqstr(file));
@@ -727,7 +724,7 @@ void PrefPaths::select_tempdir()
 void PrefPaths::select_backupdir()
 {
        docstring file(form_->controller().browsedir(
-               qstring_to_ucs4(backupDirED->text()),
+               internal_path(backupDirED->text()),
                _("Select a backups directory")));
        if (!file.empty())
                backupDirED->setText(toqstr(file));
@@ -737,7 +734,7 @@ void PrefPaths::select_backupdir()
 void PrefPaths::select_workingdir()
 {
        docstring file(form_->controller().browsedir(
-               qstring_to_ucs4(workingDirED->text()),
+               internal_path(workingDirED->text()),
                _("Select a document directory")));
        if (!file.empty())
                workingDirED->setText(toqstr(file));
@@ -747,7 +744,7 @@ void PrefPaths::select_workingdir()
 void PrefPaths::select_lyxpipe()
 {
        docstring file(form_->controller().browse(
-               qstring_to_ucs4(lyxserverDirED->text()),
+               internal_path(lyxserverDirED->text()),
                _("Give a filename for the LyX server pipe")));
        if (!file.empty())
                lyxserverDirED->setText(toqstr(file));
@@ -810,8 +807,9 @@ void PrefSpellchecker::apply(LyXRC & rc) const
        // FIXME: remove isp_use_esc_chars
        rc.isp_esc_chars = fromqstr(escapeCharactersED->text());
        rc.isp_use_esc_chars = !rc.isp_esc_chars.empty();
+       // FIXME: UNICODE
        // FIXME: remove isp_use_pers_dict
-       rc.isp_pers_dict = internal_path(persDictionaryED->text());
+       rc.isp_pers_dict = to_utf8(internal_path(persDictionaryED->text()));
        rc.isp_use_pers_dict = !rc.isp_pers_dict.empty();
        rc.isp_accept_compound = compoundWordCB->isChecked();
        rc.isp_use_input_encoding = inputEncodingCB->isChecked();
@@ -849,7 +847,8 @@ void PrefSpellchecker::update(LyXRC const & rc)
 
 void PrefSpellchecker::select_dict()
 {
-       docstring file(form_->controller().browsedict(qstring_to_ucs4(persDictionaryED->text())));
+       docstring file(form_->controller().browsedict(
+               internal_path(persDictionaryED->text())));
        if (!file.empty())
                persDictionaryED->setText(toqstr(file));
 }
@@ -1606,7 +1605,8 @@ void PrefPrinter::apply(LyXRC & rc) const
        rc.print_oddpage_flag = fromqstr(printerOddED->text());
        rc.print_collcopies_flag = fromqstr(printerCollatedED->text());
        rc.print_landscape_flag = fromqstr(printerLandscapeED->text());
-       rc.print_to_file = internal_path(printerToFileED->text());
+       // FIXME: UNICODE
+       rc.print_to_file = to_utf8(internal_path(printerToFileED->text()));
        rc.print_extra_options = fromqstr(printerExtraED->text());
        rc.print_spool_printerprefix = fromqstr(printerSpoolPrefixED->text());
        rc.print_paper_dimension_flag = fromqstr(printerPaperSizeED->text());
@@ -1677,8 +1677,9 @@ PrefUserInterface::PrefUserInterface(QPrefs * form, QWidget * parent)
 
 void PrefUserInterface::apply(LyXRC & rc) const
 {
-       rc.ui_file = internal_path(uiFileED->text());
-       rc.bind_file = internal_path(bindFileED->text());
+       // FIXME: UNICODE
+       rc.ui_file = to_utf8(internal_path(uiFileED->text()));
+       rc.bind_file = to_utf8(internal_path(bindFileED->text()));
        rc.use_lastfilepos = restoreCursorCB->isChecked();
        rc.load_session = loadSessionCB->isChecked();
        if (loadWindowSizeCB->isChecked()) {
@@ -1723,7 +1724,9 @@ void PrefUserInterface::update(LyXRC const & rc)
 
 void PrefUserInterface::select_ui()
 {
-       docstring file(form_->controller().browseUI(qstring_to_ucs4(uiFileED->text())));
+       docstring const name =
+               internal_path(uiFileED->text());
+       docstring file(form_->controller().browseUI(name));
        if (!file.empty())
                uiFileED->setText(toqstr(file));
 }
@@ -1731,7 +1734,9 @@ void PrefUserInterface::select_ui()
 
 void PrefUserInterface::select_bind()
 {
-       docstring file(form_->controller().browsebind(qstring_to_ucs4(bindFileED->text())));
+       docstring const name =
+               internal_path(bindFileED->text());
+       docstring file(form_->controller().browsebind(name));
        if (!file.empty())
                bindFileED->setText(toqstr(file));
 }
index c6abe3f27108c886a33a7aeeef156de66ceb2861..e8ed5bbfc9d3219a0cd3cbd6d6e93ff53712b158 100644 (file)
@@ -17,6 +17,7 @@
 #include "lengthcommon.h"
 #include "gettext.h"
 
+#include "support/os.h"
 #include "support/lstrings.h"
 #include "support/convert.h"
 
@@ -179,4 +180,10 @@ docstring const formatted(docstring const & text, int w)
 }
 
 
+docstring const internal_path(QString const & input)
+{
+       return lyx::support::os::internal_path(qstring_to_ucs4(input));
+}
+
+
 } // namespace lyx
index 5c52b1fdfac128e5c120df3006c81fe36904819b..acaf3c3eeb1393916fd1d4dfc70540107a67f901 100644 (file)
@@ -59,6 +59,9 @@ QString const qt_(char const * str, const char * comment = 0);
  */
 QString const qt_(std::string const & str);
 
+///
+docstring const internal_path(QString const & input);
+
 } // namespace lyx
 
 #endif // QTHELPERS_H
index d4b103f1064f6f851d06ebb6685962ee72a87f97..dffedb5fa5d101ee326281470cd2c97d38248e5b 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef OS_H
 #define OS_H
 
+#include "support/docstring.h"
+
 #include <string>
 
 
@@ -50,6 +52,9 @@ std::string external_path(std::string const & p);
 /// Converts a host OS style path to unix style.
 std::string internal_path(std::string const & p);
 
+/// Converts a host OS style path to unix style.
+docstring internal_path(docstring const & p);
+
 /// Converts a unix style path list to host OS style.
 std::string external_path_list(std::string const & p);
 
index d281294ab7bbc3a1a4ee2b4312df7f0a6017524c..63afa5bdb7489619eb206853434f73f65a32b625 100644 (file)
@@ -211,6 +211,13 @@ string internal_path(string const & p)
 }
 
 
+docstring internal_path(docstring const & p)
+{
+       // FIXME UNICODE
+       return from_utf8(convert_path(to_utf8(p), PathStyle(posix)));
+}
+
+
 string external_path_list(string const & p)
 {
        return convert_path_list(p, PathStyle(posix));
index aff294b7b4b6ade31fb64ed57972215047877008..4fb46c2e6e8ef8b6a8a82f02709fe44d0a94506e 100644 (file)
@@ -70,6 +70,12 @@ string internal_path(string const & p)
 }
 
 
+docstring internal_path(docstring const & p)
+{
+       return p;
+}
+
+
 string external_path_list(string const & p)
 {
        return p;
index 468e8491c210479ab5ee5e24d61e4fe2996f06c4..3dc6ab652a90316150f957b46867027044dbb771 100644 (file)
@@ -240,6 +240,13 @@ string internal_path(string const & p)
 }
 
 
+docstring internal_path(docstring const & p)
+{
+       // FIXME UNICODE
+       return from_utf8(subst(get_long_path(to_utf8(p)), "\\", "/"));
+}
+
+
 string external_path_list(string const & p)
 {
        return subst(p, '/', '\\');