Jürgen Spitzmüller wrote:
Abdelrazak Younes wrote:
I see that you insisted on implementing initialiseParams() and
clearParams(), that's why. You are still 'tainted' by the serialization
way ;-)
How would the new approach look?
Something like this (untested yet).
Abdel.
Index: GuiSymbols.cpp
===================================================================
--- GuiSymbols.cpp (revision 22834)
+++ GuiSymbols.cpp (working copy)
@@ -12,23 +12,19 @@
#include "GuiSymbols.h"
-#include "Buffer.h"
-#include "BufferView.h"
-
#include "GuiApplication.h"
#include "GuiView.h"
-
#include "qt_helpers.h"
+#include "Buffer.h"
+#include "BufferView.h"
#include "Encoding.h"
+
#include "support/gettext.h"
#include <QPixmap>
#include <QListWidgetItem>
-// Set to zero if unicode symbols are preferred.
-#define USE_PIXMAP 1
-
using namespace std;
namespace lyx {
@@ -160,21 +156,30 @@
int size = font.pointSize() + 3;
font.setPointSize(size);
symbolsLW->setFont(font);
-
- okPB->setEnabled(!chosenLE->text().isEmpty() &&
- !bufferview()->buffer().isReadonly());
- applyPB->setEnabled(!chosenLE->text().isEmpty() &&
- !bufferview()->buffer().isReadonly());
}
void GuiSymbols::updateView()
{
chosenLE->clear();
- initialiseParams(bufferview()->cursor().getEncoding()->name());
+
+ if (data == encoding_)
+ // everything up to date
+ return;
+ if (!data.empty())
+ encoding_ = data;
+ updateSymbolList();
}
+void GuiSymbols::enableView(bool enable)
+{
+ chosenLE->setEnabled(enable);
+ okPB->setEnabled(enable);
+ applyPB->setEnabled(enable);
+}
+
+
void GuiSymbols::on_applyPB_clicked()
{
dispatchParams();
@@ -202,8 +207,9 @@
void GuiSymbols::on_chosenLE_textChanged(QString const & text)
{
- okPB->setEnabled(!text.isEmpty() &&
!bufferview()->buffer().isReadonly());
- applyPB->setEnabled(!text.isEmpty() &&
!bufferview()->buffer().isReadonly());
+ bool const empty_sel = text.isEmpty();
+ okPB->setEnabled(okPB->isEnabled() && !empty_sel);
+ applyPB->setEnabled(applyPB->isEnabled() && !empty_sel);
}
@@ -274,19 +280,6 @@
}
-
-bool GuiSymbols::initialiseParams(string const & data)
-{
- if (data == encoding_)
- // everything up to date
- return true;
- if (!data.empty())
- encoding_ = data;
- updateSymbolList();
- return true;
-}
-
-
void GuiSymbols::dispatchParams()
{
dispatch(FuncRequest(LFUN_SELF_INSERT, fromqstr(chosenLE->text())));
Index: GuiSymbols.h
===================================================================
--- GuiSymbols.h (revision 22834)
+++ GuiSymbols.h (working copy)
@@ -33,8 +33,7 @@
//@{
void updateView();
void dispatchParams();
- bool initialiseParams(std::string const & data);
- void clearParams() {}
+ void enableView(bool enable);
bool isBufferDependent() const { return true; }
//@}