mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +00:00
qt3 compiles again
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15299 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
28ad960255
commit
e1d0ce0a6e
@ -41,6 +41,7 @@ using lyx::support::makeAbsPath;
|
||||
#endif
|
||||
|
||||
using lyx::support::FileFilterList;
|
||||
using lyx::docstring;
|
||||
|
||||
using std::endl;
|
||||
using std::string;
|
||||
@ -53,7 +54,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
FileDialog::FileDialog(string const & t,
|
||||
FileDialog::FileDialog(docstring const & t,
|
||||
kb_action s, Button b1, Button b2)
|
||||
: private_(new FileDialog::Private), title_(t), success_(s)
|
||||
{
|
||||
@ -68,23 +69,23 @@ FileDialog::~FileDialog()
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::save(string const & path,
|
||||
FileDialog::Result const FileDialog::save(docstring const & path,
|
||||
FileFilterList const & filters,
|
||||
string const & suggested)
|
||||
docstring const & suggested)
|
||||
{
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << path
|
||||
<< "\", mask \"" << filters.as_string()
|
||||
<< "\", suggested \"" << suggested << '"' << endl;
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << lyx::to_utf8(path)
|
||||
<< "\", mask \"" << lyx::to_utf8(filters.as_string())
|
||||
<< "\", suggested \"" << lyx::to_utf8(suggested) << '"' << endl;
|
||||
FileDialog::Result result;
|
||||
result.first = FileDialog::Chosen;
|
||||
|
||||
#ifdef USE_NATIVE_FILEDIALOG
|
||||
string const startsWith = makeAbsPath(suggested, path);
|
||||
string const startsWith = makeAbsPath(lyx::to_utf8(suggested), lyx::to_utf8(path));
|
||||
result.second = fromqstr(
|
||||
QFileDialog::getSaveFileName(toqstr(startsWith),
|
||||
toqstr(filters.as_string()),
|
||||
qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget(),
|
||||
title_.c_str()));
|
||||
lyx::to_utf8(title_).c_str()));
|
||||
#else
|
||||
LyXFileDialog dlg(path, filters, title_, private_->b1, private_->b2);
|
||||
dlg.setMode(QFileDialog::AnyFile);
|
||||
@ -96,30 +97,30 @@ FileDialog::Result const FileDialog::save(string const & path,
|
||||
int res = dlg.exec();
|
||||
lyxerr[Debug::GUI] << "result " << res << endl;
|
||||
if (res == QDialog::Accepted)
|
||||
result.second = fromqstr(dlg.selectedFile());
|
||||
result.second = qstring_to_ucs4(dlg.selectedFile());
|
||||
dlg.hide();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::open(string const & path,
|
||||
FileDialog::Result const FileDialog::open(docstring const & path,
|
||||
FileFilterList const & filters,
|
||||
string const & suggested)
|
||||
docstring const & suggested)
|
||||
{
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << path
|
||||
<< "\", mask \"" << filters.as_string()
|
||||
<< "\", suggested \"" << suggested << '"' << endl;
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << lyx::to_utf8(path)
|
||||
<< "\", mask \"" << lyx::to_utf8(filters.as_string())
|
||||
<< "\", suggested \"" << lyx::to_utf8(suggested) << '"' << endl;
|
||||
FileDialog::Result result;
|
||||
result.first = FileDialog::Chosen;
|
||||
|
||||
#ifdef USE_NATIVE_FILEDIALOG
|
||||
string const startsWith = makeAbsPath(suggested, path);
|
||||
string const startsWith = makeAbsPath(lyx::to_utf8(suggested), lyx::to_utf8(path));
|
||||
result.second = fromqstr(
|
||||
QFileDialog::getOpenFileName(toqstr(startsWith),
|
||||
toqstr(filters.as_string()),
|
||||
qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget(),
|
||||
title_.c_str()));
|
||||
lyx::to_utf8(title_).c_str()));
|
||||
#else
|
||||
LyXFileDialog dlg(path, filters, title_, private_->b1, private_->b2);
|
||||
|
||||
@ -130,29 +131,29 @@ FileDialog::Result const FileDialog::open(string const & path,
|
||||
int res = dlg.exec();
|
||||
lyxerr[Debug::GUI] << "result " << res << endl;
|
||||
if (res == QDialog::Accepted)
|
||||
result.second = fromqstr(dlg.selectedFile());
|
||||
result.second = qstring_to_ucs4(dlg.selectedFile());
|
||||
dlg.hide();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::opendir(string const & path,
|
||||
string const & suggested)
|
||||
FileDialog::Result const FileDialog::opendir(docstring const & path,
|
||||
docstring const & suggested)
|
||||
{
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << path
|
||||
<< "\", suggested \"" << suggested << '"' << endl;
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << lyx::to_utf8(path)
|
||||
<< "\", suggested \"" << lyx::to_utf8(suggested) << '"' << endl;
|
||||
FileDialog::Result result;
|
||||
result.first = FileDialog::Chosen;
|
||||
|
||||
#ifdef USE_NATIVE_FILEDIALOG
|
||||
string const startsWith = makeAbsPath(suggested, path);
|
||||
string const startsWith = makeAbsPath(lyx::to_utf8(suggested), lyx::to_utf8(path));
|
||||
result.second = fromqstr(
|
||||
QFileDialog::getExistingDirectory(toqstr(startsWith),
|
||||
qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget(),
|
||||
title_.c_str()));
|
||||
lyx::to_utf8(title_).c_str()));
|
||||
#else
|
||||
FileFilterList const filter(lyx::to_utf8(_("Directories")));
|
||||
FileFilterList const filter(_("Directories"));
|
||||
|
||||
LyXFileDialog dlg(path, filter, title_, private_->b1, private_->b2);
|
||||
|
||||
@ -165,7 +166,7 @@ FileDialog::Result const FileDialog::opendir(string const & path,
|
||||
int res = dlg.exec();
|
||||
lyxerr[Debug::GUI] << "result " << res << endl;
|
||||
if (res == QDialog::Accepted)
|
||||
result.second = fromqstr(dlg.selectedFile());
|
||||
result.second = qstring_to_ucs4(dlg.selectedFile());
|
||||
dlg.hide();
|
||||
#endif
|
||||
return result;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <qtoolbutton.h>
|
||||
|
||||
using lyx::support::split;
|
||||
using lyx::docstring;
|
||||
|
||||
using std::string;
|
||||
|
||||
@ -27,13 +28,13 @@ using std::string;
|
||||
namespace {
|
||||
|
||||
/// return the Qt form of the label
|
||||
string const getLabel(string const & str) {
|
||||
string label;
|
||||
string sc(split(str, label, '|'));
|
||||
docstring const getLabel(docstring const & str) {
|
||||
docstring label;
|
||||
docstring sc(split(str, label, '|'));
|
||||
if (sc.length() < 2)
|
||||
return label;
|
||||
string::size_type pos = label.find(sc[1]);
|
||||
if (pos == string::npos)
|
||||
docstring::size_type pos = label.find(sc[1]);
|
||||
if (pos == docstring::npos)
|
||||
return label;
|
||||
label.insert(pos, 1, '&');
|
||||
return label;
|
||||
@ -42,9 +43,9 @@ string const getLabel(string const & str) {
|
||||
} // namespace anon
|
||||
|
||||
|
||||
LyXFileDialog::LyXFileDialog(string const & p,
|
||||
LyXFileDialog::LyXFileDialog(docstring const & p,
|
||||
lyx::support::FileFilterList const & filters,
|
||||
string const & t,
|
||||
docstring const & t,
|
||||
FileDialog::Button const & b1,
|
||||
FileDialog::Button const & b2)
|
||||
: QFileDialog(toqstr(p), toqstr(filters.as_string()),
|
||||
|
@ -31,19 +31,19 @@ class LyXFileDialog : public QFileDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LyXFileDialog(std::string const & path,
|
||||
LyXFileDialog(lyx::docstring const & path,
|
||||
lyx::support::FileFilterList const & filters,
|
||||
std::string const & title,
|
||||
lyx::docstring const & title,
|
||||
FileDialog::Button const & b1,
|
||||
FileDialog::Button const & b2);
|
||||
public slots:
|
||||
void buttonClicked();
|
||||
private:
|
||||
QToolButton * b1_;
|
||||
std::string b1_dir_;
|
||||
lyx::docstring b1_dir_;
|
||||
|
||||
QToolButton * b2_;
|
||||
std::string b2_dir_;
|
||||
lyx::docstring b2_dir_;
|
||||
};
|
||||
|
||||
#endif // FILEDIALOG_PRIVATE_H
|
||||
|
@ -96,7 +96,7 @@ void QBibtexDialog::change_adaptor()
|
||||
|
||||
void QBibtexDialog::browsePressed()
|
||||
{
|
||||
string const file = form_->controller().browseBst("");
|
||||
string const file = lyx::to_utf8(form_->controller().browseBst(lyx::from_ascii("")));
|
||||
|
||||
if (!file.empty()) {
|
||||
string const filen = changeExtension(file, "");
|
||||
@ -121,7 +121,7 @@ void QBibtexDialog::browsePressed()
|
||||
|
||||
void QBibtexDialog::browseBibPressed()
|
||||
{
|
||||
string const file = trim(form_->controller().browseBib(""));
|
||||
string const file = trim(lyx::to_utf8(form_->controller().browseBib(lyx::from_ascii(""))));
|
||||
|
||||
if (!file.empty()) {
|
||||
string const f = changeExtension(file, "");
|
||||
|
@ -121,9 +121,9 @@ void QExternalDialog::browseClicked()
|
||||
int const choice = externalCO->currentItem();
|
||||
string const template_name =
|
||||
form_->controller().getTemplate(choice).lyxName;
|
||||
string const str =
|
||||
form_->controller().browse(fromqstr(fileED->text()),
|
||||
template_name);
|
||||
docstring const str =
|
||||
form_->controller().browse(qstring_to_ucs4(fileED->text()),
|
||||
lyx::from_utf8(template_name));
|
||||
fileED->setText(toqstr(str));
|
||||
form_->changed();
|
||||
}
|
||||
|
@ -103,8 +103,8 @@ void QGraphicsDialog::closeEvent(QCloseEvent * e)
|
||||
|
||||
void QGraphicsDialog::browse_clicked()
|
||||
{
|
||||
string const str =
|
||||
form_->controller().browse(fromqstr(filename->text()));
|
||||
docstring const str =
|
||||
form_->controller().browse(qstring_to_ucs4(filename->text()));
|
||||
filename->setText(toqstr(str));
|
||||
form_->changed();
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ void QInclude::browse()
|
||||
else
|
||||
type = ControlInclude::VERBATIM;
|
||||
|
||||
string const & name = controller().browse(fromqstr(dialog_->filenameED->text()), type);
|
||||
docstring const & name = controller().browse(qstring_to_ucs4(dialog_->filenameED->text()), type);
|
||||
if (!name.empty())
|
||||
dialog_->filenameED->setText(toqstr(name));
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ void QLPrintDialog::change_adaptor()
|
||||
|
||||
void QLPrintDialog::browseClicked()
|
||||
{
|
||||
QString file = toqstr(form_->controller().browse(""));
|
||||
QString file = toqstr(form_->controller().browse(lyx::from_ascii("")));
|
||||
if (!file.isNull()) {
|
||||
fileED->setText(file);
|
||||
form_->changed();
|
||||
|
@ -908,7 +908,7 @@ void QPrefsDialog::change_color()
|
||||
|
||||
void QPrefsDialog::select_ui()
|
||||
{
|
||||
string file(form_->controller().browseUI(fromqstr(uiModule->uiFileED->text())));
|
||||
docstring file(form_->controller().browseUI(qstring_to_ucs4(uiModule->uiFileED->text())));
|
||||
if (!file.empty())
|
||||
uiModule->uiFileED->setText(toqstr(file));
|
||||
}
|
||||
@ -916,7 +916,7 @@ void QPrefsDialog::select_ui()
|
||||
|
||||
void QPrefsDialog::select_bind()
|
||||
{
|
||||
string file(form_->controller().browsebind(fromqstr(uiModule->bindFileED->text())));
|
||||
docstring file(form_->controller().browsebind(qstring_to_ucs4(uiModule->bindFileED->text())));
|
||||
if (!file.empty())
|
||||
uiModule->bindFileED->setText(toqstr(file));
|
||||
}
|
||||
@ -924,7 +924,7 @@ void QPrefsDialog::select_bind()
|
||||
|
||||
void QPrefsDialog::select_keymap1()
|
||||
{
|
||||
string file(form_->controller().browsekbmap(fromqstr(keyboardModule->firstKeymapED->text())));
|
||||
docstring file(form_->controller().browsekbmap(qstring_to_ucs4(keyboardModule->firstKeymapED->text())));
|
||||
if (!file.empty())
|
||||
keyboardModule->firstKeymapED->setText(toqstr(file));
|
||||
}
|
||||
@ -932,7 +932,7 @@ void QPrefsDialog::select_keymap1()
|
||||
|
||||
void QPrefsDialog::select_keymap2()
|
||||
{
|
||||
string file(form_->controller().browsekbmap(fromqstr(keyboardModule->secondKeymapED->text())));
|
||||
docstring file(form_->controller().browsekbmap(qstring_to_ucs4(keyboardModule->secondKeymapED->text())));
|
||||
if (!file.empty())
|
||||
keyboardModule->secondKeymapED->setText(toqstr(file));
|
||||
}
|
||||
@ -940,7 +940,7 @@ void QPrefsDialog::select_keymap2()
|
||||
|
||||
void QPrefsDialog::select_dict()
|
||||
{
|
||||
string file(form_->controller().browsedict(fromqstr(spellcheckerModule->persDictionaryED->text())));
|
||||
docstring file(form_->controller().browsedict(qstring_to_ucs4(spellcheckerModule->persDictionaryED->text())));
|
||||
if (!file.empty())
|
||||
spellcheckerModule->persDictionaryED->setText(toqstr(file));
|
||||
}
|
||||
@ -950,7 +950,7 @@ void QPrefsDialog::select_dict()
|
||||
|
||||
void QPrefsDialog::select_templatedir()
|
||||
{
|
||||
string file(form_->controller().browsedir(fromqstr(pathsModule->templateDirED->text()), lyx::to_utf8(_("Select a document templates directory"))));
|
||||
docstring file(form_->controller().browsedir(qstring_to_ucs4(pathsModule->templateDirED->text()), _("Select a document templates directory")));
|
||||
if (!file.empty())
|
||||
pathsModule->templateDirED->setText(toqstr(file));
|
||||
}
|
||||
@ -958,7 +958,7 @@ void QPrefsDialog::select_templatedir()
|
||||
|
||||
void QPrefsDialog::select_tempdir()
|
||||
{
|
||||
string file(form_->controller().browsedir(fromqstr(pathsModule->tempDirED->text()), lyx::to_utf8(_("Select a temporary directory"))));
|
||||
docstring file(form_->controller().browsedir(qstring_to_ucs4(pathsModule->tempDirED->text()), _("Select a temporary directory")));
|
||||
if (!file.empty())
|
||||
pathsModule->tempDirED->setText(toqstr(file));
|
||||
}
|
||||
@ -966,7 +966,7 @@ void QPrefsDialog::select_tempdir()
|
||||
|
||||
void QPrefsDialog::select_backupdir()
|
||||
{
|
||||
string file(form_->controller().browsedir(fromqstr(pathsModule->backupDirED->text()), lyx::to_utf8(_("Select a backups directory"))));
|
||||
docstring file(form_->controller().browsedir(qstring_to_ucs4(pathsModule->backupDirED->text()), _("Select a backups directory")));
|
||||
if (!file.empty())
|
||||
pathsModule->backupDirED->setText(toqstr(file));
|
||||
}
|
||||
@ -974,7 +974,7 @@ void QPrefsDialog::select_backupdir()
|
||||
|
||||
void QPrefsDialog::select_workingdir()
|
||||
{
|
||||
string file(form_->controller().browsedir(fromqstr(pathsModule->workingDirED->text()), lyx::to_utf8(_("Select a document directory"))));
|
||||
docstring file(form_->controller().browsedir(qstring_to_ucs4(pathsModule->workingDirED->text()), _("Select a document directory")));
|
||||
if (!file.empty())
|
||||
pathsModule->workingDirED->setText(toqstr(file));
|
||||
}
|
||||
@ -982,7 +982,7 @@ void QPrefsDialog::select_workingdir()
|
||||
|
||||
void QPrefsDialog::select_lyxpipe()
|
||||
{
|
||||
string file(form_->controller().browse(fromqstr(pathsModule->lyxserverDirED->text()), lyx::to_utf8(_("Give a filename for the LyX server pipe"))));
|
||||
docstring file(form_->controller().browse(qstring_to_ucs4(pathsModule->lyxserverDirED->text()), _("Give a filename for the LyX server pipe")));
|
||||
if (!file.empty())
|
||||
pathsModule->lyxserverDirED->setText(toqstr(file));
|
||||
}
|
||||
|
@ -542,13 +542,14 @@ string const ltrim(string const & a, char const * p)
|
||||
}
|
||||
|
||||
|
||||
string const split(string const & a, string & piece, char delim)
|
||||
template<typename String, typename Char> inline
|
||||
String const doSplit(String const & a, String & piece, Char delim)
|
||||
{
|
||||
string tmp;
|
||||
string::size_type i = a.find(delim);
|
||||
String tmp;
|
||||
typename String::size_type i = a.find(delim);
|
||||
if (i == a.length() - 1) {
|
||||
piece = a.substr(0, i);
|
||||
} else if (i != string::npos) {
|
||||
} else if (i != String::npos) {
|
||||
piece = a.substr(0, i);
|
||||
tmp = a.substr(i + 1);
|
||||
} else if (i == 0) {
|
||||
@ -561,6 +562,18 @@ string const split(string const & a, string & piece, char delim)
|
||||
}
|
||||
|
||||
|
||||
string const split(string const & a, string & piece, char delim)
|
||||
{
|
||||
return doSplit(a, piece, delim);
|
||||
}
|
||||
|
||||
|
||||
docstring const split(docstring const & a, docstring & piece, char_type delim)
|
||||
{
|
||||
return doSplit(a, piece, delim);
|
||||
}
|
||||
|
||||
|
||||
string const split(string const & a, char delim)
|
||||
{
|
||||
string tmp;
|
||||
|
@ -189,6 +189,7 @@ std::string const ltrim(std::string const & a, char const * p = " ");
|
||||
\endcode
|
||||
*/
|
||||
std::string const split(std::string const & a, std::string & piece, char delim);
|
||||
docstring const split(docstring const & a, docstring & piece, char_type delim);
|
||||
|
||||
/// Same as split but does not return a piece
|
||||
std::string const split(std::string const & a, char delim);
|
||||
|
Loading…
Reference in New Issue
Block a user