[rkward-cvs] rkward/rkward/windows rkhtmlwindow.cpp,NONE,1.1 rkhtmlwindow.h,NONE,1.1 rkoutputwindow.rc,NONE,1.1 Makefile.am,1.5,1.6 rkhelpwindow.cpp,1.13,NONE rkhelpwindow.h,1.11,NONE rkhtmlwindowpart.cpp,1.2,NONE rkhtmlwindowpart.h,1.1,NONE rkhtmlwindowpart.rc,1.1,NONE
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Wed Oct 12 14:37:10 UTC 2005
Update of /cvsroot/rkward/rkward/rkward/windows
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30982/rkward/windows
Modified Files:
Makefile.am
Added Files:
rkhtmlwindow.cpp rkhtmlwindow.h rkoutputwindow.rc
Removed Files:
rkhelpwindow.cpp rkhelpwindow.h rkhtmlwindowpart.cpp
rkhtmlwindowpart.h rkhtmlwindowpart.rc
Log Message:
Rework HTML windows: Remove RKHelpWindow, RKHTMLWindowPart, replace with RKHTMLWindow, and two derived classes. Most code is copied unchanged, but the twisted logic previously used in RKHTMLWindowPart is cleaned.
--- rkhtmlwindowpart.rc DELETED ---
--- rkhelpwindow.h DELETED ---
--- NEW FILE: rkoutputwindow.rc ---
<!DOCTYPE kpartgui>
<kpartgui name="rkward" version="0.3.3">
<MenuBar>
<Menu name="output"><text>&Output</text>
<Separator/>
<Action name="output_refresh"/>
<Separator/>
<Action name="output_flush"/>
</Menu>
</kpartgui>
--- NEW FILE: rkhtmlwindow.cpp ---
/***************************************************************************
rkhtmlwindow - description
-------------------
begin : Wed Oct 12 2005
copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "rkhtmlwindow.h"
#include <khtmlview.h>
#include <khtml_part.h>
#include <klibloader.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kmessagebox.h>
#include <kparts/partmanager.h>
#include <qfile.h>
#include <qwidget.h>
#include <qlayout.h>
#include <qtimer.h>
#include "../rkglobals.h"
#include "../rkward.h"
#include "../settings/rksettingsmodulelogfiles.h"
#include "../debug.h"
RKHTMLWindow::RKHTMLWindow (QWidget *parent) : KMdiChildView (parent) {
scroll_position=0;
khtmlpart = new KHTMLPart (this,0,0,0,KHTMLPart::BrowserViewGUI);
khtmlpart->setSelectable (true);
khtmlpart->widget ()->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
QHBoxLayout *pLayout = new QHBoxLayout (this, 0, -1, "layout");
pLayout->addWidget (khtmlpart->widget());
// We have to connect this in order to allow browsing.
connect (khtmlpart->browserExtension (), SIGNAL(openURLRequest (const KURL &, const KParts::URLArgs &)), this, SLOT (slotOpenURLRequest (const KURL &, const KParts::URLArgs &)));
connect (khtmlpart, SIGNAL (completed ()), this, SLOT (loadDone ()));
}
RKHTMLWindow::~RKHTMLWindow () {
}
bool RKHTMLWindow::openURL (const KURL &url) {
bool ok = QFile (url.path ()).exists ();
if (!ok) return false;
khtmlpart->openURL (url);
updateCaption (url);
return true;
}
void RKHTMLWindow::updateCaption (const KURL &url) {
setMDICaption (url.filename ());
}
void RKHTMLWindow::slotOpenURLRequest(const KURL &url, const KParts::URLArgs & ) {
openURL (url);
}
void RKHTMLWindow::refresh () {
scroll_position = khtmlpart->view ()->contentsY ();
openURL (khtmlpart->url ());
}
void RKHTMLWindow::loadDone () {
khtmlpart->view()->setContentsPos (0, scroll_position);
}
//##################### BEGIN RKOutputWindow #####################
//static
RKOutputWindow* RKOutputWindow::current_output = 0;
RKOutputWindow::RKOutputWindow (QWidget *parent) : RKHTMLWindow (parent), KXMLGUIClient () {
RK_TRACE (APP);
KInstance* instance = new KInstance ("rkward");
setInstance (instance);
setXMLFile ("rkoutputwindow.rc");
khtmlpart->insertChildClient (this);
setIcon (SmallIcon ("text_block"));
setMDICaption (i18n ("Output"));
RKGlobals::rkApp ()->addWindow (this);
outputFlush = new KAction (i18n ("&Flush"), 0, 0, this, SLOT (flushOutput ()), actionCollection (), "output_flush");
outputRefresh = new KAction (i18n ("&Refresh"), 0, 0, this, SLOT (refreshOutput ()), actionCollection (), "output_refresh");
RKGlobals::rkApp ()->m_manager->addPart (khtmlpart);
}
RKOutputWindow::~RKOutputWindow () {
RK_TRACE (APP);
if (this == current_output) {
current_output = 0;
}
}
bool RKOutputWindow::openURL (const KURL &url) {
RK_TRACE (APP);
bool ok = RKHTMLWindow::openURL (url);
if (!ok) {
showOutputEmptyMessage ();
}
return ok;
}
void RKOutputWindow::updateCaption (const KURL &) {
}
void RKOutputWindow::refresh () {
scroll_position = khtmlpart->view ()->contentsHeight ();
openURL (khtmlpart->url ());
}
//static
void RKOutputWindow::refreshOutput (bool show, bool raise) {
RK_TRACE (APP);
if (current_output) {
if (raise) {
current_output->activate ();
}
current_output->refresh ();
} else {
if (show) {
// getCurrentOutput creates an output window
getCurrentOutput ();
}
}
}
//static
RKOutputWindow* RKOutputWindow::getCurrentOutput () {
RK_TRACE (APP);
if (!current_output) {
current_output = new RKOutputWindow (RKGlobals::rkApp ());
KURL url (RKSettingsModuleLogfiles::filesPath () + "/rk_out.html");
current_output->openURL (url);
}
return current_output;
}
void RKOutputWindow::flushOutput () {
RK_TRACE (APP);
int res = KMessageBox::questionYesNo (this, i18n ("Do you really want to flush the ouput? It won't be possible to restore it."), i18n ("Flush output?"));
if (res==KMessageBox::Yes) {
QFile out_file (RKSettingsModuleLogfiles::filesPath () + "/rk_out.html");
out_file.remove ();
refreshOutput (false, false);
}
}
void RKOutputWindow::refreshOutput () {
RK_TRACE (APP);
refreshOutput (true, true);
}
void RKOutputWindow::showOutputEmptyMessage () {
khtmlpart->begin();
khtmlpart->write (i18n ("<HTML><BODY><H1>RKWard output</H1>\n<P>The output is empty.</P>\n</BODY></HTML>"));
khtmlpart->end();
}
//#################### END RKOutputWindow ##########################
//#################### BEGIN RKHelpWindow ##########################
RKHelpWindow::RKHelpWindow (QWidget *parent) : RKHTMLWindow (parent), KXMLGUIClient () {
RK_TRACE (APP);
/* KInstance* instance = new KInstance ("rkward");
setInstance (instance);
setXMLFile ("rkhelpwindow.rc"); // TODO: create .rc-file
khtmlpart->insertChildClient (this); */
setIcon (SmallIcon ("help"));
setMDICaption (i18n ("R Help"));
RKGlobals::rkApp ()->addWindow (this);
RKGlobals::rkApp ()->m_manager->addPart (khtmlpart);
}
RKHelpWindow::~RKHelpWindow () {
RK_TRACE (APP);
}
#include "rkhtmlwindow.moc"
--- rkhtmlwindowpart.cpp DELETED ---
--- rkhelpwindow.cpp DELETED ---
--- rkhtmlwindowpart.h DELETED ---
Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/windows/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile.am 15 Sep 2005 21:03:27 -0000 1.5
--- Makefile.am 12 Oct 2005 14:37:07 -0000 1.6
***************
*** 2,9 ****
METASOURCES = AUTO
noinst_LIBRARIES = libwindows.a
! noinst_HEADERS = rkcommandeditorwindow.h rkhelpwindow.h \
! rkcommandeditorwindowpart.h rkhtmlwindowpart.h
! libwindows_a_SOURCES = rkcommandeditorwindow.cpp rkhelpwindow.cpp \
! rkcommandeditorwindowpart.cpp rkhtmlwindowpart.cpp
rcdir = $(kde_datadir)/rkward
! rc_DATA = rkcommandeditorwindowpart.rc rkhtmlwindowpart.rc
--- 2,7 ----
METASOURCES = AUTO
noinst_LIBRARIES = libwindows.a
! noinst_HEADERS = rkcommandeditorwindow.h rkcommandeditorwindowpart.h rkhtmlwindow.h
! libwindows_a_SOURCES = rkcommandeditorwindow.cpp rkcommandeditorwindowpart.cpp rkhtmlwindow.cpp
rcdir = $(kde_datadir)/rkward
! rc_DATA = rkcommandeditorwindowpart.rc rkoutputwindow.rc
--- NEW FILE: rkhtmlwindow.h ---
/***************************************************************************
rkhtmlwindow - description
-------------------
begin : Wed Oct 12 2005
copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKHTMLWINDOW_H
#define RKHTMLWINDOW_H
#include <kurl.h>
#include <kparts/browserextension.h>
#include <kmdichildview.h>
#include <kxmlguiclient.h>
class KHTMLPart;
/**
\brief Show html files.
This class wraps a khtml part.
It is used as a base for several purposes: Display R-help (in HTML format), display generic HTML, display RKWard output. Do not use this class directly. Use the derived classes instead.
@author Pierre Ecochard
*/
class RKHTMLWindow : public KMdiChildView {
Q_OBJECT
protected:
RKHTMLWindow (QWidget *parent = 0);
virtual ~RKHTMLWindow ();
public:
virtual bool openURL (const KURL &url);
/** Reload current page.*/
virtual void refresh ();
public slots:
/** this is used for browsing only. Use openURL instead, when calling from outside. */
void slotOpenURLRequest (const KURL &url, const KParts::URLArgs &);
private slots:
/** This slot is called when the new page has finished loading. Sets scroll position to scroll_position */
void loadDone ();
protected:
/** Here we store the position of the scroll bar before refresh. Used to scroll to the same position after a reload */
int scroll_position;
KHTMLPart * khtmlpart;
/** update caption according to given URL */
virtual void updateCaption (const KURL &url);
};
/**
\brief RKWard output window.
Used to display RKWard output.
@author Thomas Friedrichsmeier
*/
class RKOutputWindow : public RKHTMLWindow, public KXMLGUIClient {
Q_OBJECT
public:
RKOutputWindow (QWidget *parent = 0);
~RKOutputWindow ();
/** reimplemented to show "output is empty" message, if file could not be opened */
bool openURL (const KURL &url);
/** reimplemented to scroll to the bottom of the page */
void refresh ();
static void refreshOutput (bool show, bool raise);
static RKOutputWindow* getCurrentOutput ();
public slots:
void flushOutput ();
void refreshOutput ();
protected:
/** reimplemented to never change the caption (it's always "Output") */
void updateCaption (const KURL &url);
private:
void showOutputEmptyMessage ();
KAction* outputFlush;
KAction* outputRefresh;
static RKOutputWindow* current_output;
};
/**
\brief Show html help files.
This class wraps a khtml part.
Specialized HTML window for displaying R help pages
@author Pierre Ecochard
*/
class RKHelpWindow : public RKHTMLWindow, public KXMLGUIClient {
public:
RKHelpWindow (QWidget *parent = 0);
~RKHelpWindow ();
};
#endif
More information about the rkward-tracker
mailing list