mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
GuiLyXFiles: A bit more work towards generalization
Bind and Ui files can be displayed in this dialog now (via lfun dialog-show lyxfiles ui|bind), although it is not yet usable in prefs.
This commit is contained in:
parent
a410b0d698
commit
52d2ba16ed
@ -183,9 +183,6 @@ GuiLyXFiles::GuiLyXFiles(GuiView & lv)
|
||||
//filesLW->setViewMode(QListView::ListMode);
|
||||
filesLW->setIconSize(QSize(22, 22));
|
||||
|
||||
fileTypeCO->addItem(qt_("Templates"), toqstr("templates"));
|
||||
fileTypeCO->addItem(qt_("Examples"), toqstr("examples"));
|
||||
|
||||
setFocusProxy(filter_);
|
||||
}
|
||||
|
||||
@ -199,6 +196,12 @@ QString const GuiLyXFiles::getSuffix()
|
||||
}
|
||||
|
||||
|
||||
bool GuiLyXFiles::translateName() const
|
||||
{
|
||||
return (type_ == "templates" || type_ == "examples");
|
||||
}
|
||||
|
||||
|
||||
void GuiLyXFiles::changed_adaptor()
|
||||
{
|
||||
changed();
|
||||
@ -277,9 +280,9 @@ void GuiLyXFiles::updateContents()
|
||||
catItem = filesLW->findItems(cat, Qt::MatchExactly).first();
|
||||
QTreeWidgetItem * item = new QTreeWidgetItem();
|
||||
QString const filename = info.fileName();
|
||||
QString const guiname =
|
||||
toqstr(translateIfPossible(
|
||||
qstring_to_ucs4(filename.left(filename.lastIndexOf(getSuffix())).replace('_', ' '))));
|
||||
QString guiname = filename.left(filename.lastIndexOf(getSuffix())).replace('_', ' ');
|
||||
if (translateName())
|
||||
guiname = toqstr(translateIfPossible(qstring_to_ucs4(guiname)));
|
||||
item->setIcon(0, iconprovider.icon(info));
|
||||
item->setData(0, Qt::UserRole, info.filePath());
|
||||
item->setData(0, Qt::DisplayRole, guiname);
|
||||
@ -365,23 +368,33 @@ bool GuiLyXFiles::isValid()
|
||||
bool GuiLyXFiles::initialiseParams(string const & type)
|
||||
{
|
||||
type_ = type.empty() ? toqstr("templates") : toqstr(type);
|
||||
paramsToDialog(type_);
|
||||
paramsToDialog();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void GuiLyXFiles::paramsToDialog(QString const & command)
|
||||
void GuiLyXFiles::paramsToDialog()
|
||||
{
|
||||
if (!command.isEmpty()) {
|
||||
int i = fileTypeCO->findData(command);
|
||||
fileTypeCO->clear();
|
||||
if (type_ == "examples" || type_ == "templates") {
|
||||
fileTypeCO->addItem(qt_("Templates"), toqstr("templates"));
|
||||
fileTypeCO->addItem(qt_("Examples"), toqstr("examples"));
|
||||
} else if (type_ == "ui")
|
||||
fileTypeCO->addItem(qt_("User Interface Files"), toqstr("ui"));
|
||||
else if (type_ == "bind")
|
||||
fileTypeCO->addItem(qt_("Key Binding Files"), toqstr("bind"));
|
||||
|
||||
if (!type_.isEmpty()) {
|
||||
int i = fileTypeCO->findData(type_);
|
||||
if (i != -1)
|
||||
fileTypeCO->setCurrentIndex(i);
|
||||
}
|
||||
if (command == "examples")
|
||||
if (type_ == "examples")
|
||||
setTitle(qt_("Open Example File"));
|
||||
else {
|
||||
else if (type_ == "templates")
|
||||
setTitle(qt_("New File From Template"));
|
||||
}
|
||||
else
|
||||
setTitle(qt_("Open File"));
|
||||
|
||||
bc().setValid(isValid());
|
||||
}
|
||||
@ -406,7 +419,9 @@ FuncCode GuiLyXFiles::getLfun() const
|
||||
{
|
||||
if (type_ == "examples")
|
||||
return LFUN_FILE_OPEN;
|
||||
else if (type_ == "templates")
|
||||
return LFUN_BUFFER_NEW_TEMPLATE;
|
||||
return LFUN_NOACTION;
|
||||
}
|
||||
|
||||
Dialog * createGuiLyXFiles(GuiView & lv) { return new GuiLyXFiles(lv); }
|
||||
|
@ -51,7 +51,7 @@ private:
|
||||
///
|
||||
bool initialiseParams(std::string const & data);
|
||||
///
|
||||
void paramsToDialog(QString const & command);
|
||||
void paramsToDialog();
|
||||
///
|
||||
void clearParams() {}
|
||||
///
|
||||
@ -63,6 +63,8 @@ private:
|
||||
///
|
||||
QString const getSuffix();
|
||||
///
|
||||
bool translateName() const;
|
||||
///
|
||||
void getFiles(QMap<QString, QString> &, QString const);
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user