[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: koffice/kspread
From: Johannes Simon <johannes.simon () gmail ! com>
Date: 2007-10-16 22:26:20
Message-ID: 1192573580.426056.8177.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 726043 by jsimon:
* Return an empty QVariant in KSpread::BindingModel::headerData() and \
KSpread::BindingModel::data() if role is not Qt::EditRole or \
Qt::DisplayRole, otherwise we'll confuse the KDChart with data that's only \
meant for those two roles
* Add "QVariant data();" method to KSpread::Value class to allow \
integration with QVariant
These two changes fix the problem the ChartShape had when it was added to a \
KSpread document. The main reason why I sent this to the KOffice mailing \
list is the second point. I think we should reimplement KSpread::Value to \
better integrate with the existing QVariant in Qt 4. For now, I only added \
a method that converts the internal data into a QVariant, so that the \
change doesn't break any code.
CCMAIL:koffice-devel@kde.org
M +3 -5 Binding.cpp
M +37 -0 Value.cpp
M +5 -0 Value.h
--- trunk/koffice/kspread/Binding.cpp #726042:726043
@@ -127,15 +127,14 @@
QVariant BindingModel::headerData(int section, Qt::Orientation \
orientation, int role) const {
- Q_UNUSED(role);
- if (m_region.isEmpty())
+ if (m_region.isEmpty() || (role != Qt::EditRole && role != \
Qt::DisplayRole)) return QVariant();
const QPoint offset = m_region.firstRange().topLeft();
const int col = (orientation == Qt::Vertical) ? offset.x() : \
offset.x() + section;
const int row = (orientation == Qt::Vertical) ? offset.y() + section : \
offset.y(); const Sheet* sheet = m_region.firstSheet();
const Value value = sheet->cellStorage()->value(col, row);
- return QVariant(value.asString());
+ return value.data();
}
int BindingModel::rowCount(const QModelIndex& parent) const
@@ -152,8 +151,7 @@
QVariant BindingModel::data(const QModelIndex& index, int role) const
{
- Q_UNUSED(role);
- if (m_region.isEmpty())
+ if (m_region.isEmpty() || (role != Qt::EditRole && role != \
Qt::DisplayRole)) return QVariant();
const QPoint offset = m_region.firstRange().topLeft();
const Sheet* sheet = m_region.firstSheet();
--- trunk/koffice/kspread/Value.cpp #726042:726043
@@ -407,6 +407,43 @@
return result;
}
+// get the value as QVariant
+QVariant Value::data() const
+{
+ QVariant result;
+
+ switch ( d->type )
+ {
+ case Value::Empty:
+ default:
+ result = 0;
+ break;
+ case Value::Boolean:
+ result = d->b;
+ break;
+ case Value::Integer:
+ result = d->i;
+ break;
+ case Value::Float:
+ result = d->f;
+ break;
+ case Value::Complex:
+ // FIXME: add support for complex numbers
+ // pc = new complex<Number>( *o.pc );
+ break;
+ case Value::String:
+ case Value::Error:
+ result = d->ps;
+ break;
+ case Value::Array:
+ // FIXME: not supported yet
+ //result = ValueArray( d->pa );
+ break;
+ }
+
+ return result;
+}
+
// set error message
void Value::setError( const QString& msg )
{
--- trunk/koffice/kspread/Value.h #726042:726043
@@ -274,6 +274,11 @@
QString asString() const;
/**
+ * Returns the data as a QVariant
+ */
+ QVariant data() const;
+
+ /**
* Returns the date/time representation of this value.
*/
QDateTime asDateTime( const Doc* doc ) const;
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic