2006-03-05 17:24:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file Qt2BC.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Allan Rae
|
|
|
|
* \author Angus Leeming
|
|
|
|
* \author Baruch Even
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QT2BC_H
|
|
|
|
#define QT2BC_H
|
|
|
|
|
|
|
|
#include "BCView.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
|
2007-09-02 14:57:30 +00:00
|
|
|
#include <list>
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
class QWidget;
|
|
|
|
class QPushButton;
|
2007-09-02 08:19:43 +00:00
|
|
|
class QLineEdit;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-09-02 08:19:43 +00:00
|
|
|
|
|
|
|
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_;
|
|
|
|
};
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
/** 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.
|
|
|
|
*/
|
2007-09-01 20:44:14 +00:00
|
|
|
|
|
|
|
class Qt2BC : public BCView
|
|
|
|
{
|
2006-03-05 17:24:44 +00:00
|
|
|
public:
|
|
|
|
///
|
2007-09-02 07:53:07 +00:00
|
|
|
Qt2BC(ButtonController & parent);
|
2007-09-01 20:44:14 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/** 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); }
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-01 20:44:14 +00:00
|
|
|
/// 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;
|
|
|
|
|
2007-09-02 07:53:07 +00:00
|
|
|
/** Add a widget to the list of all widgets whose validity should
|
|
|
|
* be checked explicitly when the buttons are refreshed.
|
|
|
|
*/
|
2007-09-02 08:19:43 +00:00
|
|
|
void addCheckedLineEdit(QLineEdit * input, QWidget * label = 0);
|
2007-09-02 07:53:07 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/// \return true if all CheckedWidgets are in a valid state.
|
|
|
|
bool checkWidgets() const;
|
|
|
|
|
|
|
|
private:
|
2007-09-02 08:19:43 +00:00
|
|
|
typedef std::list<CheckedLineEdit> CheckedWidgetList;
|
2007-09-02 07:53:07 +00:00
|
|
|
CheckedWidgetList checked_widgets;
|
|
|
|
|
2007-09-01 20:44:14 +00:00
|
|
|
private:
|
2006-03-05 17:24:44 +00:00
|
|
|
/// Updates the widget sensitivity (enabled/disabled)
|
|
|
|
void setWidgetEnabled(QWidget *, bool enabled) const;
|
|
|
|
|
2007-09-01 20:44:14 +00:00
|
|
|
QPushButton * okay_;
|
|
|
|
QPushButton * apply_;
|
|
|
|
QPushButton * cancel_;
|
|
|
|
QPushButton * restore_;
|
|
|
|
|
|
|
|
typedef std::list<QWidget *> Widgets;
|
|
|
|
Widgets read_only_;
|
2006-03-05 17:24:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif // QT2BC_H
|