[rkward-cvs] SF.net SVN: rkward:[2501] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Tue May 26 11:54:31 UTC 2009
Revision: 2501
http://rkward.svn.sourceforge.net/rkward/?rev=2501&view=rev
Author: tfry
Date: 2009-05-26 11:54:31 +0000 (Tue, 26 May 2009)
Log Message:
-----------
Fix output window refresh. This is also a further small step towards supporting more than one output window.
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/rbackend/rinterface.cpp
trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R
trunk/rkward/rkward/rbackend/rthread.cpp
trunk/rkward/rkward/rbackend/rthread.h
trunk/rkward/rkward/rkward.cpp
trunk/rkward/rkward/windows/rkhtmlwindow.cpp
trunk/rkward/rkward/windows/rkhtmlwindow.h
trunk/rkward/rkward/windows/rkworkplace.cpp
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2009-05-25 20:53:22 UTC (rev 2500)
+++ trunk/rkward/ChangeLog 2009-05-26 11:54:31 UTC (rev 2501)
@@ -5,7 +5,7 @@
- Add option to add only single line commands from script editor to the console history
- Add action to change working directory to that of the current script file
- Fixed: No warning was shown, when an open script file was changed on disk, externally
-- Fixed: Opening most file types (e.g. PDF) from the help browser was broken TODO: output refresh is somewhat broken, now
+- Fixed: Opening most file types (e.g. PDF) from the help browser was broken
- Fixed: Make built-in editor work again for file.edit ()
- (Almost) all plugins now write a header to the output window TODO: work in progress; which ones should not?
- Add convenience function "makeHeaderCode()" for use inside plugins TODO: document, adjust for tests (->rk.describe.alternative())
Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp 2009-05-25 20:53:22 UTC (rev 2500)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp 2009-05-26 11:54:31 UTC (rev 2501)
@@ -186,11 +186,6 @@
}
}
command->finished ();
- if (command->type () & RCommand::DirectToOutput) {
- RKWorkplace::mainWorkplace ()->refreshOutputWindow ();
- } else if (command->type () & RCommand::User) {
- RKWorkplace::mainWorkplace ()->refreshOutputWindow ();
- }
delete command;
} else if ((ev->etype () == RKRBackendEvent::RIdle)) {
RKWardMainWindow::getMain ()->setRStatus (RKWardMainWindow::Idle);
@@ -314,6 +309,10 @@
} else {
issueCommand (".rk.set.reply (\"Too few arguments in call to get.tempfile.name.\")", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain);
}
+ } else if (call == "refreshOutput") {
+ RK_ASSERT (request->call.count () == 2); //but we don't use the second parameter, yet
+
+ RKWorkplace::mainWorkplace ()->refreshOutputWindow ();
} else if (call == "sync") {
RK_ASSERT (request->call.count () >= 2);
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R 2009-05-25 20:53:22 UTC (rev 2500)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R 2009-05-26 11:54:31 UTC (rev 2501)
@@ -110,6 +110,7 @@
"rk.set.output.html.file" <- function (x) {
stopifnot (is.character (x))
+ .rk.do.call ("set.output.file", x);
assign (".rk.output.html.file", x, as.environment ("package:rkward"))
}
Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp 2009-05-25 20:53:22 UTC (rev 2500)
+++ trunk/rkward/rkward/rbackend/rthread.cpp 2009-05-26 11:54:31 UTC (rev 2501)
@@ -32,6 +32,7 @@
#include <qapplication.h>
#include <QDBusConnection>
#include <QList>
+#include <QFileInfo>
#include <signal.h> // needed for pthread_kill
#include <pthread.h> // seems to be needed at least on FreeBSD
@@ -226,6 +227,11 @@
RK_ASSERT (!error);
}
}
+ if (!(command->type () & RCommand::Sync)) {
+ MUTEX_UNLOCK;
+ checkNotifyOutputTouched ();
+ MUTEX_LOCK;
+ }
if (error) {
RK_DO (qDebug ("- error message was: '%s'", command->error ().toLatin1 ().data ()), RBACKEND, dl);
@@ -372,6 +378,18 @@
MUTEX_UNLOCK;
}
+void RThread::checkNotifyOutputTouched () {
+ RK_TRACE (RBACKEND);
+
+ QFileInfo info (active_output_file);
+ if (info.exists ()) {
+ if ((!output_last_modified.isValid ()) || (output_last_modified < info.lastModified ())) {
+ output_last_modified = info.lastModified ();
+ handleSubstackCall (QStringList () << "refreshOutput" << active_output_file);
+ }
+ }
+}
+
void RThread::handleSubstackCall (QStringList &call) {
RK_TRACE (RBACKEND);
@@ -382,6 +400,11 @@
if (!changed_symbol_names.contains (call[1])) changed_symbol_names.append (call[1]);
}
return;
+ } else if (call[0] == "set.output.file") {
+ checkNotifyOutputTouched ();
+ active_output_file = call[1];
+ output_last_modified = QFileInfo (active_output_file).lastModified ();
+ return;
}
}
Modified: trunk/rkward/rkward/rbackend/rthread.h
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.h 2009-05-25 20:53:22 UTC (rev 2500)
+++ trunk/rkward/rkward/rbackend/rthread.h 2009-05-26 11:54:31 UTC (rev 2501)
@@ -21,6 +21,7 @@
#include <qstringlist.h>
#include <QList>
#include <QEvent>
+#include <QDateTime>
#include "rcommand.h"
#include "rcommandstack.h"
@@ -195,6 +196,7 @@
/** This is the function in which an RCommand actually gets processed. Basically it passes the command to REmbedInteranl::runCommandInternal () and sends RInterface some events about what is currently happening. */
void doCommand (RCommand *command);
void notifyCommandDone (RCommand *command);
+ void checkNotifyOutputTouched ();
/** thread is locked. No new commands will be executed. @see LockType @see lock @see unlock */
int locked;
/** thread is killed. Should exit as soon as possible. @see kill */
@@ -211,6 +213,9 @@
/** check wether the object list / global environment / individual symbols have changed, and updates them, if needed */
void checkObjectUpdatesNeeded (bool check_list);
QList<RCommand*> all_current_commands;
+
+ QString active_output_file;
+ QDateTime output_last_modified;
};
#endif
Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp 2009-05-25 20:53:22 UTC (rev 2500)
+++ trunk/rkward/rkward/rkward.cpp 2009-05-26 11:54:31 UTC (rev 2501)
@@ -243,8 +243,6 @@
setUpdatesEnabled (true);
show ();
- RKHTMLWindow::initializeOutputWindow ();
-
if (!open_url.isEmpty()) {
openWorkspace (open_url);
} else {
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2009-05-25 20:53:22 UTC (rev 2500)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2009-05-26 11:54:31 UTC (rev 2501)
@@ -48,7 +48,6 @@
//static
RKHTMLWindow* RKHTMLWindow::current_output = 0;
-QDateTime RKHTMLWindow::last_refresh_time;
RKHTMLWindow::RKHTMLWindow (QWidget *parent, WindowMode mode) : RKMDIWindow (parent, RKMDIWindow::HelpWindow) {
RK_TRACE (APP);
@@ -100,13 +99,6 @@
RKCommonFunctions::removeContainers (khtmlpart, QString ("tools,security,extraToolBar,saveBackground,saveFrame,printFrame,kget_menu").split (','), true);
}
-// static
-void RKHTMLWindow::initializeOutputWindow () {
- RK_TRACE (APP);
-
- last_refresh_time = QDateTime::currentDateTime ();
-}
-
QString RKHTMLWindow::getDescription () {
RK_TRACE (APP);
@@ -277,7 +269,6 @@
bool ok = out_file.exists();
if (ok) {
khtmlpart->openUrl (url);
- last_refresh_time = out_file.lastModified ();
} else {
fileDoesNotExistMessage ();
}
@@ -327,15 +318,19 @@
args.setReload (true); // this forces the next openURL to reload all images
khtmlpart->setArguments (args);
- if (window_mode == HTMLOutputWindow) scroll_position = khtmlpart->view ()->contentsHeight ();
- else scroll_position = khtmlpart->view ()->contentsY ();
+ scroll_position = khtmlpart->view ()->contentsY ();
openURL (current_url);
}
void RKHTMLWindow::loadDone () {
RK_TRACE (APP);
- if (scroll_position >= 0) khtmlpart->view()->setContentsPos (0, scroll_position);
+
+ if (window_mode == HTMLOutputWindow) { // scroll to bottom
+ khtmlpart->view ()->setContentsPos (0, khtmlpart->view ()->contentsHeight ());
+ } else { // scroll to previous pos
+ if (scroll_position >= 0) khtmlpart->view()->setContentsPos (0, scroll_position);
+ }
}
//static
@@ -353,14 +348,9 @@
}
//static
-RKHTMLWindow* RKHTMLWindow::refreshOutput (bool show, bool raise, bool only_if_modified) {
+RKHTMLWindow* RKHTMLWindow::refreshOutput (bool show, bool raise) {
RK_TRACE (APP);
- if (only_if_modified) {
- QFileInfo out_file (RKSettingsModuleGeneral::filesPath () + "/rk_out.html");
- if (last_refresh_time.isValid () && (out_file.lastModified () <= last_refresh_time)) return current_output;
- }
-
if (current_output) {
if (raise) {
current_output->activate ();
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.h 2009-05-25 20:53:22 UTC (rev 2500)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.h 2009-05-26 11:54:31 UTC (rev 2501)
@@ -67,14 +67,12 @@
KUrl url ();
void doGotoAnchor (const QString &anchor_name);
- static void initializeOutputWindow ();
-
/** return a pointer to the current output. If there is no output window, one will be created (and shown) automatically */
static RKHTMLWindow* getCurrentOutput ();
/** refresh output window.
@param show Show the window, if not currently shown (this actually means: it is created if not currently existant)
@param raise Raise the window (if currently shown, or show==true) */
- static RKHTMLWindow* refreshOutput (bool show, bool raise, bool only_if_modified);
+ static RKHTMLWindow* refreshOutput (bool show, bool raise);
/** reimplemented from RKMDIWindow */
void fixupPartGUI (bool reload);
public slots:
@@ -126,7 +124,6 @@
void fileDoesNotExistMessage ();
static RKHTMLWindow *current_output;
- static QDateTime last_refresh_time;
// for dealing with rkward://[page|component]-pages
bool renderRKHelp (const KUrl &url);
Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp 2009-05-25 20:53:22 UTC (rev 2500)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp 2009-05-26 11:54:31 UTC (rev 2501)
@@ -274,7 +274,7 @@
void RKWorkplace::openOutputWindow (const KUrl &url) {
RK_TRACE (APP);
- RKHTMLWindow::refreshOutput (true, true, false);
+ RKHTMLWindow::refreshOutput (true, true);
if (!windows.contains (RKHTMLWindow::getCurrentOutput ())) {
addWindow (RKHTMLWindow::getCurrentOutput ());
}
@@ -282,7 +282,7 @@
void RKWorkplace::refreshOutputWindow () {
RK_TRACE (APP);
- RKHTMLWindow *window = RKHTMLWindow::refreshOutput (RKSettingsModuleOutput::autoShow (), RKSettingsModuleOutput::autoRaise (), true);
+ RKHTMLWindow *window = RKHTMLWindow::refreshOutput (RKSettingsModuleOutput::autoShow (), RKSettingsModuleOutput::autoRaise ());
if (window) {
if (!windows.contains (window)) {
addWindow (window);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list