[rkward-cvs] SF.net SVN: rkward: [2193] branches/KDE4_port/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Nov 9 15:25:13 UTC 2007


Revision: 2193
          http://rkward.svn.sourceforge.net/rkward/?rev=2193&view=rev
Author:   tfry
Date:     2007-11-09 07:25:13 -0800 (Fri, 09 Nov 2007)

Log Message:
-----------
Further fixes to the data.frame editor and a small cleanup in RKVariable

Modified Paths:
--------------
    branches/KDE4_port/rkward/core/rkvariable.cpp
    branches/KDE4_port/rkward/dataeditor/rkeditordataframe.cpp
    branches/KDE4_port/rkward/dataeditor/rkvareditmodel.cpp
    branches/KDE4_port/rkward/dataeditor/twintable.cpp
    branches/KDE4_port/rkward/dataeditor/twintable.h
    branches/KDE4_port/rkward/dataeditor/twintablemember.cpp
    branches/KDE4_port/rkward/dataeditor/twintablemember.h

Modified: branches/KDE4_port/rkward/core/rkvariable.cpp
===================================================================
--- branches/KDE4_port/rkward/core/rkvariable.cpp	2007-11-09 13:54:21 UTC (rev 2192)
+++ branches/KDE4_port/rkward/core/rkvariable.cpp	2007-11-09 15:25:13 UTC (rev 2193)
@@ -17,8 +17,6 @@
 #include "rkvariable.h"
 
 #include <qstringlist.h>
-//Added by qt3to4:
-#include <Q3ValueList>
 #include "float.h"
 #include "math.h"
 #include "limits.h"
@@ -274,7 +272,6 @@
 
 	for (int i = 0; i < getLength (); ++i) {
 		data->cell_states[i] = RKVarEditData::NA;
-#warning TODO initialize storage arrays (see old revisions of initeditdatatoemtpy)
 	}
 }
 
@@ -710,16 +707,16 @@
 
 void RKVariable::removeRows (int from_row, int to_row) {
 	RK_TRACE (OBJECTS);
-	Q3ValueList<int> *changed_invalids = 0;
+
+	QList<int> changed_invalids;
 	int offset = (to_row - from_row) + 1;
 
 	for (int row = from_row; row < getLength (); ++row) {
 		QString *dummy = data->invalid_fields.take (row);
 		if (dummy) {
-			if (!changed_invalids) changed_invalids = new Q3ValueList<int>;
-			changed_invalids->append (row);
+			changed_invalids.append (row);
 			if (row > to_row) {
-				changed_invalids->append (row - offset);
+				changed_invalids.append (row - offset);
 				data->invalid_fields.replace (row - offset, dummy);
 			} else {
 				delete dummy;
@@ -740,11 +737,8 @@
 		data->cell_states[row] = RKVarEditData::Unknown;
 	}
 
-	if (changed_invalids) {
-		for (Q3ValueList<int>::const_iterator it = changed_invalids->constBegin (); it != changed_invalids->constEnd (); ++it) {
-			writeInvalidField (*it, 0);
-		}
-		delete changed_invalids;
+	for (int i = 0; i < changed_invalids.size (); ++i) {
+		writeInvalidField (changed_invalids[i], 0);
 	}
 
 	dimensions[0] -= offset;	
@@ -765,13 +759,12 @@
 		data->cell_states[i] = RKVarEditData::NA;
 	}
 
-	Q3ValueList<int> *changed_invalids = 0;
+	QList<int> changed_invalids;
 	for (int i = getLength () - count - 1; i >= row; --i) {
 		QString *dummy = data->invalid_fields.take (i);
 		if (dummy) {
-			if (!changed_invalids) changed_invalids = new Q3ValueList<int>;
-			changed_invalids->append (i);
-			changed_invalids->append (i + count);
+			changed_invalids.append (i);
+			changed_invalids.append (i + count);
 			data->invalid_fields.replace (i + count, dummy);
 		}
 	}
@@ -790,11 +783,8 @@
 		data->cell_states[i] = RKVarEditData::NA;
 	}
 
-	if (changed_invalids) {
-		for (Q3ValueList<int>::const_iterator it = changed_invalids->constBegin (); it != changed_invalids->constEnd (); ++it) {
-			writeInvalidField (*it, 0);
-		}
-		delete changed_invalids;
+	for (int i = 0; i < changed_invalids.size (); ++i) {
+		writeInvalidField (changed_invalids[i], 0);
 	}
 }
 

Modified: branches/KDE4_port/rkward/dataeditor/rkeditordataframe.cpp
===================================================================
--- branches/KDE4_port/rkward/dataeditor/rkeditordataframe.cpp	2007-11-09 13:54:21 UTC (rev 2192)
+++ branches/KDE4_port/rkward/dataeditor/rkeditordataframe.cpp	2007-11-09 15:25:13 UTC (rev 2193)
@@ -47,7 +47,7 @@
 	RK_ASSERT (object->isDataFrame ());
 
 	RKVarEditDataFrameModel* model = new RKVarEditDataFrameModel (object, this);
-	initTable (model);
+	initTable (model, object);
 
 	waitForLoad ();
 }
@@ -61,12 +61,13 @@
 	if (valid != new_object_name) KMessageBox::sorry (this, i18n ("The name you specified was already in use or not valid. Renamed to %1", valid), i18n ("Invalid Name"));
 
 	RKVarEditDataFrameModel* model = new RKVarEditDataFrameModel (valid, RObjectList::getObjectList (), open_chain, 5, this);
-	initTable (model);
 
 	RKEditor::object = model->getObject ();;
 	RK_ASSERT (object->isDataFrame ());
 
-#warning is this needed? Of is it enough to close the chain?
+	initTable (model, object);
+
+#warning is this needed? Or is it enough to close the chain?
 	waitForLoad ();
 }
 

Modified: branches/KDE4_port/rkward/dataeditor/rkvareditmodel.cpp
===================================================================
--- branches/KDE4_port/rkward/dataeditor/rkvareditmodel.cpp	2007-11-09 13:54:21 UTC (rev 2192)
+++ branches/KDE4_port/rkward/dataeditor/rkvareditmodel.cpp	2007-11-09 15:25:13 UTC (rev 2193)
@@ -52,6 +52,7 @@
 
 	beginInsertColumns (QModelIndex (), index, index);
 	if (meta_model) meta_model->beginAddDataObject (index);
+	if (object->isPending ()) object->setLength (trueRows ());	// probably we just created it ourselves
 	listenForObject (object);
 	objects.insert (index, object);
 	if (meta_model) meta_model->endAddDataObject ();
@@ -116,12 +117,12 @@
 		RK_ASSERT (false);
 		return false;
 	}
-	if (row > objects[0]->getLength ()) row = objects[0]->getLength ();
+	if (row > trueRows ()) row = trueRows ();
 	int lastrow = row+count - 1;
 	RK_ASSERT (row >= 0);
 	RK_ASSERT (lastrow <= row);
 
-	beginInsertRows (QModelIndex (), row, row+count);
+	beginInsertRows (QModelIndex (), row, row+count-1);
 	for (int i=0; i < objects.size (); ++i) {
 // TODO: this does not emit any data change notifications to other editors
 		objects[i]->insertRows (row, count);
@@ -688,10 +689,10 @@
 		return false;
 	}
 
+	if (column > trueCols ()) column = trueCols ();
 	for (int col = column; col < (column + count); ++col) {
 		RObject *obj = dataframe->createPendingChild (dataframe->validizeName (QString ()), col);
 		RK_ASSERT (obj->isVariable ());
-		if (!objects.isEmpty ()) static_cast<RKVariable*> (obj)->setLength (objects[0]->getLength ());
 //		addObject (col, obj);	// the object will be added via RKModificationTracker::addObject -> this::childAdded. That will also take care of calling beginInsertColumns()/endInsertColumns()
 	
 		RKGlobals::rInterface ()->issueCommand (new RCommand (".rk.data.frame.insert.column (" + dataframe->getFullName () + ", \"" + obj->getShortName () + "\", " + QString::number (col+1) + ")", RCommand::App | RCommand::Sync));

Modified: branches/KDE4_port/rkward/dataeditor/twintable.cpp
===================================================================
--- branches/KDE4_port/rkward/dataeditor/twintable.cpp	2007-11-09 13:54:21 UTC (rev 2192)
+++ branches/KDE4_port/rkward/dataeditor/twintable.cpp	2007-11-09 15:25:13 UTC (rev 2193)
@@ -87,7 +87,7 @@
 // TODO: are the models auto-destructed?
 }
 
-void TwinTable::initTable (RKVarEditDataFrameModel* model) {
+void TwinTable::initTable (RKVarEditModel* model, RObject* object) {
 	RK_TRACE (EDITOR);
 
 	datamodel = model;
@@ -98,7 +98,7 @@
 	metaview->setMaximumHeight (metaview->rowHeight (0) * 5 + metaview->horizontalHeader ()->height () + 5);
 	dataview->verticalHeader ()->setFixedWidth (metaview->verticalHeader ()->width ());
 
-	setCaption (model->getObject ()->getShortName ());
+	setCaption (object->getShortName ());
 }
 
 // TODO: handle situation when several entire cols are selected!

Modified: branches/KDE4_port/rkward/dataeditor/twintable.h
===================================================================
--- branches/KDE4_port/rkward/dataeditor/twintable.h	2007-11-09 13:54:21 UTC (rev 2192)
+++ branches/KDE4_port/rkward/dataeditor/twintable.h	2007-11-09 15:25:13 UTC (rev 2193)
@@ -25,7 +25,7 @@
 
 class TwinTableMember;
 class QMenu;
-class RKVarEditDataFrameModel;
+class RKVarEditModel;
 
 /**
   *@author Thomas Friedrichsmeier
@@ -49,9 +49,9 @@
 /** Flushes pending edit-operations */
 	void flushEdit ();
 
-	void initTable (RKVarEditDataFrameModel* model);
+	void initTable (RKVarEditModel* model, RObject* object);
 	
-	RKVarEditDataFrameModel* datamodel;
+	RKVarEditModel* datamodel;
 public slots:
 	void dataHeaderContextMenu (int row, int col, const QPoint& pos);
 	void metaHeaderContextMenu (int row, int col, const QPoint& pos);

Modified: branches/KDE4_port/rkward/dataeditor/twintablemember.cpp
===================================================================
--- branches/KDE4_port/rkward/dataeditor/twintablemember.cpp	2007-11-09 13:54:21 UTC (rev 2192)
+++ branches/KDE4_port/rkward/dataeditor/twintablemember.cpp	2007-11-09 15:25:13 UTC (rev 2193)
@@ -209,4 +209,41 @@
 	}
 }
 
+/////////////////// RKItemDelegate /////////////////////
+
+RKItemDelegate::RKItemDelegate (QObject *parent) : QItemDelegate (parent) {
+	RK_TRACE (EDITOR);
+}
+
+RKItemDelegate::~RKItemDelegate () {
+	RK_TRACE (EDITOR);
+}
+
+QWidget* RKItemDelegate::createEditor (QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const {
+	RK_TRACE (EDITOR);
+
+	#warning implement
+}
+
+void RKItemDelegate::setEditorData (QWidget* editor, const QModelIndex& index) const {
+	RK_TRACE (EDITOR);
+
+	if (!index.isValid ()) return;
+
+//	CellEditor* ed = new CellEditor ();
+	#warning implement
+}
+
+void RKItemDelegate::setModelData (QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const {
+	RK_TRACE (EDITOR);
+
+	#warning implement
+}
+
+void RKItemDelegate::editorDone (QWidget* editor, EditorDoneReason) {
+	RK_TRACE (EDITOR);
+
+	#warning implement
+}
+
 #include "twintablemember.moc"

Modified: branches/KDE4_port/rkward/dataeditor/twintablemember.h
===================================================================
--- branches/KDE4_port/rkward/dataeditor/twintablemember.h	2007-11-09 13:54:21 UTC (rev 2192)
+++ branches/KDE4_port/rkward/dataeditor/twintablemember.h	2007-11-09 15:25:13 UTC (rev 2193)
@@ -20,6 +20,7 @@
 
 #include <QTableView>
 #include <QItemSelectionRange>
+#include <QItemDelegate>
 #include <qpoint.h>
 //Added by qt3to4:
 #include <QEvent>
@@ -42,10 +43,6 @@
 	TwinTableMember (QWidget *parent, TwinTable *table);
 	~TwinTableMember();
 	TwinTableMember *getTwin () { return twin; };
-/** like QTable::numRows (), but returns only the "true", i.e. active rows (excluding the trailing_rows) */
-	int numTrueRows () const;
-/** like QTable::numCols (), but returns only the "true", i.e. active columns (excluding the trailing_cols) */
-	int numTrueCols () const;
 /** ends editing. Actually it's just a simple wrapper around QTable::endEdit () */
 	void stopEditing ();
 #warning maybe still needed?
@@ -87,4 +84,29 @@
 	void tableSelectionChanged (const QItemSelection& selected, const QItemSelection& deselected);
 };
 
+
+/** Item delegate for TwinTableMembers.
+ at author Thomas Friedrichsmeier */
+class RKItemDelegate : QItemDelegate {
+	Q_OBJECT
+public:
+	RKItemDelegate (QObject *parent);
+	~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;
+
+	enum EditorDoneReason {
+		Left,
+		Right,
+		Up,
+		Down,
+		No
+	};
+
+public slots:
+	void editorDone (QWidget* editor, EditorDoneReason);
+};
+
 #endif


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