mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Embedding: fix a file selection and a file copy bug
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19986 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
452348f4ce
commit
f8422ebb00
@ -64,6 +64,7 @@ using support::bformat;
|
||||
using support::zipFiles;
|
||||
using support::prefixIs;
|
||||
using support::sum;
|
||||
using support::makedir;
|
||||
|
||||
|
||||
EmbeddedFile::EmbeddedFile(string const & file, string const & inzip_name,
|
||||
@ -134,6 +135,10 @@ bool EmbeddedFile::extract(Buffer const * buf) const
|
||||
// copy file in the previous case, and a new case
|
||||
if (copyFile || (!fs::exists(ext_file) && fs::exists(emb_file))) {
|
||||
try {
|
||||
// need to make directory?
|
||||
string path = onlyPath(ext_file);
|
||||
if (!fs::is_directory(path))
|
||||
makedir(const_cast<char*>(path.c_str()), 0755);
|
||||
fs::copy_file(emb_file, ext_file, false);
|
||||
return true;
|
||||
} catch (fs::filesystem_error const & fe) {
|
||||
|
@ -64,19 +64,28 @@ void GuiEmbeddedFilesDialog::on_filesLW_itemSelectionChanged()
|
||||
EmbeddedFiles & files = form_->embeddedFiles();
|
||||
|
||||
QList<QListWidgetItem *> selection = filesLW->selectedItems();
|
||||
|
||||
fullpathLE->setEnabled(selection.size() == 1);
|
||||
|
||||
EmbeddedFile::STATUS mode = EmbeddedFile::NONE;
|
||||
|
||||
// try to find a common mode, otherwise return NONE.
|
||||
for (QList<QListWidgetItem*>::iterator it = selection.begin();
|
||||
it != selection.end(); ++it) {
|
||||
if (selection.size() == 1)
|
||||
fullpathLE->setText(toqstr(files[filesLW->row(*it)].absFilename()));
|
||||
QList<QListWidgetItem*>::iterator it = selection.begin();
|
||||
QList<QListWidgetItem*>::iterator it_end = selection.end();
|
||||
// if the selection is not empty
|
||||
if (it != it_end) {
|
||||
int idx = filesLW->row(*it);
|
||||
fullpathLE->setText(toqstr(files[idx].absFilename()));
|
||||
// go to the first selected item
|
||||
form_->goTo(files[idx]);
|
||||
}
|
||||
|
||||
EmbeddedFile::STATUS mode = EmbeddedFile::NONE;
|
||||
for (; it != it_end; ++it) {
|
||||
int idx = filesLW->row(*it);
|
||||
if (mode == EmbeddedFile::NONE) {
|
||||
mode = files[filesLW->row(*it)].status();
|
||||
mode = files[idx].status();
|
||||
continue;
|
||||
}
|
||||
if (mode != files[filesLW->row(*it)].status()) {
|
||||
if (mode != files[idx].status()) {
|
||||
mode = EmbeddedFile::NONE;
|
||||
break;
|
||||
}
|
||||
@ -85,8 +94,6 @@ void GuiEmbeddedFilesDialog::on_filesLW_itemSelectionChanged()
|
||||
autoRB->setChecked(mode == EmbeddedFile::AUTO);
|
||||
embeddedRB->setChecked(mode == EmbeddedFile::EMBEDDED);
|
||||
externalRB->setChecked(mode == EmbeddedFile::EXTERNAL);
|
||||
// go to the first selected item
|
||||
form_->goTo(files[filesLW->row(*selection.begin())]);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user