cosmetics

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24331 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-04-18 19:17:11 +00:00
parent d307a338da
commit 05f321db17
3 changed files with 25 additions and 30 deletions

View File

@ -197,10 +197,10 @@ GuiExternal::GuiExternal(GuiView & lv)
bc().addCheckedLineEdit(ytED, rtLA); bc().addCheckedLineEdit(ytED, rtLA);
bc().addCheckedLineEdit(fileED, fileLA); bc().addCheckedLineEdit(fileED, fileLA);
vector<string> templates = getTemplates(); vector<string> t = templates();
for (vector<string>::const_iterator cit = templates.begin(); for (vector<string>::const_iterator cit = t.begin();
cit != templates.end(); ++cit) { cit != t.end(); ++cit) {
externalCO->addItem(qt_(*cit)); externalCO->addItem(qt_(*cit));
} }
@ -274,18 +274,16 @@ void GuiExternal::editClicked()
} }
void GuiExternal::extraChanged(const QString & text)
void GuiExternal::extraChanged(const QString& text)
{ {
string const format = fromqstr(extraFormatCO->currentText()); extra_[extraFormatCO->currentText()] = text;
extra_[format] = text;
changed(); changed();
} }
void GuiExternal::formatChanged(const QString& format) void GuiExternal::formatChanged(const QString & format)
{ {
extraED->setText(extra_[fromqstr(format)]); extraED->setText(extra_[format]);
} }
@ -537,7 +535,7 @@ static void getExtra(external::ExtraData & data,
MapType::const_iterator it = extra.begin(); MapType::const_iterator it = extra.begin();
MapType::const_iterator const end = extra.end(); MapType::const_iterator const end = extra.end();
for (; it != end; ++it) for (; it != end; ++it)
data.set(it->first, trim(fromqstr(it->second))); data.set(fromqstr(it.key()), fromqstr(it.value().trimmed()));
} }
@ -549,7 +547,7 @@ void GuiExternal::updateContents()
params_.filename.outputFilename(fromqstr(bufferFilepath())); params_.filename.outputFilename(fromqstr(bufferFilepath()));
fileED->setText(toqstr(name)); fileED->setText(toqstr(name));
externalCO->setCurrentIndex(getTemplateNumber(params_.templatename())); externalCO->setCurrentIndex(templateNumber(params_.templatename()));
updateTemplate(); updateTemplate();
draftCB->setChecked(params_.draft); draftCB->setChecked(params_.draft);
@ -610,19 +608,18 @@ void GuiExternal::updateTemplate()
string const format = it->first; string const format = it->first;
string const opt = params_.extradata.get(format); string const opt = params_.extradata.get(format);
extraFormatCO->addItem(toqstr(format)); extraFormatCO->addItem(toqstr(format));
extra_[format] = toqstr(opt); extra_[toqstr(format)] = toqstr(opt);
} }
bool const enabled = extraFormatCO->count() > 0; bool const enabled = extraFormatCO->count() > 0;
tab->setTabEnabled( tab->setTabEnabled(tab->indexOf(optionstab), enabled);
tab->indexOf(optionstab), enabled);
extraED->setEnabled(enabled && !isBufferReadonly()); extraED->setEnabled(enabled && !isBufferReadonly());
extraFormatCO->setEnabled(enabled); extraFormatCO->setEnabled(enabled);
if (enabled) { if (enabled) {
extraFormatCO->setCurrentIndex(0); extraFormatCO->setCurrentIndex(0);
extraED->setText(extra_[fromqstr(extraFormatCO->currentText())]); extraED->setText(extra_[extraFormatCO->currentText()]);
} }
} }
@ -706,7 +703,7 @@ void GuiExternal::editExternal()
} }
vector<string> const GuiExternal::getTemplates() const vector<string> GuiExternal::templates() const
{ {
vector<string> result; vector<string> result;
@ -714,14 +711,14 @@ vector<string> const GuiExternal::getTemplates() const
i1 = external::TemplateManager::get().getTemplates().begin(); i1 = external::TemplateManager::get().getTemplates().begin();
i2 = external::TemplateManager::get().getTemplates().end(); i2 = external::TemplateManager::get().getTemplates().end();
for (; i1 != i2; ++i1) { for (; i1 != i2; ++i1)
result.push_back(i1->second.lyxName); result.push_back(i1->second.lyxName);
}
return result; return result;
} }
int GuiExternal::getTemplateNumber(string const & name) const int GuiExternal::templateNumber(string const & name) const
{ {
external::TemplateManager::Templates::const_iterator i1, i2; external::TemplateManager::Templates::const_iterator i1, i2;
i1 = external::TemplateManager::get().getTemplates().begin(); i1 = external::TemplateManager::get().getTemplates().begin();
@ -748,8 +745,7 @@ external::Template GuiExternal::getTemplate(int i) const
} }
string const string GuiExternal::templateFilters(string const & template_name) const
GuiExternal::getTemplateFilters(string const & template_name) const
{ {
/// Determine the template file extension /// Determine the template file extension
external::TemplateManager const & etm = external::TemplateManager const & etm =
@ -770,7 +766,7 @@ QString GuiExternal::browse(QString const & input,
QString const title = qt_("Select external file"); QString const title = qt_("Select external file");
QString const bufpath = bufferFilepath(); QString const bufpath = bufferFilepath();
FileFilterList const filter = FileFilterList const filter =
FileFilterList(from_utf8(getTemplateFilters(fromqstr(template_name)))); FileFilterList(from_utf8(templateFilters(fromqstr(template_name))));
QString const label1 = qt_("Documents|#o#O"); QString const label1 = qt_("Documents|#o#O");
QString const dir1 = toqstr(lyxrc.document_path); QString const dir1 = toqstr(lyxrc.document_path);

View File

@ -21,9 +21,10 @@
#include "insets/InsetExternal.h" #include "insets/InsetExternal.h"
#include <QHash>
#include <string> #include <string>
#include <vector> #include <vector>
#include <map>
namespace lyx { namespace lyx {
@ -57,7 +58,7 @@ private Q_SLOTS:
public: public:
/// ///
typedef std::map<std::string, QString> MapType; typedef QHash<QString, QString> MapType;
private: private:
/// ///
@ -85,14 +86,13 @@ private:
/// ///
void editExternal(); void editExternal();
/// ///
std::vector<std::string> const getTemplates() const; std::vector<std::string> templates() const;
/// ///
int getTemplateNumber(std::string const &) const; int templateNumber(std::string const &) const;
/// ///
external::Template getTemplate(int) const; external::Template getTemplate(int) const;
/// ///
std::string const std::string templateFilters(std::string const & template_name) const;
getTemplateFilters(std::string const & template_name) const;
/// ///
QString browse(QString const & input_file, QString browse(QString const & input_file,
QString const & template_name) const; QString const & template_name) const;

View File

@ -150,7 +150,6 @@ vector<RotationOriginPair> getRotationOriginData()
GuiGraphics::GuiGraphics(GuiView & lv) GuiGraphics::GuiGraphics(GuiView & lv)
: GuiDialog(lv, "graphics", qt_("Graphics")) : GuiDialog(lv, "graphics", qt_("Graphics"))
{ {
@ -753,7 +752,7 @@ QString GuiGraphics::browse(QString const & in_name) const
FileName clip(clipdir); FileName clip(clipdir);
// bail out to system clipart directory // bail out to system clipart directory
if (!(clip.exists() && clip.isDirectory())) if (!clip.isDirectory())
clipdir = addName(package().system_support().absFilename(), "clipart"); clipdir = addName(package().system_support().absFilename(), "clipart");
return browseRelFile(in_name, bufferFilepath(), return browseRelFile(in_name, bufferFilepath(),