mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Embedding: for safety, update before changing embedding status
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20213 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e2d5893eab
commit
905324dd16
@ -81,14 +81,15 @@ void ControlEmbeddedFiles::view(EmbeddedFile const & item)
|
||||
}
|
||||
|
||||
|
||||
void ControlEmbeddedFiles::setEmbed(EmbeddedFile & item, bool embed)
|
||||
void ControlEmbeddedFiles::setEmbed(EmbeddedFile & item, bool embed, bool update)
|
||||
{
|
||||
// FIXME: updateFromExternalFile() or extract() may fail...
|
||||
if (embed)
|
||||
item.updateFromExternalFile(&buffer());
|
||||
else
|
||||
item.extract(&buffer());
|
||||
item.setEmbed(embed);
|
||||
if (update) {
|
||||
if (embed)
|
||||
item.updateFromExternalFile(&buffer());
|
||||
else
|
||||
item.extract(&buffer());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
///
|
||||
void view(EmbeddedFile const & item);
|
||||
///
|
||||
void setEmbed(EmbeddedFile & item, bool embed);
|
||||
void setEmbed(EmbeddedFile & item, bool embed, bool update);
|
||||
///
|
||||
docstring const browseFile();
|
||||
///
|
||||
|
@ -37,12 +37,16 @@ void GuiEmbeddedFilesDialog::on_filesLW_itemChanged(QListWidgetItem* item)
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
if (files[filesLW->row(item)].embedded())
|
||||
return;
|
||||
controller_.setEmbed(files[filesLW->row(item)], true);
|
||||
// this should not be needed after EmbeddedFiles are updated correctly.
|
||||
files.update();
|
||||
controller_.setEmbed(files[filesLW->row(item)], true, files.enabled());
|
||||
controller_.dispatchMessage("Embed file " + fromqstr(item->text()));
|
||||
} else {
|
||||
if (!files[filesLW->row(item)].embedded())
|
||||
return;
|
||||
controller_.setEmbed(files[filesLW->row(item)], false);
|
||||
// this should not be needed after EmbeddedFiles are updated correctly.
|
||||
files.update();
|
||||
controller_.setEmbed(files[filesLW->row(item)], false, files.enabled());
|
||||
controller_.dispatchMessage("Stop embedding file " + fromqstr(item->text()));
|
||||
}
|
||||
}
|
||||
@ -138,11 +142,13 @@ void GuiEmbeddedFilesDialog::updateView()
|
||||
void GuiEmbeddedFilesDialog::on_selectPB_clicked()
|
||||
{
|
||||
EmbeddedFiles & files = controller_.embeddedFiles();
|
||||
// this should not be needed after EmbeddedFiles are updated correctly.
|
||||
files.update();
|
||||
QList<QListWidgetItem *> selection = filesLW->selectedItems();
|
||||
for (QList<QListWidgetItem*>::iterator it = selection.begin();
|
||||
it != selection.end(); ++it) {
|
||||
(*it)->setCheckState(Qt::Checked);
|
||||
controller_.setEmbed(files[filesLW->row(*it)], true);
|
||||
controller_.setEmbed(files[filesLW->row(*it)], true, files.enabled());
|
||||
}
|
||||
controller_.dispatchMessage("Embedding files");
|
||||
}
|
||||
@ -151,11 +157,13 @@ void GuiEmbeddedFilesDialog::on_selectPB_clicked()
|
||||
void GuiEmbeddedFilesDialog::on_unselectPB_clicked()
|
||||
{
|
||||
EmbeddedFiles & files = controller_.embeddedFiles();
|
||||
// this should not be needed after EmbeddedFiles are updated correctly.
|
||||
files.update();
|
||||
QList<QListWidgetItem *> selection = filesLW->selectedItems();
|
||||
for (QList<QListWidgetItem*>::iterator it = selection.begin();
|
||||
it != selection.end(); ++it) {
|
||||
(*it)->setCheckState(Qt::Checked);
|
||||
controller_.setEmbed(files[filesLW->row(*it)], false);
|
||||
controller_.setEmbed(files[filesLW->row(*it)], false, files.enabled());
|
||||
}
|
||||
controller_.dispatchMessage("Stop embedding files");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user