]> git.lyx.org Git - features.git/commitdiff
a few more docstring<->QString conversions
authorAndré Pönitz <poenitz@gmx.net>
Wed, 5 Mar 2008 23:10:53 +0000 (23:10 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 5 Mar 2008 23:10:53 +0000 (23:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23493 a592a061-630c-0410-9148-cb99ea01b6c8

14 files changed:
src/frontends/qt4/FileDialog.cpp
src/frontends/qt4/FileDialog.h
src/frontends/qt4/GuiBibtex.cpp
src/frontends/qt4/GuiClipboard.cpp
src/frontends/qt4/GuiInclude.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/GuiPrefs.h
src/frontends/qt4/GuiShowFile.cpp
src/frontends/qt4/GuiTexinfo.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/LyXFileDialog.cpp
src/frontends/qt4/LyXFileDialog.h
src/frontends/qt4/qt_helpers.cpp
src/frontends/qt4/qt_helpers.h

index 50d98c59eb5407fb848229f33e3ba53d9d8be984..964820b16481fbfe37e43f7ecd2f1ce2aca6a384 100644 (file)
@@ -57,7 +57,7 @@ public:
 };
 
 
-FileDialog::FileDialog(docstring const & t, kb_action s)
+FileDialog::FileDialog(QString const & t, kb_action s)
        : private_(new FileDialog::Private), title_(t), success_(s)
 {}
 
@@ -68,32 +68,32 @@ FileDialog::~FileDialog()
 }
 
 
-void FileDialog::setButton1(docstring const & label, docstring const & dir)
+void FileDialog::setButton1(QString const & label, QString const & dir)
 {
        private_->b1.first = label;
        private_->b1.second = dir;
 }
 
 
-void FileDialog::setButton2(docstring const & label, docstring const & dir)
+void FileDialog::setButton2(QString const & label, QString const & dir)
 {
        private_->b2.first = label;
        private_->b2.second = dir;
 }
 
 
-FileDialog::Result const FileDialog::save(docstring const & path,
+FileDialog::Result FileDialog::save(QString const & path,
                                          FileFilterList const & filters,
-                                         docstring const & suggested)
+                                         QString const & suggested)
 {
-       LYXERR(Debug::GUI, "Select with path \"" << to_utf8(path)
+       LYXERR(Debug::GUI, "Select with path \"" << fromqstr(path)
                           << "\", mask \"" << to_utf8(filters.as_string())
-                          << "\", suggested \"" << to_utf8(suggested) << '"');
+                          << "\", suggested \"" << fromqstr(suggested) << '"');
        FileDialog::Result result;
        result.first = FileDialog::Chosen;
 
 #ifdef USE_NATIVE_FILEDIALOG
-       docstring const startsWith = from_utf8(
+       QString const startsWith = from_utf8(
                makeAbsPath(to_utf8(suggested), to_utf8(path)).absFilename());
        QString const name = 
                QFileDialog::getSaveFileName(qApp->focusWidget(),
@@ -111,66 +111,64 @@ FileDialog::Result const FileDialog::save(docstring const & path,
        dlg.setAcceptMode(QFileDialog::AcceptSave);
        dlg.setConfirmOverwrite(false);
 
-       if (!suggested.empty())
-               dlg.selectFile(toqstr(suggested));
+       if (!suggested.isEmpty())
+               dlg.selectFile(suggested);
 
        LYXERR(Debug::GUI, "Synchronous FileDialog: ");
        int res = dlg.exec();
        LYXERR(Debug::GUI, "result " << res);
        if (res == QDialog::Accepted)
-               result.second = from_utf8(internal_path(
-                                       fromqstr(dlg.selectedFiles()[0])));
+               result.second = internalPath(dlg.selectedFiles()[0]);
        dlg.hide();
 #endif
        return result;
 }
 
 
-FileDialog::Result const FileDialog::open(docstring const & path,
+FileDialog::Result FileDialog::open(QString const & path,
                                          FileFilterList const & filters,
-                                         docstring const & suggested)
+                                         QString const & suggested)
 {
-       LYXERR(Debug::GUI, "Select with path \"" << to_utf8(path)
-                          << "\", mask \"" << to_utf8(filters.as_string())
-                          << "\", suggested \"" << to_utf8(suggested) << '"');
+       LYXERR(Debug::GUI, "Select with path \"" << fromqstr(path)
+                          << "\", mask \"" << filters.as_string()
+                          << "\", suggested \"" << fromqstr(suggested) << '"');
        FileDialog::Result result;
        result.first = FileDialog::Chosen;
 
 #ifdef USE_NATIVE_FILEDIALOG
-       docstring const startsWith = from_utf8(
-               makeAbsPath(to_utf8(suggested), to_utf8(path)).absFilename());
-       result.second = from_utf8(internal_path(fromqstr(
+       QString const startsWith = toqstr(
+               makeAbsPath(fromqstr(suggested), fromqstr(path)).absFilename());
+       result.second = internalPath(
                QFileDialog::getOpenFileName(qApp->focusWidget(),
-               toqstr(title_), toqstr(startsWith), toqstr(filters.as_string()) ))));
+               toqstr(title_), toqstr(startsWith), toqstr(filters.as_string()) ));
 #else
        LyXFileDialog dlg(title_, path, filters, private_->b1, private_->b2);
 
-       if (!suggested.empty())
-               dlg.selectFile(toqstr(suggested));
+       if (!suggested.isEmpty())
+               dlg.selectFile(suggested);
 
        LYXERR(Debug::GUI, "Synchronous FileDialog: ");
        int res = dlg.exec();
        LYXERR(Debug::GUI, "result " << res);
        if (res == QDialog::Accepted)
-               result.second = from_utf8(internal_path(
-                                       fromqstr(dlg.selectedFiles()[0])));
+               result.second = internalPath(dlg.selectedFiles()[0]);
        dlg.hide();
 #endif
        return result;
 }
 
 
-FileDialog::Result const FileDialog::opendir(docstring const & path,
-                                           docstring const & suggested)
+FileDialog::Result FileDialog::opendir(QString const & path,
+                                           QString const & suggested)
 {
-       LYXERR(Debug::GUI, "Select with path \"" << to_utf8(path)
-                          << "\", suggested \"" << to_utf8(suggested) << '"');
+       LYXERR(Debug::GUI, "Select with path \"" << fromqstr(path)
+                          << "\", suggested \"" << fromqstr(suggested) << '"');
        FileDialog::Result result;
        result.first = FileDialog::Chosen;
 
 #ifdef USE_NATIVE_FILEDIALOG
-       docstring const startsWith = from_utf8(
-               makeAbsPath(to_utf8(suggested), to_utf8(path)).absFilename());
+       QString const startsWith = toqstr(
+               makeAbsPath(fromqstr(suggested), fromqstr(path)).absFilename());
        result.second = from_utf8(internal_path(fromqstr(
                QFileDialog::getExistingDirectory(qApp->focusWidget(),
                toqstr(title_),toqstr(startsWith)))));
@@ -181,15 +179,14 @@ FileDialog::Result const FileDialog::opendir(docstring const & path,
 
        dlg.setFileMode(QFileDialog::DirectoryOnly);
 
-       if (!suggested.empty())
-               dlg.selectFile(toqstr(suggested));
+       if (!suggested.isEmpty())
+               dlg.selectFile(suggested);
 
        LYXERR(Debug::GUI, "Synchronous FileDialog: ");
        int res = dlg.exec();
        LYXERR(Debug::GUI, "result " << res);
        if (res == QDialog::Accepted)
-               result.second = from_utf8(internal_path(
-                                       fromqstr(dlg.selectedFiles()[0])));
+               result.second = internalPath(dlg.selectedFiles()[0]);
        dlg.hide();
 #endif
        return result;
index a4e69da2f286cdf31ff1429bc459f317a9d897dd..a20fb40ba8d5b9c627475991ccb186101587ffcf 100644 (file)
 #define FILEDIALOG_H
 
 #include "lfuns.h"
-#include "support/docstring.h"
 
-#include <string>
+#include <QString>
 
+#include <utility>
 
 namespace lyx {
 
@@ -32,7 +32,7 @@ class FileDialog
 {
 public:
        /// label, directory path button
-       typedef std::pair<docstring, docstring> Button;
+       typedef std::pair<QString, QString> Button;
 
        /// result type
        enum ResultType {
@@ -41,7 +41,7 @@ public:
        };
 
        /// result return
-       typedef std::pair<FileDialog::ResultType, docstring> Result;
+       typedef std::pair<FileDialog::ResultType, QString> Result;
 
        /**
         * Constructs a file dialog with title \param title.
@@ -54,26 +54,26 @@ public:
         * additional directories in the navigation (an empty
         * directory is interpreted as FileName::getcwd())
         */
-       FileDialog(docstring const & title, kb_action a = LFUN_SELECT_FILE_SYNC);
+       FileDialog(QString const & title, kb_action a = LFUN_SELECT_FILE_SYNC);
 
        ~FileDialog();
 
-       void setButton1(docstring const & label, docstring const & dir);
-       void setButton2(docstring const & label, docstring const & dir);
+       void setButton1(QString const & label, QString const & dir);
+       void setButton2(QString const & label, QString const & dir);
 
        /// Choose a file for opening, starting in directory \c path.
-       Result const open(docstring const & path,
+       Result open(QString const & path,
                          support::FileFilterList const & filters,
-                         docstring const & suggested);
+                         QString const & suggested = QString());
 
        /// Choose a directory, starting in directory \c path.
-       Result const opendir(docstring const & path = docstring(),
-                            docstring const & suggested = docstring());
+       Result opendir(QString const & path = QString(),
+                            QString const & suggested = QString());
 
        /// Choose a file for saving, starting in directory \c  path.
-       Result const save(docstring const & path,
+       Result save(QString const & path,
                          support::FileFilterList const & filters,
-                         docstring const & suggested);
+                         QString const & suggested = QString());
 
 private:
        class Private;
@@ -81,7 +81,7 @@ private:
        Private * private_;
 
        /// the dialog title
-       docstring title_;
+       QString title_;
 
        /// success action to perform if not synchronous
        kb_action success_;
index 052510b425c245360cd0c8347e4fcda6aec83231..69aebc49611014affa0c3d39208c4dbb1e9198b6 100644 (file)
@@ -461,9 +461,8 @@ void GuiBibtex::getBibStyles(vector<string> & data) const
        }
        vector<string>::iterator it  = data.begin();
        vector<string>::iterator end = data.end();
-       for (; it != end; ++it) {
-               *it = onlyFilename(*it);
-       }
+       for (; it != end; ++it)
+               *it = support::onlyFilename(*it);
        // sort on filename only (no path)
        sort(data.begin(), data.end());
 }
@@ -481,9 +480,8 @@ void GuiBibtex::getBibFiles(vector<string> & data) const
        }
        vector<string>::iterator it  = data.begin();
        vector<string>::iterator end = data.end();
-       for (; it != end; ++it) {
-               *it = onlyFilename(*it);
-       }
+       for (; it != end; ++it)
+               *it = support::onlyFilename(*it);
        // sort on filename only (no path)
        sort(data.begin(), data.end());
 }
index ccb5dab090a5cf6641862949a7d5711ad87c1b83..fb62a3b0ce981f860dc54290440c97c7f3a16bed 100644 (file)
@@ -232,15 +232,15 @@ FileName GuiClipboard::getPastedGraphicsFileName(Cursor const & cur,
                FileFilterList const filter(filterSpec);
                
                // show save dialog for the graphic
-               FileDialog dlg(_("Choose a filename to save the pasted graphic as"));
+               FileDialog dlg(qt_("Choose a filename to save the pasted graphic as"));
                FileDialog::Result result =
-               dlg.save(from_utf8(filename.onlyPath().absFilename()), filter,
-                        from_utf8(filename.onlyFileName()));
+               dlg.save(toqstr(filename.onlyPath().absFilename()), filter,
+                        toqstr(filename.onlyFileName()));
                
                if (result.first == FileDialog::Later)
                        return FileName();
                
-               string newFilename = to_utf8(result.second);
+               string newFilename = fromqstr(result.second);
                if (newFilename.empty()) {
                        cur.bv().message(_("Canceled."));
                        return FileName();
index 23a79015f3b9ac670996f99e775a5c9d863690de..2b25fea23f4cc9d77409c8e27bbee60c39eba1a0 100644 (file)
@@ -321,7 +321,7 @@ docstring GuiInclude::browse(docstring const & in_name, Type in_type) const
                break;
        }
 
-       docstring const docpath = from_utf8(onlyPath(buffer().absFileName()));
+       docstring const docpath = from_utf8(support::onlyPath(buffer().absFileName()));
 
        return browseRelFile(in_name, docpath, title, filters, false, 
                _("Documents|#o#O"), from_utf8(lyxrc.document_path));
@@ -336,7 +336,7 @@ void GuiInclude::edit(string const & file)
        else
                // tex file or other text file in verbatim mode
                formats.edit(buffer(), 
-                       makeAbsPath(file, onlyPath(buffer().absFileName())),
+                       makeAbsPath(file, support::onlyPath(buffer().absFileName())),
                        "text");
 }
 
index e35e8cc7a1b29e2e8b8b97c7e5bdc67a38196f89..ff90e69ca2b2b81b987fbe8548cc4ed18fa742cc 100644 (file)
@@ -20,6 +20,7 @@
 #include "BufferList.h"
 #include "Color.h"
 #include "ConverterCache.h"
+#include "FileDialog.h"
 #include "FuncRequest.h"
 #include "GuiFontExample.h"
 #include "GuiKeySymbol.h"
@@ -70,6 +71,154 @@ using namespace lyx::support::os;
 namespace lyx {
 namespace frontend {
 
+/////////////////////////////////////////////////////////////////////
+//
+// Browser Helpers
+//
+/////////////////////////////////////////////////////////////////////
+
+FileName libFileSearch(QString const & dir, QString const & name,
+                               QString const & ext = QString())
+{
+       return support::libFileSearch(fromqstr(dir), fromqstr(name), fromqstr(ext));
+}
+
+
+/** Launch a file dialog and return the chosen file.
+       filename: a suggested filename.
+       title: the title of the dialog.
+       pattern: *.ps etc.
+       dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
+*/
+QString browseFile(QString const & filename,
+       QString const & title,
+       support::FileFilterList const & filters,
+       bool save = false,
+       QString const & label1 = QString(),
+       QString const & dir1 = QString(),
+       QString const & label2 = QString(),
+       QString const & dir2 = QString())
+{
+       QString lastPath = ".";
+       if (!filename.isEmpty())
+               lastPath = onlyPath(filename);
+
+       FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
+       dlg.setButton2(label1, dir1);
+       dlg.setButton2(label2, dir2);
+
+       FileDialog::Result result;
+
+       if (save)
+               result = dlg.save(lastPath, filters, onlyFilename(filename));
+       else
+               result = dlg.open(lastPath, filters, onlyFilename(filename));
+
+       return result.second;
+}
+
+
+/** Wrapper around browseFile which tries to provide a filename
+*  relative to the user or system directory. The dir, name and ext
+*  parameters have the same meaning as in the
+*  support::LibFileSearch function.
+*/
+QString browseLibFile(QString const & dir,
+       QString const & name,
+       QString const & ext,
+       QString const & title,
+       support::FileFilterList const & filters)
+{
+       // FIXME UNICODE
+       QString const label1 = qt_("System files|#S#s");
+       QString const dir1 =
+               toqstr(addName(package().system_support().absFilename(), fromqstr(dir)));
+
+       QString const label2 = qt_("User files|#U#u");
+       QString const dir2 =
+               toqstr(addName(package().user_support().absFilename(), fromqstr(dir)));
+
+       QString const result = browseFile(toqstr(
+               libFileSearch(dir, name, ext).absFilename()),
+               title, filters, false, dir1, dir2);
+
+       // remove the extension if it is the default one
+       QString noextresult;
+       if (toqstr(getExtension(fromqstr(result))) == ext)
+               noextresult = toqstr(removeExtension(fromqstr(result)));
+       else
+               noextresult = result;
+
+       // remove the directory, if it is the default one
+       QString const file = onlyFilename(noextresult);
+       if (toqstr(libFileSearch(dir, file, ext).absFilename()) == result)
+               return file;
+       else
+               return noextresult;
+}
+
+
+/** Launch a file dialog and return the chosen directory.
+       pathname: a suggested pathname.
+       title: the title of the dialog.
+       dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
+*/
+QString browseDir(QString const & pathname,
+       QString const & title,
+       QString const & label1 = QString(),
+       QString const & dir1 = QString(),
+       QString const & label2 = QString(),
+       QString const & dir2 = QString())
+{
+       QString lastPath = ".";
+       if (!pathname.isEmpty())
+               lastPath = onlyPath(pathname);
+
+       FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
+       dlg.setButton1(label1, dir1);
+       dlg.setButton2(label2, dir2);
+
+       FileDialog::Result const result =
+               dlg.opendir(lastPath, onlyFilename(pathname));
+
+       return result.second;
+}
+
+
+QString browseRelFile(QString const & filename, QString const & refpath,
+       QString const & title, FileFilterList const & filters, bool save,
+       QString const & label1, QString const & dir1,
+       QString const & label2, QString const & dir2)
+{
+       QString const fname = toqstr(makeAbsPath(
+               fromqstr(filename), fromqstr(refpath)).absFilename());
+
+       QString const outname =
+               browseFile(fname, title, filters, save, label1, dir1, label2, dir2);
+
+       QString const reloutname =
+               toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(refpath)));
+
+       if (reloutname.startsWith("../"))
+               return outname;
+       else
+               return reloutname;
+}
+
+} // namespace frontend
+
+docstring browseRelFile(docstring const & filename, docstring const & refpath,
+       docstring const & title, FileFilterList const & filters, bool save,
+       docstring const & label1, docstring const & dir1,
+       docstring const & label2, docstring const & dir2)
+{
+       return qstring_to_ucs4(frontend::browseRelFile(
+               toqstr(filename), toqstr(refpath),
+               toqstr(title), filters, save,
+               toqstr(label1), toqstr(dir1),
+               toqstr(label2), toqstr(dir2)));
+}
+
 
 /////////////////////////////////////////////////////////////////////
 //
@@ -77,6 +226,8 @@ namespace frontend {
 //
 /////////////////////////////////////////////////////////////////////
 
+namespace frontend {
+
 template<class A>
 static size_t findPos_helper(vector<A> const & vec, A const & val)
 {
@@ -111,7 +262,7 @@ static void setComboxFont(QComboBox * cb, string const & family,
        if (!foundry.empty())
                fontname += " [" + toqstr(foundry) + ']';
 
-       for (int i = 0; i < cb->count(); ++i) {
+       for (int i = 0; i != cb->count(); ++i) {
                if (cb->itemText(i) == fontname) {
                        cb->setCurrentIndex(i);
                        return;
@@ -192,7 +343,7 @@ static void setComboxFont(QComboBox * cb, string const & family,
 /////////////////////////////////////////////////////////////////////
 
 PrefPlaintext::PrefPlaintext(QWidget * parent)
-       : PrefModule(_("Plain text"), 0, parent)
+       : PrefModule(qt_("Plain text"), 0, parent)
 {
        setupUi(this);
        connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
@@ -223,7 +374,7 @@ void PrefPlaintext::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefDate::PrefDate(QWidget * parent)
-       : PrefModule(_("Date format"), 0, parent)
+       : PrefModule(qt_("Date format"), 0, parent)
 {
        setupUi(this);
        connect(DateED, SIGNAL(textChanged(QString)),
@@ -250,7 +401,7 @@ void PrefDate::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefInput::PrefInput(GuiPreferences * form, QWidget * parent)
-       : PrefModule(_("Keyboard/Mouse"), form, parent)
+       : PrefModule(qt_("Keyboard/Mouse"), form, parent)
 {
        setupUi(this);
 
@@ -320,7 +471,7 @@ void PrefInput::update(LyXRC const & rc)
 
 QString PrefInput::testKeymap(QString keymap)
 {
-       return toqstr(form_->browsekbmap(from_utf8(internal_path(fromqstr(keymap)))));
+       return form_->browsekbmap(toqstr(internal_path(fromqstr(keymap))));
 }
 
 
@@ -358,7 +509,7 @@ void PrefInput::on_keymapCB_toggled(bool keymap)
 /////////////////////////////////////////////////////////////////////
 
 PrefLatex::PrefLatex(GuiPreferences * form, QWidget * parent)
-       : PrefModule(_("LaTeX"), form, parent)
+       : PrefModule(qt_("LaTeX"), form, parent)
 {
        setupUi(this);
        connect(latexEncodingED, SIGNAL(textChanged(QString)),
@@ -425,7 +576,7 @@ void PrefLatex::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefScreenFonts::PrefScreenFonts(GuiPreferences * form, QWidget * parent)
-       : PrefModule(_("Screen fonts"), form, parent)
+       : PrefModule(qt_("Screen fonts"), form, parent)
 {
        setupUi(this);
 
@@ -599,7 +750,7 @@ struct ColorSorter
 } // namespace anon
 
 PrefColors::PrefColors(GuiPreferences * form, QWidget * parent)
-       : PrefModule( _("Colors"), form, parent)
+       : PrefModule(qt_("Colors"), form, parent)
 {
        setupUi(this);
 
@@ -697,7 +848,7 @@ void PrefColors::change_lyxObjects_selection()
 /////////////////////////////////////////////////////////////////////
 
 PrefDisplay::PrefDisplay(QWidget * parent)
-       : PrefModule(_("Graphics"), 0, parent)
+       : PrefModule(qt_("Graphics"), 0, parent)
 {
        setupUi(this);
        connect(instantPreviewCO, SIGNAL(activated(int)),
@@ -768,7 +919,7 @@ void PrefDisplay::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefPaths::PrefPaths(GuiPreferences * form, QWidget * parent)
-       : PrefModule(_("Paths"), form, parent)
+       : PrefModule(qt_("Paths"), form, parent)
 {
        setupUi(this);
        connect(exampleDirPB, SIGNAL(clicked()), this, SLOT(select_exampledir()));
@@ -822,61 +973,55 @@ void PrefPaths::update(LyXRC const & rc)
 
 void PrefPaths::select_exampledir()
 {
-       docstring file(form_->browsedir(
-               from_utf8(internal_path(fromqstr(exampleDirED->text()))),
-               _("Select directory for example files")));
-       if (!file.empty())
-               exampleDirED->setText(toqstr(file));
+       QString file = form_->browsedir(internalPath(exampleDirED->text()),
+               qt_("Select directory for example files"));
+       if (!file.isEmpty())
+               exampleDirED->setText(file);
 }
 
 
 void PrefPaths::select_templatedir()
 {
-       docstring file(form_->browsedir(
-               from_utf8(internal_path(fromqstr(templateDirED->text()))),
-               _("Select a document templates directory")));
-       if (!file.empty())
-               templateDirED->setText(toqstr(file));
+       QString file = form_->browsedir(internalPath(templateDirED->text()),
+               qt_("Select a document templates directory"));
+       if (!file.isEmpty())
+               templateDirED->setText(file);
 }
 
 
 void PrefPaths::select_tempdir()
 {
-       docstring file(form_->browsedir(
-               from_utf8(internal_path(fromqstr(tempDirED->text()))),
-               _("Select a temporary directory")));
-       if (!file.empty())
-               tempDirED->setText(toqstr(file));
+       QString file = form_->browsedir(internalPath(tempDirED->text()),
+               qt_("Select a temporary directory"));
+       if (!file.isEmpty())
+               tempDirED->setText(file);
 }
 
 
 void PrefPaths::select_backupdir()
 {
-       docstring file(form_->browsedir(
-               from_utf8(internal_path(fromqstr(backupDirED->text()))),
-               _("Select a backups directory")));
-       if (!file.empty())
-               backupDirED->setText(toqstr(file));
+       QString file = form_->browsedir(internalPath(backupDirED->text()),
+               qt_("Select a backups directory"));
+       if (!file.isEmpty())
+               backupDirED->setText(file);
 }
 
 
 void PrefPaths::select_workingdir()
 {
-       docstring file(form_->browsedir(
-               from_utf8(internal_path(fromqstr(workingDirED->text()))),
-               _("Select a document directory")));
-       if (!file.empty())
-               workingDirED->setText(toqstr(file));
+       QString file = form_->browsedir(internalPath(workingDirED->text()),
+               qt_("Select a document directory"));
+       if (!file.isEmpty())
+               workingDirED->setText(file);
 }
 
 
 void PrefPaths::select_lyxpipe()
 {
-       docstring file(form_->browse(
-               from_utf8(internal_path(fromqstr(lyxserverDirED->text()))),
-               _("Give a filename for the LyX server pipe")));
-       if (!file.empty())
-               lyxserverDirED->setText(toqstr(file));
+       QString file = form_->browse(internalPath(lyxserverDirED->text()),
+               qt_("Give a filename for the LyX server pipe"));
+       if (!file.isEmpty())
+               lyxserverDirED->setText(file);
 }
 
 
@@ -887,7 +1032,7 @@ void PrefPaths::select_lyxpipe()
 /////////////////////////////////////////////////////////////////////
 
 PrefSpellchecker::PrefSpellchecker(GuiPreferences * form, QWidget * parent)
-       : PrefModule(_("Spellchecker"), form, parent)
+       : PrefModule(qt_("Spellchecker"), form, parent)
 {
        setupUi(this);
 
@@ -981,10 +1126,9 @@ void PrefSpellchecker::update(LyXRC const & rc)
 
 void PrefSpellchecker::select_dict()
 {
-       docstring file(form_->browsedict(
-               from_utf8(internal_path(fromqstr(persDictionaryED->text())))));
-       if (!file.empty())
-               persDictionaryED->setText(toqstr(file));
+       QString file = form_->browsedict(internalPath(persDictionaryED->text()));
+       if (!file.isEmpty())
+               persDictionaryED->setText(file);
 }
 
 
@@ -997,7 +1141,7 @@ void PrefSpellchecker::select_dict()
 
 
 PrefConverters::PrefConverters(GuiPreferences * form, QWidget * parent)
-       : PrefModule(_("Converters"), form, parent)
+       : PrefModule(qt_("Converters"), form, parent)
 {
        setupUi(this);
 
@@ -1267,7 +1411,7 @@ string FormatPrettynameValidator::str(Formats::const_iterator it) const
 
 
 PrefFileformats::PrefFileformats(GuiPreferences * form, QWidget * parent)
-       : PrefModule(_("File formats"), form, parent)
+       : PrefModule(qt_("File formats"), form, parent)
 {
        setupUi(this);
        formatED->setValidator(new FormatNameValidator(formatsCB, form_->formats()));
@@ -1466,7 +1610,7 @@ void PrefFileformats::on_formatRemovePB_clicked()
 /////////////////////////////////////////////////////////////////////
 
 PrefLanguage::PrefLanguage(QWidget * parent)
-       : PrefModule(_("Language"), 0, parent)
+       : PrefModule(qt_("Language"), 0, parent)
 {
        setupUi(this);
 
@@ -1555,7 +1699,7 @@ void PrefLanguage::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefPrinter::PrefPrinter(QWidget * parent)
-       : PrefModule(_("Printer"), 0, parent)
+       : PrefModule(qt_("Printer"), 0, parent)
 {
        setupUi(this);
 
@@ -1653,7 +1797,7 @@ void PrefPrinter::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent)
-       : PrefModule(_("User interface"), form, parent)
+       : PrefModule(qt_("User interface"), form, parent)
 {
        setupUi(this);
 
@@ -1752,11 +1896,9 @@ void PrefUserInterface::update(LyXRC const & rc)
 
 void PrefUserInterface::select_ui()
 {
-       docstring const name =
-               from_utf8(internal_path(fromqstr(uiFileED->text())));
-       docstring file = form_->browseUI(name);
-       if (!file.empty())
-               uiFileED->setText(toqstr(file));
+       QString file = form_->browseUI(internalPath(uiFileED->text()));
+       if (!file.isEmpty())
+               uiFileED->setText(file);
 }
 
 
@@ -1775,7 +1917,7 @@ GuiShortcutDialog::GuiShortcutDialog(QWidget * parent) : QDialog(parent)
 
 
 PrefShortcuts::PrefShortcuts(GuiPreferences * form, QWidget * parent)
-       : PrefModule(_("Shortcuts"), form, parent)
+       : PrefModule(qt_("Shortcuts"), form, parent)
 {
        setupUi(this);
 
@@ -2018,13 +2160,11 @@ void PrefShortcuts::on_shortcutsTW_itemDoubleClicked()
 
 void PrefShortcuts::select_bind()
 {
-       docstring const name =
-               from_utf8(internal_path(fromqstr(bindFileED->text())));
-       docstring file = form_->browsebind(name);
-       if (!file.empty()) {
-               bindFileED->setText(toqstr(file));
+       QString file = form_->browsebind(internalPath(bindFileED->text()));
+       if (!file.isEmpty()) {
+               bindFileED->setText(file);
                system_bind_ = KeyMap();
-               system_bind_.read(to_utf8(file));
+               system_bind_.read(fromqstr(file));
                updateShortcutsTW();
        }
 }
@@ -2170,7 +2310,7 @@ void PrefShortcuts::shortcut_clearPB_pressed()
 /////////////////////////////////////////////////////////////////////
 
 PrefIdentity::PrefIdentity(QWidget * parent)
-       : PrefModule(_("Identity"), 0, parent)
+       : PrefModule(qt_("Identity"), 0, parent)
 {
        setupUi(this);
 
@@ -2258,7 +2398,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
 void GuiPreferences::add(PrefModule * module)
 {
        BOOST_ASSERT(module);
-       prefsPS->addPanel(module, toqstr(module->title()));
+       prefsPS->addPanel(module, module->title());
        connect(module, SIGNAL(changed()), this, SLOT(change_adaptor()));
        modules_.push_back(module);
 }
@@ -2358,52 +2498,43 @@ void GuiPreferences::updateScreenFonts()
 }
 
 
-docstring const GuiPreferences::browsebind(docstring const & file) const
+QString GuiPreferences::browsebind(QString const & file) const
 {
-       return browseLibFile(from_ascii("bind"), file, from_ascii("bind"),
-                            _("Choose bind file"),
+       return browseLibFile("bind", file, "bind", qt_("Choose bind file"),
                             FileFilterList(_("LyX bind files (*.bind)")));
 }
 
 
-docstring const GuiPreferences::browseUI(docstring const & file) const
+QString GuiPreferences::browseUI(QString const & file) const
 {
-       return browseLibFile(from_ascii("ui"), file, from_ascii("ui"),
-                            _("Choose UI file"),
+       return browseLibFile("ui", file, "ui", qt_("Choose UI file"),
                             FileFilterList(_("LyX UI files (*.ui)")));
 }
 
 
-docstring const GuiPreferences::browsekbmap(docstring const & file) const
+QString GuiPreferences::browsekbmap(QString const & file) const
 {
-       return browseLibFile(from_ascii("kbd"), file, from_ascii("kmap"),
-                            _("Choose keyboard map"),
+       return browseLibFile("kbd", file, "kmap", qt_("Choose keyboard map"),
                             FileFilterList(_("LyX keyboard maps (*.kmap)")));
 }
 
 
-docstring const GuiPreferences::browsedict(docstring const & file) const
+QString GuiPreferences::browsedict(QString const & file) const
 {
-       if (lyxrc.use_spell_lib)
-               return browseFile(file,
-                                 _("Choose personal dictionary"),
-                                 FileFilterList(_("*.pws")));
-       else
-               return browseFile(file,
-                                 _("Choose personal dictionary"),
-                                 FileFilterList(_("*.ispell")));
+       return browseFile(file, qt_("Choose personal dictionary"),
+               FileFilterList(lyxrc.use_spell_lib ? _("*.pws") : _("*.ispell")));
 }
 
 
-docstring const GuiPreferences::browse(docstring const & file,
-                                 docstring const & title) const
+QString GuiPreferences::browse(QString const & file,
+                                 QString const & title) const
 {
        return browseFile(file, title, FileFilterList(), true);
 }
 
 
-docstring const GuiPreferences::browsedir(docstring const & path,
-                                    docstring const & title) const
+QString GuiPreferences::browsedir(QString const & path,
+                                    QString const & title) const
 {
        return browseDir(path, title);
 }
index ec37c76a607967dfac899b5cddaa48b45ff0eb9a..903a7d4e30e1d8ba2fc84324f31d7626975c557f 100644 (file)
@@ -65,7 +65,7 @@ class PrefModule : public QWidget
 {
        Q_OBJECT
 public:
-       PrefModule(docstring const & t,
+       PrefModule(QString const & t,
                        GuiPreferences * form = 0, QWidget * parent = 0)
                : QWidget(parent), title_(t), form_(form)
        {}
@@ -73,10 +73,10 @@ public:
        virtual void apply(LyXRC & rc) const = 0;
        virtual void update(LyXRC const & rc) = 0;
 
-       docstring const & title() const { return title_; }
+       QString const & title() const { return title_; }
 
 protected:
-       docstring title_;
+       QString title_;
        GuiPreferences * form_;
 
 Q_SIGNALS:
@@ -455,18 +455,16 @@ public:
        bool isBufferDependent() const { return false; }
 
        /// various file pickers
-       docstring const browsebind(docstring const & file) const;
-       docstring const browseUI(docstring const & file) const;
-       docstring const browsekbmap(docstring const & file) const;
-       docstring const browsedict(docstring const & file) const;
+       QString browsebind(QString const & file) const;
+       QString browseUI(QString const & file) const;
+       QString browsekbmap(QString const & file) const;
+       QString browsedict(QString const & file) const;
 
        /// general browse
-       docstring const browse(docstring const & file,
-                                docstring const & title) const;
+       QString browse(QString const & file, QString const & title) const;
 
        /// browse directory
-       docstring const browsedir(docstring const & path,
-                                   docstring const & title) const;
+       QString browsedir(QString const & path, QString const & title) const;
 
        /// set a color
        void setColor(ColorCode col, std::string const & hex);
index 9cde4ba22ef0f22c7faf2132dc2843e3f0ec7ab7..43d519610a5b4de56ffcfb544d8cdda1c208a48c 100644 (file)
@@ -40,7 +40,7 @@ GuiShowFile::GuiShowFile(GuiView & lv)
 
 void GuiShowFile::updateContents()
 {
-       setWindowTitle(toqstr(onlyFilename(filename_.absFilename())));
+       setWindowTitle(onlyFilename(toqstr(filename_.absFilename())));
 
        QString contents = toqstr(filename_.fileContents("UTF-8"));
        if (contents.isEmpty())
index b718d4b28788e22f62470c74e047ec852668181e..c482c7474cd2905bd5d5688f1a1e798f480997ee 100644 (file)
@@ -65,7 +65,7 @@ static string texFileFromList(string const & file, string const & type)
        string classfile = token(allClasses, '\n', entries);
        int count = 0;
        while ((!contains(classfile, file) ||
-               (onlyFilename(classfile) != file)) &&
+               (support::onlyFilename(classfile) != file)) &&
                (++count < 1000)) {
                classfile = token(allClasses, '\n', ++entries);
        }
@@ -167,7 +167,7 @@ void GuiTexInfo::updateStyles(TexFileType type)
        vector<string>::iterator it1  = data.begin();
        vector<string>::iterator end1 = data.end();
        for (; it1 != end1; ++it1)
-               *it1 = onlyFilename(*it1);
+               *it1 = support::onlyFilename(*it1);
 
        // sort on filename only (no path)
        sort(data.begin(), data.end());
index 45a252f592373c8deab9265d0bd1d514b77a1e6e..bc40a465b29f5996a7cdb960cd97f559fe420fc4 100644 (file)
@@ -1080,20 +1080,19 @@ FuncStatus GuiView::getStatus(FuncRequest const & cmd)
 
 static FileName selectTemplateFile()
 {
-       FileDialog dlg(_("Select template file"));
-       dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
-       dlg.setButton1(_("Templates|#T#t"), from_utf8(lyxrc.template_path));
+       FileDialog dlg(qt_("Select template file"));
+       dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
+       dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
 
        FileDialog::Result result =
-               dlg.open(from_utf8(lyxrc.template_path),
-                            FileFilterList(_("LyX Documents (*.lyx)")),
-                            docstring());
+               dlg.open(toqstr(lyxrc.template_path),
+                            FileFilterList(_("LyX Documents (*.lyx)")));
 
        if (result.first == FileDialog::Later)
                return FileName();
-       if (result.second.empty())
+       if (result.second.isEmpty())
                return FileName();
-       return FileName(to_utf8(result.second));
+       return FileName(fromqstr(result.second));
 }
 
 
@@ -1140,20 +1139,18 @@ void GuiView::openDocument(string const & fname)
        string filename;
 
        if (fname.empty()) {
-               FileDialog dlg(_("Select document to open"), LFUN_FILE_OPEN);
-               dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
-               dlg.setButton2(_("Examples|#E#e"),
-                               from_utf8(addPath(package().system_support().absFilename(), "examples")));
+               FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
+               dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
+               dlg.setButton2(qt_("Examples|#E#e"),
+                               toqstr(addPath(package().system_support().absFilename(), "examples")));
 
                FileDialog::Result result =
-                       dlg.open(from_utf8(initpath),
-                                    FileFilterList(_("LyX Documents (*.lyx)")),
-                                    docstring());
+                       dlg.open(toqstr(initpath), FileFilterList(_("LyX Documents (*.lyx)")));
 
                if (result.first == FileDialog::Later)
                        return;
 
-               filename = to_utf8(result.second);
+               filename = fromqstr(result.second);
 
                // check selected filename
                if (filename.empty()) {
@@ -1274,10 +1271,10 @@ void GuiView::importDocument(string const & argument)
                docstring const text = bformat(_("Select %1$s file to import"),
                        formats.prettyName(format));
 
-               FileDialog dlg(text, LFUN_BUFFER_IMPORT);
-               dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
-               dlg.setButton2(_("Examples|#E#e"),
-                       from_utf8(addPath(package().system_support().absFilename(), "examples")));
+               FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
+               dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
+               dlg.setButton2(qt_("Examples|#E#e"),
+                       toqstr(addPath(package().system_support().absFilename(), "examples")));
 
                docstring filter = formats.prettyName(format);
                filter += " (*.";
@@ -1286,14 +1283,12 @@ void GuiView::importDocument(string const & argument)
                filter += ')';
 
                FileDialog::Result result =
-                       dlg.open(from_utf8(initpath),
-                                    FileFilterList(filter),
-                                    docstring());
+                       dlg.open(toqstr(initpath), FileFilterList(filter));
 
                if (result.first == FileDialog::Later)
                        return;
 
-               filename = to_utf8(result.second);
+               filename = fromqstr(result.second);
 
                // check selected filename
                if (filename.empty())
@@ -1395,22 +1390,21 @@ void GuiView::insertLyXFile(docstring const & fname)
                initpath = trypath;
 
        // FIXME UNICODE
-       FileDialog dlg(_("Select LyX document to insert"), LFUN_FILE_INSERT);
-       dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
-       dlg.setButton2(_("Examples|#E#e"),
-               from_utf8(addPath(package().system_support().absFilename(),
+       FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
+       dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
+       dlg.setButton2(qt_("Examples|#E#e"),
+               toqstr(addPath(package().system_support().absFilename(),
                "examples")));
 
        FileDialog::Result result =
-               dlg.open(from_utf8(initpath),
-                            FileFilterList(_("LyX Documents (*.lyx)")),
-                            docstring());
+               dlg.open(toqstr(initpath),
+                            FileFilterList(_("LyX Documents (*.lyx)")));
 
        if (result.first == FileDialog::Later)
                return;
 
        // FIXME UNICODE
-       filename.set(to_utf8(result.second));
+       filename.set(fromqstr(result.second));
 
        // check selected filename
        if (filename.empty()) {
@@ -1438,17 +1432,17 @@ void GuiView::insertPlaintextFile(docstring const & fname,
                return;
        }
 
-       FileDialog dlg(_("Select file to insert"), (asParagraph ?
+       FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
                LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
 
-       FileDialog::Result result = dlg.open(from_utf8(bv->buffer().filePath()),
-               FileFilterList(), docstring());
+       FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
+               FileFilterList());
 
        if (result.first == FileDialog::Later)
                return;
 
        // FIXME UNICODE
-       filename.set(to_utf8(result.second));
+       filename.set(fromqstr(result.second));
 
        // check selected filename
        if (filename.empty()) {
@@ -1475,10 +1469,10 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
 
                /// No argument? Ask user through dialog.
                // FIXME UNICODE
-               FileDialog dlg(_("Choose a filename to save document as"),
+               FileDialog dlg(qt_("Choose a filename to save document as"),
                                   LFUN_BUFFER_WRITE_AS);
-               dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
-               dlg.setButton2(_("Templates|#T#t"), from_utf8(lyxrc.template_path));
+               dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
+               dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
 
                if (!isLyXFilename(fname.absFilename()))
                        fname.changeExtension(".lyx");
@@ -1486,14 +1480,14 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
                FileFilterList const filter(_("LyX Documents (*.lyx)"));
 
                FileDialog::Result result =
-                       dlg.save(from_utf8(fname.onlyPath().absFilename()),
+                       dlg.save(toqstr(fname.onlyPath().absFilename()),
                                     filter,
-                                    from_utf8(fname.onlyFileName()));
+                                    toqstr(fname.onlyFileName()));
 
                if (result.first == FileDialog::Later)
                        return false;
 
-               fname.set(to_utf8(result.second));
+               fname.set(fromqstr(result.second));
 
                if (fname.empty())
                        return false;
index f00bbd61bf31ea92f5d358e13226159b7b45c9c8..e0f94e7386c638e4fe4b2a8e66ae0712b6c335d4 100644 (file)
@@ -27,54 +27,52 @@ using namespace lyx::support;
 namespace lyx {
 
 /// return the Qt form of the label
-static docstring const getLabel(docstring const & ucs4str)
+static QString getLabel(QString const & qstr)
 {
-       // FIXME UNICODE
-       string str = to_utf8(ucs4str);
+       // FIXME UNICODE (or "qt-ify")
+       string str = fromqstr(qstr);
        string label;
        string sc = split(str, label, '|');
        if (sc.length() < 2)
-               return from_utf8(label);
+               return toqstr(label);
        size_t pos = label.find(sc[1]);
        if (pos != string::npos)
                label.insert(pos, 1, '&');
-       return from_utf8(label);
+       return toqstr(label);
 }
 
 
-LyXFileDialog::LyXFileDialog(docstring const & t,
-                            docstring const & p,
+LyXFileDialog::LyXFileDialog(QString const & title,
+                            QString const & path,
                             support::FileFilterList const & filters,
                             FileDialog::Button const & b1,
                             FileDialog::Button const & b2)
                                 // FIXME replace that with guiApp->currentView()
-       : QFileDialog(qApp->focusWidget(),
-                     toqstr(t), toqstr(p), toqstr(filters.as_string()))
+       : QFileDialog(qApp->focusWidget(), title, path, toqstr(filters.as_string()))
 {
-       QString const path = toqstr(p);
        QDir dir(path);
        // FIXME: workaround for a bug in qt which makes LyX crash
        // with hidden paths (bug 4513). Recheck with recent Qt versions.
        if (path.contains("/."))
                dir.setFilter(QDir::Hidden);
        setDirectory(dir);
-       setWindowTitle(toqstr(t));
+       setWindowTitle(title);
 
        QList<QHBoxLayout *> layout = findChildren<QHBoxLayout *>();
 
-       if (!b1.first.empty()) {
+       if (!b1.first.isEmpty()) {
                b1_dir_ = b1.second;
                QToolButton * tb = new QToolButton(this);
                connect(tb, SIGNAL(clicked()), this, SLOT(button1Clicked()));
-               tb->setText(toqstr(getLabel(b1.first)));
+               tb->setText(getLabel(b1.first));
                layout.at(0)->addWidget(tb);
        }
 
-       if (!b2.first.empty()) {
+       if (!b2.first.isEmpty()) {
                b2_dir_ = b2.second;
                QToolButton * tb = new QToolButton(this);
                connect(tb, SIGNAL(clicked()), this, SLOT(button2Clicked()));
-               tb->setText(toqstr(getLabel(b2.first)));
+               tb->setText(getLabel(b2.first));
                layout.at(0)->addWidget(tb);
        }
 }
@@ -82,13 +80,13 @@ LyXFileDialog::LyXFileDialog(docstring const & t,
 
 void LyXFileDialog::button1Clicked()
 {
-       setDirectory(toqstr(b1_dir_));
+       setDirectory(b1_dir_);
 }
 
 
 void LyXFileDialog::button2Clicked()
 {
-       setDirectory(toqstr(b2_dir_));
+       setDirectory(b2_dir_);
 }
 
 } // namespace lyx
index f04bfe459090dbc25737120f520282d9b5c604da..2419b2cad2048efea9c65385754e877dc0959da3 100644 (file)
@@ -27,8 +27,8 @@ class LyXFileDialog : public QFileDialog
        Q_OBJECT
 
 public:
-       LyXFileDialog(docstring const & title,
-                     docstring const & path,
+       LyXFileDialog(QString const & title,
+                     QString const & path,
                      support::FileFilterList const & filters,
                      FileDialog::Button const & b1,
                      FileDialog::Button const & b2);
@@ -38,8 +38,8 @@ public Q_SLOTS:
        void button2Clicked();
 
 private:
-       docstring b1_dir_;
-       docstring b2_dir_;
+       QString b1_dir_;
+       QString b2_dir_;
 };
 
 } // namespace lyx
index 02f34068d7b1c3c6031f4a544abb7a1f0548f004..d62bf9015b8b64db7f8baca20d2f65c373ea0f61 100644 (file)
@@ -206,103 +206,6 @@ vector<LanguagePair> const getLanguageData(bool character_dlg)
        return langs;
 }
 
-
-docstring browseFile(docstring const & filename, docstring const & title,
-       FileFilterList const & filters, bool save,
-       docstring const & label1, docstring const & dir1,
-       docstring const & label2, docstring const & dir2)
-{
-       docstring lastPath = from_ascii(".");
-       if (!filename.empty())
-               lastPath = from_utf8(onlyPath(to_utf8(filename)));
-
-       FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
-       dlg.setButton1(label1, dir1);
-       dlg.setButton2(label2, dir2);
-
-       FileDialog::Result result;
-
-       if (save)
-               result = dlg.save(lastPath, filters,
-                                     from_utf8(onlyFilename(to_utf8(filename))));
-       else
-               result = dlg.open(lastPath, filters,
-                                     from_utf8(onlyFilename(to_utf8(filename))));
-
-       return result.second;
-}
-
-
-docstring browseRelFile(docstring const & filename, docstring const & refpath,
-       docstring const & title, FileFilterList const & filters, bool save,
-       docstring const & label1, docstring const & dir1,
-       docstring const & label2, docstring const & dir2)
-{
-       docstring const fname = from_utf8(makeAbsPath(
-               to_utf8(filename), to_utf8(refpath)).absFilename());
-
-       docstring const outname = browseFile(fname, title, filters, save,
-                                         label1, dir1, label2, dir2);
-       docstring const reloutname = makeRelPath(outname, refpath);
-       if (prefixIs(reloutname, from_ascii("../")))
-               return outname;
-       else
-               return reloutname;
-}
-
-
-docstring browseLibFile(docstring const & dir, docstring const & name,
-       docstring const & ext, docstring const & title,
-       FileFilterList const & filters)
-{
-       // FIXME UNICODE
-       docstring const label1 = _("System files|#S#s");
-       docstring const dir1 =
-               from_utf8(addName(package().system_support().absFilename(), to_utf8(dir)));
-
-       docstring const label2 = _("User files|#U#u");
-       docstring const dir2 =
-               from_utf8(addName(package().user_support().absFilename(), to_utf8(dir)));
-
-       docstring const result = browseFile(from_utf8(
-               libFileSearch(to_utf8(dir), to_utf8(name), to_utf8(ext)).absFilename()),
-               title, filters, false, dir1, dir2);
-
-       // remove the extension if it is the default one
-       docstring noextresult;
-       if (from_utf8(getExtension(to_utf8(result))) == ext)
-               noextresult = from_utf8(removeExtension(to_utf8(result)));
-       else
-               noextresult = result;
-
-       // remove the directory, if it is the default one
-       docstring const file = from_utf8(onlyFilename(to_utf8(noextresult)));
-       if (from_utf8(libFileSearch(to_utf8(dir), to_utf8(file), to_utf8(ext)).absFilename()) == result)
-               return file;
-       else
-               return noextresult;
-}
-
-
-docstring browseDir(docstring const & pathname, docstring const & title,
-       docstring const & label1, docstring const & dir1,
-       docstring const & label2, docstring const & dir2)
-{
-       docstring lastPath = from_ascii(".");
-       if (!pathname.empty())
-               lastPath = from_utf8(onlyPath(to_utf8(pathname)));
-
-       FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
-       dlg.setButton1(label1, dir1);
-       dlg.setButton2(label2, dir2);
-
-       FileDialog::Result const result =
-               dlg.opendir(lastPath, from_utf8(onlyFilename(to_utf8(pathname))));
-
-       return result.second;
-}
-
-
 void rescanTexStyles()
 {
        // Run rescan in user lyx directory
@@ -343,4 +246,22 @@ void getTexFileList(string const & filename, vector<string> & list)
        eliminate_duplicates(list);
 }
 
+
+QString internalPath(const QString & str)
+{
+       return toqstr(os::internal_path(fromqstr(str)));
+}
+
+
+QString onlyFilename(const QString & str)
+{
+       return toqstr(support::onlyFilename(fromqstr(str)));
+}
+
+
+QString onlyPath(const QString & str)
+{
+       return toqstr(support::onlyPath(fromqstr(str)));
+}
+
 } // namespace lyx
index c2437deb10b213103c1f34ca24a132cadb60c31b..216e876fa26d1db253b2dc9a48c6ed85f7195132 100644 (file)
@@ -78,22 +78,6 @@ typedef std::pair<docstring, std::string> LanguagePair;
 */
 std::vector<LanguagePair> const getLanguageData(bool character_dlg);
 
-/** Launch a file dialog and return the chosen file.
-       filename: a suggested filename.
-       title: the title of the dialog.
-       pattern: *.ps etc.
-       dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
-*/
-docstring browseFile(docstring const & filename,
-       docstring const & title,
-       support::FileFilterList const & filters,
-       bool save = false,
-       docstring const & label1 = docstring(),
-       docstring const & dir1 = docstring(),
-       docstring const & label2 = docstring(),
-       docstring const & dir2 = docstring());
-
-
 /** Wrapper around browseFile which tries to provide a filename
        relative to relpath.  If the relative path is of the form "foo.txt"
        or "bar/foo.txt", then it is returned as relative. OTOH, if it is
@@ -111,31 +95,6 @@ docstring browseRelFile(docstring const & filename,
        docstring const & dir2 = docstring());
 
 
-/** Wrapper around browseFile which tries to provide a filename
-*  relative to the user or system directory. The dir, name and ext
-*  parameters have the same meaning as in the
-*  support::LibFileSearch function.
-*/
-docstring browseLibFile(docstring const & dir,
-       docstring const & name,
-       docstring const & ext,
-       docstring const & title,
-       support::FileFilterList const & filters);
-
-
-/** Launch a file dialog and return the chosen directory.
-       pathname: a suggested pathname.
-       title: the title of the dialog.
-       dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
-*/
-docstring browseDir(docstring const & pathname,
-       docstring const & title,
-       docstring const & label1 = docstring(),
-       docstring const & dir1 = docstring(),
-       docstring const & label2 = docstring(),
-       docstring const & dir2 = docstring());
-
-
 /** Build filelists of all availabe bst/cls/sty-files. Done through
 *  kpsewhich and an external script, saved in *Files.lst.
 */
@@ -146,6 +105,11 @@ void rescanTexStyles();
  */
 void getTexFileList(std::string const & filename, std::vector<std::string> & contents);
 
+// wrapper around the docstring versions
+QString internalPath(const QString &);
+QString onlyFilename(const QString & str);
+QString onlyPath(const QString & str);
+
 } // namespace lyx
 
 #endif // QTHELPERS_H