[rkward-cvs] SF.net SVN: rkward:[4415] trunk/rkward/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Nov 6 18:40:39 UTC 2012


Revision: 4415
          http://rkward.svn.sourceforge.net/rkward/?rev=4415&view=rev
Author:   tfry
Date:     2012-11-06 18:40:38 +0000 (Tue, 06 Nov 2012)
Log Message:
-----------
Use editor and delegate from data.frame editor in matrix input element. This takes care of cursor handling issues.

Modified Paths:
--------------
    trunk/rkward/rkward/dataeditor/CMakeLists.txt
    trunk/rkward/rkward/dataeditor/twintable.cpp
    trunk/rkward/rkward/dataeditor/twintablemember.cpp
    trunk/rkward/rkward/dataeditor/twintablemember.h
    trunk/rkward/rkward/misc/CMakeLists.txt
    trunk/rkward/rkward/plugin/rkmatrixinput.cpp
    trunk/rkward/rkward/plugin/rkmatrixinput.h

Added Paths:
-----------
    trunk/rkward/rkward/misc/celleditor.cpp
    trunk/rkward/rkward/misc/celleditor.h
    trunk/rkward/rkward/misc/editformatdialog.cpp
    trunk/rkward/rkward/misc/editformatdialog.h
    trunk/rkward/rkward/misc/editlabelsdialog.cpp
    trunk/rkward/rkward/misc/editlabelsdialog.h

Removed Paths:
-------------
    trunk/rkward/rkward/dataeditor/celleditor.cpp
    trunk/rkward/rkward/dataeditor/celleditor.h
    trunk/rkward/rkward/dataeditor/editformatdialog.cpp
    trunk/rkward/rkward/dataeditor/editformatdialog.h
    trunk/rkward/rkward/dataeditor/editlabelsdialog.cpp
    trunk/rkward/rkward/dataeditor/editlabelsdialog.h

Modified: trunk/rkward/rkward/dataeditor/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/dataeditor/CMakeLists.txt	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/dataeditor/CMakeLists.txt	2012-11-06 18:40:38 UTC (rev 4415)
@@ -8,9 +8,6 @@
    twintablemember.cpp
    rkeditor.cpp
    rkeditordataframe.cpp
-   celleditor.cpp
-   editlabelsdialog.cpp
-   editformatdialog.cpp
    rkvareditmodel.cpp
    rktextmatrix.cpp
    )

Deleted: trunk/rkward/rkward/dataeditor/celleditor.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/celleditor.cpp	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/dataeditor/celleditor.cpp	2012-11-06 18:40:38 UTC (rev 4415)
@@ -1,116 +0,0 @@
-/***************************************************************************
-                          celleditor  -  description
-                             -------------------
-    begin                : Mon Sep 13 2004
-    copyright            : (C) 2004, 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 "celleditor.h"
-
-#include <QMenu>
-#include <QTimer>
-#include <QEvent>
-#include <QKeyEvent>
-
-#include "../debug.h"
-
-CellEditor::CellEditor (QWidget* parent) : QLineEdit (parent) {
-	RK_TRACE (EDITOR);
-
-	setFrame (false);
-
-	value_list = 0;
-}
-
-CellEditor::~CellEditor () {
-	RK_TRACE (EDITOR);
-}
-
-void CellEditor::setValueLabels (const RObject::ValueLabels& labels) {
-	RK_TRACE (EDITOR);
-
-	if (labels.isEmpty ()) return;
-
-// NOTE: not using a QComboBox, as we do not want it to pop up immediately
-	value_list = new QMenu (this);
-	value_list->setFont (font ());
-	value_list->setPalette (palette ());
-	value_list->setFocusProxy (this);
-	value_list->installEventFilter (this);	// somehow setting us as a focus proxy is not enough to continue to receive the key-presses
-
-	for (RObject::ValueLabels::const_iterator it = labels.constBegin (); it != labels.constEnd (); ++it) {
-		value_list->addAction (it.key () + ": " + it.value ())->setData (it.key ());
-	}
-	connect (value_list, SIGNAL (triggered(QAction*)), SLOT (selectedFromList(QAction*)));
-
-	QTimer::singleShot (200, this, SLOT (showValueLabels ()));
-}
-
-void CellEditor::selectedFromList (QAction* action) {
-	RK_TRACE (EDITOR);
-	RK_ASSERT (action);
-
-	setText (action->data ().toString ());	// which is a string representation of an int, really
-}
-
-void CellEditor::setText (const QString& text) {
-	RK_TRACE (EDITOR);
-
-	QLineEdit::setText (text);
-	selectAll ();
-}
-
-void CellEditor::showValueLabels () {
-	RK_TRACE (EDITOR);
-	RK_ASSERT (value_list);
-
-	QPoint pos = mapToGlobal (QPoint (5, height ()+5));
-	value_list->popup (QPoint (pos));
-}
-
-void CellEditor::keyPressEvent (QKeyEvent *e) {
-	if (e->modifiers () == Qt::NoModifier) {
-		if ((e->key () == Qt::Key_Left) || (e->key () == Qt::Key_Backspace)) {
-			if (cursorPosition () < 1) {
-				emit (done (this, RKItemDelegate::EditorExitLeft));
-				return;
-			}
-		}
-		if (e->key () == Qt::Key_Right) {
-			if (cursorPosition () >= (int) text ().length ()) {
-				emit (done (this, RKItemDelegate::EditorExitRight));
-				return;
-			}
-		}
-		if (e->key () == Qt::Key_Up) {
-			emit (done (this, RKItemDelegate::EditorExitUp));
-			return;
-		}
-		if (e->key () == Qt::Key_Down) {
-			emit (done (this, RKItemDelegate::EditorExitDown));
-			return;
-		}
-	}
-	QLineEdit::keyPressEvent (e);
-}
-
-bool CellEditor::eventFilter (QObject* object, QEvent* e) {
-	if (object && (object == value_list)) {
-		if (e->type() == QEvent::KeyPress) {
-			RK_TRACE (EDITOR);
-			return event (e);
-		}
-	}
-	return false;
-}
-
-#include "celleditor.moc"

Deleted: trunk/rkward/rkward/dataeditor/celleditor.h
===================================================================
--- trunk/rkward/rkward/dataeditor/celleditor.h	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/dataeditor/celleditor.h	2012-11-06 18:40:38 UTC (rev 4415)
@@ -1,62 +0,0 @@
-/***************************************************************************
-                          celleditor  -  description
-                             -------------------
-    begin                : Mon Sep 13 2004
-    copyright            : (C) 2004, 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 CELLEDITOR_H
-#define CELLEDITOR_H
-
-#include <QLineEdit>
-#include <QList>
-
-#include "../core/robject.h"
-#include "twintablemember.h"
-
-class QStringList;
-class QMenu;
-class QEvent;
-class QKeyEvent;
-
-/**
-This is the main editor used in the TwinTableMembers
-
-TODO: the acutal editor will have to be separated from the value_list-popup in order to allow showing the popup, even if the list does not have strong
-focus.
-
- at author Thomas Friedrichsmeier
-*/
-class CellEditor : public QLineEdit {
-Q_OBJECT
-public:
-	CellEditor (QWidget* parent);
-	~CellEditor ();
-
-	void setValueLabels (const RObject::ValueLabels& labels);
-
-	void setText (const QString& text);
-signals:
-	void done (QWidget* widget, RKItemDelegate::EditorDoneReason reason);
-public slots:
-	void selectedFromList (QAction* action);
-	void showValueLabels ();
-protected:
-/// reimplemented to ignore arrow left/right if at the beginning/end
-	void keyPressEvent (QKeyEvent *e);
-	bool eventFilter (QObject* object, QEvent* event);
-private:
-	QMenu *value_list;
-	TwinTableMember *table;
-};
-
-#endif

Deleted: trunk/rkward/rkward/dataeditor/editformatdialog.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/editformatdialog.cpp	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/dataeditor/editformatdialog.cpp	2012-11-06 18:40:38 UTC (rev 4415)
@@ -1,148 +0,0 @@
-/***************************************************************************
-                          editformatdialog  -  description
-                             -------------------
-    begin                : Thu Sep 30 2004
-    copyright            : (C) 2004 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 "editformatdialog.h"
-
-#include <QButtonGroup>
-#include <QGroupBox>
-#include <qradiobutton.h>
-#include <qspinbox.h>
-#include <qstringlist.h>
-#include <QVBoxLayout>
-#include <QTimer>
-
-#include <klocale.h>
-#include <kvbox.h>
-
-#include "../core/rkvariable.h"
-#include "../rkglobals.h"
-#include "../debug.h"
-
-EditFormatDialog::EditFormatDialog (QWidget *parent) : KDialog (parent) {
-	RK_TRACE (EDITOR);
-
-	KVBox *vbox = new KVBox ();
-	setMainWidget (vbox);
-
-	alignment_group = new QButtonGroup (this);
-	QGroupBox* alignment_box = new QGroupBox (i18n ("Alignment"), vbox);
-	QVBoxLayout* group_layout = new QVBoxLayout (alignment_box);
-	group_layout->setContentsMargins (0, 0, 0, 0);
-	QRadioButton* button;
-	alignment_group->addButton (button = new QRadioButton (i18n ("Default"), alignment_box), (int) RKVariable::FormattingOptions::AlignDefault);
-	group_layout->addWidget (button);
-	alignment_group->addButton (button = new QRadioButton (i18n ("Left"), alignment_box), (int) RKVariable::FormattingOptions::AlignLeft);
-	group_layout->addWidget (button);
-	alignment_group->addButton (button = new QRadioButton (i18n ("Right"), alignment_box), (int) RKVariable::FormattingOptions::AlignRight);
-	group_layout->addWidget (button);
-	alignment_group->button ((int) RKVariable::FormattingOptions::AlignDefault)->setChecked (true);
-
-	precision_group = new QButtonGroup (this);
-	QGroupBox* precision_box = new QGroupBox (i18n ("Decimal Places"), vbox);
-	group_layout = new QVBoxLayout (precision_box);
-	precision_group->addButton (button = new QRadioButton (i18n ("Default setting"), precision_box), (int) RKVariable::FormattingOptions::PrecisionDefault);
-	group_layout->addWidget (button);
-	precision_group->addButton (button = new QRadioButton (i18n ("As required"), precision_box), (int) RKVariable::FormattingOptions::PrecisionRequired);
-	group_layout->addWidget (button);
-	precision_group->addButton (button = new QRadioButton (i18n ("Fixed precision:"), precision_box), (int) RKVariable::FormattingOptions::PrecisionFixed);
-	group_layout->addWidget (button);
-	precision_field = new QSpinBox (precision_box);
-	precision_field->setRange (0, 10);
-	connect (precision_field, SIGNAL (valueChanged (int)), this, SLOT (precisionFieldChanged (int)));
-	group_layout->addWidget (precision_field);
-	precision_group->button ((int) RKVariable::FormattingOptions::PrecisionDefault)->setChecked (true);
-
-	setButtons (KDialog::Ok | KDialog::Cancel);
-}
-
-EditFormatDialog::~EditFormatDialog () {
-	RK_TRACE (EDITOR);
-}
-
-void EditFormatDialog::initialize (const RKVariable::FormattingOptions& options, const QString& varname) {
-	RK_TRACE (EDITOR);
-
-	setCaption (i18n ("Formatting options for '%1'", varname));
-
-	EditFormatDialog::options = options;
-
-	alignment_group->button ((int) options.alignment)->setChecked (true);
-	precision_group->button ((int) options.precision_mode)->setChecked (true);
-	precision_field->setValue (options.precision);
-}
-
-void EditFormatDialog::accept () {
-	RK_TRACE (EDITOR);
-
-	options.alignment = (RKVariable::FormattingOptions::Alignment) alignment_group->checkedId ();
-
-	options.precision_mode = (RKVariable::FormattingOptions::Precision) precision_group->checkedId ();
-	if (options.precision_mode == RKVariable::FormattingOptions::PrecisionFixed) {
-		options.precision = precision_field->value ();
-	} else {
-		options.precision = 0;
-	}
-
-	KDialog::accept ();
-}
-
-void EditFormatDialog::precisionFieldChanged (int) {
-	RK_TRACE (EDITOR);
-
-	precision_group->button ((int) RKVariable::FormattingOptions::PrecisionFixed)->setChecked (true);
-}
-
-
-///////////// EditFormatDialogProxy ////////////////////
-
-EditFormatDialogProxy::EditFormatDialogProxy (QWidget* parent) : QWidget (parent) {
-	RK_TRACE (EDITOR);
-
-	dialog = 0;
-}
-
-EditFormatDialogProxy::~EditFormatDialogProxy () {
-	RK_TRACE (EDITOR);
-}
-
-void EditFormatDialogProxy::initialize (const RKVariable::FormattingOptions& options, const QString& varname) {
-	RK_TRACE (EDITOR);
-
-	if (dialog) return;	// one dialog at a time, please!
-
-	EditFormatDialogProxy::options = options;
-	dialog = new EditFormatDialog (this);
-	dialog->initialize (options, varname);
-
-	connect (dialog, SIGNAL (finished(int)), this, SLOT (dialogDone(int)));
-	QTimer::singleShot (0, dialog, SLOT (exec()));
-}
-
-void EditFormatDialogProxy::dialogDone (int result) {
-	RK_TRACE (EDITOR);
-	RK_ASSERT (dialog);
-
-	if (result == QDialog::Accepted) {
-		options = dialog->options;
-		emit (done (this, RKItemDelegate::EditorExit));
-	} else {
-		emit (done (this, RKItemDelegate::EditorReject));
-	}
-	dialog->deleteLater ();
-	dialog = 0;
-}
-
-#include "editformatdialog.moc"

Deleted: trunk/rkward/rkward/dataeditor/editformatdialog.h
===================================================================
--- trunk/rkward/rkward/dataeditor/editformatdialog.h	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/dataeditor/editformatdialog.h	2012-11-06 18:40:38 UTC (rev 4415)
@@ -1,74 +0,0 @@
-/***************************************************************************
-                          editformatdialog  -  description
-                             -------------------
-    begin                : Thu Sep 30 2004
-    copyright            : (C) 2004 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 EDITFORMATDIALOG_H
-#define EDITFORMATDIALOG_H
-
-#include <kdialog.h>
-
-#include "../core/rkvariable.h"
-#include "twintablemember.h"
-
-class QButtonGroup;
-class QSpinBox;
-
-/**
-Allows editing of format-attributes for an RKVariable
-
- at author Thomas Friedrichsmeier
-*/
-class EditFormatDialog : public KDialog {
-	Q_OBJECT
-public slots:
-	void precisionFieldChanged (int);
-protected:
-/** reimplemented to make the newly selected options available */
-	void accept ();
-
-friend class EditFormatDialogProxy;
-/** ctor */
-	EditFormatDialog (QWidget *parent);
-/** dtor */
-	~EditFormatDialog ();
-
-/** initializes the GUI-options from the settings for the variable */
-	void initialize (const RKVariable::FormattingOptions& options, const QString& varname);
-private:
-	QButtonGroup *alignment_group;
-	QButtonGroup *precision_group;
-	QSpinBox *precision_field;
-	RKVariable::FormattingOptions options;
-};
-
-/** Simple proxy wrapper to allow using a model EditFormatDialog in a QTableView */
-class EditFormatDialogProxy : public QWidget {
-	Q_OBJECT
-public:
-	EditFormatDialogProxy (QWidget* parent);
-	~EditFormatDialogProxy ();
-
-	void initialize (const RKVariable::FormattingOptions& options, const QString& varname);
-	RKVariable::FormattingOptions getOptions () const { return options; };
-signals:
-	void done (QWidget* widget, RKItemDelegate::EditorDoneReason reason);
-protected slots:
-	void dialogDone (int result);
-private:
-	RKVariable::FormattingOptions options;
-	EditFormatDialog* dialog;
-};
-
-#endif

Deleted: trunk/rkward/rkward/dataeditor/editlabelsdialog.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/editlabelsdialog.cpp	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/dataeditor/editlabelsdialog.cpp	2012-11-06 18:40:38 UTC (rev 4415)
@@ -1,281 +0,0 @@
-/***************************************************************************
-                          editlabelsdialog  -  description
-                             -------------------
-    begin                : Tue Sep 21 2004
-    copyright            : (C) 2004, 2006, 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 "editlabelsdialog.h"
-
-#include <klocale.h>
-#include <kdialog.h>
-#include <kaction.h>
-#include <kactioncollection.h>
-#include <kvbox.h>
-
-#include <qlabel.h>
-#include <qlayout.h>
-#include <QHeaderView>
-#include <QTimer>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
-
-#include "../core/rkvariable.h"
-#include "rktextmatrix.h"
-#include "celleditor.h"
-
-#include "../debug.h"
-
-RKVarLevelsTable::RKVarLevelsTable (QWidget *parent, const RObject::ValueLabels& labels) : QTableView (parent) {
-	RK_TRACE (EDITOR);
-
-	setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
-	setSelectionMode (QAbstractItemView::ContiguousSelection);
-	horizontalHeader ()->setStretchLastSection (true);
-	verticalHeader ()->setFixedWidth (40);
-	setMinimumWidth (80);
-
-	KActionCollection *ac = new KActionCollection (this);
-	ac->addAction (KStandardAction::Cut, this, SLOT (cut ()));
-	ac->addAction (KStandardAction::Copy, this, SLOT (copy ()));
-	ac->addAction (KStandardAction::Paste, this, SLOT (paste ()));
-
-	setModel (lmodel = new RKVarLevelsTableModel (labels, this));
-}
-
-RKVarLevelsTable::~RKVarLevelsTable () {
-	RK_TRACE (EDITOR);
-}
-
-bool RKVarLevelsTable::getSelectionBoundaries (int* top, int* bottom) const {
-	RK_TRACE (EDITOR);
-
-	RK_ASSERT (selectionModel ());
-	QItemSelection sel = selectionModel ()->selection ();
-	if (sel.isEmpty ()){
-		QModelIndex current = currentIndex ();
-		if (!current.isValid ()) return false;
-
-		*top = current.row ();
-		*bottom = current.row ();
-	} else {
-		RK_ASSERT (sel.size () == 1);
-		*top = sel[0].top ();
-		*bottom = sel[0].bottom ();
-	}
-	return true;
-}
-
-void RKVarLevelsTable::cut () {
-	RK_TRACE (EDITOR);
-
-	int top;
-	int bottom;
-	if (!getSelectionBoundaries (&top, &bottom)) return;
-
-	copy ();
-
-	for (int i = top; i <= bottom; ++i) lmodel->setData (lmodel->index (i, 0), QString ());
-}
-
-void RKVarLevelsTable::copy () {
-	RK_TRACE (EDITOR);
-
-	int top;
-	int bottom;
-	if (!getSelectionBoundaries (&top, &bottom)) return;
-
-	RKTextMatrix mat;
-	int trow = 0;
-	for (int i = top; i <= bottom; ++i) {
-		mat.setText (trow++, 0, lmodel->data (lmodel->index (i, 0)).toString ());
-	}
-	mat.copyToClipboard ();
-}
-
-void RKVarLevelsTable::paste () {
-	RK_TRACE (EDITOR);
-
-// Unfortunately, we need to duplicate some of TwinTable::paste () and RKEditorDataFramPart::doPaste. Those are not easy to reconcile.
-	QModelIndex current = currentIndex ();
-	if (!current.isValid ()) return;
-	int row = current.row ();
-	RK_ASSERT (current.column () == 0);
-
-	RKTextMatrix pasted = RKTextMatrix::matrixFromClipboard ();
-	if (pasted.isEmpty ()) return;
-
-	if (pasted.numColumns () > 1) {		// there were tabs in the pasted text. Let's transpose the first row
-		for (int i = 0; i < pasted.numColumns (); ++i) {
-			lmodel->setData (lmodel->index (row++, 0), pasted.getText (0, i));
-		}
-	} else {		// else paste the first column
-		for (int i = 0; i < pasted.numRows (); ++i) {
-			lmodel->setData (lmodel->index (row++, 0), pasted.getText (i, 0));
-		}
-	}
-}
-
-/////////////// RKVarLevelsTableModel /////////////////
-
-RKVarLevelsTableModel::RKVarLevelsTableModel (const RObject::ValueLabels& labels, QObject* parent) : QAbstractTableModel (parent) {
-	RK_TRACE (EDITOR);
-
-	RKVarLevelsTableModel::labels = labels;
-}
-
-RKVarLevelsTableModel::~RKVarLevelsTableModel () {
-	RK_TRACE (EDITOR);
-}
-
-int RKVarLevelsTableModel::rowCount (const QModelIndex& parent) const {
-	RK_TRACE (EDITOR);
-
-	if (parent.isValid ()) return 0;
-	return labels.count () + 1;
-}
-
-int RKVarLevelsTableModel::columnCount (const QModelIndex& parent) const {
-	RK_TRACE (EDITOR);
-
-	if (parent.isValid ()) return 0;
-	return 1;
-}
-
-QVariant RKVarLevelsTableModel::data (const QModelIndex& index, int role) const {
-	RK_TRACE (EDITOR);
-
-	if (!index.isValid ()) return QVariant ();
-	if (index.column () != 0) return QVariant ();
-	if ((role == Qt::BackgroundRole) && (index.row () == labels.count ())) return QBrush (Qt::gray);
-	if (index.row () >= labels.count ()) return QVariant ();
-
-	if ((role == Qt::DisplayRole) || (role == Qt::EditRole)) return labels.value (QString::number (index.row ()+1));
-
-	return QVariant ();
-}
-
-Qt::ItemFlags RKVarLevelsTableModel::flags (const QModelIndex& index) const {
-	RK_TRACE (EDITOR);
-
-	if (!index.isValid ()) return 0;
-	if (index.column () != 0) return 0;
-	if (index.row () >= labels.count ()) return (Qt::ItemIsEditable | Qt::ItemIsEnabled);
-	return (Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
-}
-
-bool RKVarLevelsTableModel::setData (const QModelIndex& index, const QVariant& value, int role) {
-	RK_TRACE (EDITOR);
-
-	if (role != Qt::EditRole) return false;
-	if (!index.isValid ()) return false;
-	if (index.column () != 0) return false;
-	if (!value.isValid ()) return false;
-	if (index.row () > labels.count ()) return false;
-
-	QString text = value.toString ();
-	if (index.row () == labels.count ()) {
-		beginInsertRows (QModelIndex (), index.row (), index.row ());
-		labels.insert (QString::number (index.row () + 1), text);
-		endInsertRows ();
-	} else {
-		labels.insert (QString::number (index.row () + 1), text);
-		emit (dataChanged (index, index));
-	}
-
-	if (text.isEmpty ()) {	// remove trailing empty rows
-		while ((!labels.isEmpty ()) && labels.value (QString::number (labels.count ())).isEmpty ()) {
-			int row = labels.count () - 1;
-			beginRemoveRows (QModelIndex (), row, row);
-			labels.remove (QString::number (row + 1));
-			endRemoveRows ();
-		}
-	}
-
-	return true;
-}
-
-QVariant RKVarLevelsTableModel::headerData (int section, Qt::Orientation orientation, int role) const {
-	RK_TRACE (EDITOR);
-
-	if (role != Qt::DisplayRole) return QVariant ();
-	if (orientation == Qt::Vertical) return QString::number (section + 1);
-	if (section != 0) return QVariant ();
-	return i18n ("Label");
-}
-
-//////////////// EditLabelsDialog ///////////////////////
-
-EditLabelsDialog::EditLabelsDialog (QWidget *parent, const RObject::ValueLabels& labels, const QString& varname) : KDialog (parent) {
-	RK_TRACE (EDITOR);
-
-	KVBox *mainvbox = new KVBox ();
-	setMainWidget (mainvbox);
-	QLabel *label = new QLabel (i18n ("Levels can be assigned only to consecutive integers starting with 1 (the index column is read only). To remove levels at the end of the list, just set them to empty."), mainvbox);
-	label->setWordWrap (true);
-
-	table = new RKVarLevelsTable (mainvbox, labels);
-
-	setButtons (KDialog::Ok | KDialog::Cancel);
-	setCaption (i18n ("Levels / Value labels for '%1'", varname));
-}
-
-EditLabelsDialog::~EditLabelsDialog () {
-	RK_TRACE (EDITOR);
-}
-
-void EditLabelsDialog::accept () {
-	RK_TRACE (EDITOR);
-
-	table->setCurrentIndex (QModelIndex ());	// should flush editing
-	KDialog::accept ();
-}
-
-////////////////// EditLabelsDialogProxy /////////////////////////
-
-EditLabelsDialogProxy::EditLabelsDialogProxy (QWidget* parent) : QWidget (parent) {
-	RK_TRACE (EDITOR);
-	dialog = 0;
-}
-
-EditLabelsDialogProxy::~EditLabelsDialogProxy () {
-	RK_TRACE (EDITOR);
-}
-
-void EditLabelsDialogProxy::initialize (const RObject::ValueLabels& labels, const QString& varname) {
-	RK_TRACE (EDITOR);
-
-	if (dialog) return;	// one dialog at a time, please!
-
-	EditLabelsDialogProxy::labels = labels;		// we need to take a copy in case the dialog is rejected
-
-	dialog = new EditLabelsDialog (this, labels, varname);
-	connect (dialog, SIGNAL (finished(int)), this, SLOT (dialogDone(int)));
-	QTimer::singleShot (0, dialog, SLOT (exec()));
-}
-
-void EditLabelsDialogProxy::dialogDone (int result) {
-	RK_TRACE (EDITOR);
-	RK_ASSERT (dialog);
-
-	if (result == QDialog::Accepted) {
-		labels = dialog->table->lmodel->labels;
-		emit (done (this, RKItemDelegate::EditorExit));
-	} else {
-		emit (done (this, RKItemDelegate::EditorReject));
-	}
-	dialog->deleteLater ();
-	dialog = 0;
-}
-
-
-#include "editlabelsdialog.moc"

Deleted: trunk/rkward/rkward/dataeditor/editlabelsdialog.h
===================================================================
--- trunk/rkward/rkward/dataeditor/editlabelsdialog.h	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/dataeditor/editlabelsdialog.h	2012-11-06 18:40:38 UTC (rev 4415)
@@ -1,112 +0,0 @@
-/***************************************************************************
-                          editlabelsdialog  -  description
-                             -------------------
-    begin                : Tue Sep 21 2004
-    copyright            : (C) 2004, 2006, 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 EDITLABELSDIALOG_H
-#define EDITLABELSDIALOG_H
-
-#include <kdialog.h>
-
-#include <QTableView>
-#include <QAbstractTableModel>
-
-#include "../core/robject.h"
-#include "twintablemember.h"
-
-class RKVariable;
-class RKVarLevelsTableModel;
-
-/** special mini class provides the table in EditLabelsDialog
-
- at author Thomas Friedrichsmeier
-*/
-class RKVarLevelsTable : public QTableView {
-	Q_OBJECT
-public:
-	RKVarLevelsTable (QWidget *parent, const RObject::ValueLabels& labels);
-	~RKVarLevelsTable ();
-public slots:
-/** cut */
-	void cut ();
-/** cut */
-	void copy ();
-/** paste */
-	void paste ();
-private:
-	bool getSelectionBoundaries (int* top, int* bottom) const;
-friend class EditLabelsDialogProxy;
-	RKVarLevelsTableModel* lmodel;
-	bool updating_size;
-};
-
-/** Data model for the RKVarLevelsTable */
-class RKVarLevelsTableModel : public QAbstractTableModel {
-public:
-	RKVarLevelsTableModel (const RObject::ValueLabels& labels, QObject* parent);
-	~RKVarLevelsTableModel ();
-
-	int rowCount (const QModelIndex& parent = QModelIndex()) const;
-	int columnCount (const QModelIndex& parent = QModelIndex()) const;
-	QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
-	Qt::ItemFlags flags (const QModelIndex& index) const;
-	bool setData (const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
-	QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
-private:
-friend class EditLabelsDialogProxy;
-	RObject::ValueLabels labels;
-};
-
-/**
-Allows editing of value labels / factor levels for an RKVariable. Use EditLabelsDialogProxy.
-
- at author Thomas Friedrichsmeier
-*/
-class EditLabelsDialog : public KDialog {
-protected:
-friend class EditLabelsDialogProxy;
-/** constuctor., the variable to work on.
- at param parent a QWidget parent */
-	EditLabelsDialog (QWidget *parent, const RObject::ValueLabels& labels, const QString& varname);
-
-	~EditLabelsDialog ();
-
-/** reimplemented to make sure pending edit operations are not lost */
-	void accept ();
-private:
-	RKVarLevelsTable* table;
-};
-
-/**
-Simple proxy / wrapper to allow using a modal EditLabelsDialog in a QTableView
- at author Thomas Friedrichsmeier */
-class EditLabelsDialogProxy : public QWidget {
-	Q_OBJECT
-public:
-	EditLabelsDialogProxy (QWidget* parent);
-	~EditLabelsDialogProxy ();
-
-	void initialize (const RObject::ValueLabels& labels, const QString& varname);
-
-	RObject::ValueLabels getLabels () const { return labels; };
-signals:
-	void done (QWidget* widget, RKItemDelegate::EditorDoneReason reason);
-protected slots:
-	void dialogDone (int result);
-private:
-	EditLabelsDialog* dialog;
-	RObject::ValueLabels labels;
-};
-
-#endif

Modified: trunk/rkward/rkward/dataeditor/twintable.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/twintable.cpp	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/dataeditor/twintable.cpp	2012-11-06 18:40:38 UTC (rev 4415)
@@ -160,8 +160,8 @@
 	dataview->setRKModel (model);
 	metaview->setRKModel (model->getMetaModel ());
 	model->setEditor (this);
-	dataview->seRKItemDelegate (new RKItemDelegate (this, datamodel));
-	metaview->seRKItemDelegate (new RKItemDelegate (this, datamodel->getMetaModel ()));
+	dataview->setRKItemDelegate (new RKItemDelegate (this, datamodel));
+	metaview->setRKItemDelegate (new RKItemDelegate (this, datamodel->getMetaModel ()));
 
 	metaview->setMinimumHeight (metaview->horizontalHeader ()->height ());
 	metaview->setMaximumHeight (metaview->rowHeight (0) * 5 + metaview->horizontalHeader ()->height () + 5);

Modified: trunk/rkward/rkward/dataeditor/twintablemember.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/twintablemember.cpp	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/dataeditor/twintablemember.cpp	2012-11-06 18:40:38 UTC (rev 4415)
@@ -21,9 +21,6 @@
 #include <QScrollBar>
 #include <QHeaderView>
 
-#include "celleditor.h"
-#include "editformatdialog.h"
-#include "editlabelsdialog.h"
 #include "twintable.h"
 #include "rktextmatrix.h"
 #include "rkvareditmodel.h"
@@ -62,13 +59,6 @@
 	connect (selectionModel (), SIGNAL (selectionChanged(const QItemSelection&,const QItemSelection&)), this, SLOT (tableSelectionChanged(const QItemSelection&,const QItemSelection&)));
 }
 
-void TwinTableMember::seRKItemDelegate (RKItemDelegate* delegate) {
-	RK_TRACE (EDITOR);
-
-	setItemDelegate (delegate);
-	connect (delegate, SIGNAL (doCloseEditor(QWidget*,RKItemDelegate::EditorDoneReason)), this, SLOT (editorDone(QWidget*,RKItemDelegate::EditorDoneReason)));
-}
-
 void TwinTableMember::setTwin (TwinTableMember * new_twin) {
 	RK_TRACE (EDITOR);
 	twin = new_twin;
@@ -84,33 +74,12 @@
 	if (!selected.isEmpty ()) twin->clearSelection ();
 }
 
-void TwinTableMember::editorDone (QWidget* editor, RKItemDelegate::EditorDoneReason reason) {
-	RK_TRACE (EDITOR);
+int TwinTableMember::trueColumns () const {
+    return mymodel->trueCols ();
+}
 
-	int row = currentIndex ().row ();
-	int col = currentIndex ().column ();
-
-	closeEditor (editor, QAbstractItemDelegate::NoHint);
-
-	if (reason == RKItemDelegate::EditorExitRight) ++col;
-	else if (reason == RKItemDelegate::EditorExitLeft) --col;
-	else if (reason == RKItemDelegate::EditorExitUp) --row;
-	else if (reason == RKItemDelegate::EditorExitDown) ++row;
-
-	if (row >= mymodel->trueRows ()) {
-		// if we have edited the trailing row, a new row may have been inserted, apparently *above* the
-		// current index. We need to fix this up. Basically, we can only ever be in the last row after
-		// a reject, or an exit to the next row
-		if ((reason != RKItemDelegate::EditorExitDown) && (reason != RKItemDelegate::EditorReject)) --row;
-	}
-	if (col >= mymodel->trueCols ()) {
-		// see above
-		if ((reason != RKItemDelegate::EditorExitRight) && (reason != RKItemDelegate::EditorReject)) --col;
-	}
-
-	if ((row < mymodel->rowCount ()) && (col < mymodel->columnCount ())) {
-		setCurrentIndex (mymodel->index (row, col));
-	}
+int TwinTableMember::trueRows () const {
+    return mymodel->trueRows();
 }
 
 void TwinTableMember::stopEditing () {
@@ -213,154 +182,4 @@
 	}
 }
 
-/////////////////// RKItemDelegate /////////////////////
-
-RKItemDelegate::RKItemDelegate (QObject *parent, RKVarEditModel* datamodel) : QItemDelegate (parent) {
-	RK_TRACE (EDITOR);
-
-	RKItemDelegate::datamodel = datamodel;
-	metamodel = 0;
-	locked_for_modal_editor = false;
-}
-
-RKItemDelegate::RKItemDelegate (QObject *parent, RKVarEditMetaModel* metamodel) : QItemDelegate (parent) {
-	RK_TRACE (EDITOR);
-
-	RKItemDelegate::metamodel = metamodel;
-	datamodel = 0;
-	locked_for_modal_editor = false;
-}
-
-RKItemDelegate::~RKItemDelegate () {
-	RK_TRACE (EDITOR);
-}
-
-QWidget* RKItemDelegate::createEditor (QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const {
-	RK_TRACE (EDITOR);
-
-	QWidget* ed = 0;
-	if (datamodel) {
-		ed = new CellEditor (parent);
-	} else if (metamodel) {
-		int row = index.row ();
-		if (row == RKVarEditMetaModel::FormatRow) {
-			ed = new EditFormatDialogProxy (parent);
-			const_cast<RKItemDelegate*> (this)->locked_for_modal_editor = true;
-		} else if (row == RKVarEditMetaModel::LevelsRow) {
-			ed = new EditLabelsDialogProxy (parent);
-			const_cast<RKItemDelegate*> (this)->locked_for_modal_editor = true;
-		} else {
-			ed = new CellEditor (parent);
-		}
-	}
-
-	if (ed) {
-		ed->setFont (option.font);
-		connect (ed, SIGNAL (done(QWidget*,RKItemDelegate::EditorDoneReason)), this, SLOT (editorDone(QWidget*,RKItemDelegate::EditorDoneReason)));
-		return ed;
-	}
-
-	RK_ASSERT (false);
-	return 0;
-}
-
-void RKItemDelegate::setEditorData (QWidget* editor, const QModelIndex& index) const {
-	RK_TRACE (EDITOR);
-
-	if (!index.isValid ()) return;
-
-	if (datamodel) {
-		CellEditor* ced = static_cast<CellEditor*> (editor);
-		ced->setText (datamodel->data (index, Qt::EditRole).toString ());
-
-		if (index.column () < datamodel->trueCols ()) {
-			ced->setValueLabels (datamodel->getObject (index.column ())->getValueLabels ());
-		}
-	} else if (metamodel) {
-		int row = index.row ();
-		if (row == RKVarEditMetaModel::FormatRow) {
-			EditFormatDialogProxy* fed = static_cast<EditFormatDialogProxy*> (editor);
-			fed->initialize (RKVariable::parseFormattingOptionsString (metamodel->data (index, Qt::EditRole).toString ()), metamodel->headerData (index.column (), Qt::Horizontal).toString ());
-		} else if (row == RKVarEditMetaModel::LevelsRow) {
-			EditLabelsDialogProxy* led = static_cast<EditLabelsDialogProxy*> (editor);
-			led->initialize (metamodel->getValueLabels (index.column ()), metamodel->headerData (index.column (), Qt::Horizontal).toString ());
-		} else {
-			CellEditor* ced = static_cast<CellEditor*> (editor);
-			ced->setText (metamodel->data (index, Qt::EditRole).toString ());
-
-			if (row == RKVarEditMetaModel::TypeRow) {
-				RObject::ValueLabels labels;
-				for (int i = RObject::MinKnownDataType; i <= RObject::MaxKnownDataType; ++i) {
-					labels.insert (QString::number (i), RObject::typeToText ((RObject::RDataType) i));
-				}
-				ced->setValueLabels (labels);
-			}
-		}
-	} else {
-		RK_ASSERT (false);
-	}
-
-
-}
-
-void RKItemDelegate::setModelData (QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const {
-	RK_TRACE (EDITOR);
-
-	if (!index.isValid ()) return;
-
-	if (datamodel) {
-		RK_ASSERT (model == datamodel);
-		// real work is done down below
-	} else if (metamodel) {
-		RK_ASSERT (model == metamodel);
-
-		int row = index.row ();
-		if (row == RKVarEditMetaModel::FormatRow) {
-			EditFormatDialogProxy* fed = static_cast<EditFormatDialogProxy*> (editor);
-			model->setData (index, RKVariable::formattingOptionsToString (fed->getOptions ()), Qt::EditRole);
-			return;
-		} else if (row == RKVarEditMetaModel::LevelsRow) {
-			EditLabelsDialogProxy* led = static_cast<EditLabelsDialogProxy*> (editor);
-			metamodel->setValueLabels (index.column (), led->getLabels ());
-			return;
-		} // else all others use the regular CellEditor
-	} else {
-		RK_ASSERT (false);
-	}
-
-	CellEditor* ced = static_cast<CellEditor*> (editor);
-	model->setData (index, ced->text (), Qt::EditRole);
-}
-
-bool RKItemDelegate::eventFilter (QObject* object, QEvent* event) {
-	RK_TRACE (EDITOR);
-
-	if (locked_for_modal_editor) return false;	// Needed on MacOSX: Pressing Ok in one of the modal editors seems to
-							// generate a Return-like event.
-							// This would be handled *before* the editor had a chance to update its data,
-							// thus committing the old, not new state.
-
-	QWidget *editor = qobject_cast<QWidget*> (object);
-	if (!editor) return false;
-
-	if (event->type() == QEvent::KeyPress) {
-		QKeyEvent* ke = static_cast<QKeyEvent *> (event);
-		if (ke->key () == Qt::Key_Tab) editorDone (editor, EditorExitRight);
-		else if (ke->key () == Qt::Key_Tab) editorDone (editor, EditorExitRight);
-		else if (ke->key () == Qt::Key_Enter) editorDone (editor, EditorExitDown);
-		else if (ke->key () == Qt::Key_Return) editorDone (editor, EditorExitDown);
-		else return QItemDelegate::eventFilter (editor, event);
-		return true;
-	}
-	return QItemDelegate::eventFilter (editor, event);
-}
-
-void RKItemDelegate::editorDone (QWidget* editor, RKItemDelegate::EditorDoneReason reason) {
-	RK_TRACE (EDITOR);
-
-	if (reason != EditorReject) commitData (editor);
-	emit (doCloseEditor (editor, reason));
-	locked_for_modal_editor = false;
-}
-
 #include "twintablemember.moc"

Modified: trunk/rkward/rkward/dataeditor/twintablemember.h
===================================================================
--- trunk/rkward/rkward/dataeditor/twintablemember.h	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/dataeditor/twintablemember.h	2012-11-06 18:40:38 UTC (rev 4415)
@@ -18,8 +18,6 @@
 #ifndef TWINTABLEMEMBER_H
 #define TWINTABLEMEMBER_H
 
-#include <QItemSelectionRange>
-#include <QItemDelegate>
 #include <qpoint.h>
 #include <QEvent>
 #include <QKeyEvent>
@@ -31,43 +29,6 @@
 #include "../misc/rktableview.h"
 #include "rkeditor.h"
 
-class RKVarEditMetaModel;
-class RKVarEditModel;
-
-/** Item delegate for TwinTableMembers.
- at author Thomas Friedrichsmeier */
-class RKItemDelegate : public QItemDelegate {
-	Q_OBJECT
-public:
-	RKItemDelegate (QObject *parent, RKVarEditModel* datamodel);
-	RKItemDelegate (QObject *parent, RKVarEditMetaModel* metamodel);
-	~RKItemDelegate ();
-
-	QWidget* createEditor (QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
-	void setEditorData (QWidget* editor, const QModelIndex& index) const;
-	void setModelData (QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
-	bool eventFilter (QObject* editor, QEvent* event);
-
-	enum EditorDoneReason {
-		EditorExitLeft,
-		EditorExitRight,
-		EditorExitUp,
-		EditorExitDown,
-		EditorReject,
-		EditorExit
-	};
-signals:
-	// much like QAbstractItemDelegate::closeEditor(), but with our own flexible EndEditHint
-	void doCloseEditor (QWidget* editor, RKItemDelegate::EditorDoneReason);
-public slots:
-	void editorDone (QWidget* editor, RKItemDelegate::EditorDoneReason reason);
-private:
-	RKVarEditModel* datamodel;
-	RKVarEditMetaModel* metamodel;
-	bool locked_for_modal_editor;
-};
-
-
 /** One of the tables used in a TwinTable.
 @author Thomas Friedrichsmeier
 */
@@ -89,7 +50,8 @@
 	void blankSelected ();
 
 	void setRKModel (RKVarEditModelBase* model);
-	void seRKItemDelegate (RKItemDelegate* delegate);
+	int trueRows () const;	// re-implemented from RKTableView
+	int trueColumns () const;	// re-implemented from RKTableView
 signals:
 	void contextMenuRequest (int row, int col, const QPoint& pos);
 protected:
@@ -104,8 +66,6 @@
 	bool rw;
 friend class TwinTable;
 	void setTwin (TwinTableMember *new_twin);
-public slots:
-	void editorDone (QWidget* editor, RKItemDelegate::EditorDoneReason);
 protected slots:
 	void handleContextMenuRequest (const QPoint& pos);
 	void updateColWidth (int section, int old_w, int new_w);

Modified: trunk/rkward/rkward/misc/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/misc/CMakeLists.txt	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/misc/CMakeLists.txt	2012-11-06 18:40:38 UTC (rev 4415)
@@ -20,6 +20,9 @@
    rkxmlguisyncer.cpp
    rkcommandhistory.cpp
    rktableview.cpp
+   celleditor.cpp
+   editlabelsdialog.cpp
+   editformatdialog.cpp
    )
 
 QT4_AUTOMOC(${misc_STAT_SRCS})

Copied: trunk/rkward/rkward/misc/celleditor.cpp (from rev 4341, trunk/rkward/rkward/dataeditor/celleditor.cpp)
===================================================================
--- trunk/rkward/rkward/misc/celleditor.cpp	                        (rev 0)
+++ trunk/rkward/rkward/misc/celleditor.cpp	2012-11-06 18:40:38 UTC (rev 4415)
@@ -0,0 +1,116 @@
+/***************************************************************************
+                          celleditor  -  description
+                             -------------------
+    begin                : Mon Sep 13 2004
+    copyright            : (C) 2004, 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 "celleditor.h"
+
+#include <QMenu>
+#include <QTimer>
+#include <QEvent>
+#include <QKeyEvent>
+
+#include "../debug.h"
+
+CellEditor::CellEditor (QWidget* parent) : QLineEdit (parent) {
+	RK_TRACE (EDITOR);
+
+	setFrame (false);
+
+	value_list = 0;
+}
+
+CellEditor::~CellEditor () {
+	RK_TRACE (EDITOR);
+}
+
+void CellEditor::setValueLabels (const RObject::ValueLabels& labels) {
+	RK_TRACE (EDITOR);
+
+	if (labels.isEmpty ()) return;
+
+// NOTE: not using a QComboBox, as we do not want it to pop up immediately
+	value_list = new QMenu (this);
+	value_list->setFont (font ());
+	value_list->setPalette (palette ());
+	value_list->setFocusProxy (this);
+	value_list->installEventFilter (this);	// somehow setting us as a focus proxy is not enough to continue to receive the key-presses
+
+	for (RObject::ValueLabels::const_iterator it = labels.constBegin (); it != labels.constEnd (); ++it) {
+		value_list->addAction (it.key () + ": " + it.value ())->setData (it.key ());
+	}
+	connect (value_list, SIGNAL (triggered(QAction*)), SLOT (selectedFromList(QAction*)));
+
+	QTimer::singleShot (200, this, SLOT (showValueLabels ()));
+}
+
+void CellEditor::selectedFromList (QAction* action) {
+	RK_TRACE (EDITOR);
+	RK_ASSERT (action);
+
+	setText (action->data ().toString ());	// which is a string representation of an int, really
+}
+
+void CellEditor::setText (const QString& text) {
+	RK_TRACE (EDITOR);
+
+	QLineEdit::setText (text);
+	selectAll ();
+}
+
+void CellEditor::showValueLabels () {
+	RK_TRACE (EDITOR);
+	RK_ASSERT (value_list);
+
+	QPoint pos = mapToGlobal (QPoint (5, height ()+5));
+	value_list->popup (QPoint (pos));
+}
+
+void CellEditor::keyPressEvent (QKeyEvent *e) {
+	if (e->modifiers () == Qt::NoModifier) {
+		if ((e->key () == Qt::Key_Left) || (e->key () == Qt::Key_Backspace)) {
+			if (cursorPosition () < 1) {
+				emit (done (this, RKItemDelegate::EditorExitLeft));
+				return;
+			}
+		}
+		if (e->key () == Qt::Key_Right) {
+			if (cursorPosition () >= (int) text ().length ()) {
+				emit (done (this, RKItemDelegate::EditorExitRight));
+				return;
+			}
+		}
+		if (e->key () == Qt::Key_Up) {
+			emit (done (this, RKItemDelegate::EditorExitUp));
+			return;
+		}
+		if (e->key () == Qt::Key_Down) {
+			emit (done (this, RKItemDelegate::EditorExitDown));
+			return;
+		}
+	}
+	QLineEdit::keyPressEvent (e);
+}
+
+bool CellEditor::eventFilter (QObject* object, QEvent* e) {
+	if (object && (object == value_list)) {
+		if (e->type() == QEvent::KeyPress) {
+			RK_TRACE (EDITOR);
+			return event (e);
+		}
+	}
+	return false;
+}
+
+#include "celleditor.moc"

Copied: trunk/rkward/rkward/misc/celleditor.h (from rev 4341, trunk/rkward/rkward/dataeditor/celleditor.h)
===================================================================
--- trunk/rkward/rkward/misc/celleditor.h	                        (rev 0)
+++ trunk/rkward/rkward/misc/celleditor.h	2012-11-06 18:40:38 UTC (rev 4415)
@@ -0,0 +1,61 @@
+/***************************************************************************
+                          celleditor  -  description
+                             -------------------
+    begin                : Mon Sep 13 2004
+    copyright            : (C) 2004, 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 CELLEDITOR_H
+#define CELLEDITOR_H
+
+#include <QLineEdit>
+#include <QList>
+
+#include "../core/robject.h"
+#include "rktableview.h"
+
+class QStringList;
+class QMenu;
+class QEvent;
+class QKeyEvent;
+
+/**
+This is the main editor used in the TwinTableMembers
+
+TODO: the acutal editor will have to be separated from the value_list-popup in order to allow showing the popup, even if the list does not have strong
+focus.
+
+ at author Thomas Friedrichsmeier
+*/
+class CellEditor : public QLineEdit {
+Q_OBJECT
+public:
+	CellEditor (QWidget* parent);
+	~CellEditor ();
+
+	void setValueLabels (const RObject::ValueLabels& labels);
+
+	void setText (const QString& text);
+signals:
+	void done (QWidget* widget, RKItemDelegate::EditorDoneReason reason);
+public slots:
+	void selectedFromList (QAction* action);
+	void showValueLabels ();
+protected:
+/// reimplemented to ignore arrow left/right if at the beginning/end
+	void keyPressEvent (QKeyEvent *e);
+	bool eventFilter (QObject* object, QEvent* event);
+private:
+	QMenu *value_list;
+};
+
+#endif

Copied: trunk/rkward/rkward/misc/editformatdialog.cpp (from rev 4341, trunk/rkward/rkward/dataeditor/editformatdialog.cpp)
===================================================================
--- trunk/rkward/rkward/misc/editformatdialog.cpp	                        (rev 0)
+++ trunk/rkward/rkward/misc/editformatdialog.cpp	2012-11-06 18:40:38 UTC (rev 4415)
@@ -0,0 +1,148 @@
+/***************************************************************************
+                          editformatdialog  -  description
+                             -------------------
+    begin                : Thu Sep 30 2004
+    copyright            : (C) 2004 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 "editformatdialog.h"
+
+#include <QButtonGroup>
+#include <QGroupBox>
+#include <qradiobutton.h>
+#include <qspinbox.h>
+#include <qstringlist.h>
+#include <QVBoxLayout>
+#include <QTimer>
+
+#include <klocale.h>
+#include <kvbox.h>
+
+#include "../core/rkvariable.h"
+#include "../rkglobals.h"
+#include "../debug.h"
+
+EditFormatDialog::EditFormatDialog (QWidget *parent) : KDialog (parent) {
+	RK_TRACE (EDITOR);
+
+	KVBox *vbox = new KVBox ();
+	setMainWidget (vbox);
+
+	alignment_group = new QButtonGroup (this);
+	QGroupBox* alignment_box = new QGroupBox (i18n ("Alignment"), vbox);
+	QVBoxLayout* group_layout = new QVBoxLayout (alignment_box);
+	group_layout->setContentsMargins (0, 0, 0, 0);
+	QRadioButton* button;
+	alignment_group->addButton (button = new QRadioButton (i18n ("Default"), alignment_box), (int) RKVariable::FormattingOptions::AlignDefault);
+	group_layout->addWidget (button);
+	alignment_group->addButton (button = new QRadioButton (i18n ("Left"), alignment_box), (int) RKVariable::FormattingOptions::AlignLeft);
+	group_layout->addWidget (button);
+	alignment_group->addButton (button = new QRadioButton (i18n ("Right"), alignment_box), (int) RKVariable::FormattingOptions::AlignRight);
+	group_layout->addWidget (button);
+	alignment_group->button ((int) RKVariable::FormattingOptions::AlignDefault)->setChecked (true);
+
+	precision_group = new QButtonGroup (this);
+	QGroupBox* precision_box = new QGroupBox (i18n ("Decimal Places"), vbox);
+	group_layout = new QVBoxLayout (precision_box);
+	precision_group->addButton (button = new QRadioButton (i18n ("Default setting"), precision_box), (int) RKVariable::FormattingOptions::PrecisionDefault);
+	group_layout->addWidget (button);
+	precision_group->addButton (button = new QRadioButton (i18n ("As required"), precision_box), (int) RKVariable::FormattingOptions::PrecisionRequired);
+	group_layout->addWidget (button);
+	precision_group->addButton (button = new QRadioButton (i18n ("Fixed precision:"), precision_box), (int) RKVariable::FormattingOptions::PrecisionFixed);
+	group_layout->addWidget (button);
+	precision_field = new QSpinBox (precision_box);
+	precision_field->setRange (0, 10);
+	connect (precision_field, SIGNAL (valueChanged (int)), this, SLOT (precisionFieldChanged (int)));
+	group_layout->addWidget (precision_field);
+	precision_group->button ((int) RKVariable::FormattingOptions::PrecisionDefault)->setChecked (true);
+
+	setButtons (KDialog::Ok | KDialog::Cancel);
+}
+
+EditFormatDialog::~EditFormatDialog () {
+	RK_TRACE (EDITOR);
+}
+
+void EditFormatDialog::initialize (const RKVariable::FormattingOptions& options, const QString& varname) {
+	RK_TRACE (EDITOR);
+
+	setCaption (i18n ("Formatting options for '%1'", varname));
+
+	EditFormatDialog::options = options;
+
+	alignment_group->button ((int) options.alignment)->setChecked (true);
+	precision_group->button ((int) options.precision_mode)->setChecked (true);
+	precision_field->setValue (options.precision);
+}
+
+void EditFormatDialog::accept () {
+	RK_TRACE (EDITOR);
+
+	options.alignment = (RKVariable::FormattingOptions::Alignment) alignment_group->checkedId ();
+
+	options.precision_mode = (RKVariable::FormattingOptions::Precision) precision_group->checkedId ();
+	if (options.precision_mode == RKVariable::FormattingOptions::PrecisionFixed) {
+		options.precision = precision_field->value ();
+	} else {
+		options.precision = 0;
+	}
+
+	KDialog::accept ();
+}
+
+void EditFormatDialog::precisionFieldChanged (int) {
+	RK_TRACE (EDITOR);
+
+	precision_group->button ((int) RKVariable::FormattingOptions::PrecisionFixed)->setChecked (true);
+}
+
+
+///////////// EditFormatDialogProxy ////////////////////
+
+EditFormatDialogProxy::EditFormatDialogProxy (QWidget* parent) : QWidget (parent) {
+	RK_TRACE (EDITOR);
+
+	dialog = 0;
+}
+
+EditFormatDialogProxy::~EditFormatDialogProxy () {
+	RK_TRACE (EDITOR);
+}
+
+void EditFormatDialogProxy::initialize (const RKVariable::FormattingOptions& options, const QString& varname) {
+	RK_TRACE (EDITOR);
+
+	if (dialog) return;	// one dialog at a time, please!
+
+	EditFormatDialogProxy::options = options;
+	dialog = new EditFormatDialog (this);
+	dialog->initialize (options, varname);
+
+	connect (dialog, SIGNAL (finished(int)), this, SLOT (dialogDone(int)));
+	QTimer::singleShot (0, dialog, SLOT (exec()));
+}
+
+void EditFormatDialogProxy::dialogDone (int result) {
+	RK_TRACE (EDITOR);
+	RK_ASSERT (dialog);
+
+	if (result == QDialog::Accepted) {
+		options = dialog->options;
+		emit (done (this, RKItemDelegate::EditorExit));
+	} else {
+		emit (done (this, RKItemDelegate::EditorReject));
+	}
+	dialog->deleteLater ();
+	dialog = 0;
+}
+
+#include "editformatdialog.moc"

Copied: trunk/rkward/rkward/misc/editformatdialog.h (from rev 4341, trunk/rkward/rkward/dataeditor/editformatdialog.h)
===================================================================
--- trunk/rkward/rkward/misc/editformatdialog.h	                        (rev 0)
+++ trunk/rkward/rkward/misc/editformatdialog.h	2012-11-06 18:40:38 UTC (rev 4415)
@@ -0,0 +1,74 @@
+/***************************************************************************
+                          editformatdialog  -  description
+                             -------------------
+    begin                : Thu Sep 30 2004
+    copyright            : (C) 2004 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 EDITFORMATDIALOG_H
+#define EDITFORMATDIALOG_H
+
+#include <kdialog.h>
+
+#include "../core/rkvariable.h"
+#include "rktableview.h"
+
+class QButtonGroup;
+class QSpinBox;
+
+/**
+Allows editing of format-attributes for an RKVariable
+
+ at author Thomas Friedrichsmeier
+*/
+class EditFormatDialog : public KDialog {
+	Q_OBJECT
+public slots:
+	void precisionFieldChanged (int);
+protected:
+/** reimplemented to make the newly selected options available */
+	void accept ();
+
+friend class EditFormatDialogProxy;
+/** ctor */
+	EditFormatDialog (QWidget *parent);
+/** dtor */
+	~EditFormatDialog ();
+
+/** initializes the GUI-options from the settings for the variable */
+	void initialize (const RKVariable::FormattingOptions& options, const QString& varname);
+private:
+	QButtonGroup *alignment_group;
+	QButtonGroup *precision_group;
+	QSpinBox *precision_field;
+	RKVariable::FormattingOptions options;
+};
+
+/** Simple proxy wrapper to allow using a model EditFormatDialog in a QTableView */
+class EditFormatDialogProxy : public QWidget {
+	Q_OBJECT
+public:
+	EditFormatDialogProxy (QWidget* parent);
+	~EditFormatDialogProxy ();
+
+	void initialize (const RKVariable::FormattingOptions& options, const QString& varname);
+	RKVariable::FormattingOptions getOptions () const { return options; };
+signals:
+	void done (QWidget* widget, RKItemDelegate::EditorDoneReason reason);
+protected slots:
+	void dialogDone (int result);
+private:
+	RKVariable::FormattingOptions options;
+	EditFormatDialog* dialog;
+};
+
+#endif

Copied: trunk/rkward/rkward/misc/editlabelsdialog.cpp (from rev 4341, trunk/rkward/rkward/dataeditor/editlabelsdialog.cpp)
===================================================================
--- trunk/rkward/rkward/misc/editlabelsdialog.cpp	                        (rev 0)
+++ trunk/rkward/rkward/misc/editlabelsdialog.cpp	2012-11-06 18:40:38 UTC (rev 4415)
@@ -0,0 +1,281 @@
+/***************************************************************************
+                          editlabelsdialog  -  description
+                             -------------------
+    begin                : Tue Sep 21 2004
+    copyright            : (C) 2004, 2006, 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 "editlabelsdialog.h"
+
+#include <klocale.h>
+#include <kdialog.h>
+#include <kaction.h>
+#include <kactioncollection.h>
+#include <kvbox.h>
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <QHeaderView>
+#include <QTimer>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+
+#include "../core/rkvariable.h"
+#include "../dataeditor/rktextmatrix.h"
+#include "celleditor.h"
+
+#include "../debug.h"
+
+RKVarLevelsTable::RKVarLevelsTable (QWidget *parent, const RObject::ValueLabels& labels) : QTableView (parent) {
+	RK_TRACE (EDITOR);
+
+	setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
+	setSelectionMode (QAbstractItemView::ContiguousSelection);
+	horizontalHeader ()->setStretchLastSection (true);
+	verticalHeader ()->setFixedWidth (40);
+	setMinimumWidth (80);
+
+	KActionCollection *ac = new KActionCollection (this);
+	ac->addAction (KStandardAction::Cut, this, SLOT (cut ()));
+	ac->addAction (KStandardAction::Copy, this, SLOT (copy ()));
+	ac->addAction (KStandardAction::Paste, this, SLOT (paste ()));
+
+	setModel (lmodel = new RKVarLevelsTableModel (labels, this));
+}
+
+RKVarLevelsTable::~RKVarLevelsTable () {
+	RK_TRACE (EDITOR);
+}
+
+bool RKVarLevelsTable::getSelectionBoundaries (int* top, int* bottom) const {
+	RK_TRACE (EDITOR);
+
+	RK_ASSERT (selectionModel ());
+	QItemSelection sel = selectionModel ()->selection ();
+	if (sel.isEmpty ()){
+		QModelIndex current = currentIndex ();
+		if (!current.isValid ()) return false;
+
+		*top = current.row ();
+		*bottom = current.row ();
+	} else {
+		RK_ASSERT (sel.size () == 1);
+		*top = sel[0].top ();
+		*bottom = sel[0].bottom ();
+	}
+	return true;
+}
+
+void RKVarLevelsTable::cut () {
+	RK_TRACE (EDITOR);
+
+	int top;
+	int bottom;
+	if (!getSelectionBoundaries (&top, &bottom)) return;
+
+	copy ();
+
+	for (int i = top; i <= bottom; ++i) lmodel->setData (lmodel->index (i, 0), QString ());
+}
+
+void RKVarLevelsTable::copy () {
+	RK_TRACE (EDITOR);
+
+	int top;
+	int bottom;
+	if (!getSelectionBoundaries (&top, &bottom)) return;
+
+	RKTextMatrix mat;
+	int trow = 0;
+	for (int i = top; i <= bottom; ++i) {
+		mat.setText (trow++, 0, lmodel->data (lmodel->index (i, 0)).toString ());
+	}
+	mat.copyToClipboard ();
+}
+
+void RKVarLevelsTable::paste () {
+	RK_TRACE (EDITOR);
+
+// Unfortunately, we need to duplicate some of TwinTable::paste () and RKEditorDataFramPart::doPaste. Those are not easy to reconcile.
+	QModelIndex current = currentIndex ();
+	if (!current.isValid ()) return;
+	int row = current.row ();
+	RK_ASSERT (current.column () == 0);
+
+	RKTextMatrix pasted = RKTextMatrix::matrixFromClipboard ();
+	if (pasted.isEmpty ()) return;
+
+	if (pasted.numColumns () > 1) {		// there were tabs in the pasted text. Let's transpose the first row
+		for (int i = 0; i < pasted.numColumns (); ++i) {
+			lmodel->setData (lmodel->index (row++, 0), pasted.getText (0, i));
+		}
+	} else {		// else paste the first column
+		for (int i = 0; i < pasted.numRows (); ++i) {
+			lmodel->setData (lmodel->index (row++, 0), pasted.getText (i, 0));
+		}
+	}
+}
+
+/////////////// RKVarLevelsTableModel /////////////////
+
+RKVarLevelsTableModel::RKVarLevelsTableModel (const RObject::ValueLabels& labels, QObject* parent) : QAbstractTableModel (parent) {
+	RK_TRACE (EDITOR);
+
+	RKVarLevelsTableModel::labels = labels;
+}
+
+RKVarLevelsTableModel::~RKVarLevelsTableModel () {
+	RK_TRACE (EDITOR);
+}
+
+int RKVarLevelsTableModel::rowCount (const QModelIndex& parent) const {
+	RK_TRACE (EDITOR);
+
+	if (parent.isValid ()) return 0;
+	return labels.count () + 1;
+}
+
+int RKVarLevelsTableModel::columnCount (const QModelIndex& parent) const {
+	RK_TRACE (EDITOR);
+
+	if (parent.isValid ()) return 0;
+	return 1;
+}
+
+QVariant RKVarLevelsTableModel::data (const QModelIndex& index, int role) const {
+	RK_TRACE (EDITOR);
+
+	if (!index.isValid ()) return QVariant ();
+	if (index.column () != 0) return QVariant ();
+	if ((role == Qt::BackgroundRole) && (index.row () == labels.count ())) return QBrush (Qt::gray);
+	if (index.row () >= labels.count ()) return QVariant ();
+
+	if ((role == Qt::DisplayRole) || (role == Qt::EditRole)) return labels.value (QString::number (index.row ()+1));
+
+	return QVariant ();
+}
+
+Qt::ItemFlags RKVarLevelsTableModel::flags (const QModelIndex& index) const {
+	RK_TRACE (EDITOR);
+
+	if (!index.isValid ()) return 0;
+	if (index.column () != 0) return 0;
+	if (index.row () >= labels.count ()) return (Qt::ItemIsEditable | Qt::ItemIsEnabled);
+	return (Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+}
+
+bool RKVarLevelsTableModel::setData (const QModelIndex& index, const QVariant& value, int role) {
+	RK_TRACE (EDITOR);
+
+	if (role != Qt::EditRole) return false;
+	if (!index.isValid ()) return false;
+	if (index.column () != 0) return false;
+	if (!value.isValid ()) return false;
+	if (index.row () > labels.count ()) return false;
+
+	QString text = value.toString ();
+	if (index.row () == labels.count ()) {
+		beginInsertRows (QModelIndex (), index.row (), index.row ());
+		labels.insert (QString::number (index.row () + 1), text);
+		endInsertRows ();
+	} else {
+		labels.insert (QString::number (index.row () + 1), text);
+		emit (dataChanged (index, index));
+	}
+
+	if (text.isEmpty ()) {	// remove trailing empty rows
+		while ((!labels.isEmpty ()) && labels.value (QString::number (labels.count ())).isEmpty ()) {
+			int row = labels.count () - 1;
+			beginRemoveRows (QModelIndex (), row, row);
+			labels.remove (QString::number (row + 1));
+			endRemoveRows ();
+		}
+	}
+
+	return true;
+}
+
+QVariant RKVarLevelsTableModel::headerData (int section, Qt::Orientation orientation, int role) const {
+	RK_TRACE (EDITOR);
+
+	if (role != Qt::DisplayRole) return QVariant ();
+	if (orientation == Qt::Vertical) return QString::number (section + 1);
+	if (section != 0) return QVariant ();
+	return i18n ("Label");
+}
+
+//////////////// EditLabelsDialog ///////////////////////
+
+EditLabelsDialog::EditLabelsDialog (QWidget *parent, const RObject::ValueLabels& labels, const QString& varname) : KDialog (parent) {
+	RK_TRACE (EDITOR);
+
+	KVBox *mainvbox = new KVBox ();
+	setMainWidget (mainvbox);
+	QLabel *label = new QLabel (i18n ("Levels can be assigned only to consecutive integers starting with 1 (the index column is read only). To remove levels at the end of the list, just set them to empty."), mainvbox);
+	label->setWordWrap (true);
+
+	table = new RKVarLevelsTable (mainvbox, labels);
+
+	setButtons (KDialog::Ok | KDialog::Cancel);
+	setCaption (i18n ("Levels / Value labels for '%1'", varname));
+}
+
+EditLabelsDialog::~EditLabelsDialog () {
+	RK_TRACE (EDITOR);
+}
+
+void EditLabelsDialog::accept () {
+	RK_TRACE (EDITOR);
+
+	table->setCurrentIndex (QModelIndex ());	// should flush editing
+	KDialog::accept ();
+}
+
+////////////////// EditLabelsDialogProxy /////////////////////////
+
+EditLabelsDialogProxy::EditLabelsDialogProxy (QWidget* parent) : QWidget (parent) {
+	RK_TRACE (EDITOR);
+	dialog = 0;
+}
+
+EditLabelsDialogProxy::~EditLabelsDialogProxy () {
+	RK_TRACE (EDITOR);
+}
+
+void EditLabelsDialogProxy::initialize (const RObject::ValueLabels& labels, const QString& varname) {
+	RK_TRACE (EDITOR);
+
+	if (dialog) return;	// one dialog at a time, please!
+
+	EditLabelsDialogProxy::labels = labels;		// we need to take a copy in case the dialog is rejected
+
+	dialog = new EditLabelsDialog (this, labels, varname);
+	connect (dialog, SIGNAL (finished(int)), this, SLOT (dialogDone(int)));
+	QTimer::singleShot (0, dialog, SLOT (exec()));
+}
+
+void EditLabelsDialogProxy::dialogDone (int result) {
+	RK_TRACE (EDITOR);
+	RK_ASSERT (dialog);
+
+	if (result == QDialog::Accepted) {
+		labels = dialog->table->lmodel->labels;
+		emit (done (this, RKItemDelegate::EditorExit));
+	} else {
+		emit (done (this, RKItemDelegate::EditorReject));
+	}
+	dialog->deleteLater ();
+	dialog = 0;
+}
+
+
+#include "editlabelsdialog.moc"

Copied: trunk/rkward/rkward/misc/editlabelsdialog.h (from rev 4341, trunk/rkward/rkward/dataeditor/editlabelsdialog.h)
===================================================================
--- trunk/rkward/rkward/misc/editlabelsdialog.h	                        (rev 0)
+++ trunk/rkward/rkward/misc/editlabelsdialog.h	2012-11-06 18:40:38 UTC (rev 4415)
@@ -0,0 +1,111 @@
+/***************************************************************************
+                          editlabelsdialog  -  description
+                             -------------------
+    begin                : Tue Sep 21 2004
+    copyright            : (C) 2004, 2006, 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 EDITLABELSDIALOG_H
+#define EDITLABELSDIALOG_H
+
+#include <kdialog.h>
+
+#include <QAbstractTableModel>
+
+#include "../core/robject.h"
+#include "rktableview.h"
+
+class RKVariable;
+class RKVarLevelsTableModel;
+
+/** special mini class provides the table in EditLabelsDialog
+
+ at author Thomas Friedrichsmeier
+*/
+class RKVarLevelsTable : public QTableView {
+	Q_OBJECT
+public:
+	RKVarLevelsTable (QWidget *parent, const RObject::ValueLabels& labels);
+	~RKVarLevelsTable ();
+public slots:
+/** cut */
+	void cut ();
+/** cut */
+	void copy ();
+/** paste */
+	void paste ();
+private:
+	bool getSelectionBoundaries (int* top, int* bottom) const;
+friend class EditLabelsDialogProxy;
+	RKVarLevelsTableModel* lmodel;
+	bool updating_size;
+};
+
+/** Data model for the RKVarLevelsTable */
+class RKVarLevelsTableModel : public QAbstractTableModel {
+public:
+	RKVarLevelsTableModel (const RObject::ValueLabels& labels, QObject* parent);
+	~RKVarLevelsTableModel ();
+
+	int rowCount (const QModelIndex& parent = QModelIndex()) const;
+	int columnCount (const QModelIndex& parent = QModelIndex()) const;
+	QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
+	Qt::ItemFlags flags (const QModelIndex& index) const;
+	bool setData (const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
+	QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+private:
+friend class EditLabelsDialogProxy;
+	RObject::ValueLabels labels;
+};
+
+/**
+Allows editing of value labels / factor levels for an RKVariable. Use EditLabelsDialogProxy.
+
+ at author Thomas Friedrichsmeier
+*/
+class EditLabelsDialog : public KDialog {
+protected:
+friend class EditLabelsDialogProxy;
+/** constuctor., the variable to work on.
+ at param parent a QWidget parent */
+	EditLabelsDialog (QWidget *parent, const RObject::ValueLabels& labels, const QString& varname);
+
+	~EditLabelsDialog ();
+
+/** reimplemented to make sure pending edit operations are not lost */
+	void accept ();
+private:
+	RKVarLevelsTable* table;
+};
+
+/**
+Simple proxy / wrapper to allow using a modal EditLabelsDialog in a QTableView
+ at author Thomas Friedrichsmeier */
+class EditLabelsDialogProxy : public QWidget {
+	Q_OBJECT
+public:
+	EditLabelsDialogProxy (QWidget* parent);
+	~EditLabelsDialogProxy ();
+
+	void initialize (const RObject::ValueLabels& labels, const QString& varname);
+
+	RObject::ValueLabels getLabels () const { return labels; };
+signals:
+	void done (QWidget* widget, RKItemDelegate::EditorDoneReason reason);
+protected slots:
+	void dialogDone (int result);
+private:
+	EditLabelsDialog* dialog;
+	RObject::ValueLabels labels;
+};
+
+#endif

Modified: trunk/rkward/rkward/plugin/rkmatrixinput.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkmatrixinput.cpp	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/plugin/rkmatrixinput.cpp	2012-11-06 18:40:38 UTC (rev 4415)
@@ -23,6 +23,7 @@
 
 #include "../misc/rktableview.h"
 #include "../dataeditor/rktextmatrix.h"
+#include "../dataeditor/twintablemember.h"
 #include "kstandardaction.h"
 #include "kaction.h"
 #include "klocale.h"
@@ -104,6 +105,8 @@
 	KAction *paste = KStandardAction::paste (this, SLOT (paste()), this);
 	display->addAction (paste);
 	display->setContextMenuPolicy (Qt::ActionsContextMenu);
+
+	display->setRKItemDelegate (new RKItemDelegate (display, model, true));
 }
 
 RKMatrixInput::~RKMatrixInput () {

Modified: trunk/rkward/rkward/plugin/rkmatrixinput.h
===================================================================
--- trunk/rkward/rkward/plugin/rkmatrixinput.h	2012-11-06 17:09:09 UTC (rev 4414)
+++ trunk/rkward/rkward/plugin/rkmatrixinput.h	2012-11-06 18:40:38 UTC (rev 4415)
@@ -20,6 +20,8 @@
 
 #include <rkcomponent.h>
 
+#include "../dataeditor/twintablemember.h"
+
 #include <QDomElement>
 #include <QStringList>
 
@@ -27,8 +29,7 @@
 class RKMatrixInputModel;
 
 /* TODO:
- * - key-handling: del, backspace, left / right while editing
- * - cursor-placement after editing trailing rows / columns
+ * - key-handling: del, backspace
  */
 
 /** Provides a table for editing one- or two-dimensional data

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