[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [skrooge] /: Code quality
From: Stephane Mankowski <stephane () mankowski ! fr>
Date: 2013-08-31 16:43:08
Message-ID: E1VFoGS-0000Up-Bp () scm ! kde ! org
[Download RAW message or body]
Git commit dd62ca60602af58fb06e2fb47de3e9e5ddc1a242 by Stephane Mankowski.
Committed on 31/08/2013 at 16:42.
Pushed by smankowski into branch 'master'.
Code quality
M +16 -16 plugins/import/skrooge_import_qif/skgimportpluginqif.cpp
M +7 -7 skgbankmodeler/skgcategoryobject.cpp
M +3 -11 skgbankmodeler/skgdocumentbank.cpp
M +7 -7 skgbankmodeler/skgimportexportmanager.cpp
M +39 -81 skgbankmodeler/skgreportbank.cpp
M +2 -2 skgbankmodeler/skgruleobject.cpp
M +15 -15 skgbankmodeler/skgunitobject.cpp
M +76 -76 skgbasegui/skgmainpanel.cpp
M +78 -81 skgbasegui/skgobjectmodelbase.cpp
M +1 -1 skgbasemodeler/CMakeLists.txt
M +4 -4 tests/skgbankmodelertest/skgtestbankandaccount.cpp
M +5 -5 tests/skgbankmodelertest/skgtestdocparameter.cpp
http://commits.kde.org/skrooge/dd62ca60602af58fb06e2fb47de3e9e5ddc1a242
diff --git a/plugins/import/skrooge_import_qif/skgimportpluginqif.cpp \
b/plugins/import/skrooge_import_qif/skgimportpluginqif.cpp index 0b8fd07..eeaf97d \
100644
--- a/plugins/import/skrooge_import_qif/skgimportpluginqif.cpp
+++ b/plugins/import/skrooge_import_qif/skgimportpluginqif.cpp
@@ -691,9 +691,9 @@ SKGError SKGImportPluginQif::importFile()
SKGObjectBase::SKGListSKGObjectBase \
list;
IFOKDO(err, \
currentOperation.getGroupedOperations(list))
foreach(const SKGObjectBase & o, list) {
- SKGOperationObject op(o);
- IFOKDO(err, \
op.setStatus(SKGOperationObject::NONE))
- IFOKDO(err, op.remove(false, true))
+ SKGOperationObject op2(o);
+ IFOKDO(err, \
op2.setStatus(SKGOperationObject::NONE)) + \
IFOKDO(err, op2.remove(false, true)) }
} else {
//Create target account if needed
@@ -722,9 +722,9 @@ SKGError SKGImportPluginQif::importFile()
IFOKDO(err, \
accountTransfer.addOperation(opTransfer, true))
IFOKDO(err, \
opTransfer.setDate(opOrigin.getDate()))
IFOKDO(err, \
opTransfer.setComment(opOrigin.getComment()))
- SKGPayeeObject payeeObj;
- opTransfer.getPayee(payeeObj);
- IFOKDO(err, \
opTransfer.setPayee(payeeObj)) + \
SKGPayeeObject payeeObj2; + \
opTransfer.getPayee(payeeObj2); + \
IFOKDO(err, opTransfer.setPayee(payeeObj2))
IFOKDO(err, \
opTransfer.setStatus(opOrigin.getStatus()))
IFOKDO(err, opTransfer.setUnit(unit))
IFOKDO(err, opTransfer.setImportID("QIF \
TRANSFER-" % accountOrigin.getName())) @@ -954,9 +954,9 @@ SKGError \
SKGImportPluginQif::exportFile() SKGObjectBase::SKGListSKGObjectBase suboperations;
err = operation.getSubOperations(suboperations);
IFOK(err) {
- int nb = suboperations.size();
+ int nbSubOps = suboperations.size();
QString category;
- if (nb == 1) {
+ if (nbSubOps == 1) {
SKGSubOperationObject suboperation(suboperations.at(0));
//Dump quantity
if (unitExported) {
@@ -981,18 +981,18 @@ SKGError SKGImportPluginQif::exportFile()
}
if (!category.isEmpty()) stream << 'L' << category << endl;
- if (nb > 1) {
+ if (nbSubOps > 1) {
//Split operation
- for (int i = 0; i < nb; ++i) {
- SKGSubOperationObject \
suboperation(suboperations.at(i)); + for (int k = 0; k < \
nbSubOps; ++k) { + SKGSubOperationObject \
suboperation(suboperations.at(k)); SKGCategoryObject cat;
suboperation.getCategory(cat);
- QString category = \
cat.getFullName().replace(OBJECTSEPARATOR, ":");
- if (!category.isEmpty()) stream << 'S' << category \
<< endl;
- QString memo = suboperation.getComment();
- memo = memo.trimmed();
- if (!memo.isEmpty()) stream << 'E' << memo << endl;
+ QString category2 = \
cat.getFullName().replace(OBJECTSEPARATOR, ":"); + if \
(!category2.isEmpty()) stream << 'S' << category2 << endl; + \
QString memo2 = suboperation.getComment(); + memo2 = \
memo2.trimmed(); + if (!memo2.isEmpty()) stream << 'E' \
<< memo2 << endl;
stream << '$' << \
SKGServices::doubleToString(suboperation.getQuantity()) << endl; }
}
diff --git a/skgbankmodeler/skgcategoryobject.cpp \
b/skgbankmodeler/skgcategoryobject.cpp index 4590225..dc7c108 100644
--- a/skgbankmodeler/skgcategoryobject.cpp
+++ b/skgbankmodeler/skgcategoryobject.cpp
@@ -180,9 +180,9 @@ SKGError SKGCategoryObject::setParentCategory(const \
SKGCategoryObject& iCategory if (current == *this) {
err = SKGError(ERR_FAIL, i18nc("Error message", "You cannot create \
a loop.")); } else {
- SKGCategoryObject parent;
- current.getParentCategory(parent);
- current = parent;
+ SKGCategoryObject parent2;
+ current.getParentCategory(parent2);
+ current = parent2;
}
} while (!err && current.getID() != 0);
@@ -207,15 +207,15 @@ SKGError \
SKGCategoryObject::getParentCategory(SKGCategoryObject& oCategory) cons SKGError \
SKGCategoryObject::getRootCategory(SKGCategoryObject& oCategory) const {
SKGError err;
- SKGCategoryObject parent;
- err = getParentCategory(parent);
+ SKGCategoryObject parent2;
+ err = getParentCategory(parent2);
IFOK(err) {
- if (!parent.exist()) {
+ if (!parent2.exist()) {
//No parent
oCategory = *this;
} else {
//Parent exist
- err = parent.getRootCategory(oCategory);
+ err = parent2.getRootCategory(oCategory);
}
}
return err;
diff --git a/skgbankmodeler/skgdocumentbank.cpp b/skgbankmodeler/skgdocumentbank.cpp
index 6527f65..12887c1 100644
--- a/skgbankmodeler/skgdocumentbank.cpp
+++ b/skgbankmodeler/skgdocumentbank.cpp
@@ -2654,9 +2654,7 @@ QVariantList SKGDocumentBank::getBudget(const QString& iMonth)
listTmp);
int nbval = listTmp.count();
if (!err && nbval > 1) {
- QVariantList line;
- line << "sum" << getDisplay("t_CATEGORY") << \
getDisplay("f_budgeted_modified") << getDisplay("f_CURRENTAMOUNT") << \
getDisplay("f_DELTA");
- table.push_back(line);
+ table.push_back(QVariantList() << "sum" << getDisplay("t_CATEGORY") << \
getDisplay("f_budgeted_modified") << getDisplay("f_CURRENTAMOUNT") << \
getDisplay("f_DELTA")); double sum1 = 0;
double sum2 = 0;
double sum3 = 0;
@@ -2666,20 +2664,14 @@ QVariantList SKGDocumentBank::getBudget(const QString& \
iMonth) double v2 = SKGServices::stringToDouble(listTmp.at(i).at(2));
double v3 = SKGServices::stringToDouble(listTmp.at(i).at(3));
double v4 = SKGServices::stringToDouble(listTmp.at(i).at(4));
- QVariantList line;
- line << false << listTmp.at(i).at(0) << v1 << v2 << v3 << v4;
- table.push_back(line);
+ table.push_back(QVariantList() << false << listTmp.at(i).at(0) << v1 << \
v2 << v3 << v4);
sum1 += v1;
sum2 += v2;
sum3 += v3;
sum4 += v4;
}
- {
- QVariantList line;
- line << true << i18nc("Noun, the numerical total of a sum of values", \
"Total") << sum1 << sum2 << sum3 << sum4;
- table.push_back(line);
- }
+ table.push_back(QVariantList() << true << i18nc("Noun, the numerical total \
of a sum of values", "Total") << sum1 << sum2 << sum3 << sum4); }
return table;
}
diff --git a/skgbankmodeler/skgimportexportmanager.cpp \
b/skgbankmodeler/skgimportexportmanager.cpp index ca2e04f..7dc105d 100644
--- a/skgbankmodeler/skgimportexportmanager.cpp
+++ b/skgbankmodeler/skgimportexportmanager.cpp
@@ -263,10 +263,10 @@ SKGError SKGImportExportManager::finalizeImportation()
if (m_document && !getImportParameters().contains("donotfinalize")) {
//Count the number of operations imported but already existing
QString wc = "v_operation.t_imported='T' AND v_operation.t_import_id<>'' AND \
exists (SELECT 1 from v_operation op2 WHERE op2.t_imported!='T' AND \
op2.rd_account_id=v_operation.rd_account_id AND \
op2.t_import_id=v_operation.t_import_id AND \
ABS(op2.f_CURRENTAMOUNT-v_operation.f_CURRENTAMOUNT)<" % \
SKGServices::doubleToString(EPSILON) % ')';
- int nb;
- err = m_document->getNbObjects("v_operation", wc, nb);
- if (!err && nb) {
- err = m_document->sendMessage(i18np("one operation not imported because \
it already exists", "%1 operations not imported because they already exists", nb), \
SKGDocument::Warning); + int nbOperations;
+ err = m_document->getNbObjects("v_operation", wc, nbOperations);
+ if (!err && nbOperations) {
+ err = m_document->sendMessage(i18np("one operation not imported because \
it already exists", "%1 operations not imported because they already exists", \
nbOperations), SKGDocument::Warning);
//Remove operations imported for nothing
IFOKDO(err, m_document->executeSqliteOrder("DELETE from operation WHERE \
id IN (SELECT id from v_operation WHERE " % wc % ')')) @@ -289,9 +289,9 @@ SKGError \
SKGImportExportManager::finalizeImportation() SKGObjectBase::SKGListSKGObjectBase \
rules;
IFOKDO(err, m_document->getObjects("v_rule", "1=1 ORDER BY f_sortorder", \
rules))
- int nb = rules.count();
- IFOKDO(err, m_document->beginTransaction("#INTERNAL#" % \
i18nc("Progression step", "Finalize import"), nb))
- for (int i = 0; !err && i < nb; ++i) {
+ int nbRules = rules.count();
+ IFOKDO(err, m_document->beginTransaction("#INTERNAL#" % \
i18nc("Progression step", "Finalize import"), nbRules)) + for (int i = 0; \
!err && i < nbRules; ++i) { SKGRuleObject rule(rules.at(i));
err = rule.execute(SKGRuleObject::IMPORTING);
IFOKDO(err, m_document->stepForward(i + 1))
diff --git a/skgbankmodeler/skgreportbank.cpp b/skgbankmodeler/skgreportbank.cpp
index dabb596..161bbe0 100644
--- a/skgbankmodeler/skgreportbank.cpp
+++ b/skgbankmodeler/skgreportbank.cpp
@@ -139,20 +139,20 @@ QVariantList SKGReportBank::getPortfolio()
nb = listUnitValues.count();
for (int j = 0; j < nb; ++j) {
- unitValues current = listUnitValues.at(j);
+ unitValues current2 = listUnitValues.at(j);
- SKGServices::SKGUnitInfo ui = current.unit.getUnitInfo();
+ SKGServices::SKGUnitInfo ui = current2.unit.getUnitInfo();
ui.Value = 1;
QVariantList line2;
- line2 << current.unit.getSymbol()
- << current.unit.getName()
- << doc->formatMoney(current.quantity, ui, false)
- << current.purchaseAmount
- << current.initalAmount
- << current.currentAmount
- << current.currentAmount - current.initalAmount
- << (current.initalAmount == 0.0 ? 0.0 : \
(current.currentAmount - current.initalAmount) / current.initalAmount); + \
line2 << current2.unit.getSymbol() + << \
current2.unit.getName() + << \
doc->formatMoney(current2.quantity, ui, false) + << \
current2.purchaseAmount + << current2.initalAmount
+ << current2.currentAmount
+ << current2.currentAmount - current2.initalAmount
+ << (current2.initalAmount == 0.0 ? 0.0 : \
(current2.currentAmount - current2.initalAmount) / current2.initalAmount); table << \
QVariant(line2); }
}
@@ -228,10 +228,8 @@ QVariantList SKGReportBank::getAccountTable()
SKGObjectBase::SKGListSKGObjectBase accounts;
SKGError err = doc->getObjects("v_account_display", "1=1 ORDER BY \
t_TYPENLS, t_BANK, t_name", accounts); IFOK(err) {
- QVariantList line;
- line << "sum" << doc->getDisplay("t_ACCOUNT") << \
loc->formatDate(date1, KLocale::ShortDate) << loc->formatDate(date2, \
KLocale::ShortDate) <<
- "%" << loc->formatDate(date3, KLocale::ShortDate) << \
loc->formatDate(date2, KLocale::ShortDate) << "%";
- table.push_back(line);
+ table.push_back(QVariantList() << "sum" << \
doc->getDisplay("t_ACCOUNT") << loc->formatDate(date1, KLocale::ShortDate) << \
loc->formatDate(date2, KLocale::ShortDate) << + \
"%" << loc->formatDate(date3, KLocale::ShortDate) << loc->formatDate(date2, \
KLocale::ShortDate) << "%"); double sumTypeV1 = 0;
double sumTypeV2 = 0;
double sumTypeV3 = 0;
@@ -249,12 +247,10 @@ QVariantList SKGReportBank::getAccountTable()
bool closed = account.isClosed();
if (type != currentType) {
if (!currentType.isEmpty()) {
- QVariantList line2;
- line2 << true << i18nc("Noun", "Total of %1", \
currentType) << sumTypeV1 << sumTypeV2 <<
- (100.0 * (sumTypeV2 - sumTypeV1) / \
qAbs(sumTypeV1)) << sumTypeV3 << sumTypeV2
- << (100.0 * (sumTypeV2 - sumTypeV3) / \
qAbs(sumTypeV3))
- << "" << "";
- table.push_back(line2);
+ table.push_back(QVariantList() << true << \
i18nc("Noun", "Total of %1", currentType) << sumTypeV1 << sumTypeV2 << + \
(100.0 * (sumTypeV2 - sumTypeV1) / qAbs(sumTypeV1)) << sumTypeV3 << sumTypeV2 + \
<< (100.0 * (sumTypeV2 - sumTypeV3) / qAbs(sumTypeV3)) + \
<< "" << ""); sumTypeV1 = 0;
sumTypeV2 = 0;
sumTypeV3 = 0;
@@ -262,15 +258,13 @@ QVariantList SKGReportBank::getAccountTable()
currentType = type;
}
if (!closed || qAbs(v1) > 0.01 || qAbs(v2) > 0.01 || \
qAbs(v3) > 0.01) {
- QVariantList line2;
QString icon = account.getAttribute("t_ICON");
if (!icon.isEmpty()) {
QDir dirLogo(KStandardDirs::locate("data", \
QString::fromLatin1("skrooge/images/logo/"))); icon = \
dirLogo.absoluteFilePath(icon); }
- line2 << false << account.getName() << v1 << v2 << \
(100.0 * (v2 - v1) / qAbs(v1)) << v3 << v2
- << (100.0 * (v2 - v3) / qAbs(v3)) << \
account.getAttribute("t_BANK") << icon ;
- table.push_back(line2);
+ table.push_back(QVariantList() << false << \
account.getName() << v1 << v2 << (100.0 * (v2 - v1) / qAbs(v1)) << v3 << v2 + \
<< (100.0 * (v2 - v3) / qAbs(v3)) << account.getAttribute("t_BANK") << icon); ;
}
sumTypeV1 += v1;
@@ -281,21 +275,13 @@ QVariantList SKGReportBank::getAccountTable()
sumV3 += v3;
}
- {
- QVariantList line;
- line << true << i18nc("Noun", "Total of %1", currentType) \
<< sumTypeV1 << sumTypeV2
- << (100.0 * (sumTypeV2 - sumTypeV1) / qAbs(sumTypeV1)) \
<< sumTypeV3 << sumTypeV2 << (100.0 * (sumTypeV2 - sumTypeV3) / \
qAbs(sumTypeV3))
- << "" << "";
- table.push_back(line);
- }
+ table.push_back(QVariantList() << true << i18nc("Noun", "Total \
of %1", currentType) << sumTypeV1 << sumTypeV2 + \
<< (100.0 * (sumTypeV2 - sumTypeV1) / qAbs(sumTypeV1)) << sumTypeV3 << sumTypeV2 << \
(100.0 * (sumTypeV2 - sumTypeV3) / qAbs(sumTypeV3)) + \
<< "" << "");
- {
- QVariantList line;
- line << true << i18nc("Noun, the numerical total of a sum of \
values", "Total") << sumV1 << sumV2
- << (100.0 * (sumV2 - sumV1) / qAbs(sumV1)) << sumV3 << \
sumV2 << (100.0 * (sumV2 - sumV3) / qAbs(sumV3))
- << "" << "";
- table.push_back(line);
- }
+ table.push_back(QVariantList() << true << i18nc("Noun, the \
numerical total of a sum of values", "Total") << sumV1 << sumV2 + \
<< (100.0 * (sumV2 - sumV1) / qAbs(sumV1)) << sumV3 << sumV2 << (100.0 * (sumV2 - \
sumV3) / qAbs(sumV3)) + << "" << "");
}
}
}
@@ -324,10 +310,8 @@ QVariantList SKGReportBank::getBankTable()
SKGObjectBase::SKGListSKGObjectBase accounts;
SKGError err = doc->getObjects("v_account", "1=1 ORDER BY t_BANK", \
accounts); IFOK(err) {
- QVariantList line;
- line << "sum" << doc->getDisplay("t_BANK") << \
loc->formatDate(date1, KLocale::ShortDate) << loc->formatDate(date2, \
KLocale::ShortDate) <<
- "%" << loc->formatDate(date3, KLocale::ShortDate) << \
loc->formatDate(date2, KLocale::ShortDate) << "%";
- table.push_back(line);
+ table.push_back(QVariantList() << "sum" << \
doc->getDisplay("t_BANK") << loc->formatDate(date1, KLocale::ShortDate) << \
loc->formatDate(date2, KLocale::ShortDate) << + \
"%" << loc->formatDate(date3, KLocale::ShortDate) << loc->formatDate(date2, \
KLocale::ShortDate) << "%"); double sumTypeV1 = 0;
double sumTypeV2 = 0;
double sumTypeV3 = 0;
@@ -355,11 +339,9 @@ QVariantList SKGReportBank::getBankTable()
bool open = !account.isClosed();
if (type != currentType) {
if (!currentType.isEmpty() && currentOpen) {
- QVariantList line;
- line << false << currentType << sumTypeV1 << \
sumTypeV2 <<
- (100.0 * (sumTypeV2 - sumTypeV1) / \
qAbs(sumTypeV1)) << sumTypeV3 << sumTypeV2 << (100.0 * (sumTypeV2 - sumTypeV3) / \
qAbs(sumTypeV3)) <<
- currentIcon;
- table.push_back(line);
+ table.push_back(QVariantList() << false << \
currentType << sumTypeV1 << sumTypeV2 << + \
(100.0 * (sumTypeV2 - sumTypeV1) / qAbs(sumTypeV1)) << sumTypeV3 << sumTypeV2 << \
(100.0 * (sumTypeV2 - sumTypeV3) / qAbs(sumTypeV3)) << + \
currentIcon); sumTypeV1 = 0;
sumTypeV2 = 0;
sumTypeV3 = 0;
@@ -379,19 +361,13 @@ QVariantList SKGReportBank::getBankTable()
}
if (currentOpen) {
- QVariantList line;
- line << false << currentType << sumTypeV1 << sumTypeV2
- << (100.0 * (sumTypeV2 - sumTypeV1) / qAbs(sumTypeV1)) \
<< sumTypeV3
- << sumTypeV2 << (100.0 * (sumTypeV2 - sumTypeV3) / \
qAbs(sumTypeV3))
- << currentIcon;
- table.push_back(line);
+ table.push_back(QVariantList() << false << currentType << \
sumTypeV1 << sumTypeV2 + << (100.0 * \
(sumTypeV2 - sumTypeV1) / qAbs(sumTypeV1)) << sumTypeV3 + \
<< sumTypeV2 << (100.0 * (sumTypeV2 - sumTypeV3) / qAbs(sumTypeV3)) + \
<< currentIcon); }
- {
- QVariantList line;
- line << true << i18nc("Noun, the numerical total of a sum of \
values", "Total") << sumV1 << sumV2 << (100.0 * (sumV2 - sumV1) / qAbs(sumV1)) << \
sumV3 << sumV2 << (100.0 * (sumV2 - sumV3) / qAbs(sumV3));
- table.push_back(line);
- }
+ table.push_back(QVariantList() << true << i18nc("Noun, the \
numerical total of a sum of values", "Total") << sumV1 << sumV2 << (100.0 * (sumV2 - \
sumV1) / qAbs(sumV1)) << sumV3 << sumV2 << (100.0 * (sumV2 - sumV3) / qAbs(sumV3))); \
} }
}
@@ -483,9 +459,7 @@ QVariantList SKGReportBank::getIncomeVsExpenditure()
SKGError err = doc->getObjects("v_operation_display", "d_DATEMONTH IN \
('" % month % "', '" % previousmonth % "') AND t_TRANSFER='N'", ops); int nbval = \
ops.count(); if (!err && nbval > 0) {
- QVariantList line;
- line << "sum" << "" << previousmonth << month << "max";
- table.push_back(line);
+ table.push_back(QVariantList() << "sum" << "" << previousmonth << \
month << "max");
double income_previous_month = 0;
double expense_previous_month = 0;
@@ -505,26 +479,10 @@ QVariantList SKGReportBank::getIncomeVsExpenditure()
double saving_previous_month = income_previous_month + \
expense_previous_month; double saving_month = income_month + expense_month;
- {
- QVariantList line;
- line << false << doc->getDisplay("f_CURRENTAMOUNT_INCOME") << \
qAbs(income_previous_month) << qAbs(income_month);
- table.push_back(line);
- }
- {
- QVariantList line;
- line << false << doc->getDisplay("f_CURRENTAMOUNT_EXPENSE") << \
qAbs(expense_previous_month) << qAbs(expense_month);
- table.push_back(line);
- }
- {
- QVariantList line;
- line << true << i18nc("Noun", "Savings possible") << \
saving_previous_month << saving_month;
- table.push_back(line);
- }
- {
- QVariantList line;
- line << true << i18nc("Noun", "Max") << \
qMax(qAbs(income_previous_month), qAbs(expense_previous_month)) << \
qMax(qAbs(income_month), qAbs(expense_month));
- table.push_back(line);
- }
+ table.push_back(QVariantList() << false << \
doc->getDisplay("f_CURRENTAMOUNT_INCOME") << qAbs(income_previous_month) << \
qAbs(income_month)); + table.push_back(QVariantList() << false << \
doc->getDisplay("f_CURRENTAMOUNT_EXPENSE") << qAbs(expense_previous_month) << \
qAbs(expense_month)); + table.push_back(QVariantList() << true << \
i18nc("Noun", "Savings possible") << saving_previous_month << saving_month); + \
table.push_back(QVariantList() << true << i18nc("Noun", "Max") << \
qMax(qAbs(income_previous_month), qAbs(expense_previous_month)) << \
qMax(qAbs(income_month), qAbs(expense_month))); }
m_cache["getIncomeVsExpenditure"] = table;
}
diff --git a/skgbankmodeler/skgruleobject.cpp b/skgbankmodeler/skgruleobject.cpp
index ffde167..da7add6 100644
--- a/skgbankmodeler/skgruleobject.cpp
+++ b/skgbankmodeler/skgruleobject.cpp
@@ -227,8 +227,8 @@ SKGError SKGRuleObject::execute(ProcessMode iMode)
SKGStringListList result;
err = doc->executeSelectSqliteOrder("SELECT changes()", result);
if (!err && result.count() == 2) {
- int nb = SKGServices::stringToInt(result.at(1).at(0));
- if (nb) doc->sendMessage(i18np("1 operation modified by %2", "%1 \
operations modified by %2", nb, getAttribute("i_ORDER"))); + int \
nbChanges = SKGServices::stringToInt(result.at(1).at(0)); + if \
(nbChanges) doc->sendMessage(i18np("1 operation modified by %2", "%1 operations \
modified by %2", nbChanges, getAttribute("i_ORDER"))); }
}
diff --git a/skgbankmodeler/skgunitobject.cpp b/skgbankmodeler/skgunitobject.cpp
index 0c1fc07..31034c1 100644
--- a/skgbankmodeler/skgunitobject.cpp
+++ b/skgbankmodeler/skgunitobject.cpp
@@ -462,25 +462,25 @@ SKGError SKGUnitObject::simplify()
QDate limit3 = QDate::currentDate().addYears(-3);
for (int i = nb - 1; !err && i >= 0 ; --i) {
SKGUnitValueObject v(values.at(i));
- QDate d = v.getDate();
- if (d >= limit1) {
+ QDate date = v.getDate();
+ if (date >= limit1) {
//No simplification ==> nothing to do
- } else if (d >= limit2) {
+ } else if (date >= limit2) {
//Simplification by group of 30 days
- QString key = limit1.addDays(30 * (limit1.daysTo(d) / \
30)).toString(); + QString key = limit1.addDays(30 * \
(limit1.daysTo(date) / 30)).toString(); SKGListSKGObjectBase group = groups[key];
group.push_back(v);
groups[key] = group;
- } else if (d >= limit3) {
+ } else if (date >= limit3) {
//Simplification by group of 2 months
- QString key = limit2.addDays(60 * (limit2.daysTo(d) / \
60)).toString(); + QString key = limit2.addDays(60 * \
(limit2.daysTo(date) / 60)).toString(); SKGListSKGObjectBase group = groups[key];
group.push_back(v);
groups[key] = group;
} else {
//Simplification by group of 6 months
- QString key = limit3.addDays(180 * (limit2.daysTo(d) / \
180)).toString(); + QString key = limit3.addDays(180 * \
(limit2.daysTo(date) / 180)).toString(); SKGListSKGObjectBase group = groups[key];
group.push_back(v);
groups[key] = group;
@@ -749,10 +749,10 @@ SKGError SKGUnitObject::downloadUnitValue(UnitDownloadMode \
iMode, int nbMaxValue
double rate2 = 100.0 * (qExp(qLn(1 + rate / 100.0) / step) - 1.0);
//Get last value
- SKGStringListList result;
+ SKGStringListList result2;
double value = 100;
- doc->executeSelectSqliteOrder("SELECT f_quantity FROM unitvalue where \
rd_unit_id=(SELECT id from unit where t_name='" % \
SKGServices::stringToSqlString(unitname) % "') AND d_date='" % \
SKGServices::dateToSqlString(QDateTime(firstDate)) % '\'', result);
- if (result.count() == 2) value = \
SKGServices::stringToDouble(result.at(1).at(0)); + \
doc->executeSelectSqliteOrder("SELECT f_quantity FROM unitvalue where \
rd_unit_id=(SELECT id from unit where t_name='" % \
SKGServices::stringToSqlString(unitname) % "') AND d_date='" % \
SKGServices::dateToSqlString(QDateTime(firstDate)) % '\'', result2); + if \
(result2.count() == 2) value = SKGServices::stringToDouble(result2.at(1).at(0));
//Compute and add values
while (!err && firstDate <= QDate::currentDate()) {
@@ -1074,17 +1074,17 @@ SKGError SKGUnitObject::downloadUnitValue(UnitDownloadMode \
iMode, int nbMaxValue
double val = 0.0;
if (priceRegExp.indexIn(data) > -1) val = \
SKGServices::stringToDouble(priceRegExp.cap(1));
- QString d;
- if (dateRegExp.indexIn(data) > -1) d = \
dateRegExp.cap(1); + QString date2;
+ if (dateRegExp.indexIn(data) > -1) date2 = \
dateRegExp.cap(1);
SKGTRACEL(1) << "Price found=[" << val << "]" << \
endl;
- SKGTRACEL(1) << "Date found=[" << d << "]" << endl;
+ SKGTRACEL(1) << "Date found=[" << date2 << "]" << \
endl;
//Set value
if (val) {
QDate ds;
if (dateFormat == "UNIX")
- ds = \
QDateTime::fromTime_t(SKGServices::stringToInt(d)).date();
- else ds = QDate::fromString(d, dateFormat);
+ ds = \
QDateTime::fromTime_t(SKGServices::stringToInt(date2)).date(); + \
else ds = QDate::fromString(date2, dateFormat);
if (!ds.isValid()) ds = QDate::currentDate();
if (!dateFormat.contains("yyyy") && ds.year() < \
2000) ds = ds.addYears(100);
diff --git a/skgbasegui/skgmainpanel.cpp b/skgbasegui/skgmainpanel.cpp
index 3dc5d33..0f5d146 100644
--- a/skgbasegui/skgmainpanel.cpp
+++ b/skgbasegui/skgmainpanel.cpp
@@ -466,11 +466,11 @@ SKGMainPanel::SKGMainPanel(KSplashScreen* iSplashScreen, \
SKGDocument* iDocument,
d->ui.kContextList->addItem(contextItem);
- KAction* action = contextMenu->addAction(icon, title);
- if (action) {
- action->setCheckable(false);
- action->setData(page2);
- contextItem->setData(15, \
qVariantFromValue(static_cast<void*>(action))); //context item ==> action + \
KAction* newAction = contextMenu->addAction(icon, title); + if \
(newAction) { + newAction->setCheckable(false);
+ newAction->setData(page2);
+ contextItem->setData(15, \
qVariantFromValue(static_cast<void*>(newAction))); //context item ==> action if \
(!shortCutPrefix.isEmpty()) { ++shortCutIndex;
if (shortCutIndex == 10) {
@@ -478,18 +478,18 @@ SKGMainPanel::SKGMainPanel(KSplashScreen* iSplashScreen, \
SKGDocument* iDocument,
if (shortCutPrefix == "Ctrl+") shortCutPrefix += \
"Alt+"; else shortCutPrefix = "";
}
- if (!shortCutPrefix.isEmpty()) \
action->setShortcut(QString(shortCutPrefix % \
SKGServices::intToString(shortCutIndex))); + if \
(!shortCutPrefix.isEmpty()) newAction->setShortcut(QString(shortCutPrefix % \
SKGServices::intToString(shortCutIndex))); }
- connect(action, \
SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, \
SLOT(onOpenContext(Qt::MouseButtons,Qt::KeyboardModifiers))); + \
connect(newAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, \
SLOT(onOpenContext(Qt::MouseButtons,Qt::KeyboardModifiers)));
- contextActionList.append(action);
+ contextActionList.append(newAction);
if (!visible) pageNotVisible.push_back(contextItem);
//Register action
QString id = "page_" % pluginInterface->objectName();
- registerGlobalAction(id, action);
- registerGlobalAction(id, action);
+ registerGlobalAction(id, newAction);
+ registerGlobalAction(id, newAction);
}
}
@@ -544,8 +544,8 @@ SKGMainPanel::SKGMainPanel(KSplashScreen* iSplashScreen, \
SKGDocument* iDocument, \
kProgressBar->setObjectName(QString::fromUtf8("kProgressBar")); \
kProgressBar->setValue(0); kProgressBar->setMinimumSize(100, 20);
- QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
- kProgressBar->setSizePolicy(sizePolicy);
+ QSizePolicy sizePolicyProgessBar(QSizePolicy::Fixed, QSizePolicy::Expanding);
+ kProgressBar->setSizePolicy(sizePolicyProgessBar);
kProgressBar->setToolTip(i18nc("Widget description", "Progress of the current \
action")); QFont f = kProgressBar->font();
f.setPointSize(6.0);
@@ -555,7 +555,7 @@ SKGMainPanel::SKGMainPanel(KSplashScreen* iSplashScreen, \
SKGDocument* iDocument, kProgressBar->setRange(0, 100);
d->m_zoomSelector = new SKGZoomSelector(this);
- d->m_zoomSelector->setSizePolicy(sizePolicy);
+ d->m_zoomSelector->setSizePolicy(sizePolicyProgessBar);
connect(d->m_zoomSelector, SIGNAL(changed(int)), this, SLOT(onZoomChanged()));
statusBar()->addWidget(d->m_kNormalMessage);
@@ -574,11 +574,11 @@ SKGMainPanel::SKGMainPanel(KSplashScreen* iSplashScreen, \
SKGDocument* iDocument, KToolBar* tb = toolBar();
if (tb) {
QLabel* label = new QLabel(this);
- QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
- sizePolicy.setHorizontalStretch(0);
- sizePolicy.setVerticalStretch(0);
- sizePolicy.setHeightForWidth(label->sizePolicy().hasHeightForWidth());
- label->setSizePolicy(sizePolicy);
+ QSizePolicy sizePolicyLabel(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ sizePolicyLabel.setHorizontalStretch(0);
+ sizePolicyLabel.setVerticalStretch(0);
+ sizePolicyLabel.setHeightForWidth(label->sizePolicy().hasHeightForWidth());
+ label->setSizePolicy(sizePolicyLabel);
tb->addWidget(label);
tb->addAction(d->m_buttonMenuAction);
}
@@ -612,9 +612,9 @@ SKGMainPanel::SKGMainPanel(KSplashScreen* iSplashScreen, \
SKGDocument* iDocument, //Tip of day
if (tipsFound) {
//Tip of day is available
- KSharedConfigPtr config = KSharedConfig::openConfig();
- KConfigGroup pref = config->group("TipOfDay");
- if (pref.readEntry("RunOnStart", true)) onTipOfDay();
+ KSharedConfigPtr config2 = KSharedConfig::openConfig();
+ KConfigGroup pref2 = config2->group("TipOfDay");
+ if (pref2.readEntry("RunOnStart", true)) onTipOfDay();
} else {
//Remove useless menu
delete d->m_tipOfDayAction;
@@ -671,9 +671,9 @@ SKGMainPanel::~SKGMainPanel()
delete d;
}
-void SKGMainPanel::showMenu(const QPoint& pos)
+void SKGMainPanel::showMenu(const QPoint& iPos)
{
- if (d->m_contextMenu) \
d->m_contextMenu->popup(d->ui.kContextList->mapToGlobal(pos)); + if \
(d->m_contextMenu) d->m_contextMenu->popup(d->ui.kContextList->mapToGlobal(iPos)); }
void SKGMainPanel::setContextVisibility(QListWidgetItem* iItem, bool iVisibility)
@@ -797,13 +797,13 @@ void SKGMainPanel::setupActions()
registerGlobalAction("new_tab", d->m_addTabAction);
//Add new tab widget
- QToolButton* addTab = new QToolButton(this);
- addTab->setIcon(d->m_addTabAction->icon());
- addTab->setAutoRaise(true);
- addTab->raise();
- addTab->setDefaultAction(d->m_addTabAction);
- addTab->setToolButtonStyle(Qt::ToolButtonIconOnly);
- d->m_tabWidget->setCornerWidget(addTab);
+ QToolButton* addTabButton = new QToolButton(this);
+ addTabButton->setIcon(d->m_addTabAction->icon());
+ addTabButton->setAutoRaise(true);
+ addTabButton->raise();
+ addTabButton->setDefaultAction(d->m_addTabAction);
+ addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
+ d->m_tabWidget->setCornerWidget(addTabButton);
d->m_actLock = new KAction(KIcon("document-encrypt"), i18nc("Verb", "Lock \
panels"), this);
connect(d->m_actLock, SIGNAL(triggered(bool)), this, SLOT(onLockDocks()));
@@ -951,16 +951,16 @@ void SKGMainPanel::onPrevious()
SKGTabPage* cPage = currentPage();
if (cPage) {
//Get index in history of page to refresh
- int pos = static_cast<QAction*>(sender())->data().toInt();
+ int indexPrevious = static_cast<QAction*>(sender())->data().toInt();
//Get lists
QList<SKGTabPage::SKGPageHistoryItem> listPrevious = \
cPage->getPreviousPages();
- if (pos < listPrevious.count()) {
+ if (indexPrevious < listPrevious.count()) {
QList<SKGTabPage::SKGPageHistoryItem> listNext = cPage->getNextPages();
SKGTabPage::SKGPageHistoryItem current = currentPageHistoryItem();
//Get item to refresh
- SKGTabPage::SKGPageHistoryItem item = listPrevious.at(pos);
+ SKGTabPage::SKGPageHistoryItem item = listPrevious.at(indexPrevious);
//Open page
cPage = openPage(getPluginByName(item.plugin), currentPageIndex(), \
item.state, item.name, item.bookmarkID); @@ -969,10 +969,10 @@ void \
SKGMainPanel::onPrevious()
//Update lists
listNext.insert(0, current);
- listPrevious.removeAt(pos);
- for (int i = 0; i < pos; ++i) {
- SKGTabPage::SKGPageHistoryItem item = listPrevious.at(0); \
//Because the list is modified
- listNext.insert(0, item);
+ listPrevious.removeAt(indexPrevious);
+ for (int i = 0; i < indexPrevious; ++i) {
+ SKGTabPage::SKGPageHistoryItem itemPrevious = \
listPrevious.at(0); //Because the list is modified + \
listNext.insert(0, itemPrevious); listPrevious.removeAt(0);
}
@@ -1064,7 +1064,7 @@ void SKGMainPanel::onNext()
SKGTabPage* cPage = currentPage();
if (cPage) {
//Get index in history of page to refresh
- int pos = static_cast<QAction*>(sender())->data().toInt();
+ int posNext = static_cast<QAction*>(sender())->data().toInt();
//Get lists
QList<SKGTabPage::SKGPageHistoryItem> listPrevious = \
cPage->getPreviousPages(); @@ -1072,7 +1072,7 @@ void SKGMainPanel::onNext()
SKGTabPage::SKGPageHistoryItem current = currentPageHistoryItem();
//Get item to refresh
- SKGTabPage::SKGPageHistoryItem item = listNext.at(pos);
+ SKGTabPage::SKGPageHistoryItem item = listNext.at(posNext);
//Open page
cPage = openPage(getPluginByName(item.plugin), currentPageIndex(), \
item.state, item.name, item.bookmarkID); @@ -1081,10 +1081,10 @@ void \
SKGMainPanel::onNext()
//Update lists
listPrevious.insert(0, current);
- listNext.removeAt(pos);
- for (int i = 0; i < pos; ++i) {
- SKGTabPage::SKGPageHistoryItem item = listNext.at(0); //Because the \
list is modified
- listPrevious.insert(0, item);
+ listNext.removeAt(posNext);
+ for (int i = 0; i < posNext; ++i) {
+ SKGTabPage::SKGPageHistoryItem itemNext = listNext.at(0); //Because \
the list is modified + listPrevious.insert(0, itemNext);
listNext.removeAt(0);
}
@@ -1331,8 +1331,8 @@ void SKGMainPanel::optionsPreferences(const QString& \
iPluginName)
KConfigDialog* dialog = new KConfigDialog(this, "settings", \
skgbasegui_settings::self());
//Add main
- QWidget* widget = new QWidget();
- d->uipref.setupUi(widget);
+ QWidget* w = new QWidget();
+ d->uipref.setupUi(w);
d->uipref.kcfg_date_format->addItem(i18nc("Date format", "Short date (%1, %2)",
\
KGlobal::locale()->formatDate(QDate::currentDate(), KLocale::ShortDate), @@ -1356,16 \
+1356,16 @@ void SKGMainPanel::optionsPreferences(const QString& \
iPluginName)
\
KGlobal::locale()->formatDate(QDate::currentDate(), \
KLocale::IsoOrdinalDate),
\
KGlobal::locale()->formatDate(QDate::currentDate().addDays(-10), \
KLocale::IsoOrdinalDate)));
- dialog->addPage(widget, skgbasegui_settings::self(), i18nc("Noun", "General"), \
"preferences-other"); + dialog->addPage(w, skgbasegui_settings::self(), \
i18nc("Noun", "General"), "preferences-other");
//Add plugin in client in right order
int nbplugin = d->m_pluginsList.count();
for (int j = 0; j < nbplugin; ++j) {
SKGInterfacePlugin* pluginInterface = getPluginByIndex(j);
if (pluginInterface) {
- QWidget* w = pluginInterface->getPreferenceWidget();
- if (w) {
- KPageWidgetItem* p = dialog->addPage(w, \
pluginInterface->getPreferenceSkeleton(), pluginInterface->title(), \
pluginInterface->icon()); + QWidget* w2 = \
pluginInterface->getPreferenceWidget(); + if (w2) {
+ KPageWidgetItem* p = dialog->addPage(w2, \
pluginInterface->getPreferenceSkeleton(), pluginInterface->title(), \
pluginInterface->icon());
if (p && pluginName == pluginInterface->objectName()) \
dialog->setCurrentPage(p); }
}
@@ -1478,13 +1478,13 @@ void SKGMainPanel::refresh()
d->m_zoomSelector->setVisible(toSave && toSave->isZoomable());
if (toSave) {
d->m_zoomSelector->setValue(toSave->zoomPosition());
- QWidget* widget = toSave->zoomableWidget();
- SKGTreeView* treeView = qobject_cast<SKGTreeView*>(widget);
+ QWidget* zoomWidget = toSave->zoomableWidget();
+ SKGTreeView* treeView = qobject_cast<SKGTreeView*>(zoomWidget);
if (treeView) {
disconnect(treeView, SIGNAL(zoomChanged(int)), d->m_zoomSelector, \
SLOT(setValue(int)));
connect(treeView, SIGNAL(zoomChanged(int)), d->m_zoomSelector, \
SLOT(setValue(int))); } else {
- SKGWebView* webView = qobject_cast<SKGWebView*>(widget);
+ SKGWebView* webView = qobject_cast<SKGWebView*>(zoomWidget);
if (webView) {
disconnect(webView, SIGNAL(zoomChanged(int)), d->m_zoomSelector, \
SLOT(setValue(int)));
connect(webView, SIGNAL(zoomChanged(int)), d->m_zoomSelector, \
SLOT(setValue(int))); @@ -1537,21 +1537,21 @@ void SKGMainPanel::refresh()
SKGTabPage::SKGPageHistoryItem SKGMainPanel::currentPageHistoryItem() const
{
- SKGTabPage::SKGPageHistoryItem page;
+ SKGTabPage::SKGPageHistoryItem cpage;
int currentIndex = currentPageIndex();
SKGTabPage* cPage = currentPage();
if (currentIndex >= 0 && cPage) {
- page.plugin = cPage->objectName();
- SKGInterfacePlugin* plugin = \
SKGMainPanel::getMainPanel()->getPluginByName(page.plugin); + cpage.plugin = \
cPage->objectName(); + SKGInterfacePlugin* plugin = \
SKGMainPanel::getMainPanel()->getPluginByName(cpage.plugin); if (plugin) {
- page.name = d->m_tabWidget->tabText(currentIndex);
- page.icon = plugin->icon();
+ cpage.name = d->m_tabWidget->tabText(currentIndex);
+ cpage.icon = plugin->icon();
}
- page.state = cPage->getState();
- page.bookmarkID = cPage->getBookmarkID();
+ cpage.state = cPage->getState();
+ cpage.bookmarkID = cPage->getBookmarkID();
}
- return page;
+ return cpage;
}
SKGTabPage* SKGMainPanel::openPage(SKGInterfacePlugin* plugin, int index, const \
QString& parameters, const QString& title, const QString& iID, bool iSetCurrent) @@ \
-1701,9 +1701,9 @@ bool SKGMainPanel::openPage(const QUrl& iUrl, bool iNewPage) }
} else {
//Trigger action
- QAction* action = \
SKGMainPanel::getMainPanel()->getGlobalAction(url.host());
- if (action) {
- action->trigger();
+ QAction* act = \
SKGMainPanel::getMainPanel()->getGlobalAction(url.host()); + if (act) {
+ act->trigger();
return true;
}
}
@@ -1739,11 +1739,11 @@ SKGTabPage* SKGMainPanel::openPage(int iPage, bool iNewPage)
void SKGMainPanel::onOpenContext(Qt::MouseButtons iMouse, Qt::KeyboardModifiers \
iKeyboard) {
SKGTRACEIN(1, "SKGMainPanel::onOpenContext");
- int page = -1;
- QAction* sender = qobject_cast<QAction*>(this->sender());
- if (sender) page = sender->data().toInt();
- else page = d->ui.kContextList->currentRow();
- if (page != -1) openPage(page, QApplication::keyboardModifiers() \
&Qt::ControlModifier || d->m_middleClick || iMouse & Qt::MidButton || iKeyboard & \
Qt::ControlModifier); + int cpage = -1;
+ QAction* s = qobject_cast<QAction*>(this->sender());
+ if (s) cpage = s->data().toInt();
+ else cpage = d->ui.kContextList->currentRow();
+ if (cpage != -1) openPage(cpage, QApplication::keyboardModifiers() \
&Qt::ControlModifier || d->m_middleClick || iMouse & Qt::MidButton || iKeyboard & \
Qt::ControlModifier); d->m_middleClick = false;
}
@@ -1877,12 +1877,12 @@ void SKGMainPanel::addTab()
if (cPage) openPage(getPluginByName(cPage->objectName()));
}
-bool SKGMainPanel::eventFilter(QObject* object, QEvent* event)
+bool SKGMainPanel::eventFilter(QObject* iObject, QEvent* iEvent)
{
- if (event && object) {
- QResizeEvent* resizeEvent = dynamic_cast<QResizeEvent*>(event);
- if (resizeEvent) {
- QSize newSize = resizeEvent->size();
+ if (iEvent && iObject) {
+ QResizeEvent* rEvent = dynamic_cast<QResizeEvent*>(iEvent);
+ if (rEvent) {
+ QSize newSize = rEvent->size();
//Compute icon size
int s = qMax(qMin(newSize.width() / 5, 64), 16);
@@ -2012,9 +2012,9 @@ KMessageWidget* SKGMainPanel::displayMessage(const QString& \
iMessage, SKGDocumen // [Event/error]
// [Event/neutral]
// [Event/positive]
- KNotification* notify = new KNotification(iType == SKGDocument::Error ? "error" \
: (iType == SKGDocument::Positive ? "positive" : "neutral") , this);
- notify->setText(iMessage);
- notify->sendEvent();
+ KNotification* notification = new KNotification(iType == SKGDocument::Error ? \
"error" : (iType == SKGDocument::Positive ? "positive" : "neutral") , this); + \
notification->setText(iMessage); + notification->sendEvent();
//Alert
if (iType == SKGDocument::Error || iType == SKGDocument::Warning) \
qApp->alert(this);
diff --git a/skgbasegui/skgobjectmodelbase.cpp b/skgbasegui/skgobjectmodelbase.cpp
index 80e6c64..d37db74 100644
--- a/skgbasegui/skgobjectmodelbase.cpp
+++ b/skgbasegui/skgobjectmodelbase.cpp
@@ -398,10 +398,7 @@ int SKGObjectModelBase::rowCount(const QModelIndex& iParent) \
const int idParent = 0;
if (iParent.isValid()) idParent = iParent.internalId();
- QList<int> children = m_parentChildRelations.value(idParent);
- //SKGTRACE << table << "-rowCount(" << idParent << " )=" << children.count() << \
endl;
- return children.count();
-
+ return m_parentChildRelations.value(idParent).count();
}
int SKGObjectModelBase::columnCount(const QModelIndex& iParent) const
@@ -424,13 +421,13 @@ QModelIndex SKGObjectModelBase::index(int row, int column, \
const QModelIndex& iP return (idChild ? createIndex(row, column, idChild) : \
QModelIndex()); }
-QModelIndex SKGObjectModelBase::parent(const QModelIndex& index) const
+QModelIndex SKGObjectModelBase::parent(const QModelIndex& iIndex) const
{
- if (!index.isValid()) return QModelIndex();
+ if (!iIndex.isValid()) return QModelIndex();
_SKGTRACEIN(10, "SKGObjectModelBase::parent");
int idChild = 0;
- if (index.isValid()) idChild = index.internalId();
+ if (iIndex.isValid()) idChild = iIndex.internalId();
int idParent = m_childParentRelations.value(idChild);
int row = m_objectsHashTableRows.value(idParent);
@@ -495,29 +492,29 @@ QVariant SKGObjectModelBase::headerData(int section, \
Qt::Orientation orientation return QVariant();
}
-SKGObjectBase SKGObjectModelBase::getObject(const QModelIndex& index) const
+SKGObjectBase SKGObjectModelBase::getObject(const QModelIndex& iIndex) const
{
- SKGObjectBase* obj = getObjectPointer(index);
+ SKGObjectBase* obj = getObjectPointer(iIndex);
SKGObjectBase output;
if (obj != NULL) output = *obj;
return output;
}
-SKGObjectBase* SKGObjectModelBase::getObjectPointer(const QModelIndex& index) const
+SKGObjectBase* SKGObjectModelBase::getObjectPointer(const QModelIndex& iIndex) const
{
_SKGTRACEIN(10, "SKGObjectModelBase::getObject");
//SKGTRACE << "getObject:" << index.internalId() << endl;
- return m_objectsHashTable.value(index.internalId());
+ return m_objectsHashTable.value(iIndex.internalId());
}
-QVariant SKGObjectModelBase::data(const QModelIndex& index, int role) const
+QVariant SKGObjectModelBase::data(const QModelIndex& iIndex, int iRole) const
{
- if (!index.isValid()) return QVariant();
+ if (!iIndex.isValid()) return QVariant();
_SKGTRACEIN(10, "SKGObjectModelBase::data");
- switch (role) {
+ switch (iRole) {
case Qt::BackgroundRole: {
- SKGObjectBase* obj = getObjectPointer(index);
+ SKGObjectBase* obj = getObjectPointer(iIndex);
if (obj->getTable().isEmpty()) {
//This is a group
return QApplication::palette().brush(QPalette::Button);
@@ -527,16 +524,16 @@ QVariant SKGObjectModelBase::data(const QModelIndex& index, int \
role) const case Qt::DisplayRole:
case Qt::EditRole:
case Qt::UserRole: {
- SKGObjectBase* obj = getObjectPointer(index);
- QString att = m_listAttibutes[index.column()];
+ SKGObjectBase* obj = getObjectPointer(iIndex);
+ QString att = m_listAttibutes[iIndex.column()];
if (obj->getTable().isEmpty()) {
//This is a group
- if (index.column() == 0) {
- if (role == Qt::UserRole) return -obj->getID(); //For sorting
+ if (iIndex.column() == 0) {
+ if (iRole == Qt::UserRole) return -obj->getID(); //For sorting
else return i18nc("How to display a grouping title. Here \"title \
(count)\"", "%1: %2 (%3)",
getDocument()->getDisplay(m_groupby),
obj->getAttribute("t_title"),
- \
rowCount(SKGObjectModelBase::index(index.row(), 0))); + \
rowCount(SKGObjectModelBase::index(iIndex.row(), 0))); }
return "";
} else {
@@ -549,7 +546,7 @@ QVariant SKGObjectModelBase::data(const QModelIndex& index, int \
role) const val = obj->getAttribute(att);
}
- switch (getAttributeType(index.column())) {
+ switch (getAttributeType(iIndex.column())) {
case SKGServices::FLOAT: {
double dval = SKGServices::stringToDouble(val);
return dval;
@@ -559,7 +556,7 @@ QVariant SKGObjectModelBase::data(const QModelIndex& index, int \
role) const }
case SKGServices::DATE: {
QDate dval = SKGServices::stringToTime(val).date();
- if (role == Qt::DisplayRole) {
+ if (iRole == Qt::DisplayRole) {
return KGlobal::locale()->formatDate(dval, \
static_cast<KLocale::DateFormat>(skgbasegui_settings::date_format())); } else {
return dval;
@@ -577,11 +574,11 @@ QVariant SKGObjectModelBase::data(const QModelIndex& index, int \
role) const }
case Qt::FontRole: {
- SKGObjectBase* obj = getObjectPointer(index);
+ SKGObjectBase* obj = getObjectPointer(iIndex);
//Text color
if (obj->getTable().isEmpty()) {
//This is a group
- if (index.column() == 0) {
+ if (iIndex.column() == 0) {
QFont f;
f.setBold(true);
@@ -593,8 +590,8 @@ QVariant SKGObjectModelBase::data(const QModelIndex& index, int \
role) const }
case Qt::TextColorRole: {
//Text color
- if (getAttributeType(index.column()) == SKGServices::FLOAT) {
- QVariant value_displayed = SKGObjectModelBase::data(index, \
Qt::UserRole); + if (getAttributeType(iIndex.column()) == SKGServices::FLOAT) \
{ + QVariant value_displayed = SKGObjectModelBase::data(iIndex, \
Qt::UserRole); bool ok = false;
double value_double = value_displayed.toDouble(&ok);
if (ok && value_double < 0) return m_fontNegativeColor;
@@ -603,22 +600,22 @@ QVariant SKGObjectModelBase::data(const QModelIndex& index, int \
role) const }
case Qt::TextAlignmentRole: {
//Text alignment
- SKGServices::AttributeType attType = getAttributeType(index.column());
+ SKGServices::AttributeType attType = getAttributeType(iIndex.column());
return static_cast<int>(Qt::AlignVCenter | (attType == SKGServices::FLOAT || \
attType == SKGServices::INTEGER ? Qt::AlignRight : Qt::AlignLeft)); }
case Qt::DecorationRole: {
//Decoration
- SKGObjectBase* obj = getObjectPointer(index);
- QString att = m_listAttibutes[index.column()];
+ SKGObjectBase* obj = getObjectPointer(iIndex);
+ QString att = m_listAttibutes[iIndex.column()];
if (obj->getTable().isEmpty()) {
//This is a group
- if (index.column() == 0) return \
qVariantFromValue(static_cast<QIcon>(KIcon("arrow-right")));; + if \
(iIndex.column() == 0) return \
qVariantFromValue(static_cast<QIcon>(KIcon("arrow-right")));; return "";
} else {
- if (index.column() == 0 && m_nodeTable) {
+ if (iIndex.column() == 0 && m_nodeTable) {
SKGNodeObject node(*obj);
return qVariantFromValue(node.getIcon());
- } else if (index.column() == 0 && m_doctransactionTable) {
+ } else if (iIndex.column() == 0 && m_doctransactionTable) {
return \
qVariantFromValue(static_cast<QIcon>(KIcon(obj->getAttribute("t_mode") == "U" ? \
"edit-undo" : "edit-redo"))); } else if (m_doctransactionTable && att == \
"t_savestep") {
if (obj->getAttribute("t_savestep") == "Y") return \
qVariantFromValue(static_cast<QIcon>(KIcon("document-save"))); @@ -629,7 +626,7 @@ \
QVariant SKGObjectModelBase::data(const QModelIndex& index, int role) const case \
Qt::ToolTipRole: { //Tooltip
QString toolTipString;
- SKGObjectBase* obj = getObjectPointer(index);
+ SKGObjectBase* obj = getObjectPointer(iIndex);
if (obj && m_document) {
if (m_doctransactionTable) {
@@ -643,8 +640,8 @@ QVariant SKGObjectModelBase::data(const QModelIndex& index, int \
role) const toolTipString += msg.at(i);
}
}
- } else if (getAttributeType(index.column()) == SKGServices::DATE) {
- QString att = m_listAttibutes[index.column()];
+ } else if (getAttributeType(iIndex.column()) == SKGServices::DATE) {
+ QString att = m_listAttibutes[iIndex.column()];
QString val = obj->getAttribute(att);
QDate dval = SKGServices::stringToTime(val).date();
@@ -671,7 +668,7 @@ QVariant SKGObjectModelBase::data(const QModelIndex& index, int \
role) const return toolTipString;
}
case 99: {
- SKGObjectBase* obj = getObjectPointer(index);
+ SKGObjectBase* obj = getObjectPointer(iIndex);
if (obj) return \
SKGServices::stringToDouble(obj->getAttribute("f_sortorder"));
break;
@@ -683,53 +680,53 @@ QVariant SKGObjectModelBase::data(const QModelIndex& index, int \
role) const return QVariant();
}
-Qt::ItemFlags SKGObjectModelBase::flags(const QModelIndex& index) const
+Qt::ItemFlags SKGObjectModelBase::flags(const QModelIndex& iIndex) const
{
_SKGTRACEIN(10, "SKGObjectModelBase::flags");
- Qt::ItemFlags flags = QAbstractItemModel::flags(index) | Qt::ItemIsDropEnabled;
+ Qt::ItemFlags f = QAbstractItemModel::flags(iIndex) | Qt::ItemIsDropEnabled;
- if (index.isValid()) flags |= Qt::ItemIsUserCheckable;
+ if (iIndex.isValid()) f |= Qt::ItemIsUserCheckable;
- if (m_nodeTable && index.isValid()) flags |= Qt::ItemIsEditable | \
Qt::ItemIsDragEnabled; + if (m_nodeTable && iIndex.isValid()) f |= \
Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
- if (index.isValid()) {
- QString att = m_listAttibutes[index.column()];
- if (att.toLower() == att || !getDocument()->getRealAttribute(att).isEmpty()) \
flags |= Qt::ItemIsEditable;
- SKGObjectBase* obj = getObjectPointer(index);
- if (obj->getTable().isEmpty()) flags = Qt::ItemIsEnabled;
+ if (iIndex.isValid()) {
+ QString att = m_listAttibutes[iIndex.column()];
+ if (att.toLower() == att || !getDocument()->getRealAttribute(att).isEmpty()) \
f |= Qt::ItemIsEditable; + SKGObjectBase* obj = getObjectPointer(iIndex);
+ if (obj->getTable().isEmpty()) f = Qt::ItemIsEnabled;
}
- return flags;
+ return f;
}
-bool SKGObjectModelBase::setData(const QModelIndex& index, const QVariant& value, \
int role) +bool SKGObjectModelBase::setData(const QModelIndex& iIndex, const \
QVariant& iValue, int iRole) {
- if (!index.isValid()) return false;
+ if (!iIndex.isValid()) return false;
- if (role == Qt::EditRole) {
+ if (iRole == Qt::EditRole) {
SKGError err;
if (m_nodeTable) {
- SKGNodeObject obj(getObject(index));
- QString name = value.toString();
+ SKGNodeObject obj(getObject(iIndex));
+ QString name = iValue.toString();
SKGBEGINTRANSACTION(*getDocument(), i18nc("Noun, name of the user \
action", "Bookmark update '%1'", name), err); err = obj.setName(name);
IFOKDO(err, obj.save())
} else {
- SKGObjectBase obj(getObject(index));
+ SKGObjectBase obj(getObject(iIndex));
SKGBEGINTRANSACTION(*getDocument(), i18nc("Noun, name of the user \
action", "Update object"), err);
SKGObjectBase obj2(obj.getDocument(), obj.getRealTable(), obj.getID()); \
//To be sure this is not a complex object
- QString att = m_listAttibutes[index.column()];
- err = obj2.setAttribute(att, att.startsWith(QLatin1String("d_")) && \
value.canConvert<QDateTime>() ? SKGServices::dateToSqlString(value.toDateTime()) : \
value.toString()); + QString att = m_listAttibutes[iIndex.column()];
+ err = obj2.setAttribute(att, att.startsWith(QLatin1String("d_")) && \
iValue.canConvert<QDateTime>() ? SKGServices::dateToSqlString(iValue.toDateTime()) : \
iValue.toString()); IFOKDO(err, obj2.save())
}
SKGMainPanel::displayErrorMessage(err);
return !err;
}
- return QAbstractItemModel::setData(index, value, role);
+ return QAbstractItemModel::setData(iIndex, iValue, iRole);
}
Qt::DropActions SKGObjectModelBase::supportedDragActions() const
@@ -751,41 +748,41 @@ QStringList SKGObjectModelBase::mimeTypes() const
return types;
}
-QMimeData* SKGObjectModelBase::mimeData(const QModelIndexList& indexes) const
+QMimeData* SKGObjectModelBase::mimeData(const QModelIndexList& iIndexes) const
{
- QMimeData* mimeData = new QMimeData();
+ QMimeData* md = new QMimeData();
QByteArray encodedData;
QDataStream stream(&encodedData, QIODevice::WriteOnly);
QString t = getTable();
- foreach(const QModelIndex & index, indexes) {
- if (index.isValid() && index.column() == 0) {
- SKGObjectBase obj = getObject(index);
+ foreach(const QModelIndex & idx, iIndexes) {
+ if (idx.isValid() && idx.column() == 0) {
+ SKGObjectBase obj = getObject(idx);
t = obj.getRealTable();
stream << t;
stream << obj.getID();
}
}
- mimeData->setData("application/skg." % t % ".ids", encodedData);
- return mimeData;
+ md->setData("application/skg." % t % ".ids", encodedData);
+ return md;
}
-bool SKGObjectModelBase::dropMimeData(const QMimeData* data,
- Qt::DropAction action,
- int row, int column,
+bool SKGObjectModelBase::dropMimeData(const QMimeData* iData,
+ Qt::DropAction iAction,
+ int iRow, int iColumn,
const QModelIndex& iParent)
{
- Q_UNUSED(row);
- if (action == Qt::IgnoreAction) return true;
- if (!data || !(data->hasFormat("application/skg.node.ids") || data->hasUrls())) \
return false; //TODO: accept all
- if (column > 0) return false;
+ Q_UNUSED(iRow);
+ if (iAction == Qt::IgnoreAction) return true;
+ if (!iData || !(iData->hasFormat("application/skg.node.ids") || \
iData->hasUrls())) return false; //TODO: accept all + if (iColumn > 0) return \
false;
SKGError err;
//Drop files
- if (data->hasUrls() && iParent.isValid() && getRealTable() != "node") {
- QList<QUrl> urls = data->urls();
+ if (iData->hasUrls() && iParent.isValid() && getRealTable() != "node") {
+ QList<QUrl> urls = iData->urls();
int nb = urls.count();
{
SKGObjectBase obj(getObject(iParent));
@@ -793,19 +790,19 @@ bool SKGObjectModelBase::dropMimeData(const QMimeData* data,
SKGBEGINPROGRESSTRANSACTION(*getDocument(), i18nc("Noun, name of the \
user action", "Property creation"), err, nb); for (int i = 0; !err && i < nb; ++i) {
QString name = i18n("File");
- int index = 1;
+ int idx = 1;
while (!err && !obj.getProperty(name).isEmpty()) {
- index++;
- name = i18n("File") % " (" % SKGServices::intToString(index) % \
')'; + idx++;
+ name = i18n("File") % " (" % SKGServices::intToString(idx) % \
')'; }
- err = obj.setProperty(name, urls.at(i).toLocalFile(), action == \
Qt::LinkAction ? "" : urls.at(i).toLocalFile()); + err = \
obj.setProperty(name, urls.at(i).toLocalFile(), iAction == Qt::LinkAction ? "" : \
urls.at(i).toLocalFile()); IFOKDO(err, getDocument()->stepForward(i + 1))
}
}
}
//Drop nodes
- else if (data->hasFormat("application/skg.node.ids")) {
- QByteArray encodedData = data->data("application/skg.node.ids");
+ else if (iData->hasFormat("application/skg.node.ids")) {
+ QByteArray encodedData = iData->data("application/skg.node.ids");
QDataStream stream(&encodedData, QIODevice::ReadOnly);
QStringList newItems;
@@ -824,15 +821,15 @@ bool SKGObjectModelBase::dropMimeData(const QMimeData* data,
double min = 0;
double max = 0;
- if (row >= 1) {
- QModelIndex previousIndex = SKGObjectModelBase::index(row - 1, 0, \
parentIndex); + if (iRow >= 1) {
+ QModelIndex previousIndex = SKGObjectModelBase::index(iRow - 1, 0, \
parentIndex); SKGNodeObject previousObject(getObject(previousIndex));
min = previousObject.getOrder();
}
- if (row >= rowCount(parentIndex)) max = min + 1;
+ if (iRow >= rowCount(parentIndex)) max = min + 1;
else {
- QModelIndex nextIndex = SKGObjectModelBase::index(row, 0, \
parentIndex); + QModelIndex nextIndex = \
SKGObjectModelBase::index(iRow, 0, parentIndex); SKGNodeObject \
nextObject(getObject(nextIndex)); max = nextObject.getOrder();
}
diff --git a/skgbasemodeler/CMakeLists.txt b/skgbasemodeler/CMakeLists.txt
index 38d53cd..0951c4f 100644
--- a/skgbasemodeler/CMakeLists.txt
+++ b/skgbasemodeler/CMakeLists.txt
@@ -21,7 +21,7 @@ PROJECT(SKGBASEMODELER)
LINK_DIRECTORIES (${LIBRARY_OUTPUT_PATH})
FIND_PACKAGE(QCA2 2.0.0 REQUIRED)
-FIND_PACKAGE(QJSON 0.8.0 REQUIRED)
+FIND_PACKAGE(QJSON 0.7.1 REQUIRED)
FIND_PACKAGE(Sqlite 3.7.0 REQUIRED)
INCLUDE_DIRECTORIES( ${PROJECT_BINARY_DIR} ${KDE4_INCLUDES} ${QT_INCLUDES} \
${QCA2_INCLUDE_DIR} ${QT_QTSQL_INCLUDE_DIR} ${Grantlee_INCLUDE_DIRS} \
${SQLITE_INCLUDE_DIR} ${QJSON_INCLUDE_DIR})
diff --git a/tests/skgbankmodelertest/skgtestbankandaccount.cpp \
b/tests/skgbankmodelertest/skgtestbankandaccount.cpp index 03fcf2e..8c075f4 100644
--- a/tests/skgbankmodelertest/skgtestbankandaccount.cpp
+++ b/tests/skgbankmodelertest/skgtestbankandaccount.cpp
@@ -203,15 +203,15 @@ int main(int argc, char** argv)
SKGInterestObject oInterest;
SKGTESTERROR("ACCOUNT:getInterests", \
account2.getInterest(QDate::currentDate(), oInterest), false);
-
+
SKGObjectBase account4(&document1, "account", account1.getID());
SKGTESTERROR("ACCOUNT:load", account4.load(), true);
SKGTESTERROR("ACCOUNT:setAttribute", account4.setAttribute("t_BANK", \
"bankname"), true);
- SKGTESTERROR("ACCOUNT:save", account4.save(), true);
+ SKGTESTERROR("ACCOUNT:save", account4.save(), true);
SKGTESTERROR("BANK:load", bank1.load(), true);
SKGTEST("BANK:getName", bank1.getName(), "bankname");
-
- SKGTESTERROR("DOC:dump", document1.dump(DUMPACCOUNT), true);
+
+ SKGTESTERROR("DOC:dump", document1.dump(DUMPACCOUNT), true);
}
}
diff --git a/tests/skgbankmodelertest/skgtestdocparameter.cpp \
b/tests/skgbankmodelertest/skgtestdocparameter.cpp index 8240565..1a2d22c 100644
--- a/tests/skgbankmodelertest/skgtestdocparameter.cpp
+++ b/tests/skgbankmodelertest/skgtestdocparameter.cpp
@@ -70,8 +70,8 @@ int main(int argc, char** argv)
SKGTEST("PROP:getParameter", document1.getParameter("ATT1"), "VAL1");
SKGTEST("PROP:getProperty", obj1.getProperty("ATT1"), "VAL2");
SKGTEST("PROP:getProperty", obj1.getPropertyBlob("ATT1").toInt(), 145);
-
-
+
+
QStringList oResult;
SKGTESTERROR("PROP:getDistinctValues", \
document1.getDistinctValues("parameters", "t_value", "t_value like 'VAL%'", oResult), \
true); SKGTEST("PROP:oResult.size", oResult.size(), 2);
@@ -80,9 +80,9 @@ int main(int argc, char** argv)
SKGTESTERROR("PROP:Replace", obj1.remove(), true);
SKGTESTERROR("PROP:getDistinctValues", \
document1.getDistinctValues("parameters", "t_value", "t_value like 'VAL%'", oResult), \
true); SKGTEST("PROP:oResult.size", oResult.size(), 1);
-
- SKGTESTERROR("PROP:setProperty", obj1.setProperty("ATT4", "VAL4", \
SKGTest::getTestPath("IN") % "/dates.txt"), true);
- SKGTESTERROR("PROP:setProperty", obj1.setProperty("ATT5", "VAL5", \
SKGTest::getTestPath("IN")), true); +
+ SKGTESTERROR("PROP:setProperty", obj1.setProperty("ATT4", "VAL4", \
SKGTest::getTestPath("IN") % "/dates.txt"), true); + \
SKGTESTERROR("PROP:setProperty", obj1.setProperty("ATT5", "VAL5", \
SKGTest::getTestPath("IN")), true); }
{
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic