Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-08 Thread Kornel
Am streda 08 Jún 2011 schrieb Enrico Forestieri:
> On Wed, Jun 08, 2011 at 10:19:07PM +0200, Kornel wrote:
> > Am streda 08 Jún 2011 schrieb Enrico Forestieri:
> > > On Wed, Jun 08, 2011 at 08:24:37PM +0200, Vincent van Ravesteijn wrote:
> > > > On 7-6-2011 15:24, Enrico Forestieri wrote:
> > > > > On Tue, Jun 07, 2011 at 03:06:30PM +0200, Enrico Forestieri wrote:
> > > > >> The only problem that I foresee is when one of the minor numbers
> > > > >> in the Qt version is greater than 9. For example, it will fail
> > > > >> for Qt 4.10.0 (in its present form), but it can be complicated
> > > > >> a bit to also account for that.
> > > > > 
> > > > > Like the attached, for example.
> > > > 
> > > > Is this good enough to be committed ?
> > > 
> > > I think so.
> > 
> > I am not sure, how e.g. "4.10.11" should convert.
> > 
> > 1.) As proposed by enrico: "0x040a0b"
> > 
> > or
> > 
> > 2.) As used in official cmake module "FindQt.cmake" as "0x041011"
> 
> Doh! It seems Qt people have to change their macro in qglobal.h, then :)
> 
> Excerpt from qglobal.h:
> 
> /*
>can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
> */
> #define QT_VERSION_CHECK(major, minor, patch)
> ((major<<16)|(minor<<8)|(patch))

Ok then.

I seem unable to construct a hexadecimal number representation in cmake. But in 
our case
using the equivalent decimal should be ok.
In my case (4.7.2) it evaluates e.g.
-DQT_VERSION=263938 ...

I will change it.

Kornel


signature.asc
Description: This is a digitally signed message part.


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-08 Thread Enrico Forestieri
On Wed, Jun 08, 2011 at 10:19:07PM +0200, Kornel wrote:
> Am streda 08 Jún 2011 schrieb Enrico Forestieri:
> > On Wed, Jun 08, 2011 at 08:24:37PM +0200, Vincent van Ravesteijn wrote:
> > > On 7-6-2011 15:24, Enrico Forestieri wrote:
> > > > On Tue, Jun 07, 2011 at 03:06:30PM +0200, Enrico Forestieri wrote:
> > > >> The only problem that I foresee is when one of the minor numbers
> > > >> in the Qt version is greater than 9. For example, it will fail
> > > >> for Qt 4.10.0 (in its present form), but it can be complicated
> > > >> a bit to also account for that.
> > > > 
> > > > Like the attached, for example.
> > > 
> > > Is this good enough to be committed ?
> > 
> > I think so.
> 
> I am not sure, how e.g. "4.10.11" should convert.
>   1.) As proposed by enrico: "0x040a0b"
> or
>   2.) As used in official cmake module "FindQt.cmake" as "0x041011"

Doh! It seems Qt people have to change their macro in qglobal.h, then :)

Excerpt from qglobal.h:

/*
   can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
*/
#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))

-- 
Enrico


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-08 Thread Kornel
Am streda 08 Jún 2011 schrieb Enrico Forestieri:
> On Wed, Jun 08, 2011 at 08:24:37PM +0200, Vincent van Ravesteijn wrote:
> > On 7-6-2011 15:24, Enrico Forestieri wrote:
> > > On Tue, Jun 07, 2011 at 03:06:30PM +0200, Enrico Forestieri wrote:
> > >> The only problem that I foresee is when one of the minor numbers
> > >> in the Qt version is greater than 9. For example, it will fail
> > >> for Qt 4.10.0 (in its present form), but it can be complicated
> > >> a bit to also account for that.
> > > 
> > > Like the attached, for example.
> > 
> > Is this good enough to be committed ?
> 
> I think so.

I am not sure, how e.g. "4.10.11" should convert.
1.) As proposed by enrico: "0x040a0b"
or
2.) As used in official cmake module "FindQt.cmake" as "0x041011"

Kornel


signature.asc
Description: This is a digitally signed message part.


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-08 Thread Enrico Forestieri
On Wed, Jun 08, 2011 at 08:24:37PM +0200, Vincent van Ravesteijn wrote:
> On 7-6-2011 15:24, Enrico Forestieri wrote:
> > On Tue, Jun 07, 2011 at 03:06:30PM +0200, Enrico Forestieri wrote:
> >>
> >> The only problem that I foresee is when one of the minor numbers
> >> in the Qt version is greater than 9. For example, it will fail
> >> for Qt 4.10.0 (in its present form), but it can be complicated
> >> a bit to also account for that.
> > 
> > Like the attached, for example.
> > 
> 
> Is this good enough to be committed ?

I think so.

-- 
Enrico


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-08 Thread Andre Poenitz
On Tue, Jun 07, 2011 at 03:06:30PM +0200, Enrico Forestieri wrote:
> On Tue, Jun 07, 2011 at 02:43:47PM +0200, Jean-Marc Lasgouttes wrote:
> 
> > How portable is this in your opinion?
> 
> It assumes a bourne compatible shell, but that assumption is made
> in so many places that I think it's very safe.
> 
> The only problem that I foresee is when one of the minor numbers
> in the Qt version is greater than 9. For example, it will fail
> for Qt 4.10.0 (in its present form), but it can be complicated
> a bit to also account for that.

There won't be a Qt 4.10.

Andre'


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-08 Thread Vincent van Ravesteijn
On 7-6-2011 15:24, Enrico Forestieri wrote:
> On Tue, Jun 07, 2011 at 03:06:30PM +0200, Enrico Forestieri wrote:
>>
>> The only problem that I foresee is when one of the minor numbers
>> in the Qt version is greater than 9. For example, it will fail
>> for Qt 4.10.0 (in its present form), but it can be complicated
>> a bit to also account for that.
> 
> Like the attached, for example.
> 

Is this good enough to be committed ?

Vincent


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-07 Thread Enrico Forestieri
On Tue, Jun 07, 2011 at 03:06:30PM +0200, Enrico Forestieri wrote:
> 
> The only problem that I foresee is when one of the minor numbers
> in the Qt version is greater than 9. For example, it will fail
> for Qt 4.10.0 (in its present form), but it can be complicated
> a bit to also account for that.

Like the attached, for example.

-- 
Enrico
Index: src/frontends/qt4/Makefile.am
===
--- src/frontends/qt4/Makefile.am   (revisione 38970)
+++ src/frontends/qt4/Makefile.am   (copia locale)
@@ -16,9 +16,12 @@ ui_%.h: ui/%.ui
 
 MOCEDFILES = $(MOCHEADER:%.h=moc_%.cpp)
 
+QT_VERSION = $(shell IFS=.; set -- `echo $(QT4_VERSION)`; \
+echo 0x0`echo "obase=16; $$1*65536+$$2*256+$$3" | bc`)
+
 # The moc_%.cpp pattern must match the filter in ../../../po/Rules-lyx
 moc_%.cpp: %.h
-   $(AM_V_GEN)$(MOC4) -o $@ $<
+   $(AM_V_GEN)$(MOC4) -DQT_VERSION=$(QT_VERSION) -o $@ $<
 
 Resources.qrc: Makefile
$(AM_V_GEN)echo "" > $@ ; \
Index: src/frontends/qt4/FancyLineEdit.h
===
--- src/frontends/qt4/FancyLineEdit.h   (revisione 38970)
+++ src/frontends/qt4/FancyLineEdit.h   (copia locale)
@@ -22,6 +22,7 @@ namespace frontend {
 
 class FancyLineEditPrivate;
 
+#if QT_VERSION >= 0x040600
 class IconButton: public QAbstractButton
 {
Q_OBJECT
@@ -44,7 +45,7 @@ private:
 bool m_autoHide;
 QPixmap m_pixmap;
 };
-
+#endif
 
 /* A line edit with an embedded pixmap on one side that is connected to
  * a menu. Additionally, it can display a grayed hintText (like "Type Here to")


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-07 Thread Jean-Marc Lasgouttes

Le 07/06/2011 15:06, Enrico Forestieri a écrit :

It assumes a bourne compatible shell, but that assumption is made
in so many places that I think it's very safe.


Yes. The important think is to avoid bash-isms.


The only problem that I foresee is when one of the minor numbers
in the Qt version is greater than 9. For example, it will fail
for Qt 4.10.0 (in its present form), but it can be complicated
a bit to also account for that.


That's OK IMO. Qt5 will be there before qt 4.10...

We could also let autoconf define another QT_VERSION variable that uses 
the numeric form. Or use only the numeric form.


JMarc



Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-07 Thread Enrico Forestieri
On Tue, Jun 07, 2011 at 02:43:47PM +0200, Jean-Marc Lasgouttes wrote:

> How portable is this in your opinion?

It assumes a bourne compatible shell, but that assumption is made
in so many places that I think it's very safe.

The only problem that I foresee is when one of the minor numbers
in the Qt version is greater than 9. For example, it will fail
for Qt 4.10.0 (in its present form), but it can be complicated
a bit to also account for that.

-- 
Enrico


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-07 Thread Jean-Marc Lasgouttes

Le 07/06/2011 14:41, Enrico Forestieri a écrit :

I think this is not going to work. From what I see looking at qt4.m4,
QT4_VERSION contains the string version, i.e., 4.7.3 and not 0x040703.
So, either we extract the definition of QT_VERSION (rather than
QT_VERSION_STR) from qglobal.h or manipulate QT4_VERSION in order
to produce the right format.


The attached patch (revised from yours) works for me.


Oohh ! You are better at shell scripting that I am. How portable is this 
in your opinion?


JMarc


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-07 Thread Jean-Marc Lasgouttes

Le 07/06/2011 13:29, Enrico Forestieri a écrit :

On Tue, Jun 07, 2011 at 11:52:02AM +0200, Jean-Marc Lasgouttes wrote:

Le 07/06/2011 09:01, Enrico Forestieri a écrit :

The moc doesn't have a definition of QT_VERSION, so the check
"#if QT_VERSION>= 0x040600" fails and you always get the "#else"
clause.


Here is my next try. Something similar will have to be done for
cmake and scons.


I think this is not going to work. From what I see looking at qt4.m4,
QT4_VERSION contains the string version, i.e., 4.7.3 and not 0x040703.
So, either we extract the definition of QT_VERSION (rather than
QT_VERSION_STR) from qglobal.h or manipulate QT4_VERSION in order
to produce the right format.


I knew I should not try to fiddle with this when I do not have enough 
time to do it seriously :( Thanks Enrico.


JMarc


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-07 Thread Enrico Forestieri
On Tue, Jun 07, 2011 at 01:29:27PM +0200, Enrico Forestieri wrote:
> On Tue, Jun 07, 2011 at 11:52:02AM +0200, Jean-Marc Lasgouttes wrote:
> > Le 07/06/2011 09:01, Enrico Forestieri a écrit :
> > >The moc doesn't have a definition of QT_VERSION, so the check
> > >"#if QT_VERSION>= 0x040600" fails and you always get the "#else"
> > >clause.
> > 
> > Here is my next try. Something similar will have to be done for
> > cmake and scons.
> 
> I think this is not going to work. From what I see looking at qt4.m4,
> QT4_VERSION contains the string version, i.e., 4.7.3 and not 0x040703.
> So, either we extract the definition of QT_VERSION (rather than
> QT_VERSION_STR) from qglobal.h or manipulate QT4_VERSION in order
> to produce the right format.

The attached patch (revised from yours) works for me.

-- 
Enrico
Index: src/frontends/qt4/Makefile.am
===
--- src/frontends/qt4/Makefile.am   (revisione 38970)
+++ src/frontends/qt4/Makefile.am   (copia locale)
@@ -16,9 +16,11 @@ ui_%.h: ui/%.ui
 
 MOCEDFILES = $(MOCHEADER:%.h=moc_%.cpp)
 
+QT_VERSION = $(shell IFS=.; set -- `echo $(QT4_VERSION)`; echo 0x0$$10$$20$$3)
+
 # The moc_%.cpp pattern must match the filter in ../../../po/Rules-lyx
 moc_%.cpp: %.h
-   $(AM_V_GEN)$(MOC4) -o $@ $<
+   $(AM_V_GEN)$(MOC4) -DQT_VERSION=$(QT_VERSION) -o $@ $<
 
 Resources.qrc: Makefile
$(AM_V_GEN)echo "" > $@ ; \
Index: src/frontends/qt4/FancyLineEdit.h
===
--- src/frontends/qt4/FancyLineEdit.h   (revisione 38970)
+++ src/frontends/qt4/FancyLineEdit.h   (copia locale)
@@ -22,6 +22,7 @@ namespace frontend {
 
 class FancyLineEditPrivate;
 
+#if QT_VERSION >= 0x040600
 class IconButton: public QAbstractButton
 {
Q_OBJECT
@@ -44,7 +45,7 @@ private:
 bool m_autoHide;
 QPixmap m_pixmap;
 };
-
+#endif
 
 /* A line edit with an embedded pixmap on one side that is connected to
  * a menu. Additionally, it can display a grayed hintText (like "Type Here to")


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-07 Thread Kornel
Am utorok 07 Jún 2011 schrieb Jean-Marc Lasgouttes:
> Le 07/06/2011 09:01, Enrico Forestieri a écrit :
> > The moc doesn't have a definition of QT_VERSION, so the check
> > "#if QT_VERSION>= 0x040600" fails and you always get the "#else"
> > clause.
> 
> Here is my next try. Something similar will have to be done for cmake 
> and scons.
> 
> JMarc

Cmake should be ready.

Kornel
Index: development/cmake/modules/LyXMacros.cmake
===
--- development/cmake/modules/LyXMacros.cmake	(Revision 38972)
+++ development/cmake/modules/LyXMacros.cmake	(Arbeitskopie)
@@ -108,7 +108,7 @@
 	#set(_moc ${_abs_PATH}/${_current_MOC})
 	add_custom_command(OUTPUT ${_moc}
 			  COMMAND ${QT_MOC_EXECUTABLE}
-			  ARGS ${_def} ${_moc_INCS} ${_header} -o ${_moc}
+			  ARGS "-DQT_VERSION=${QT4_VERSION}" ${_def} ${_moc_INCS} ${_header} -o ${_moc}
 			  MAIN_DEPENDENCY ${_header})
 	macro_add_file_dependencies(${_abs_FILE} ${_moc})
 	SET_SOURCE_FILES_PROPERTIES(${_moc} GENERATED)
Index: CMakeLists.txt
===
--- CMakeLists.txt	(Revision 38972)
+++ CMakeLists.txt	(Arbeitskopie)
@@ -616,6 +616,11 @@
 
 configure_file(${LYX_CMAKE_DIR}/config.h.cmake ${TOP_BINARY_DIR}/config.h)
 
+# Compute qt4-version from ${QTVERSION}
+if(QTVERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*")
+	MATH(EXPR QT4_VERSIONNUM "${CMAKE_MATCH_1}*1+${CMAKE_MATCH_2}*100+${CMAKE_MATCH_3}")
+	set(QT4_VERSION "0x${QT4_VERSIONNUM}")
+endif()
 
 add_subdirectory(src "${TOP_BINARY_DIR}/src")
 add_subdirectory(lib/lyx2lyx "${TOP_BINARY_DIR}/lyx2lyx")


signature.asc
Description: This is a digitally signed message part.


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-07 Thread Enrico Forestieri
On Tue, Jun 07, 2011 at 11:52:02AM +0200, Jean-Marc Lasgouttes wrote:
> Le 07/06/2011 09:01, Enrico Forestieri a écrit :
> >The moc doesn't have a definition of QT_VERSION, so the check
> >"#if QT_VERSION>= 0x040600" fails and you always get the "#else"
> >clause.
> 
> Here is my next try. Something similar will have to be done for
> cmake and scons.

I think this is not going to work. From what I see looking at qt4.m4,
QT4_VERSION contains the string version, i.e., 4.7.3 and not 0x040703.
So, either we extract the definition of QT_VERSION (rather than
QT_VERSION_STR) from qglobal.h or manipulate QT4_VERSION in order
to produce the right format.


> Index: src/frontends/qt4/Makefile.am
> ===
> --- src/frontends/qt4/Makefile.am (révision 38972)
> +++ src/frontends/qt4/Makefile.am (copie de travail)
> @@ -18,7 +18,7 @@
>  
>  # The moc_%.cpp pattern must match the filter in ../../../po/Rules-lyx
>  moc_%.cpp: %.h
> - $(AM_V_GEN)$(MOC4) -o $@ $<
> + $(AM_V_GEN)$(MOC4) -DQT_VERSION=$(QT4_VERSION) -o $@ $<
>  
>  Resources.qrc: Makefile
>   $(AM_V_GEN)echo "" > $@ ; \
> Index: src/frontends/qt4/FancyLineEdit.h
> ===
> --- src/frontends/qt4/FancyLineEdit.h (révision 38972)
> +++ src/frontends/qt4/FancyLineEdit.h (copie de travail)
> @@ -22,6 +22,7 @@
>  
>  class FancyLineEditPrivate;
>  
> +#if QT_VERSION >= 0x040600
>  class IconButton: public QAbstractButton
>  {
>   Q_OBJECT
> @@ -44,8 +45,8 @@
>  bool m_autoHide;
>  QPixmap m_pixmap;
>  };
> +#endif
>  
> -
>  /* A line edit with an embedded pixmap on one side that is connected to
>   * a menu. Additionally, it can display a grayed hintText (like "Type Here 
> to")
>   * when not focused and empty. When connecting to the changed signals and


-- 
Enrico


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-07 Thread Jean-Marc Lasgouttes

Le 07/06/2011 09:01, Enrico Forestieri a écrit :

The moc doesn't have a definition of QT_VERSION, so the check
"#if QT_VERSION>= 0x040600" fails and you always get the "#else"
clause.


Here is my next try. Something similar will have to be done for cmake 
and scons.


JMarc


Index: src/frontends/qt4/Makefile.am
===
--- src/frontends/qt4/Makefile.am	(révision 38972)
+++ src/frontends/qt4/Makefile.am	(copie de travail)
@@ -18,7 +18,7 @@
 
 # The moc_%.cpp pattern must match the filter in ../../../po/Rules-lyx
 moc_%.cpp: %.h
-	$(AM_V_GEN)$(MOC4) -o $@ $<
+	$(AM_V_GEN)$(MOC4) -DQT_VERSION=$(QT4_VERSION) -o $@ $<
 
 Resources.qrc: Makefile
 	$(AM_V_GEN)echo "" > $@ ; \
Index: src/frontends/qt4/FancyLineEdit.h
===
--- src/frontends/qt4/FancyLineEdit.h	(révision 38972)
+++ src/frontends/qt4/FancyLineEdit.h	(copie de travail)
@@ -22,6 +22,7 @@
 
 class FancyLineEditPrivate;
 
+#if QT_VERSION >= 0x040600
 class IconButton: public QAbstractButton
 {
 	Q_OBJECT
@@ -44,8 +45,8 @@
 bool m_autoHide;
 QPixmap m_pixmap;
 };
+#endif
 
-
 /* A line edit with an embedded pixmap on one side that is connected to
  * a menu. Additionally, it can display a grayed hintText (like "Type Here to")
  * when not focused and empty. When connecting to the changed signals and


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-07 Thread Enrico Forestieri
On Mon, Jun 06, 2011 at 08:20:41PM +0200, Vincent van Ravesteijn wrote:
> On 6-6-2011 17:53, lasgout...@lyx.org wrote:
> > Author: lasgouttes
> > Date: Mon Jun  6 17:53:43 2011
> > New Revision: 38969
> > URL: http://www.lyx.org/trac/changeset/38969
> > 
> > Log:
> > Revert r38963. Compilation is now broken with qt 4.5, but I do not know Qt 
> > moc business and do not have time to investigate.
> > 
> 
> 
> Moc doesn't work if the class is within #if's (a bit strange, but this
> seems to be the case). This means you can't put the whole class inside
> the #if because compilation with the newest Qt does not work. That's
> also the reason I moved the Q_SIGNAL definitions out of the #if clause.

The moc doesn't have a definition of QT_VERSION, so the check
"#if QT_VERSION >= 0x040600" fails and you always get the "#else"
clause. Indeed, launching LyX from a terminal, with Qt 4.7.3 one gets:

Object::connect: No such slot 
lyx::frontend::FancyLineEdit::checkButtons(QString) in 
../../../../src/frontends/qt4/FancyLineEdit.cpp:105
Object::connect: No such slot lyx::frontend::FancyLineEdit::iconClicked() in 
../../../../src/frontends/qt4/FancyLineEdit.cpp:106
Object::connect: No such slot lyx::frontend::FancyLineEdit::iconClicked() in 
../../../../src/frontends/qt4/FancyLineEdit.cpp:107

You have to pass a definition for QT_VERSION when calling moc:
moc -DQT_VERSION=...
otherwise it will not work.

-- 
Enrico


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-06 Thread Jean-Marc Lasgouttes

Le 06/06/11 20:20, Vincent van Ravesteijn a écrit :

Moc doesn't work if the class is within #if's (a bit strange, but this
seems to be the case). This means you can't put the whole class inside
the #if because compilation with the newest Qt does not work. That's
also the reason I moved the Q_SIGNAL definitions out of the #if clause.


OK.


Why did you also put the #ifs around the IconButton class. I can't see
why this class would not compile on older Qt's.


I get with current trunk

make[4]: entrant dans le répertoire « /home/local/lasgoutt/devbuild/src »
  CXXLD  lyx
frontends/qt4/liblyxqt4.a(FancyLineEdit.o):(.rodata._ZTVN3lyx8frontend10IconButtonE[vtable 
for lyx::frontend::IconButton]+0xf8): undefined reference to 
`lyx::frontend::IconButton::paintEvent(QPaintEvent*)'

collect2: ld returned 1 exit status

JMarc


Re: r38969 - lyx-devel/trunk/src/frontends/qt4

2011-06-06 Thread Vincent van Ravesteijn
On 6-6-2011 17:53, lasgout...@lyx.org wrote:
> Author: lasgouttes
> Date: Mon Jun  6 17:53:43 2011
> New Revision: 38969
> URL: http://www.lyx.org/trac/changeset/38969
> 
> Log:
> Revert r38963. Compilation is now broken with qt 4.5, but I do not know Qt 
> moc business and do not have time to investigate.
> 


Moc doesn't work if the class is within #if's (a bit strange, but this
seems to be the case). This means you can't put the whole class inside
the #if because compilation with the newest Qt does not work. That's
also the reason I moved the Q_SIGNAL definitions out of the #if clause.

The change in FancyLineEdit.cpp was ok, because one should not #include
. I fixed this in 38970.

Why did you also put the #ifs around the IconButton class. I can't see
why this class would not compile on older Qt's.

Vincent