mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
Simplify Dialog::name() handling.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21736 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d4b02ad711
commit
10cc0a8842
@ -19,18 +19,29 @@
|
||||
#include "FuncStatus.h"
|
||||
#include "LyXFunc.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
|
||||
Dialog::Dialog(GuiView & lv, std::string const & name)
|
||||
: lyxview_(&lv), name_(name.c_str())
|
||||
{}
|
||||
|
||||
|
||||
Dialog::~Dialog()
|
||||
{}
|
||||
|
||||
|
||||
std::string Dialog::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
bool Dialog::canApply() const
|
||||
{
|
||||
FuncRequest const fr(getLfun(), name());
|
||||
FuncRequest const fr(getLfun(), name_);
|
||||
FuncStatus const fs(getStatus(fr));
|
||||
return fs.enabled();
|
||||
}
|
||||
@ -42,15 +53,15 @@ void Dialog::dispatch(FuncRequest const & fr) const
|
||||
}
|
||||
|
||||
|
||||
void Dialog::updateDialog(std::string const & name) const
|
||||
void Dialog::updateDialog() const
|
||||
{
|
||||
dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name));
|
||||
dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name_));
|
||||
}
|
||||
|
||||
|
||||
void Dialog::disconnect(std::string const & name) const
|
||||
void Dialog::disconnect() const
|
||||
{
|
||||
lyxview_->disconnectDialog(name);
|
||||
lyxview_->disconnectDialog(name_);
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,7 +47,8 @@ public:
|
||||
/// \param lv is the access point for the dialog to the LyX kernel.
|
||||
/// \param name is the identifier given to the dialog by its parent
|
||||
/// container.
|
||||
Dialog(GuiView & lv) : lyxview_(&lv) {}
|
||||
Dialog(GuiView & lv, std::string const & name);
|
||||
|
||||
virtual ~Dialog();
|
||||
|
||||
/** \name Container Access
|
||||
@ -107,7 +108,7 @@ public:
|
||||
//@}
|
||||
|
||||
///
|
||||
virtual std::string name() const = 0;
|
||||
std::string name() const;
|
||||
|
||||
//@{
|
||||
/** Enable the controller to initialise its data structures.
|
||||
@ -188,7 +189,7 @@ public:
|
||||
* It must, therefore, ask the kernel to provide this information.
|
||||
* \param name is used to identify the dialog to the kernel.
|
||||
*/
|
||||
void updateDialog(std::string const & name) const;
|
||||
void updateDialog() const;
|
||||
|
||||
/** A request from the Controller that future changes to the data
|
||||
* stored by the dialog are not applied to the inset currently
|
||||
@ -196,7 +197,7 @@ public:
|
||||
* a new inset at the cursor position.
|
||||
* \param name is used to identify the dialog to the kernel.
|
||||
*/
|
||||
void disconnect(std::string const & name) const;
|
||||
void disconnect() const;
|
||||
|
||||
/** \name Kernel Wrappers
|
||||
* Simple wrapper functions to Buffer methods.
|
||||
@ -229,9 +230,13 @@ protected:
|
||||
virtual void apply() {}
|
||||
|
||||
private:
|
||||
/** The Dialog's name is the means by which a dialog identifies
|
||||
* itself to the LyXView.
|
||||
*/
|
||||
char const * const name_;
|
||||
///
|
||||
GuiView * lyxview_;
|
||||
|
||||
private:
|
||||
/// intentionally unimplemented, therefore uncopiable
|
||||
Dialog(Dialog const &);
|
||||
void operator=(Dialog const &);
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
bool modal = false, ///< Window modality.
|
||||
Qt::WindowFlags flags = 0
|
||||
)
|
||||
: QDialog(&parent, flags), name_(name)
|
||||
: QDialog(&parent, flags), Dialog(parent, name)
|
||||
{
|
||||
setModal(modal);
|
||||
QGridLayout * gridLayout = new QGridLayout(this);
|
||||
@ -82,17 +82,15 @@ public:
|
||||
{
|
||||
widget_->updateView();
|
||||
}
|
||||
std::string name() const { return name_; }
|
||||
//@}
|
||||
private:
|
||||
/// The encapsulated widget.
|
||||
MyWidget * widget_;
|
||||
std::string name_;
|
||||
|
||||
void showEvent(QShowEvent * e)
|
||||
{
|
||||
QSettings settings;
|
||||
std::string key = name_ + "/geometry";
|
||||
std::string key = name() + "/geometry";
|
||||
QDialog::restoreGeometry(settings.value(key.c_str()).toByteArray());
|
||||
QDialog::showEvent(e);
|
||||
}
|
||||
@ -100,7 +98,7 @@ private:
|
||||
void closeEvent(QCloseEvent * e)
|
||||
{
|
||||
QSettings settings;
|
||||
std::string key = name_ + "/geometry";
|
||||
std::string key = name() + "/geometry";
|
||||
settings.setValue(key.c_str(), QDialog::saveGeometry());
|
||||
QDialog::closeEvent(e);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
|
||||
Qt::WindowFlags flags = 0
|
||||
)
|
||||
: QDockWidget(&parent, flags), Dialog(parent), name_(name)
|
||||
: QDockWidget(&parent, flags), Dialog(parent, name)
|
||||
{
|
||||
if (flags & Qt::Drawer)
|
||||
setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
@ -65,10 +65,7 @@ public:
|
||||
updateView();
|
||||
}
|
||||
bool isClosing() const { return false; }
|
||||
std::string name() const { return name_; }
|
||||
//@}
|
||||
private:
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
} // frontend
|
||||
|
@ -24,7 +24,7 @@ namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
GuiDialog::GuiDialog(GuiView & lv, std::string const & name)
|
||||
: Dialog(lv), is_closing_(false), name_(name)
|
||||
: Dialog(lv, name), is_closing_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ void GuiDialog::slotRestore()
|
||||
// Tell the controller that a request to refresh the dialog's contents
|
||||
// has been received. It's up to the controller to supply the necessary
|
||||
// info by calling GuiDialog::updateView().
|
||||
updateDialog(name_);
|
||||
updateDialog();
|
||||
bc().restore();
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ void GuiDialog::showData(string const & data)
|
||||
return;
|
||||
|
||||
if (!initialiseParams(data)) {
|
||||
lyxerr << "Dialog \"" << name_
|
||||
lyxerr << "Dialog \"" << name()
|
||||
<< "\" failed to translate the data "
|
||||
"string passed to show()" << std::endl;
|
||||
return;
|
||||
@ -186,7 +186,7 @@ void GuiDialog::updateData(string const & data)
|
||||
return;
|
||||
|
||||
if (!initialiseParams(data)) {
|
||||
lyxerr << "Dialog \"" << name_
|
||||
lyxerr << "Dialog \"" << name()
|
||||
<< "\" could not be initialized" << std::endl;
|
||||
return;
|
||||
}
|
||||
@ -205,7 +205,7 @@ void GuiDialog::hide()
|
||||
|
||||
clearParams();
|
||||
hideView();
|
||||
Dialog::disconnect(name_);
|
||||
Dialog::disconnect();
|
||||
}
|
||||
|
||||
|
||||
@ -221,7 +221,7 @@ void GuiDialog::apply()
|
||||
dispatchParams();
|
||||
|
||||
if (disconnectOnApply() && !is_closing_) {
|
||||
Dialog::disconnect(name_);
|
||||
Dialog::disconnect();
|
||||
initialiseParams(string());
|
||||
updateView();
|
||||
}
|
||||
@ -231,7 +231,7 @@ void GuiDialog::apply()
|
||||
void GuiDialog::showEvent(QShowEvent * e)
|
||||
{
|
||||
QSettings settings;
|
||||
string key = name_ + "/geometry";
|
||||
string key = name() + "/geometry";
|
||||
restoreGeometry(settings.value(key.c_str()).toByteArray());
|
||||
QDialog::showEvent(e);
|
||||
}
|
||||
@ -240,7 +240,7 @@ void GuiDialog::showEvent(QShowEvent * e)
|
||||
void GuiDialog::closeEvent(QCloseEvent * e)
|
||||
{
|
||||
QSettings settings;
|
||||
string key = name_ + "/geometry";
|
||||
string key = name() + "/geometry";
|
||||
settings.setValue(key.c_str(), saveGeometry());
|
||||
QDialog::closeEvent(e);
|
||||
}
|
||||
|
@ -115,9 +115,6 @@ public:
|
||||
*/
|
||||
bool isClosing() const { return is_closing_; }
|
||||
|
||||
///
|
||||
std::string name() const { return name_; }
|
||||
|
||||
void apply();
|
||||
|
||||
/// Update the display of the dialog whilst it is still visible.
|
||||
@ -129,10 +126,6 @@ private:
|
||||
bool updating_;
|
||||
|
||||
bool is_closing_;
|
||||
/** The Dialog's name is the means by which a dialog identifies
|
||||
* itself to the kernel.
|
||||
*/
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
GuiParagraph::GuiParagraph(GuiView & lv)
|
||||
: Dialog(lv)
|
||||
: Dialog(lv, "paragraph")
|
||||
{
|
||||
setupUi(this);
|
||||
setWindowTitle(qt_("Paragraph Settings"));
|
||||
|
@ -1367,7 +1367,7 @@ void GuiView::updateBufferDependent(bool switched) const
|
||||
// A bit clunky, but the dialog will request
|
||||
// that the kernel provides it with the necessary
|
||||
// data.
|
||||
dialog->updateDialog(dialog->name());
|
||||
dialog->updateDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user