[bt-devel] BibleTime 1.5.2 won't compile with KDE < 3.3
Jeremy Erickson
jerickson314 at users.sourceforge.net
Fri Oct 21 22:12:09 MST 2005
I had even more fixes needed for CentOS/RHEL 3 (KDE 3.1 and Qt 3.1).
Following my message is the complete patch I needed. It uses the preprocessor
to check versions, so the same patched code creates a working binary on a
newer system, as we are planning for 1.5.3. I didn't look too much at the
context of the code, but attempted to write code that was logically equivalent
using the older API. I tested on CentOS 3 and FC3, and both worked as
expected to the degree I tested. I basically just made sure everything ran,
though. Anyway, hopefully the patch will be helpful. It can probably be merged
for 1.5.3, hopefully with a better fix for the "Find" menu option.
-Jeremy Erickson
<patch begins>
diff -ur bibletime-orig/bibletime.cpp bibletime/bibletime.cpp
--- bibletime-orig/bibletime.cpp 2005-09-10 03:19:42.000000000 -0500
+++ bibletime/bibletime.cpp 2005-10-21 23:17:36.000000000 -0500
@@ -32,6 +32,7 @@
#include <qsplitter.h>
//KDE includes
+#include <kdeversion.h>
#include <kaction.h>
#include <kapplication.h>
#include <kconfig.h>
@@ -44,7 +45,11 @@
BibleTime::BibleTime()
: BibleTimeInterface("BibleTimeInterface"),
+#if KDE_VERSION >= 0x030200
KMainWindow(KMainWindow::NoDCOPObject, 0,0, WType_TopLevel),
+#else
+KMainWindow(0,0, WType_TopLevel),
+#endif
m_windowActionCollection(0),
m_initialized(false),
m_moduleList(0),
diff -ur bibletime-orig/bibletime_slots.cpp bibletime/bibletime_slots.cpp
--- bibletime-orig/bibletime_slots.cpp 2005-09-10 10:31:03.000000000 -0500
+++ bibletime/bibletime_slots.cpp 2005-10-21 22:41:14.000000000 -0500
@@ -159,11 +159,19 @@
slotUpdateWindowArrangementActions(0); //update the window tile/cascade states
m_windowCloseAll_action->setEnabled( true );
}
-
+
+#if QT_VERSION >= 0x030200
QPtrList<KAction>::iterator end = m_windowOpenWindowsList.end();
for (QPtrList<KAction>::iterator it = m_windowOpenWindowsList.begin(); it != end; ++it ) {
(*it)->unplugAll();
}
+#else
+ QPtrListIterator<KAction> it(m_windowOpenWindowsList);
+ while (it.current() != 0){
+ it.current()->unplugAll();
+ ++it;
+ }
+#endif
m_windowOpenWindowsList.setAutoDelete(true);
m_windowOpenWindowsList.clear();
diff -ur bibletime-orig/frontend/cbtconfig.cpp bibletime/frontend/cbtconfig.cpp
--- bibletime-orig/frontend/cbtconfig.cpp 2005-10-15 08:06:02.000000000 -0500
+++ bibletime/frontend/cbtconfig.cpp 2005-10-21 23:17:19.000000000 -0500
@@ -16,8 +16,13 @@
#include <qmap.h>
//KDE includes
+#include <kdeversion.h>
#include <kapplication.h>
+#if KDE_VERSION >= 0x030200
#include <kactioncollection.h>
+#else
+#include <kaction.h>
+#endif
#include <kconfig.h>
#include <kcharsets.h>
#include <kglobal.h>
diff -ur bibletime-orig/frontend/cmdiarea.cpp bibletime/frontend/cmdiarea.cpp
--- bibletime-orig/frontend/cmdiarea.cpp 2005-09-12 07:37:00.000000000 -0500
+++ bibletime/frontend/cmdiarea.cpp 2005-10-21 22:49:49.000000000 -0500
@@ -19,6 +19,10 @@
#include <qtimer.h>
#include <qevent.h>
#include <qtimer.h>
+#if QT_VERSION < 0x030200
+//We need this to close all windows with Qt < 3.2
+#include <qwidgetlist.h>
+#endif
CMDIArea::CMDIArea(QWidget *parent, const char *name )
@@ -116,7 +120,15 @@
/** Deletes all the presenters in the MDI area. */
void CMDIArea::deleteAll() {
+#if QT_VERSION >= 0x030200
closeAllWindows();
+#else
+ QWidgetListIt it(windowList());
+ while (it.current() != 0){
+ it.current()->close();
+ ++it;
+ }
+#endif
}
/** Enable / disable autoCascading */
@@ -279,6 +291,7 @@
QWidget* w = dynamic_cast<QWidget*>( o );
bool ret = QWorkspace::eventFilter(o,e);
+#if QT_VERSION >= 0x030300
if ( w && (e->type() == QEvent::WindowStateChange) ) {
if (o->inherits("CDisplayWindow") && ((w->windowState() & Qt::WindowMinimized) || w->isHidden())) { //window was minimized, trigger a tile/cascade update if necessary
triggerWindowUpdate();
@@ -290,7 +303,20 @@
o->dumpObjectTree();
}
}
-
+#else
+ if (w && o->inherits("CDisplayWindow")){
+ if ((e->type() == QEvent::ShowMinimized) ||
+ (e->type() == QEvent::Hide)){
+ triggerWindowUpdate();
+ ret = false;
+ }
+ }
+ else if (!o->inherits("CDisplayWindow")){
+ qDebug("bad mdi child classname: %s", o->className());
+ o->dumpObjectInfo();
+ o->dumpObjectTree();
+ }
+#endif
return ret; // standard event processing
}
diff -ur bibletime-orig/frontend/coptionsdialog.cpp bibletime/frontend/coptionsdialog.cpp
--- bibletime-orig/frontend/coptionsdialog.cpp 2005-10-05 05:19:37.000000000 -0500
+++ bibletime/frontend/coptionsdialog.cpp 2005-10-21 23:30:48.000000000 -0500
@@ -968,11 +968,31 @@
list.append(m_settings.keys.book.keyChooser);
//commit all changes in the keychoosers
+#if QT_VERSION >= 0x030200
for (KeyChooserList::iterator it(list.begin()); it != list.end(); ++it) {
if (*it) { //the list may contain NULL pointers
(*it)->commitChanges();
}
}
+#else
+ //Normally we know a QPtrListIterator is done when it.current() == 0
+ //but now a value can actually be zero, which would be
+ //indistinguishable from the end condition.
+ //Therefore, more complex logic is needed.
+ QPtrListIterator<KKeyChooser> it(list);
+ if (!it.isEmpty()){
+ while (!it.atLast()){
+ if (it.current()){
+ it.current()->commitChanges();
+ }
+ ++it;
+ }
+ //We still have the last item to process.
+ if (it.current()){
+ it.current()->commitChanges();
+ }
+ }
+#endif
/* Delete all the keychoosers in the list,
* the keychoosers are set to NULL, because they are QGuardedPtr
*/
diff -ur bibletime-orig/frontend/cswordsetupmodulelistview.cpp bibletime/frontend/cswordsetupmodulelistview.cpp
--- bibletime-orig/frontend/cswordsetupmodulelistview.cpp 2005-10-03 15:26:39.000000000 -0500
+++ bibletime/frontend/cswordsetupmodulelistview.cpp 2005-10-21 22:59:25.000000000 -0500
@@ -94,7 +94,7 @@
}
void CSwordSetupModuleListView::init() {
-#if QT_VERSION >= 320
+#if QT_VERSION >= 0x030200
m_categoryBible = new QCheckListItem(this, i18n("Bibles"), QCheckListItem::CheckBoxController);
m_categoryCommentary = new QCheckListItem(this, i18n("Commentaries"), QCheckListItem::CheckBoxController);
m_categoryLexicon = new QCheckListItem(this, i18n("Lexicons"), QCheckListItem::CheckBoxController);
@@ -200,7 +200,7 @@
}
if (!langFolder) { //not yet there
-#if QT_VERSION >= 320
+#if QT_VERSION >= 0x030200
langFolder = new QCheckListItem(parent, langName, QCheckListItem::CheckBoxController);
#else
diff -ur bibletime-orig/frontend/display/chtmlreaddisplay.cpp bibletime/frontend/display/chtmlreaddisplay.cpp
--- bibletime-orig/frontend/display/chtmlreaddisplay.cpp 2005-10-07 12:09:01.000000000 -0500
+++ bibletime/frontend/display/chtmlreaddisplay.cpp 2005-10-21 23:18:52.000000000 -0500
@@ -15,6 +15,9 @@
#include "util/cpointers.h"
#include "util/scoped_resource.h"
+//We will need to reference this in the Qt includes
+#include <kdeversion.h>
+
//Qt includes
#include <qcursor.h>
#include <qscrollview.h>
@@ -23,6 +26,10 @@
#include <qpopupmenu.h>
#include <qlayout.h>
#include <qtimer.h>
+#if KDE_VERSION < 0x030300
+//We will need to show the error message.
+#include <qmessagebox.h>
+#endif
//KDE includes
#include <kapplication.h>
@@ -447,5 +454,14 @@
}
void CHTMLReadDisplay::openFindTextDialog() {
+#if KDE_VERSION >= 0x030300
findText();
+#else
+ QMessageBox::information(0, "Not Supported",
+ "This copy of BibleTime was built against a version of KDE older\n"
+ "than 3.3 (probably due to your distro), so this search feature\n"
+ "does not work.\n\n"
+ "This is a known issue. If we do not have a fix for the next\n"
+ "version of BibleTime, we will remove the option.");
+#endif
}
diff -ur bibletime-orig/frontend/displaywindow/cdisplaywindow.cpp bibletime/frontend/displaywindow/cdisplaywindow.cpp
--- bibletime-orig/frontend/displaywindow/cdisplaywindow.cpp 2005-10-07 11:38:30.000000000 -0500
+++ bibletime/frontend/displaywindow/cdisplaywindow.cpp 2005-10-21 23:20:11.000000000 -0500
@@ -33,6 +33,7 @@
//Qt includes
//KDE includes
+#include <kdeversion.h>
#include <kaccel.h>
#include <klocale.h>
@@ -65,7 +66,11 @@
}
CDisplayWindow::CDisplayWindow(ListCSwordModuleInfo modules, CMDIArea *parent, const char *name )
+#if KDE_VERSION >= 0x030200
: KMainWindow(KMainWindow::NoDCOPObject, parent, name, WDestructiveClose),
+#else
+: KMainWindow(parent, name, WDestructiveClose),
+#endif
m_mdi(parent),
// m_modules(modules),
m_filterOptions(),
More information about the bt-devel
mailing list