[rkward-cvs] rkward/rkward rkward.cpp,1.96,1.97 rkward.h,1.45,1.46
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Sat Sep 17 17:00:07 UTC 2005
Update of /cvsroot/rkward/rkward/rkward
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11202/rkward
Modified Files:
rkward.cpp rkward.h
Log Message:
Some more code cleanups, small bugfixes, more API-documentation
Index: rkward.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.cpp,v
retrieving revision 1.96
retrieving revision 1.97
diff -C2 -d -r1.96 -r1.97
*** rkward.cpp 17 Sep 2005 15:55:30 -0000 1.96
--- rkward.cpp 17 Sep 2005 17:00:04 -0000 1.97
***************
*** 113,127 ****
RKGlobals::manager = new RKEditorManager ();
- /* KMdiChildView * editorManagerView = createWrapper(RKGlobals::editorManager (), i18n( "Data editor"), i18n( "Data editor"));
- editorManagerView->setIcon(SmallIcon("spreadsheet"));
- editorManagerView->setName("dataeditor");
- addWindow( editorManagerView ); */
-
-
-
connect (this, SIGNAL (childWindowCloseRequest (KMdiChildView *)), this, SLOT (slotChildWindowCloseRequest (KMdiChildView *)));
- // connect (this, SIGNAL (viewActivated (KMdiChildView *)), this, SLOT (slotViewActivated (KMdiChildView *)));
-
RKGlobals::mtracker = new RKModificationTracker (this);
--- 113,118 ----
***************
*** 129,133 ****
initial_url = load_url;
!
startup_timer = new QTimer (this);
startup_timer->start (50);
--- 120,124 ----
initial_url = load_url;
!
startup_timer = new QTimer (this);
startup_timer->start (50);
***************
*** 138,142 ****
// When the manager says the active part changes,
// the builder updates (recreates) the GUI
! connect( m_manager, SIGNAL( activePartChanged( KParts::Part * ) ), this, SLOT( createGUI( KParts::Part * ) ) );
if (!kapp->dcopClient ()->isRegistered ()) {
--- 129,133 ----
// When the manager says the active part changes,
// the builder updates (recreates) the GUI
! connect (m_manager, SIGNAL (activePartChanged (KParts::Part *)), this, SLOT (createGUI (KParts::Part *)));
if (!kapp->dcopClient ()->isRegistered ()) {
***************
*** 289,293 ****
fileOpen = KStdAction::open(this, SLOT(slotOpenCommandEditor()), actionCollection(), "file_openy");
fileOpen->setText (i18n ("Open Command File"));
! fileOpenRecent = KStdAction::openRecent(this, SLOT(slotOpenRecentCommandEditor(const KURL&)), actionCollection(), "file_open_recenty");
fileOpenWorkspace = KStdAction::open(this, SLOT(slotFileOpenWorkspace()), actionCollection(), "file_openx");
--- 280,284 ----
fileOpen = KStdAction::open(this, SLOT(slotOpenCommandEditor()), actionCollection(), "file_openy");
fileOpen->setText (i18n ("Open Command File"));
! fileOpenRecent = KStdAction::openRecent(this, SLOT(slotOpenCommandEditor (const KURL&)), actionCollection(), "file_open_recenty");
fileOpenWorkspace = KStdAction::open(this, SLOT(slotFileOpenWorkspace()), actionCollection(), "file_openx");
***************
*** 298,302 ****
fileSaveWorkspaceAs = KStdAction::saveAs(this, SLOT(slotFileSaveWorkspaceAs()), actionCollection(), "file_save_asx");
fileSaveWorkspaceAs->setText (i18n ("Save Workspace As"));
- //file_load_libs = new KAction (i18n ("Libraries"), 0, 0, this, SLOT (slotFileLoadLibs ()), actionCollection (), "file_load_libs");
filePrint = KStdAction::print(this, SLOT(slotFilePrint()), actionCollection(), "file_printx");
--- 289,292 ----
***************
*** 306,311 ****
! viewToolBar = KStdAction::showToolbar(this, SLOT(slotViewToolBar()), actionCollection());
! viewStatusBar = KStdAction::showStatusbar(this, SLOT(slotViewStatusBar()), actionCollection());
interruptCommand = new KAction (i18n ("Interrupt running command"), 0, 0, this, SLOT (slotInterruptCommand ()), actionCollection (), "interrupt");
--- 296,301 ----
! viewToolBar = KStdAction::showToolbar(this, SLOT (slotViewToolBar()), actionCollection());
! viewStatusBar = KStdAction::showStatusbar(this, SLOT (slotViewStatusBar()), actionCollection());
interruptCommand = new KAction (i18n ("Interrupt running command"), 0, 0, this, SLOT (slotInterruptCommand ()), actionCollection (), "interrupt");
***************
*** 313,317 ****
close_all_editors = new KAction (i18n ("Close All Data"), 0, 0, this, SLOT (slotCloseAllEditors ()), actionCollection (), "close_all_editors");
! window_close_all = new KAction (i18n ("Close All Windows"), 0, 0, this, SLOT (slotCloseAllWindows ()), actionCollection (), "window_close_all");
window_detach = new KAction (i18n ("Detach"), 0, 0, this, SLOT (slotDetachWindow ()), actionCollection (), "window_detach");
outputShow= new KAction (i18n ("Show &Output"), 0, 0, this, SLOT (slotOutputShow ()), actionCollection (), "output_show");
--- 303,308 ----
close_all_editors = new KAction (i18n ("Close All Data"), 0, 0, this, SLOT (slotCloseAllEditors ()), actionCollection (), "close_all_editors");
! window_close = new KAction (i18n ("Close"), 0, KShortcut ("Ctrl+W"), this, SLOT (slotCloseWindow ()), actionCollection (), "window_close");
! window_close_all = new KAction (i18n ("Close All"), 0, 0, this, SLOT (slotCloseAllWindows ()), actionCollection (), "window_close_all");
window_detach = new KAction (i18n ("Detach"), 0, 0, this, SLOT (slotDetachWindow ()), actionCollection (), "window_detach");
outputShow= new KAction (i18n ("Show &Output"), 0, 0, this, SLOT (slotOutputShow ()), actionCollection (), "output_show");
***************
*** 462,467 ****
bool RKwardApp::queryClose () {
RK_TRACE (APP);
-
- bool quit = true;
if (!RKGlobals::rObjectList ()->isEmpty ()) {
--- 453,456 ----
***************
*** 471,496 ****
new RKSaveAgent (RKGlobals::rObjectList ()->getWorkspaceURL (), false, RKSaveAgent::Quit);
} else if (res != KMessageBox::No) {
! quit = false;
}
}
! if (quit) {
! QValueList<KMdiChildView *> children;
! for(KMdiChildView *w = m_pDocumentViews->first();w;w= m_pDocumentViews->next()){
! children.append(w);
! }
! QValueListIterator<KMdiChildView *> childIt;
! for (childIt = children.begin(); childIt != children.end(); ++childIt) {
! if ((*childIt)->inherits("RKCommandEditorWindow") ) {
! if (! (*childIt)->close()) {
! //If a child refuses to close, we return false.
! return false;
! }
! }
}
- return true;
}
! return false;
}
--- 460,480 ----
new RKSaveAgent (RKGlobals::rObjectList ()->getWorkspaceURL (), false, RKSaveAgent::Quit);
} else if (res != KMessageBox::No) {
! return false;
}
}
! QValueList<KMdiChildView *> child_copy;
! for(KMdiChildView *w = m_pDocumentViews->first ();w;w= m_pDocumentViews->next ()){
! child_copy.append (w);
! }
! QValueListIterator<KMdiChildView *> childIt;
! for (childIt = child_copy.begin (); childIt != child_copy.end (); ++childIt) {
! if (!(*childIt)->close ()) {
! // If a child refuses to close, we return false.
! return false;
}
}
! return true;
}
***************
*** 506,516 ****
/////////////////////////////////////////////////////////////////////
- // TODO: remove
- void RKwardApp::slotEditorsChanged () {
- RK_TRACE (APP);
- // close_editor->setEnabled (RKGlobals::editorManager ()->numEditors ());
- // close_all_editors->setEnabled (RKGlobals::editorManager ()->numEditors ());
- }
-
void RKwardApp::slotNewDataFrame () {
RK_TRACE (APP);
--- 490,493 ----
***************
*** 530,533 ****
--- 507,513 ----
void RKwardApp::fileOpenNoSave (const KURL &url) {
RK_TRACE (APP);
+
+ slotCloseAllEditors ();
+
slotStatusMsg(i18n("Opening workspace..."));
KURL lurl = url;
***************
*** 662,665 ****
--- 642,651 ----
}
+ void RKwardApp::slotCloseWindow () {
+ RK_TRACE (APP);
+
+ closeActiveView ();
+ }
+
void RKwardApp::slotCloseAllWindows () {
RK_TRACE (APP);
***************
*** 699,797 ****
!
! void RKwardApp::slotNewCommandEditor(){
RKCommandEditorWindow *editor = new RKCommandEditorWindow;
! editor->setIcon(SmallIcon("source"));
! editor->name("RCEditor");
! addWindow(editor);
!
}
!
! void RKwardApp::slotOpenURL(const KURL &url){
RKCommandEditorWindow *editor;
!
! if (!url.isLocalFile())
! {
! KMessageBox::messageBox(this,KMessageBox::Information,
! i18n ("You specified a file that is not on local system"), i18n ("Cannot open file"));
! return;
! }
!
editor = new RKCommandEditorWindow;
!
! if (!editor->openURL(url))
! {
! QString errstr = i18n ("Unable to open ");
!
! errstr += url.prettyURL();
!
! KMessageBox::messageBox(this,KMessageBox::Error,
! errstr, i18n ("Error!"));
delete editor;
return;
}
-
- fileOpenRecent->addURL (url);
- editor->setIcon(SmallIcon("source"));
- editor->name("RCEditor");
- addWindow(editor);
-
};
! void RKwardApp::slotOpenCommandEditor(){
KURL::List urls;
KURL::List::const_iterator it;
! KFileDialog dlg(QString("."),QString("*.R *.r"),this,i18n("Open file"),true);
!
! dlg.setOperationMode(KFileDialog::Opening);
! dlg.setMode(KFile::Files);
! if (dlg.exec() == QDialog::Rejected)
! return;
!
! urls = dlg.selectedURLs();
for (it = urls.begin() ; it != urls.end() ; ++it){
! slotOpenURL(*it);
}
-
};
- bool RKwardApp::getFilenameAndPath(const KURL &url,QString *fname)
- {
- QString fullpath = url.path();
- int i,length,fnamepos;
- bool done;
-
- if ((length = (int)fullpath.length()) == 0)
- return false;
-
- fnamepos = 0;
- for (i = length-1,done = false ; i >= 0 && !done ; i--)
- {
- if (fullpath[i] == '/')
- {
- done = true;
- fnamepos = i+1;
- }
- }
-
- if (!done)
- return false;
-
- if (fnamepos >= length)
- return false;
-
- if (fname)
- *fname = fullpath.right(length-fnamepos);
-
-
- return true;
- }
-
-
-
void RKwardApp::slotChildWindowCloseRequest (KMdiChildView * window) {
//If it's an unsaved command editor window, there is a warning.
// TODO: it's sort of ugly, having to handle this here. Can't we somehow handle it in RKCommandEditorWindow instead?
--- 685,730 ----
! void RKwardApp::slotNewCommandEditor () {
! RK_TRACE (APP);
RKCommandEditorWindow *editor = new RKCommandEditorWindow;
! editor->setIcon (SmallIcon("source"));
! addWindow (editor);
! editor->activate ();
}
! void RKwardApp::slotOpenCommandEditor (const KURL &url) {
! RK_TRACE (APP);
RKCommandEditorWindow *editor;
!
editor = new RKCommandEditorWindow;
!
! if (!editor->openURL (url)) {
! QString errstr = i18n ("Unable to open \"%1\"").arg (url.prettyURL ());
!
! KMessageBox::messageBox (this, KMessageBox::Error, errstr, i18n ("Could not open command file"));
delete editor;
return;
}
+ fileOpenRecent->addURL (url);
+ editor->setIcon (SmallIcon("source"));
+ addWindow (editor);
+ editor->activate ();
};
! void RKwardApp::slotOpenCommandEditor (){
! RK_TRACE (APP);
KURL::List urls;
KURL::List::const_iterator it;
! urls = KFileDialog::getOpenURLs (QString("."), QString("*.R *.r"), this, i18n ("Open command file(s)"));
!
for (it = urls.begin() ; it != urls.end() ; ++it){
! slotOpenCommandEditor (*it);
}
};
void RKwardApp::slotChildWindowCloseRequest (KMdiChildView * window) {
+ RK_TRACE (APP);
//If it's an unsaved command editor window, there is a warning.
// TODO: it's sort of ugly, having to handle this here. Can't we somehow handle it in RKCommandEditorWindow instead?
***************
*** 810,822 ****
}
- void RKwardApp::slotViewActivated (KMdiChildView * window) {
- setCaption(window->caption());
- }
-
- void RKwardApp::slotOpenRecentCommandEditor(const KURL& url)
- {
- slotOpenURL(url);
- }
-
void RKwardApp::slotInterruptCommand () {
// TODO!
--- 743,746 ----
***************
*** 824,839 ****
void RKwardApp::openHTML(const KURL &url) {
RKHTMLWindowPart::openHTML (url, false);
}
void RKwardApp::openHTMLHelp (const QString & url) {
openHTML (url);
}
- /*!
- \fn RKwardApp::slotOutputShow()
- Show html output.
- */
void RKwardApp::slotOutputShow () {
RKHTMLWindowPart::refreshOutput (true, true);
}
--- 748,762 ----
void RKwardApp::openHTML(const KURL &url) {
+ RK_TRACE (APP);
RKHTMLWindowPart::openHTML (url, false);
}
void RKwardApp::openHTMLHelp (const QString & url) {
+ RK_TRACE (APP);
openHTML (url);
}
void RKwardApp::slotOutputShow () {
+ RK_TRACE (APP);
RKHTMLWindowPart::refreshOutput (true, true);
}
Index: rkward.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** rkward.h 17 Sep 2005 15:55:30 -0000 1.45
--- rkward.h 17 Sep 2005 17:00:05 -0000 1.46
***************
*** 84,99 ****
Q_OBJECT
public:
! /** construtor of RKwardApp, calls all init functions to create the application.
! */
RKwardApp(KURL *load_url=0);
~RKwardApp();
void startR ();
!
void newOutput ();
!
void fileOpenNoSave (const KURL &url);
void fileOpenAskSave (const KURL &url);
void openHTMLHelp (const QString &url);
void openHTML (const KURL &url);
--- 84,108 ----
Q_OBJECT
public:
! /** construtor
! @param load_url The workspace file to load on startup. If 0, show a dialog asking what to do. */
RKwardApp(KURL *load_url=0);
+ /** destructor */
~RKwardApp();
+ /** initialize the backend */
void startR ();
!
! /** signal there was new output, show/raise/refresh the output window as appropriate.
!
! TODO: rename to something sensible, and check whether it is redundant. */
void newOutput ();
!
! /** open a workspace. Do not ask whether to save the old one. The old workspace is deleted! */
void fileOpenNoSave (const KURL &url);
+ /** open a workspace. If the current workspace is not empty, ask wether to save first. */
void fileOpenAskSave (const KURL &url);
+ /** opens the given url, assuming it is an HTML-help page. Like openHTML (), but with a QString parameter instead for DCOP. Generally you should use openHTML () instead. */
void openHTMLHelp (const QString &url);
+ /** opens the given url, assuming it is an HTML-help page. */
void openHTML (const KURL &url);
***************
*** 107,116 ****
protected:
void openWorkspace (const KURL &url);
! /** save general Options like all bar positions and status as well as the geometry and the recent file list to the configuration
! * file
! */
void saveOptions();
! /** read general Options again and initialize all variables like the recent file list
! */
void readOptions();
/** initializes the KActions of the application */
--- 116,122 ----
protected:
void openWorkspace (const KURL &url);
! /** save Options/Settings. Includes general Options like all bar positions and status as well as the geometry and the recent file list */
void saveOptions();
! /** read general Options again and initialize all variables like the recent file list */
void readOptions();
/** initializes the KActions of the application */
***************
*** 136,139 ****
--- 142,147 ----
* opened file by a temporary filename provided by KApplication.
* @see KTMainWindow#saveProperties
+
+ // TODO: defunct!! Find out what this is really for.
*/
virtual void saveProperties(KConfig *_cfg);
***************
*** 141,144 ****
--- 149,154 ----
* temporary files saved by saveProperties()
* @see KTMainWindow#readProperties
+
+ // TODO: defunct!! Find out what this is really for.
*/
virtual void readProperties(KConfig *_cfg);
***************
*** 157,161 ****
/** shows the dialog to install/load/unload packages */
void slotFileLoadLibs ();
! /** close all editors */
void slotCloseAllEditors ();
/** print the actual file */
--- 167,171 ----
/** shows the dialog to install/load/unload packages */
void slotFileLoadLibs ();
! /** close all editor windows */
void slotCloseAllEditors ();
/** print the actual file */
***************
*** 175,200 ****
*/
void slotStatusMsg(const QString &text);
void slotStatusReady ();
! /** configures RKward-settings */
void slotConfigure ();
/** Init-procedures to be done after the exec-loop was started */
void doPostInit ();
!
! void slotEditorsChanged ();
!
void slotNewCommandEditor();
! void slotOpenCommandEditor();
! void slotOpenURL(const KURL &url);
void slotChildWindowCloseRequest (KMdiChildView * window);
void slotInterruptCommand();
- void slotViewActivated (KMdiChildView *window);
- void slotOpenRecentCommandEditor(const KURL&);
/** close all windows (Windows->Close All) */
void slotCloseAllWindows ();
/** detach current window (Windows->Detach) */
void slotDetachWindow ();
private:
/** the configuration object of the application */
--- 185,219 ----
*/
void slotStatusMsg(const QString &text);
+ /** changes the status-message to "Ready". See \ref slotStatusMsg (). */
void slotStatusReady ();
! /** configures RKward-settings */
void slotConfigure ();
/** Init-procedures to be done after the exec-loop was started */
void doPostInit ();
!
! /** open a new command editor (blank file) */
void slotNewCommandEditor();
! /** open a new command editor (ask for file to open) */
! void slotOpenCommandEditor ();
! /** open a new command editor (load given url) */
! void slotOpenCommandEditor (const KURL &url);
!
! /** a child window has received a close event. Check, whether data needs to be saved. Ask if necessary. Close only if safe. */
void slotChildWindowCloseRequest (KMdiChildView * window);
+
+ /** interrupt current command. TODO: defunct!!! */
void slotInterruptCommand();
+ /** close current window (Windows->Close). Note: the only reason we need to implement this, is so we can set a default shortcut (Ctrl+W). Usually, KMdiMainFrm would provide an action like this by itselt */
+ void slotCloseWindow ();
/** close all windows (Windows->Close All) */
void slotCloseAllWindows ();
/** detach current window (Windows->Detach) */
void slotDetachWindow ();
+
+ /** ensure output window is shown. */
+ void slotOutputShow ();
private:
/** the configuration object of the application */
***************
*** 230,233 ****
--- 249,253 ----
KToggleAction* viewStatusBar;
+ KAction* window_close;
KAction* window_close_all;
KAction* window_detach;
***************
*** 248,252 ****
RObjectBrowser *object_browser;
KHelpDlg *helpDlg;
- RKKonsole * konsole ;
RKConsole * console;
--- 268,271 ----
***************
*** 256,264 ****
friend class RInterface;
void setRStatus (bool busy);
- bool getFilenameAndPath(const KURL &url,QString *fname);
void saveAsProcedure(RKCommandEditorWindow *editor);
- KMdiChildView* outputView();
/** refreshes the output.
--- 275,282 ----
friend class RInterface;
+ /** set the R status message ("R engine idel/busy") to idle or busy */
void setRStatus (bool busy);
void saveAsProcedure(RKCommandEditorWindow *editor);
/** refreshes the output.
***************
*** 267,273 ****
void refreshOutput (bool show, bool raise);
signals:
! void childWindowCloseRequest(KMdiChildView * window);
! private slots:
! void slotOutputShow();
};
--- 285,290 ----
void refreshOutput (bool show, bool raise);
signals:
! /** no idea, why we have to declare this explicitly, to somehow we do. */
! void childWindowCloseRequest (KMdiChildView *);
};
More information about the rkward-tracker
mailing list