]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Qt2BC.h
Another compile fix.
[lyx.git] / src / frontends / qt4 / Qt2BC.h
index a851a118f1c456c50fa59d2a43c2b07ee13f663b..fbef62c96254ff564d693a440b0b73929f48f75c 100644 (file)
 #include "BCView.h"
 #include "gettext.h"
 
+#include <list>
+
 class QWidget;
 class QPushButton;
+class QLineEdit;
 
 namespace lyx {
 namespace frontend {
 
+
+void addCheckedLineEdit(BCView & bcview,
+       QLineEdit * input, QWidget * label = 0);
+
+class CheckedLineEdit
+{
+public:
+       CheckedLineEdit(QLineEdit * input, QWidget * label = 0);
+       bool check() const;
+
+private:
+       // non-owned
+       QLineEdit * input_;
+       QWidget * label_;
+};
+
 /** General purpose button controller for up to four buttons.
     Controls the activation of the OK, Apply and Cancel buttons.
     Actually supports 4 buttons in all and it's up to the user to decide on
     the activation policy and which buttons correspond to which output of the
     state machine.
 */
-class Qt2BC : public GuiBC<QPushButton, QWidget> {
+
+class Qt2BC : public BCView
+{
 public:
        ///
-       Qt2BC(ButtonController const &,
-             std::string const & = lyx::to_utf8(_("Cancel")),
-             std::string const & = lyx::to_utf8(_("Close")));
+       Qt2BC(ButtonController & parent);
+
+       //@{
+       /** Store pointers to these widgets.
+        */
+       void setOK(QPushButton * obj) { okay_ = obj; }
+       void setApply(QPushButton * obj) { apply_ = obj; }
+       void setCancel(QPushButton * obj) { cancel_ = obj; }
+       void setRestore(QPushButton * obj) { restore_ = obj; }
+       //@}
+
+       /** Add a pointer to the list of widgets whose activation
+        *  state is dependent upon the read-only status of the
+        *  underlying buffer.
+        */
+       void addReadOnly(QWidget * obj) { read_only_.push_back(obj); }
+
+       /// Refresh the status of the Ok, Apply, Restore, Cancel buttons.
+       virtual void refresh() const;
+       /// Refresh the status of any widgets in the read_only list
+       virtual void refreshReadOnly() const;
+
+       /** Add a widget to the list of all widgets whose validity should
+        *  be checked explicitly when the buttons are refreshed.
+        */
+       void addCheckedLineEdit(QLineEdit * input, QWidget * label = 0);
+
+protected:
+       /// \return true if all CheckedWidgets are in a valid state.
+       bool checkWidgets() const;
+
 private:
-       /// Updates the button sensitivity (enabled/disabled)
-       void setButtonEnabled(QPushButton *, bool enabled) const;
+       typedef std::list<CheckedLineEdit> CheckedWidgetList;
+       CheckedWidgetList checked_widgets;
 
+private:
        /// Updates the widget sensitivity (enabled/disabled)
        void setWidgetEnabled(QWidget *, bool enabled) const;
 
-       /// Set the label on the button
-       void setButtonLabel(QPushButton *, std::string const & label) const;
+       QPushButton * okay_;
+       QPushButton * apply_;
+       QPushButton * cancel_;
+       QPushButton * restore_;
+
+       typedef std::list<QWidget *> Widgets;
+       Widgets read_only_;
 };
 
 } // namespace frontend