[rkward-cvs] SF.net SVN: rkward:[4376] trunk/rkward/rkward/plugin/rkmatrixinput.h

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Oct 16 08:37:31 UTC 2012


Revision: 4376
          http://rkward.svn.sourceforge.net/rkward/?rev=4376&view=rev
Author:   tfry
Date:     2012-10-16 08:37:31 +0000 (Tue, 16 Oct 2012)
Log Message:
-----------
Mostly complete API-sketch for matrix input element.

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/rkmatrixinput.h

Modified: trunk/rkward/rkward/plugin/rkmatrixinput.h
===================================================================
--- trunk/rkward/rkward/plugin/rkmatrixinput.h	2012-10-16 07:54:50 UTC (rev 4375)
+++ trunk/rkward/rkward/plugin/rkmatrixinput.h	2012-10-16 08:37:31 UTC (rev 4376)
@@ -20,24 +20,35 @@
 
 #include <rkcomponent.h>
 
+#include <QAbstractTableModel>
 #include <QDomElement>
 
+class QTableView;
+
 /** Provides a table for editing one- or two-dimensional data
   *@author Thomas Friedrichsmeier
   */
-class RKMatrixInput : public RKComponent {
+class RKMatrixInput : public RKComponent, public QAbstractTableModel {
 	Q_OBJECT
 public:
 	RKMatrixInput (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
 	~RKMatrixInput ();
 	int type () { return ComponentMatrixInput; };
-	bool isValid ();
+	bool isValid () { return is_valid; };
+	QString value (const QString &modifier);
 private slots:
 	void dimensionPropertyChanged (RKComponentPropertyBase *property);
+	void tsvPropertyChanged (RKComponentPropertyBase *property);
 private:
 	RKComponentPropertyInt *row_count;
 	RKComponentPropertyInt *column_count;
+	RKComponentPropertyBase *tsv_data;
 
+	int rowCount (const QModelIndex &parent = QModelIndex()) const; // implemented for QAbstractTableModel
+	int columnCount (const QModelIndex &parent = QModelIndex()) const; // implemented for QAbstractTableModel
+	QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const; // re-implemented for QAbstractTableModel
+	bool setData (const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); // re-implemented for QAbstractTableModel
+
 	enum Mode {
 		Integer,
 		Real,
@@ -50,6 +61,26 @@
 	bool allow_missings;
 	bool allow_user_resize_rows;
 	bool allow_user_resize_columns;
+
+	bool isValueValid (const QString &value) const;
+	void updateValidityFlag ();
+
+	bool setCellValue (int row, int column, const QString& value);
+	bool setColumnValue (int column, const QString& value);
+	bool setTableValue (const QString& value);
+
+	bool is_valid;
+
+	// NOTE: The storage may contain more rows / columns than the current dimensions of the table. This is so that no data gets
+	// lost, if a user shrinks a table, accidentally, then re-grows it.
+	struct Column {
+		int valid_up_to_row;	// to save validizing the entire table on each change, we keep track of validity per column
+		QStringList storage;
+		QString cached_joined_string;
+	};
+	QList<Column> columns;
+
+	QTableView *display;
 };
 
 #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