--nextPart2052587.ctYcBN4qSW
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8Bit

Wilfried Huss wrote:
> But if you are only interested in an DVI-viewer you could remove the
> whole plugin code and link the DVI part directly. The rest is more or
> less normal Qt code.
>
> You probably should first try to inherit the KMultiPage-class from
> QWidget instead of KParts::ReadOnlyPart,


Hi, Wilfried. Apologies for the delay but I'mm now addressing this. I have
a KMultipage that derives only from QWidget. I've got it to compile by
adding those KParts::ReadOnlyPart members that the compiler complained
were missing. In the future, I guess I'll be looking to strip it down
further, but, for now, compilation is my goal.

I have a question about the (undocumented) contructor:

KMultiPage::KMultiPage(QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name);

what's the difference bwtween "parentWidget" and "parent"? I've done as you
have done, passing "parent" to the derived-from class (here QWidget) and
using parentWidget in the KMultiPage c-tor, but it would be nice to know
what I'm doing ;-)

> than you can replace the KPart
> initialization in kviewpart.cpp (line 80-155) with a simple
> multiPage = new KDVIMultiPage(...);


Ok. However, to resolve some further compiler errors I had to create:
QWidget *widget() { return 0; }
The real function is defined in KParts::ReadOnlyPart to return m_widget. On
initial construction of the KMultiPage, m_widget is zero. So, dumm
question X: do I need it, or am I on the right track?

Current diff attached. The code here compiles but libkviewshell.a does not
link because I haven't defined KDVIMultiPageFactory.

I guess that I'll have to move KMultiPage into the kdvi directory. If I'm
deriving from QWidget, do I need KViewPart at all? Shouldn't I be just
creating a KDVIMultiPage in my main.cpp?

Angus

ps. I'm a svn newbie. Is there any way to tell "svn diff" to ignore
whitespace changes in a file? The equivalent of "cvs diff -Bbw file.cpp".
I have tried "svn help diff" but neither
$ svn diff -x "-Bbw"
$ svn diff --diff-cmd "diff -u -Bbw"
work.

pps. Should we continue this conversation on the mailing list or in
private?

A.

--nextPart2052587.ctYcBN4qSW
Content-Type: text/x-diff; name="angus_1.diff"
Content-Transfer-Encoding: 8Bit
Content-Disposition: attachment; filename="angus_1.diff"

Index: kmultipage.cpp
================================================== =================
--- kmultipage.cpp (revision 438868)
+++ kmultipage.cpp (working copy)
@@ -28,25 +28,19 @@
#include "searchWidget.h"
#include "zoomlimits.h"

+#include

//#define DEBUG_KMULTIPAGE

KMultiPage::KMultiPage(QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name)
- : DCOPObject("kmultipage"), KParts::ReadOnlyPart(parent, name)
+ : QWidget(parent, name)
{
- // For reasons which I don't understand, the initialization of the
- // DCOPObject above does not work properly, the name is ignored. It
- // works fine if we repeat the name here. -- Stefan Kebekus
- // This is because of the virtual inheritance. Get rid of it (but it's BC, and this is a lib...) -- DF
- setObjId("kmultipage");
-
parentWdg = parentWidget;
lastCurrentPage = 0;
timer_id = -1;
searchInProgress = false;

QVBox* verticalBox = new QVBox(parentWidget);
- setWidget(verticalBox);

splitterWidget = new QSplitter(verticalBox, widgetName);
splitterWidget->setOpaqueResize(false);
@@ -163,6 +157,31 @@
}


+bool KMultiPage:penURL( const KURL &url )
+{
+ if ( !url.isValid() )
+ return false;
+ if ( !closeURL() )
+ return false;
+ m_url = url;
+ if ( m_url.isLocalFile() )
+ {
+ emit started( 0 );
+ m_file = m_url.path();
+ bool ret = openFile();
+ if (ret)
+ {
+ emit completed();
+ emit setWindowCaption( m_url.prettyURL() );
+ };
+ return ret;
+ }
+ else
+ {
+ std::assert(false);
+ }
+}
+
bool KMultiPage::closeURL()
{
#ifdef DEBUG_KMULTIPAGE
Index: kmultipage.h
================================================== =================
--- kmultipage.h (revision 438868)
+++ kmultipage.h (working copy)
@@ -40,7 +40,8 @@
*/

// TODO remove virtual inheritance for KDE 4. It's the reason for the strange DCOPObject construction
-class KMultiPage : public KParts::ReadOnlyPart, virtual public kmultipageInterface
+
+class KMultiPage : public QWidget
{
Q_OBJECT

@@ -65,6 +66,12 @@
kmultipage. This method checks if a given file is loaded. */
bool is_file_loaded(QString filename);

+ /**
+ * Copied from KParts::ReadOnlyPart. Here is always zero.
+ * @return The widget defined by this part, set by setWidget().
+ */
+ virtual QWidget *widget() { return 0; }
+
/** Prints a document

This method prints a document. The default implementation offers
@@ -293,10 +300,27 @@
the userPreferredSize is returned. */
virtual SimplePageSize sizeOfPage(PageNumber page = 1) const { return pageCache->sizeOfPage(page); };

+ /**
+ * Returns the currently in part used URL.
+ *
+ * @return The current used URL.
+ */
+ KURL url() const { return m_url; }
+
public slots:
/* Sets the userPreferredSize, which is explained below */
virtual void setUserPreferredSize(SimplePageSize t) { pageCache->setUserPreferredSize(t); };
virtual void setUseDocumentSpecifiedSize(bool b) { pageCache->setUseDocumentSpecifiedSize(b); };
+
+ /**
+ * Only reimplement openURL if you don't want synchronous network transparency
+ * Otherwise, reimplement openFile() only .
+ *
+ * If you reimplement it, don't forget to set the caption, usually with
+ * emit setWindowCaption( url.prettyURL() );
+ */
+ virtual bool openURL( const KURL &url );
+
// --------------------------------------------------------------------

protected:
@@ -505,6 +529,32 @@

void searchEnabled(bool);

+ /**
+ * The part emits this when starting data.
+ * If using a KIO::Job, it sets the job in the signal, so that
+ * progress information can be shown. Otherwise, job is 0.
+ **/
+ void started( KIO::Job * );
+
+ /**
+ * Emit this when you have completed loading data.
+ * Hosting apps will want to know when the process of loading the data
+ * is finished, so that they can access the data when everything is loaded.
+ **/
+ void completed();
+
+ /**
+ * Emitted by the part, to set the caption of the window(s)
+ * hosting this part
+ */
+ void setWindowCaption( const QString & caption );
+
+ /**
+ * Emited by the part, to set a text in the statusbar of the window(s)
+ * hosting this part
+ */
+ void setStatusBarText( const QString & text );
+
// Interface definition end --------------------------------------------------

public slots:
@@ -620,6 +670,15 @@
// This is set to true while a text search is performed.
// If set to false the search is interrupted.
bool searchInProgress;
+
+ /**
+ * Local file - the only one the part implementation should deal with.
+ */
+ QString m_file;
+ /**
+ * Remote (or local) url - the one displayed to the user.
+ */
+ KURL m_url;
};


Index: kviewpart.cpp
================================================== =================
--- kviewpart.cpp (revision 438868)
+++ kviewpart.cpp (working copy)
@@ -50,6 +50,14 @@

#include "kvsprefs.h"

+#if ! defined (DERIVED_FROM_KPART_READONLYPART)
+
+KMultiPage * KDVIMultiPageFactory(QWidget *parentWidget,
+ const char *widgetName,
+ QObject *parent,
+ const char *name);
+#endif
+
#define MULTIPAGE_VERSION 1

typedef KParts::GenericFactory KViewPartFactory;
@@ -78,6 +86,10 @@

// create the displaying part

+#if ! defined (DERIVED_FROM_KPART_READONLYPART)
+ multiPage = KDVIMultiPageFactory(parentWidget, widgetName, parent, name);
+
+#else
// Search for service
KTrader::OfferList offers;

@@ -153,6 +165,8 @@
}
// Remember the name of the library.
multiPageLibrary = service->library();
+#endif // DERIVED_FROM_KPART_READONLYPART
+
mainLayout->addWidget(multiPage->widget());

// edit menu
@@ -344,9 +358,11 @@
connect(multiPage, SIGNAL(searchEnabled(bool)), findNextAction, SLOT(setEnabled(bool)));
connect(multiPage, SIGNAL(searchEnabled(bool)), findPrevAction, SLOT(setEnabled(bool)));

+#if defined (DERIVED_FROM_KPART_READONLYPART)
// allow parts to have a GUI, too :-)
// (will be merged automatically)
insertChildClient( multiPage );
+#endif
}

void KViewPart::slotStartFitTimer()
@@ -717,7 +733,9 @@

// Remove the old MultiPage.
mainLayout->remove(multiPage->widget());
+#if defined (DERIVED_FROM_KPART_READONLYPART)
removeChildClient(multiPage);
+#endif
delete multiPage;

// This fixes the crash when we are unloading the dvi plugin. I'm not sure why.
@@ -725,9 +743,12 @@

// Try to load the multiPage
int error;
+#if ! defined (DERIVED_FROM_KPART_READONLYPART)
+ multiPage = 0;
+#else
multiPage = static_cast(KParts::ComponentFactory::createInstanceFromServi ce(service, mainWidget,
service->name().utf8(), QStringList(), &error ));
-
+#endif

if (multiPage == 0) {
QString reason;

--nextPart2052587.ctYcBN4qSW
Content-Type: text/plain; charset="iso-8859-1"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

=

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscrib=

e <<

--nextPart2052587.ctYcBN4qSW--