mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Embedding: handle readOnly files correctly.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20262 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a750970781
commit
1109af0b0f
@ -67,6 +67,12 @@ void ControlEmbeddedFiles::dispatchMessage(string const & msg)
|
||||
}
|
||||
|
||||
|
||||
bool ControlEmbeddedFiles::isReadonly()
|
||||
{
|
||||
return buffer().isReadonly();
|
||||
}
|
||||
|
||||
|
||||
void ControlEmbeddedFiles::setEmbedding(bool enable)
|
||||
{
|
||||
if (embeddedFiles().enabled() == enable)
|
||||
|
@ -38,12 +38,14 @@ public:
|
||||
///
|
||||
bool canApply() const { return true; }
|
||||
///
|
||||
virtual bool canApplyToReadOnly() const { return true; }
|
||||
virtual bool canApplyToReadOnly() const { return false; }
|
||||
///
|
||||
void dispatchMessage(std::string const & msg);
|
||||
///
|
||||
void dispatchParams() {};
|
||||
///
|
||||
bool isReadonly();
|
||||
///
|
||||
void setEmbedding(bool enable);
|
||||
///
|
||||
void goTo(EmbeddedFile const & item, int idx);
|
||||
|
@ -48,6 +48,9 @@ void GuiEmbeddedFilesDialog::on_filesLW_itemChanged(QListWidgetItem* item)
|
||||
|
||||
void GuiEmbeddedFilesDialog::on_filesLW_itemSelectionChanged()
|
||||
{
|
||||
if (controller_.isReadonly())
|
||||
return;
|
||||
|
||||
QList<QListWidgetItem *> selection = filesLW->selectedItems();
|
||||
|
||||
if (selection.empty()) {
|
||||
@ -107,6 +110,15 @@ void GuiEmbeddedFilesDialog::on_filesLW_itemDoubleClicked(QListWidgetItem* item)
|
||||
|
||||
void GuiEmbeddedFilesDialog::updateView()
|
||||
{
|
||||
bool readOnly = controller_.isReadonly();
|
||||
fullpathLE->setEnabled(!readOnly);
|
||||
selectPB->setEnabled(!readOnly);
|
||||
unselectPB->setEnabled(!readOnly);
|
||||
addPB->setEnabled(!readOnly);
|
||||
extractPB->setEnabled(!readOnly);
|
||||
updatePB->setEnabled(!readOnly);
|
||||
enableCB->setEnabled(!readOnly);
|
||||
|
||||
filesLW->clear();
|
||||
EmbeddedFiles const & files = controller_.embeddedFiles();
|
||||
enableCB->setCheckState(files.enabled() ? Qt::Checked : Qt::Unchecked);
|
||||
@ -117,7 +129,9 @@ void GuiEmbeddedFilesDialog::updateView()
|
||||
if (it->refCount() > 1)
|
||||
label += " (1/" + QString::number(it->refCount()) + ")";
|
||||
QListWidgetItem * item = new QListWidgetItem(label);
|
||||
Qt::ItemFlags flag = Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
|
||||
Qt::ItemFlags flag = Qt::ItemIsSelectable;
|
||||
if (!readOnly)
|
||||
flag |= Qt::ItemIsUserCheckable;
|
||||
if (it->valid())
|
||||
flag |= Qt::ItemIsEnabled;
|
||||
item->setFlags(flag);
|
||||
|
Loading…
Reference in New Issue
Block a user