4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
16 #include "ButtonController.h"
18 #include "insets/InsetCommandParams.h"
29 /** \c Dialog collects the different parts of a Model-Controller-View
30 * split of a generic dialog together.
32 class GuiDialog : public QDialog, public Dialog
37 /// \param lv is the access point for the dialog to the LyX kernel.
38 /// \param name is the identifier given to the dialog by its parent
40 explicit GuiDialog(GuiView & lv, std::string const & name);
45 * These methods are publicly accessible because they are invoked
46 * by the View when the user presses... guess what ;-)
48 // Restore button clicked
52 // Apply button clicked
54 // Close button clicked or closed from WindowManager
58 /** Check whether we may apply our data.
60 * The buttons are disabled if not and (re-)enabled if yes.
63 void setButtonsValid(bool valid);
65 /** \name Dialog Components
66 * Methods to access the various components making up a dialog.
69 ButtonController const & bc() const { return bc_; }
70 ButtonController & bc() { return bc_; }
73 void setViewTitle(docstring const & title);
76 /// the dialog has changed contents
77 virtual void changed();
79 /// default: do nothing
80 virtual void applyView() {}
81 /// default: do nothing
82 virtual void updateContents() {}
84 void closeEvent(QCloseEvent *);
86 void showEvent(QShowEvent *);
90 virtual void hideView();
91 /// Create the dialog if necessary, update it and display it.
92 virtual void showView();
94 virtual bool isVisibleView() const;
95 /// is the dialog currently valid ?
96 virtual bool isValid() { return true; }
99 /** \name Container Access
100 * These methods are publicly accessible because they are invoked
101 * by the parent container acting on commands from the LyX kernel.
104 /// \param data is a string encoding of the data to be displayed.
105 /// It is passed to the Controller to be translated into a useable form.
106 void showData(std::string const & data);
107 void updateData(std::string const & data);
113 /** When applying, it's useful to know whether the dialog is about
114 * to close or not (no point refreshing the display for example).
116 bool isClosing() const { return is_closing_; }
119 std::string name() const { return name_; }
123 /// Update the display of the dialog whilst it is still visible.
124 virtual void updateView();
127 ButtonController bc_;
128 /// are we updating ?
132 /** The Dialog's name is the means by which a dialog identifies
133 * itself to the kernel.
139 class GuiCommand : public GuiDialog
142 /// We need to know with what sort of inset we're associated.
143 // FIXME This should probably be an InsetCode
144 GuiCommand(GuiView &, std::string const & name);
146 bool initialiseParams(std::string const & data);
147 /// clean-up on hide.
148 void clearParams() { params_.clear(); }
149 /// clean-up on hide.
150 void dispatchParams();
152 bool isBufferDependent() const { return true; }
156 InsetCommandParams params_;
157 //FIXME It should be possible to eliminate lfun_name_
158 //now and recover that information from params().insetType().
159 //But let's not do that quite yet.
160 /// Flags what action is taken by Kernel::dispatch()
161 std::string const lfun_name_;
164 } // namespace frontend
167 #endif // GUIDIALOG_H