mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-22 16:37:28 +00:00
Embedding: small adjustments of interfaces, single and double click in the embedding dialog
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19960 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c94eb3deeb
commit
e4e09c4b0b
@ -221,28 +221,6 @@ bool EmbeddedFiles::write(DocFileName const & filename)
|
||||
}
|
||||
|
||||
|
||||
string EmbeddedFiles::filename(size_t idx) const
|
||||
{
|
||||
return (file_list_.begin() + idx)->absFilename();
|
||||
}
|
||||
|
||||
|
||||
EmbeddedFile::STATUS EmbeddedFiles::status(size_t idx) const
|
||||
{
|
||||
return (file_list_.begin() + idx)->status();
|
||||
}
|
||||
|
||||
|
||||
void EmbeddedFiles::setStatus(size_t idx, EmbeddedFile::STATUS status)
|
||||
{
|
||||
if ((file_list_.begin() + idx)->status() != status) {
|
||||
// file will be changed
|
||||
buffer_->markDirty();
|
||||
(file_list_.begin() + idx)->setStatus(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool EmbeddedFiles::validInzipName(string const & name)
|
||||
{
|
||||
EmbeddedFileList::iterator it = file_list_.begin();
|
||||
|
@ -211,10 +211,9 @@ public:
|
||||
|
||||
void clear() { file_list_.clear(); }
|
||||
|
||||
/// FIXME: I am wondering if we should use index or filename (a std::map)
|
||||
std::string filename(size_t idx) const;
|
||||
EmbeddedFile::STATUS status(size_t idx) const;
|
||||
void setStatus(size_t idx, EmbeddedFile::STATUS status);
|
||||
///
|
||||
EmbeddedFile & operator[](size_t idx) { return *(file_list_.begin() + idx); }
|
||||
EmbeddedFile const & operator[](size_t idx) const { return *(file_list_.begin() + idx); }
|
||||
///
|
||||
EmbeddedFileList::iterator begin() { return file_list_.begin(); }
|
||||
EmbeddedFileList::iterator end() { return file_list_.end(); }
|
||||
|
@ -17,7 +17,10 @@
|
||||
#include "FuncRequest.h"
|
||||
#include "gettext.h"
|
||||
#include "debug.h"
|
||||
#include "Format.h"
|
||||
|
||||
#include "frontends/LyXView.h"
|
||||
#include "support/convert.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
@ -50,5 +53,17 @@ void ControlEmbeddedFiles::dispatchParams()
|
||||
}
|
||||
|
||||
|
||||
void ControlEmbeddedFiles::goTo(EmbeddedFile const & item)
|
||||
{
|
||||
string const tmp = convert<string>(item.parID());
|
||||
kernel().lyxview().dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
|
||||
}
|
||||
|
||||
|
||||
void ControlEmbeddedFiles::view(EmbeddedFile const & item)
|
||||
{
|
||||
formats.view(kernel().buffer(), item, formats.getFormatFromFile(item));
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
@ -26,8 +26,8 @@ public:
|
||||
///
|
||||
virtual ~ControlEmbeddedFiles() {}
|
||||
///
|
||||
EmbeddedFiles const * embeddedFiles() const { return embedded_files; }
|
||||
EmbeddedFiles * embeddedFiles() { return embedded_files; }
|
||||
EmbeddedFiles const & embeddedFiles() const { return *embedded_files; }
|
||||
EmbeddedFiles & embeddedFiles() { return *embedded_files; }
|
||||
///
|
||||
virtual bool initialiseParams(std::string const &);
|
||||
/// obtain embedded files from buffer
|
||||
@ -44,7 +44,11 @@ public:
|
||||
void setMessage(std::string const & msg) { message_ = msg; }
|
||||
///
|
||||
void dispatchParams();
|
||||
|
||||
///
|
||||
void goTo(EmbeddedFile const & item);
|
||||
///
|
||||
void view(EmbeddedFile const & item);
|
||||
|
||||
protected:
|
||||
// directly handle buffer embedded files
|
||||
EmbeddedFiles * embedded_files;
|
||||
|
@ -39,10 +39,10 @@ GuiEmbeddedFilesDialog::GuiEmbeddedFilesDialog(GuiEmbeddedFiles * form)
|
||||
|
||||
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();
|
||||
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())
|
||||
@ -71,7 +71,7 @@ GuiEmbeddedFilesDialog::GuiEmbeddedFilesDialog(GuiEmbeddedFiles * form)
|
||||
|
||||
void GuiEmbeddedFilesDialog::on_filesLW_itemSelectionChanged()
|
||||
{
|
||||
EmbeddedFiles * files = form_->embeddedFiles();
|
||||
EmbeddedFiles & files = form_->embeddedFiles();
|
||||
|
||||
QList<QListWidgetItem *> selection = filesLW->selectedItems();
|
||||
fullpathLE->setEnabled(selection.size() == 1);
|
||||
@ -81,12 +81,12 @@ void GuiEmbeddedFilesDialog::on_filesLW_itemSelectionChanged()
|
||||
for (QList<QListWidgetItem*>::iterator it = selection.begin();
|
||||
it != selection.end(); ++it) {
|
||||
if (selection.size() == 1)
|
||||
fullpathLE->setText(toqstr(files->filename(filesLW->row(*it))));
|
||||
fullpathLE->setText(toqstr(files[filesLW->row(*it)].absFilename()));
|
||||
if (mode == EmbeddedFile::NONE) {
|
||||
mode = files->status(filesLW->row(*it));
|
||||
mode = files[filesLW->row(*it)].status();
|
||||
continue;
|
||||
}
|
||||
if (mode != files->status(filesLW->row(*it))) {
|
||||
if (mode != files[filesLW->row(*it)].status()) {
|
||||
mode = EmbeddedFile::NONE;
|
||||
break;
|
||||
}
|
||||
@ -95,20 +95,24 @@ 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())]);
|
||||
}
|
||||
|
||||
|
||||
void GuiEmbeddedFilesDialog::on_filesLW_itemDoubleClicked()
|
||||
{
|
||||
// FIXME: view or edit file
|
||||
EmbeddedFiles & files = form_->embeddedFiles();
|
||||
QList<QListWidgetItem *> selection = filesLW->selectedItems();
|
||||
form_->view(files[filesLW->row(*selection.begin())]);
|
||||
}
|
||||
|
||||
|
||||
void GuiEmbeddedFilesDialog::update()
|
||||
{
|
||||
EmbeddedFiles const * files = form_->embeddedFiles();
|
||||
EmbeddedFiles const & files = form_->embeddedFiles();
|
||||
|
||||
bool enabled = files->enabled();
|
||||
bool enabled = files.enabled();
|
||||
enableCB->setChecked(enabled);
|
||||
statusGB->setEnabled(enabled);
|
||||
filesLW->setEnabled(enabled);
|
||||
@ -150,7 +154,7 @@ void GuiEmbeddedFilesDialog::on_enableCB_toggled(bool enable)
|
||||
// When a embedded file is turned to disabled, it should save its
|
||||
// embedded files. Otherwise, embedded files will be lost!!!
|
||||
//
|
||||
form_->embeddedFiles()->enable(enable);
|
||||
form_->embeddedFiles().enable(enable);
|
||||
update();
|
||||
// immediately post the change to buffer (and bufferView)
|
||||
if (enable)
|
||||
@ -164,11 +168,14 @@ void GuiEmbeddedFilesDialog::on_enableCB_toggled(bool enable)
|
||||
|
||||
void GuiEmbeddedFilesDialog::set_embedding_status(EmbeddedFile::STATUS status)
|
||||
{
|
||||
EmbeddedFiles * files = form_->embeddedFiles();
|
||||
EmbeddedFiles & files = form_->embeddedFiles();
|
||||
QList<QListWidgetItem *> selection = filesLW->selectedItems();
|
||||
for (QList<QListWidgetItem*>::iterator it = selection.begin();
|
||||
it != selection.end(); ++it) {
|
||||
files->setStatus(filesLW->row(*it), status);
|
||||
int row = filesLW->row(*it);
|
||||
// FIXME: mark buffer dirty
|
||||
if (status != files[row].status())
|
||||
files[row].setStatus(status);
|
||||
if(status == EmbeddedFile::AUTO)
|
||||
(*it)->setTextColor(AUTO_COLOR);
|
||||
else if(status == EmbeddedFile::EMBEDDED)
|
||||
|
Loading…
x
Reference in New Issue
Block a user