Fix loading non-lyx child documents with relative path names, change Load to Edit in the child document dialog. (Bug 4107 and 4111)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19345 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bo Peng 2007-08-07 18:37:33 +00:00
parent 8908823bc5
commit b08540d0d8
6 changed files with 23 additions and 16 deletions

View File

@ -100,14 +100,16 @@ docstring const ControlInclude::browse(docstring const & in_name, Type in_type)
} }
void ControlInclude::load(string const & file) void ControlInclude::edit(string const & file)
{ {
string const ext = support::getExtension(file); string const ext = support::getExtension(file);
if (ext == "lyx") if (ext == "lyx")
kernel().dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN, file)); kernel().dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN, file));
else else
// tex file or other text file in verbatim mode // tex file or other text file in verbatim mode
formats.edit(kernel().buffer(), FileName(file), "text"); formats.edit(kernel().buffer(),
FileName(makeAbsPath(file, onlyPath(kernel().buffer().fileName()))),
"text");
} }

View File

@ -58,8 +58,9 @@ public:
/// Browse for a file /// Browse for a file
docstring const browse(docstring const &, Type) const; docstring const browse(docstring const &, Type) const;
/// load a file /// edit the child document, .lyx file will be opened in lyx
void load(std::string const & file); /// other formats will be edited by external applications.
void edit(std::string const & file);
/// test if file exist /// test if file exist
bool fileExists(std::string const & file); bool fileExists(std::string const & file);

View File

@ -56,7 +56,7 @@ QIncludeDialog::QIncludeDialog(QInclude * form)
connect(visiblespaceCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); connect(visiblespaceCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(filenameED, SIGNAL(textChanged(const QString &)), connect(filenameED, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(loadPB, SIGNAL(clicked()), this, SLOT(loadClicked())); connect(editPB, SIGNAL(clicked()), this, SLOT(editClicked()));
connect(browsePB, SIGNAL(clicked()), this, SLOT(browseClicked())); connect(browsePB, SIGNAL(clicked()), this, SLOT(browseClicked()));
connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(typeCO, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); connect(typeCO, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
@ -168,9 +168,9 @@ void QIncludeDialog::typeChanged(int v)
} }
void QIncludeDialog::loadClicked() void QIncludeDialog::editClicked()
{ {
form_->load(); form_->edit();
} }
@ -336,12 +336,12 @@ void QInclude::browse()
} }
void QInclude::load() void QInclude::edit()
{ {
if (isValid()) { if (isValid()) {
string const file = fromqstr(dialog_->filenameED->text()); string const file = fromqstr(dialog_->filenameED->text());
slotOK(); slotOK();
controller().load(file); controller().edit(file);
} }
} }

View File

@ -35,7 +35,7 @@ public:
docstring validate_listings_params(); docstring validate_listings_params();
protected Q_SLOTS: protected Q_SLOTS:
virtual void change_adaptor(); virtual void change_adaptor();
virtual void loadClicked(); virtual void editClicked();
virtual void browseClicked(); virtual void browseClicked();
virtual void typeChanged(int v); virtual void typeChanged(int v);
/// AFAIK, QValidator only works for QLineEdit so /// AFAIK, QValidator only works for QLineEdit so
@ -70,8 +70,9 @@ private:
/// build the dialog /// build the dialog
virtual void build_dialog(); virtual void build_dialog();
/// load the file /// edit the child document, .lyx file will be opened in lyx
void load(); /// other formats will be edited by external applications.
void edit();
/// browse for a file /// browse for a file
void browse(); void browse();

View File

@ -331,12 +331,12 @@
</widget> </widget>
</item> </item>
<item row="1" column="4" > <item row="1" column="4" >
<widget class="QPushButton" name="loadPB" > <widget class="QPushButton" name="editPB" >
<property name="toolTip" > <property name="toolTip" >
<string>Load the file</string> <string>Edit the file</string>
</property> </property>
<property name="text" > <property name="text" >
<string>&amp;Load</string> <string>&amp;Edit</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -346,7 +346,7 @@
<tabstop>filenameED</tabstop> <tabstop>filenameED</tabstop>
<tabstop>browsePB</tabstop> <tabstop>browsePB</tabstop>
<tabstop>typeCO</tabstop> <tabstop>typeCO</tabstop>
<tabstop>loadPB</tabstop> <tabstop>editPB</tabstop>
<tabstop>visiblespaceCB</tabstop> <tabstop>visiblespaceCB</tabstop>
<tabstop>previewCB</tabstop> <tabstop>previewCB</tabstop>
<tabstop>captionLE</tabstop> <tabstop>captionLE</tabstop>

View File

@ -38,6 +38,9 @@ What's new
* USER INTERFACE: * USER INTERFACE:
- Fix loading non-lyx child documents with relative path names, change
'Load' to 'Edit' in the child document dialog. (Bug 4107 and 4111)
* DOCUMENTATION * DOCUMENTATION