mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Embedding: fix a few embedding bugs
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20017 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
15dc381ce9
commit
c247f0ffe0
@ -297,8 +297,9 @@ string const EmbeddedFiles::getInzipName(string const & abs_filename)
|
||||
from_utf8(buffer_->fileName())));
|
||||
// if inzip_name is an absolute path, use filename only to avoid
|
||||
// leaking of filesystem information in inzip_name
|
||||
if (absolutePath(inzip_name) || prefixIs(inzip_name, ".."))
|
||||
inzip_name = onlyFilename(inzip_name);
|
||||
// The second case covers cases '../path/file' and '.'
|
||||
if (absolutePath(inzip_name) || prefixIs(inzip_name, "."))
|
||||
inzip_name = onlyFilename(abs_filename);
|
||||
// if this name has been used...
|
||||
// use _1_name, _2_name etc
|
||||
string tmp = inzip_name;
|
||||
|
@ -35,10 +35,16 @@ using support::FileFilterList;
|
||||
namespace frontend {
|
||||
|
||||
ControlEmbeddedFiles::ControlEmbeddedFiles(Dialog & parent)
|
||||
: Dialog::Controller(parent), embedded_files(NULL)
|
||||
: Dialog::Controller(parent)
|
||||
{}
|
||||
|
||||
|
||||
EmbeddedFiles & ControlEmbeddedFiles::embeddedFiles()
|
||||
{
|
||||
return kernel().buffer().embeddedFiles();
|
||||
}
|
||||
|
||||
|
||||
bool ControlEmbeddedFiles::initialiseParams(string const &)
|
||||
{
|
||||
return true;
|
||||
@ -49,7 +55,7 @@ void ControlEmbeddedFiles::updateEmbeddedFiles()
|
||||
{
|
||||
// copy buffer embeddedFiles to a local copy
|
||||
kernel().buffer().embeddedFiles().update();
|
||||
embedded_files = &kernel().buffer().embeddedFiles();
|
||||
kernel().buffer().embeddingChanged();
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,8 +26,7 @@ public:
|
||||
///
|
||||
virtual ~ControlEmbeddedFiles() {}
|
||||
///
|
||||
EmbeddedFiles const & embeddedFiles() const { return *embedded_files; }
|
||||
EmbeddedFiles & embeddedFiles() { return *embedded_files; }
|
||||
EmbeddedFiles & embeddedFiles();
|
||||
///
|
||||
virtual bool initialiseParams(std::string const &);
|
||||
/// obtain embedded files from buffer
|
||||
@ -54,8 +53,6 @@ public:
|
||||
bool extract(EmbeddedFile const & item);
|
||||
|
||||
protected:
|
||||
// directly handle buffer embedded files
|
||||
EmbeddedFiles * embedded_files;
|
||||
//
|
||||
std::string message_;
|
||||
};
|
||||
|
@ -34,26 +34,6 @@ GuiEmbeddedFilesDialog::GuiEmbeddedFilesDialog(GuiEmbeddedFiles * form)
|
||||
: form_(form)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
form_->updateEmbeddedFiles();
|
||||
|
||||
EmbeddedFiles const & files = form_->embeddedFiles();
|
||||
enableCB->setChecked(files.enabled());
|
||||
EmbeddedFiles::EmbeddedFileList::const_iterator it = files.begin();
|
||||
EmbeddedFiles::EmbeddedFileList::const_iterator it_end = files.end();
|
||||
for (; it != it_end; ++it) {
|
||||
QListWidgetItem * item = new QListWidgetItem(toqstr(it->inzipName()));
|
||||
if (!it->valid())
|
||||
item->setTextColor(INVALID_COLOR);
|
||||
else if(it->status() == EmbeddedFile::AUTO)
|
||||
item->setTextColor(AUTO_COLOR);
|
||||
else if(it->status() == EmbeddedFile::EMBEDDED)
|
||||
item->setTextColor(EMBEDDED_COLOR);
|
||||
else
|
||||
item->setTextColor(EXTERNAL_COLOR);
|
||||
filesLW->addItem(item);
|
||||
}
|
||||
filesLW->setCurrentRow(0);
|
||||
//
|
||||
update();
|
||||
}
|
||||
@ -107,12 +87,28 @@ void GuiEmbeddedFilesDialog::on_filesLW_itemDoubleClicked()
|
||||
|
||||
void GuiEmbeddedFilesDialog::update()
|
||||
{
|
||||
EmbeddedFiles const & files = form_->embeddedFiles();
|
||||
filesLW->clear();
|
||||
|
||||
//
|
||||
EmbeddedFiles const & files = form_->embeddedFiles();
|
||||
EmbeddedFiles::EmbeddedFileList::const_iterator it = files.begin();
|
||||
EmbeddedFiles::EmbeddedFileList::const_iterator it_end = files.end();
|
||||
for (; it != it_end; ++it) {
|
||||
QListWidgetItem * item = new QListWidgetItem(toqstr(it->inzipName()));
|
||||
if (!it->valid())
|
||||
item->setTextColor(INVALID_COLOR);
|
||||
else if(it->status() == EmbeddedFile::AUTO)
|
||||
item->setTextColor(AUTO_COLOR);
|
||||
else if(it->status() == EmbeddedFile::EMBEDDED)
|
||||
item->setTextColor(EMBEDDED_COLOR);
|
||||
else
|
||||
item->setTextColor(EXTERNAL_COLOR);
|
||||
filesLW->addItem(item);
|
||||
}
|
||||
//
|
||||
bool enabled = files.enabled();
|
||||
enableCB->setChecked(enabled);
|
||||
statusGB->setEnabled(enabled);
|
||||
filesLW->setEnabled(enabled);
|
||||
fullpathLE->setEnabled(enabled);
|
||||
}
|
||||
|
||||
@ -145,7 +141,6 @@ void GuiEmbeddedFilesDialog::on_enableCB_toggled(bool enable)
|
||||
// embedded files. Otherwise, embedded files will be lost!!!
|
||||
//
|
||||
form_->embeddedFiles().enable(enable);
|
||||
update();
|
||||
// immediately post the change to buffer (and bufferView)
|
||||
if (enable)
|
||||
form_->setMessage("Enable file embedding");
|
||||
|
Loading…
Reference in New Issue
Block a user