[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/office/skrooge
From: Stephane Mankowski <stephane () mankowski ! fr>
Date: 2011-02-14 11:46:18
Message-ID: 20110214114618.DC58EAC8BC () svn ! kde ! org
[Download RAW message or body]
SVN commit 1220566 by smankowski:
feature: Some fields are directly editable in view
AM 20110319-KDE4.6 release party-skrooge.odp
M +7 -0 skgbankmodeler/skgdocumentbank.cpp
M +7 -0 skgbankmodeler/skgdocumentbank.h
M +1 -1 skgbasegui/skgobjectmodelbase.cpp
M +6 -0 skgbasemodeler/skgdocument.cpp
M +7 -0 skgbasemodeler/skgdocument.h
M +33 -1 skgbasemodeler/skgobjectbase.cpp
--- trunk/extragear/office/skrooge/skgbankmodeler/skgdocumentbank.cpp \
#1220565:1220566 @@ -2299,6 +2299,13 @@
return SKGDocument::getDisplay(iString);
}
+QString SKGDocumentBank::getRealAttribute(const QString& iString) const
+{
+ if(iString.endsWith(QLatin1String("t_BANK"))) return "bank.rd_bank_id.t_name";
+ if(iString.endsWith(QLatin1String("t_BANK_NUMBER"))) return \
"bank.rd_bank_id.t_bank_number"; + return SKGDocument::getRealAttribute(iString);
+}
+
SKGServices::AttributeType SKGDocumentBank::getAttributeType(const QString& \
iAttributeName) const {
SKGServices::AttributeType output = SKGServices::TEXT;
--- trunk/extragear/office/skrooge/skgbankmodeler/skgdocumentbank.h #1220565:1220566
@@ -149,6 +149,13 @@
virtual QString getDisplay(const QString& iString) const;
/**
+ * Get the real attribute
+ * @param iString the name of the attribute (something like t_BANK)
+ * @return the real attribute (something like bank.rd_bank_id.t_name)
+ */
+ virtual QString getRealAttribute(const QString& iString) const;
+
+ /**
* Get the icon for attribute
* @param iString the name of the attribute
* @return the icon
--- trunk/extragear/office/skrooge/skgbasegui/skgobjectmodelbase.cpp #1220565:1220566
@@ -577,7 +577,7 @@
if(index.isValid()) flags |= Qt::ItemIsDragEnabled;
}
QString att = m_listAttibutes[index.column()];
- if(att.toLower() == att) flags |= Qt::ItemIsEditable;
+ if(att.toLower() == att || !getDocument()->getRealAttribute(att).isEmpty()) \
flags |= Qt::ItemIsEditable;
return flags;
--- trunk/extragear/office/skrooge/skgbasemodeler/skgdocument.cpp #1220565:1220566
@@ -1898,6 +1898,12 @@
return QIcon();
}
+QString SKGDocument::getRealAttribute(const QString& iString) const
+{
+ if(iString == iString.toLower()) return iString;
+ return "";
+}
+
SKGServices::AttributeType SKGDocument::getAttributeType(const QString & \
iAttributeName) const {
SKGServices::AttributeType output = SKGServices::TEXT;
--- trunk/extragear/office/skrooge/skgbasemodeler/skgdocument.h #1220565:1220566
@@ -465,6 +465,13 @@
virtual QIcon getIcon(const QString& iString) const;
/**
+ * Get the real attribute
+ * @param iString the name of the attribute (something like t_BANK)
+ * @return the real attribute (something like bank.rd_bank_id.t_name)
+ */
+ virtual QString getRealAttribute(const QString& iString) const;
+
+ /**
* Get the attribute type
* @param iAttributeName the name of an attribute
* @return the type
--- trunk/extragear/office/skrooge/skgbasemodeler/skgobjectbase.cpp #1220565:1220566
@@ -52,6 +52,11 @@
* internal attributes
*/
SKGQStringQStringMap attributes;
+
+ /**
+ * objects to save
+ */
+ SKGObjectBase::SKGListSKGObjectBase objects;
};
SKGError SKGObjectBase::getObjects(SKGDocument* iDocument, const QString& iTable,
@@ -302,6 +307,8 @@
SKGError err;
if(iValue != NOUPDATE) {
QString val = iValue;
+
+ //Case modificator
if(iValue.startsWith(QLatin1String("="))) {
QString op = iValue.right(iValue.length() - 1).toLower();
@@ -311,6 +318,24 @@
else if(op == "upper") val = val.toUpper();
else val = iValue;
}
+ //Case modification on pointed document
+ else if(this->getRealTable()==this->getTable() && iName != iName.toLower()) \
{ + QString realAttribute = d->document->getRealAttribute(iName);
+ if(!realAttribute.isEmpty()) {
+ QStringList l = realAttribute.split('.');
+ if(l.size() == 3) {
+ SKGObjectBase obj;
+ QString refId = getAttribute(l.at(1));
+ if(!refId.isEmpty()) {
+ err = getObject(getDocument(), "v_" + l.at(0), "id=" + \
refId, obj); + if(err.isSucceeded()) {
+ err = obj.setAttribute(l.at(2), iValue);
+ d->objects.push_back(obj);
+ }
+ }
+ }
+ }
+ }
d->attributes[iName] = val;
}
return err;
@@ -393,8 +418,15 @@
if(!d->document) err = SKGError(ERR_POINTER, i18nc("Error message", "Operation \
impossible because the document is missing")); else {
+ //Save linking objects
+ int nb = d->objects.count();
+ for(int i = 0; err.isSucceeded() && i < nb; ++i) {
+ SKGObjectBase ref = d->objects.at(i);
+ err = ref.save(iInsertOrUpdate, iReloadAfterSave);
+ }
+
//Check if we are in a transaction
- err = d->document->checkExistingTransaction();
+ if(err.isSucceeded()) err = d->document->checkExistingTransaction();
if(err.isSucceeded()) {
//Table to use
QString tablename = getRealTable();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic