[rkward-cvs] SF.net SVN: rkward: [974] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Thu Nov 30 16:20:30 UTC 2006
Revision: 974
http://svn.sourceforge.net/rkward/?rev=974&view=rev
Author: tfry
Date: 2006-11-30 08:20:30 -0800 (Thu, 30 Nov 2006)
Log Message:
-----------
Auto refresh output if modified in user commands
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/rbackend/rinterface.cpp
trunk/rkward/rkward/rkward.cpp
trunk/rkward/rkward/windows/rkhtmlwindow.cpp
trunk/rkward/rkward/windows/rkhtmlwindow.h
trunk/rkward/rkward/windows/rkworkplace.cpp
trunk/rkward/rkward/windows/rkworkplace.h
trunk/rkward/subdirs
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2006-11-30 13:28:17 UTC (rev 973)
+++ trunk/rkward/ChangeLog 2006-11-30 16:20:30 UTC (rev 974)
@@ -1,3 +1,4 @@
+- if a user command results in the output html file to be modified, auto-refresh output
- add RMB menu to script editor windows
- add options "clear" and "configure" in the console RMB menu, and the command log RMB menu
- add option to save workplace layout not per workspace, but at the end of the session
Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp 2006-11-30 13:28:17 UTC (rev 973)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp 2006-11-30 16:20:30 UTC (rev 974)
@@ -154,7 +154,9 @@
RKGlobals::controlWindow ()->removeCommand (command);
command->finished ();
if (command->type () & RCommand::DirectToOutput) {
- RKWorkplace::mainWorkplace ()->newOutput ();
+ RKWorkplace::mainWorkplace ()->newOutput (false);
+ } else if (command->type () & RCommand::User) {
+ RKWorkplace::mainWorkplace ()->newOutput (true);
}
delete command;
} else if ((e->type () == RIDLE_EVENT)) {
Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp 2006-11-30 13:28:17 UTC (rev 973)
+++ trunk/rkward/rkward/rkward.cpp 2006-11-30 16:20:30 UTC (rev 974)
@@ -201,6 +201,8 @@
RKGlobals::helpDialog ()->setIcon (SmallIcon ("help"));
search_help_view = addToolWindow (RKGlobals::helpDialog (), KDockWidget::DockBottom, getMainDockWidget (), 10);
+ RKOutputWindow::initialize ();
+
if (initial_url) {
openWorkspace (*initial_url);
delete initial_url;
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2006-11-30 13:28:17 UTC (rev 973)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2006-11-30 16:20:30 UTC (rev 974)
@@ -25,7 +25,7 @@
#include <krun.h>
#include <kparts/partmanager.h>
-#include <qfile.h>
+#include <qfileinfo.h>
#include <qwidget.h>
#include <qlayout.h>
#include <qtimer.h>
@@ -172,6 +172,7 @@
//##################### BEGIN RKOutputWindow #####################
//static
RKOutputWindow* RKOutputWindow::current_output = 0;
+QDateTime RKOutputWindow::last_refresh_time;
RKOutputWindow::RKOutputWindow (QWidget *parent) : RKHTMLWindow (parent), KXMLGUIClient () {
RK_TRACE (APP);
@@ -199,6 +200,14 @@
if (action) action->setText (i18n ("Save Output as HTML"));
}
+//static
+void RKOutputWindow::initialize () {
+ RK_TRACE (APP);
+
+ QFileInfo out_file (RKSettingsModuleGeneral::filesPath () + "/rk_out.html");
+ last_refresh_time = out_file.lastModified ();
+}
+
RKOutputWindow::~RKOutputWindow () {
RK_TRACE (APP);
@@ -220,10 +229,11 @@
RK_TRACE (APP);
output_url = url;
- QFile out_file (url.path ());
+ QFileInfo out_file (url.path ());
bool ok = out_file.exists();
if (ok) {
RKHTMLWindow::openURL (url);
+ last_refresh_time = out_file.lastModified ();
} else {
showOutputEmptyMessage ();
}
@@ -239,9 +249,14 @@
}
//static
-void RKOutputWindow::refreshOutput (bool show, bool raise) {
+RKOutputWindow* RKOutputWindow::refreshOutput (bool show, bool raise, bool only_if_modified) {
RK_TRACE (APP);
+ if (only_if_modified) {
+ QFileInfo out_file (RKSettingsModuleGeneral::filesPath () + "/rk_out.html");
+ if (out_file.lastModified () <= last_refresh_time) return current_output;
+ }
+
if (current_output) {
if (raise) {
current_output->activate ();
@@ -253,6 +268,8 @@
getCurrentOutput ();
}
}
+
+ return current_output;
}
//static
@@ -276,14 +293,14 @@
if (res==KMessageBox::Yes) {
QFile out_file (RKSettingsModuleGeneral::filesPath () + "/rk_out.html");
out_file.remove ();
- refreshOutput (false, false);
+ refreshOutput (false, false, false);
}
}
void RKOutputWindow::refreshOutput () {
RK_TRACE (APP);
- refreshOutput (true, true);
+ refreshOutput (true, true, false);
}
void RKOutputWindow::showOutputEmptyMessage () {
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.h 2006-11-30 13:28:17 UTC (rev 973)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.h 2006-11-30 16:20:30 UTC (rev 974)
@@ -105,16 +105,18 @@
/** 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 void refreshOutput (bool show, bool raise);
+ static RKOutputWindow* refreshOutput (bool show, bool raise, bool only_if_modified);
/** return a pointer to the current output. If there is no output window, one will be created (and shown) automatically */
static RKOutputWindow* getCurrentOutput ();
+ static void initialize ();
+
QString getDescription ();
public slots:
/** flush current output. */
void flushOutput ();
-/** refresh current output. Slot Wrapper around refresh. */
+/** Slot wrapper around refreshOutput (bool, bool, bool). */
void refreshOutput ();
protected:
/** reimplemented to never change the caption (it's always "Output") */
@@ -129,6 +131,7 @@
static RKOutputWindow* current_output;
/** In case the output is empty (i.e. output file does not exist), we need to store, where the output *would* be, if it existed, so we can properly refresh the output */
KURL output_url;
+ static QDateTime last_refresh_time;
};
/**
Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp 2006-11-30 13:28:17 UTC (rev 973)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp 2006-11-30 16:20:30 UTC (rev 974)
@@ -144,18 +144,18 @@
void RKWorkplace::openOutputWindow (const KURL &url) {
RK_TRACE (APP);
- RKOutputWindow::refreshOutput (true, true);
+ RKOutputWindow::refreshOutput (true, true, false);
if (windows.find (RKOutputWindow::getCurrentOutput ()) == windows.end ()) {
addWindow (RKOutputWindow::getCurrentOutput ());
}
}
-void RKWorkplace::newOutput () {
+void RKWorkplace::newOutput (bool only_if_modified) {
RK_TRACE (APP);
- RKOutputWindow::refreshOutput (RKSettingsModuleOutput::autoShow (), RKSettingsModuleOutput::autoRaise ());
- if (RKSettingsModuleOutput::autoShow ()) {
- if (windows.find (RKOutputWindow::getCurrentOutput ()) == windows.end ()) {
- addWindow (RKOutputWindow::getCurrentOutput ());
+ RKOutputWindow *window = RKOutputWindow::refreshOutput (RKSettingsModuleOutput::autoShow (), RKSettingsModuleOutput::autoRaise (), only_if_modified);
+ if (window) {
+ if (windows.find (window) == windows.end ()) {
+ addWindow (window);
}
}
}
Modified: trunk/rkward/rkward/windows/rkworkplace.h
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.h 2006-11-30 13:28:17 UTC (rev 973)
+++ trunk/rkward/rkward/windows/rkworkplace.h 2006-11-30 16:20:30 UTC (rev 974)
@@ -74,7 +74,7 @@
void openOutputWindow (const KURL &url=KURL ());
/** signal there was new output, show/raise/refresh the output window as appropriate.
TODO: this should be obsoleted somehow */
- void newOutput ();
+ void newOutput (bool only_if_modified);
void newX11Window (WId window_to_embed, int device_number);
Modified: trunk/rkward/subdirs
===================================================================
--- trunk/rkward/subdirs 2006-11-30 13:28:17 UTC (rev 973)
+++ trunk/rkward/subdirs 2006-11-30 16:20:30 UTC (rev 974)
@@ -1,3 +1,4 @@
doc
po
rkward
+rkward-0.4.2pre1
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