[rkward-cvs] SF.net SVN: rkward: [2120] branches/KDE4_port
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Wed Oct 24 20:27:59 UTC 2007
Revision: 2120
http://rkward.svn.sourceforge.net/rkward/?rev=2120&view=rev
Author: tfry
Date: 2007-10-24 13:27:59 -0700 (Wed, 24 Oct 2007)
Log Message:
-----------
Some work on icons an code completion in script editor
Modified Paths:
--------------
branches/KDE4_port/ChangeLog
branches/KDE4_port/TODO_KDE4
branches/KDE4_port/rkward/core/robject.h
branches/KDE4_port/rkward/misc/CMakeLists.txt
branches/KDE4_port/rkward/misc/multistringselector.cpp
branches/KDE4_port/rkward/misc/multistringselector.h
branches/KDE4_port/rkward/rkconsole.cpp
branches/KDE4_port/rkward/rkward.cpp
branches/KDE4_port/rkward/windows/rkcommandeditorwindow.cpp
branches/KDE4_port/rkward/windows/rkcommandeditorwindow.h
branches/KDE4_port/rkward/windows/rkcommandeditorwindowpart.cpp
branches/KDE4_port/rkward/windows/rkcommandlog.cpp
branches/KDE4_port/rkward/windows/rkhtmlwindow.cpp
Added Paths:
-----------
branches/KDE4_port/rkward/misc/rkstandardicons.cpp
branches/KDE4_port/rkward/misc/rkstandardicons.h
Modified: branches/KDE4_port/ChangeLog
===================================================================
--- branches/KDE4_port/ChangeLog 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/ChangeLog 2007-10-24 20:27:59 UTC (rev 2120)
@@ -1,3 +1,4 @@
+- code completion in script editor shows icons for the different object types
- settings dialog is now shown in "page list" mode
- port to KDE 4 (TODO)
Modified: branches/KDE4_port/TODO_KDE4
===================================================================
--- branches/KDE4_port/TODO_KDE4 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/TODO_KDE4 2007-10-24 20:27:59 UTC (rev 2120)
@@ -29,9 +29,6 @@
rkcommandeditorwindow
- polish code completion (e.g. hide window, when there are no completions)
- - should go away, when the focus is lost
- - adding icons should not be too hard?
- - does the popup-menu still work? See SVN rev. 962.
- placement of menu options?
rkward
Modified: branches/KDE4_port/rkward/core/robject.h
===================================================================
--- branches/KDE4_port/rkward/core/robject.h 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/rkward/core/robject.h 2007-10-24 20:27:59 UTC (rev 2120)
@@ -87,11 +87,11 @@
virtual void setLabel (const QString &value, bool sync=true);
virtual void setMetaProperty (const QString &id, const QString &value, bool sync=true);
- bool isContainer () { return (type & Container); };
- bool isDataFrame () { return (type & DataFrame); };
- bool isVariable () { return (type & Variable); };
- bool isType (int type) { return (RObject::type & type); };
- bool hasMetaObject () { return (type & HasMetaObject); };
+ bool isContainer () const { return (type & Container); };
+ bool isDataFrame () const { return (type & DataFrame); };
+ bool isVariable () const { return (type & Variable); };
+ bool isType (int type) const { return (RObject::type & type); };
+ bool hasMetaObject () const { return (type & HasMetaObject); };
/** trigger an update of this and all descendent objects */
virtual void updateFromR (RCommandChain *chain);
@@ -140,7 +140,7 @@
/** array of child objects. Always 0, reimplemented in RContainerObject */
virtual RObject **children () { return 0; };
- RDataType getDataType () { return (typeToDataType (type)); };
+ RDataType getDataType () const { return (typeToDataType (type)); };
static RDataType typeToDataType (int ftype) { return ((RDataType) ((ftype & DataTypeMask) >> 14)); };
void setDataType (RDataType new_type) {
int n_type = type - (type & DataTypeMask);
Modified: branches/KDE4_port/rkward/misc/CMakeLists.txt
===================================================================
--- branches/KDE4_port/rkward/misc/CMakeLists.txt 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/rkward/misc/CMakeLists.txt 2007-10-24 20:27:59 UTC (rev 2120)
@@ -14,6 +14,7 @@
rkprogresscontrol.cpp
rksaveobjectchooser.cpp
rkdummypart.cpp
+ rkstandardicons.cpp
)
QT4_AUTOMOC(${misc_STAT_SRCS})
Modified: branches/KDE4_port/rkward/misc/multistringselector.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/multistringselector.cpp 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/rkward/misc/multistringselector.cpp 2007-10-24 20:27:59 UTC (rev 2120)
@@ -1,7 +1,7 @@
/***************************************************************************
multistringselector - description
-------------------
- begin : Fir Sep 10 2005
+ begin : Fri Sep 10 2005
copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
Modified: branches/KDE4_port/rkward/misc/multistringselector.h
===================================================================
--- branches/KDE4_port/rkward/misc/multistringselector.h 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/rkward/misc/multistringselector.h 2007-10-24 20:27:59 UTC (rev 2120)
@@ -1,7 +1,7 @@
/***************************************************************************
multistringselector - description
-------------------
- begin : Fir Sep 10 2005
+ begin : Fri Sep 10 2005
copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
Added: branches/KDE4_port/rkward/misc/rkstandardicons.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/rkstandardicons.cpp (rev 0)
+++ branches/KDE4_port/rkward/misc/rkstandardicons.cpp 2007-10-24 20:27:59 UTC (rev 2120)
@@ -0,0 +1,99 @@
+/***************************************************************************
+ rkstandardicons - description
+ -------------------
+ begin : Wed Oct 24 2007
+ copyright : (C) 2007 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 "rkstandardicons.h"
+
+#include "kicon.h"
+
+#include "../core/robject.h"
+#include "../core/robjectlist.h"
+#include "../windows/rkmdiwindow.h"
+#include "../misc/rkcommonfunctions.h"
+
+#include "../debug.h"
+
+// static
+QIcon RKStandardIcons::icons[Last];
+
+void RKStandardIcons::initIcons () {
+ RK_TRACE (APP);
+
+ RK_ASSERT (icons[ActionRunAll].isNull ()); // init only once
+
+ // base path for icons provided by rkward itself
+ QString rkward_icon_base = RKCommonFunctions::getRKWardDataDir () + "icons/";
+
+ // actions
+ icons[ActionRunAll] = QIcon (rkward_icon_base + "run_all.png");
+ icons[ActionRunLine] = QIcon (rkward_icon_base + "run_line.png");
+ icons[ActionRunSelection] = QIcon (rkward_icon_base + "run_selection.png");
+
+ // objects
+ icons[ObjectList] = QIcon (rkward_icon_base + "list.png");
+ icons[ObjectFunction] = QIcon (rkward_icon_base + "function.png");
+#warning KDE 4: some of these icons have been renamed
+ icons[ObjectEnvironment] = KIcon ("konqueror");
+ icons[ObjectPackageEnvironment] = KIcon ("ark");
+ icons[ObjectDataFrame] = KIcon ("spreadsheet");
+ icons[ObjectDataNumeric] = KIcon ("math_paren");
+ icons[ObjectDataFactor] = KIcon ("math_onetwomatrix");
+ icons[ObjectDataCharacter] = KIcon ("text");
+#warning TODO icon for logical
+ icons[ObjectDataLogical] = QIcon ();
+ icons[ObjectDataUnknown] = KIcon ("help");
+ icons[ObjectDataOther] = KIcon ("no");
+ icons[ObjectObjectList] = KIcon ("view_tree");
+
+ // windows
+#warning TODO icons for windows
+}
+
+QIcon RKStandardIcons::iconForObject (const RObject* object) {
+ // don't trace this
+
+ if (!object) return icons[ObjectDataOther];
+ if (object->isDataFrame ()) return icons[ObjectDataFrame];
+ if (object->isVariable()) {
+ switch (object->getDataType ()) {
+ case RObject::DataNumeric:
+ return icons[ObjectDataNumeric];
+ case RObject::DataFactor:
+ return icons[ObjectDataFactor];
+ case RObject::DataCharacter:
+ return icons[ObjectDataCharacter];
+ case RObject::DataLogical:
+ return icons[ObjectDataLogical];
+ case RObject::DataUnknown:
+ return icons[ObjectDataUnknown];
+ default:
+ return icons[ObjectDataOther];
+ }
+ }
+ if (object->isType (RObject::List)) return icons[ObjectList];
+ if (object->isType (RObject::Function)) return icons[ObjectFunction];
+ if (object->isType (RObject::PackageEnv)) return icons[ObjectPackageEnvironment];
+ if (object->isType (RObject::Environment)) return icons[ObjectEnvironment];
+ if (object == RObjectList::getObjectList ()) return icons[ObjectObjectList];
+
+ return QIcon ();
+}
+
+QIcon RKStandardIcons::iconForWindow (const RKMDIWindow* window) {
+ // don't trace this
+#warning TODO
+ return QIcon ();
+}
Added: branches/KDE4_port/rkward/misc/rkstandardicons.h
===================================================================
--- branches/KDE4_port/rkward/misc/rkstandardicons.h (rev 0)
+++ branches/KDE4_port/rkward/misc/rkstandardicons.h 2007-10-24 20:27:59 UTC (rev 2120)
@@ -0,0 +1,73 @@
+/***************************************************************************
+ rkstandardicons - description
+ -------------------
+ begin : Wed Oct 24 2007
+ copyright : (C) 2007 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 RKSTANDARDICONS_H
+#define RKSTANDARDICONS_H
+
+#include <QIcon>
+
+class RObject;
+class RKMDIWindow;
+
+/** This class (it's a namespace, really, except I did not figure out how to put the storage array in it as a "private" member) provides easy access to the icons used in RKWard. This helps staying consistent across the whole application.
+
+Also, since QIcons are only loaded on demand, and implicitely shared, this should save some ressources for icons that are used often.
+
+Eventually all icons (even those that are only used once, so far) should be added, here. All direct constructions of QIcons (or KIconLoader) should be removed elsewhere.
+
+TODO: we should also have RKStandardActions
+
+ at author Thomas Friedrichsmeier */
+class RKStandardIcons {
+public:
+ /** initializes the items. */
+ static void initIcons ();
+
+ enum IconName {
+ ActionRunAll=0,
+ ActionRunLine,
+ ActionRunSelection,
+
+ ObjectList,
+ ObjectFunction,
+ ObjectEnvironment,
+ ObjectPackageEnvironment,
+ ObjectDataFrame,
+ ObjectDataNumeric,
+ ObjectDataFactor,
+ ObjectDataCharacter,
+ ObjectDataLogical,
+ ObjectDataUnknown,
+ ObjectDataOther,
+ ObjectObjectList,
+
+ Last /**< not really an item, only the count of items available. Do not use. */
+ };
+
+ /** get the icon with the given name */
+ static QIcon getIcon (IconName name) { return icons[name]; };
+
+ /** convenience function to get the icon most suited for the given RObject */
+ static QIcon iconForObject (const RObject* object);
+
+ /** convenience function to get the icon most suited for the given RKMDIWindow */
+ static QIcon iconForWindow (const RKMDIWindow* window);
+private:
+ static QIcon icons[Last];
+};
+
+#endif
Modified: branches/KDE4_port/rkward/rkconsole.cpp
===================================================================
--- branches/KDE4_port/rkward/rkconsole.cpp 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/rkward/rkconsole.cpp 2007-10-24 20:27:59 UTC (rev 2120)
@@ -49,6 +49,7 @@
#include "settings/rksettings.h"
#include "settings/rksettingsmoduleconsole.h"
#include "misc/rkcommonfunctions.h"
+#include "misc/rkstandardicons.h"
#include "core/robjectlist.h"
#include "core/rfunctionobject.h"
@@ -789,7 +790,7 @@
run_selection_action = ac->addAction ("run_selection", this, SLOT (runSelection()));
run_selection_action->setText (i18n ("Run selection"));
- run_selection_action->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/run_selection.png"));
+ run_selection_action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunSelection));
run_selection_action->setShortcut (Qt::Key_F8);
interrupt_command_action = ac->addAction ("interrupt", this, SLOT (slotInterruptCommand()));
Modified: branches/KDE4_port/rkward/rkward.cpp
===================================================================
--- branches/KDE4_port/rkward/rkward.cpp 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/rkward/rkward.cpp 2007-10-24 20:27:59 UTC (rev 2120)
@@ -58,6 +58,7 @@
#include "rbackend/rinterface.h"
#include "core/robjectlist.h"
#include "core/renvironmentobject.h"
+#include "misc/rkstandardicons.h"
#include "rkglobals.h"
#include "robjectbrowser.h"
#include "dialogs/startupdialog.h"
@@ -121,6 +122,7 @@
///////////////////////////////////////////////////////////////////
// call inits to invoke all other construction parts
+ RKStandardIcons::initIcons ();
initActions();
initStatusBar();
Modified: branches/KDE4_port/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- branches/KDE4_port/rkward/windows/rkcommandeditorwindow.cpp 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/rkward/windows/rkcommandeditorwindow.cpp 2007-10-24 20:27:59 UTC (rev 2120)
@@ -47,6 +47,7 @@
#include <kiconloader.h>
#include "../misc/rkcommonfunctions.h"
+#include "../misc/rkstandardicons.h"
#include "../core/robjectlist.h"
#include "../settings/rksettings.h"
#include "../settings/rksettingsmodulecommandeditor.h"
@@ -92,7 +93,8 @@
connect (m_doc, SIGNAL (modifiedChanged (KTextEditor::Document*)), this, SLOT (updateCaption (KTextEditor::Document*))); // of course most of the time this causes a redundant call to updateCaption. Not if a modification is undone, however.
connect (m_doc, SIGNAL (textChanged (KTextEditor::Document*)), this, SLOT (tryCompletionProxy (KTextEditor::Document*)));
// somehow the katepart loses the context menu each time it loses focus
- connect (m_view, SIGNAL (focusIn(KTextEditor::View*)), this, SLOT (setPopupMenu(KTextEditor::View*)));
+ connect (m_view, SIGNAL (focusIn(KTextEditor::View*)), this, SLOT (focusIn(KTextEditor::View*)));
+ connect (m_view, SIGNAL (focusOut(KTextEditor::View*)), this, SLOT (focusOut(KTextEditor::View*)));
completion_timer = new QTimer (this);
connect (completion_timer, SIGNAL (timeout ()), this, SLOT (tryCompletion()));
@@ -115,16 +117,30 @@
delete m_doc;
}
-void RKCommandEditorWindow::setPopupMenu (KTextEditor::View* v) {
+void RKCommandEditorWindow::focusIn (KTextEditor::View* v) {
RK_TRACE (COMMANDEDITOR);
RK_ASSERT (v == m_view);
- if (!getPart ()->factory ()) return;
- m_view->setContextMenu (static_cast<QMenu *> (getPart ()->factory ()->container ("ktexteditor_popup", getPart ())));
+ setPopupMenu ();
}
+void RKCommandEditorWindow::focusOut (KTextEditor::View* v) {
+ RK_TRACE (COMMANDEDITOR);
+ RK_ASSERT (v == m_view);
+
+ KTextEditor::CodeCompletionInterface *iface = qobject_cast<KTextEditor::CodeCompletionInterface*> (m_view);
+ if (!iface) {
+ RK_ASSERT (false);
+ return;
+ }
+ iface->abortCompletion ();
+}
+
void RKCommandEditorWindow::setPopupMenu () {
- setPopupMenu (m_view);
+ RK_TRACE (COMMANDEDITOR);
+
+ if (!getPart ()->factory ()) return;
+ m_view->setContextMenu (static_cast<QMenu *> (getPart ()->factory ()->container ("ktexteditor_popup", getPart ())));
}
QString RKCommandEditorWindow::fullCaption () {
@@ -267,6 +283,8 @@
} else {
iface->startCompletion (range, completion_model);
}
+#warning TODO: flicker when no matches. Nag Kate devels? Remove?
+ if (!completion_model->rowCount ()) iface->abortCompletion ();
} else {
iface->abortCompletion ();
}
@@ -539,6 +557,10 @@
if (col == KTextEditor::CodeCompletionModel::Name) {
return (object->getBaseName ());
}
+ } else if (role == Qt::DecorationRole) {
+ if (col == KTextEditor::CodeCompletionModel::Icon) {
+ return RKStandardIcons::iconForObject (object);
+ }
}
return QVariant ();
Modified: branches/KDE4_port/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- branches/KDE4_port/rkward/windows/rkcommandeditorwindow.h 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/rkward/windows/rkcommandeditorwindow.h 2007-10-24 20:27:59 UTC (rev 2120)
@@ -133,7 +133,8 @@
/** show a code completion box if appropriate. Use tryCompletionProxy () instead, which will call this function after a timeout */
void tryCompletion ();
void setPopupMenu ();
- void setPopupMenu (KTextEditor::View *);
+ void focusIn (KTextEditor::View *);
+ void focusOut (KTextEditor::View *);
/** Show help about the current word. */
void showHelp ();
/** run the currently selected command(s) */
Modified: branches/KDE4_port/rkward/windows/rkcommandeditorwindowpart.cpp
===================================================================
--- branches/KDE4_port/rkward/windows/rkcommandeditorwindowpart.cpp 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/rkward/windows/rkcommandeditorwindowpart.cpp 2007-10-24 20:27:59 UTC (rev 2120)
@@ -23,7 +23,7 @@
#include <kxmlguifactory.h>
#include "rkcommandeditorwindow.h"
-#include "../misc/rkcommonfunctions.h"
+#include "../misc/rkstandardicons.h"
#include "../debug.h"
RKCommandEditorWindowPart::RKCommandEditorWindowPart (QWidget *parent, RKCommandEditorWindow *editor_widget) : KParts::Part (parent) {
@@ -48,17 +48,17 @@
runAll = actionCollection ()->addAction ("run_all", command_editor, SLOT (runAll()));
runAll->setText (i18n ("Run all"));
- runAll->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/run_all.png"));
+ runAll->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunAll));
runAll->setShortcut (Qt::Key_F9);
runSelection = actionCollection ()->addAction ("run_selection", command_editor, SLOT (runSelection()));
runSelection->setText (i18n ("Run selection"));
- runSelection->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/run_selection.png"));
+ runSelection->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunSelection));
runSelection->setShortcut (Qt::Key_F9);
runLine = actionCollection ()->addAction ("run_line", command_editor, SLOT (runLine()));
runLine->setText (i18n ("Run current line"));
- runLine->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/run_line.png"));
+ runLine->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunLine));
runLine->setShortcut (Qt::ControlModifier + Qt::Key_L);
helpFunction = actionCollection ()->addAction ("function_reference", command_editor, SLOT (showHelp()));
Modified: branches/KDE4_port/rkward/windows/rkcommandlog.cpp
===================================================================
--- branches/KDE4_port/rkward/windows/rkcommandlog.cpp 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/rkward/windows/rkcommandlog.cpp 2007-10-24 20:27:59 UTC (rev 2120)
@@ -21,7 +21,7 @@
#include "../rkglobals.h"
#include "../rkconsole.h"
#include "../settings/rksettingsmodulewatch.h"
-#include "../misc/rkcommonfunctions.h"
+#include "../misc/rkstandardicons.h"
#include "rkcommandeditorwindow.h"
#include <qpushbutton.h>
@@ -276,7 +276,7 @@
run_selection = actionCollection ()->addAction ("log_run_selection", log, SLOT(runSelection()));
run_selection->setText (i18n ("Run selection"));
- run_selection->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/run_selection.png"));
+ run_selection->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunSelection));
run_selection->setShortcut (Qt::Key_F8);
connect (log->getView (), SIGNAL (popupMenuRequest (const QPoint &)), this, SLOT (doPopupMenu (const QPoint &)));
Modified: branches/KDE4_port/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- branches/KDE4_port/rkward/windows/rkhtmlwindow.cpp 2007-10-23 16:55:03 UTC (rev 2119)
+++ branches/KDE4_port/rkward/windows/rkhtmlwindow.cpp 2007-10-24 20:27:59 UTC (rev 2120)
@@ -39,6 +39,7 @@
#include "../rkconsole.h"
#include "../settings/rksettingsmodulegeneral.h"
#include "../misc/rkcommonfunctions.h"
+#include "../misc/rkstandardicons.h"
#include "../misc/xmlhelper.h"
#include "../plugin/rkcomponentmap.h"
#include "../windows/rkworkplace.h"
@@ -96,7 +97,7 @@
// run selection
run_selection = action_collection->addAction ("run_selection", this, SLOT (runSelection()));
run_selection->setText (i18n ("Run selection"));
- run_selection->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/run_selection.png"));
+ run_selection->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunSelection));
run_selection->setShortcut (Qt::Key_F8);
// needed to enable / disable the run selection action
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