[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [skrooge] /: "Alarm" dashboard widget is now compliant with QML mode
From: Stephane Mankowski <stephane () mankowski ! fr>
Date: 2016-12-01 21:37:49
Message-ID: E1cCZ37-0002qf-Jj () code ! kde ! org
[Download RAW message or body]
Git commit 0df4efd0238c5995c635d11cd78730f5c746674f by Stephane Mankowski.
Committed on 01/12/2016 at 21:34.
Pushed by smankowski into branch 'master'.
"Alarm" dashboard widget is now compliant with QML mode
M +2 -1 CHANGELOG
M +0 -2 TODO
A +43 -0 plugins/skrooge/default/alarm.qml [License: GPL (v2+)]
M +11 -0 plugins/skrooge/skrooge_search/skgsearchplugin.cpp
M +36 -0 skgbankmodeler/skgreportbank.cpp
M +12 -0 skgbankmodeler/skgreportbank.h
https://commits.kde.org/skrooge/0df4efd0238c5995c635d11cd78730f5c746674f
diff --git a/CHANGELOG b/CHANGELOG
index b679041..f19cb04 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,7 +17,8 @@ skrooge (2.6.0)
*Correction: BitcoinCharts currency import order must be inverted because CSV file has been inverted
*Correction: Better display for "Income vs Expenditure" on QML dashboard
*New feature: Addition of "nocolor" to the "money" Grantlee filter
- *New feature: Remove .skg in backup file name if .skg is added in the prefix \
(https://forum.kde.org/viewtopic.php?f=210&t=136518&p=366065#p366065) + *New feature: Remove .skg in \
backup file name if .skg is added in the prefix \
(https://forum.kde.org/viewtopic.php?f=210&t=136518&p=366065#p366065) + *New feature: "Alarm" dashboard \
widget is now compliant with QML mode
-- Stephane MANKOWSKI <stephane@mankowski.fr> xxx
diff --git a/TODO b/TODO
index 0f991bc..1dc5745 100644
--- a/TODO
+++ b/TODO
@@ -92,6 +92,4 @@ Not Possible, otherwise every keypress on space (even in the edition panel) woul
152:P1: Description of SKGPeriodEdit is not correct "Courant mois"
-155:P1: Update the ALAM dashboard widget to be QML, with test displayed and compliant with monthy \
reports
-
156:P1: Update the ESTIMATED INTEREST dashboard widget to be QML and compliant with monthy reports
diff --git a/plugins/skrooge/default/alarm.qml b/plugins/skrooge/default/alarm.qml
new file mode 100644
index 0000000..8226e2f
--- /dev/null
+++ b/plugins/skrooge/default/alarm.qml
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/> *
+ ***************************************************************************/
+import QtQuick 2.0
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+
+RowLayout {
+ id: grid
+ property var m: report.alarms
+ spacing: 2
+
+ ColumnLayout {
+ id: column
+ spacing: 0
+ property var modelId: 6
+
+ // Set values
+ Repeater {
+ model: m
+ SKGValue {
+ horizontalAlignment: Text.AlignHCenter
+ value: modelData[1]
+ max: modelData[2]
+ backgroundColor: '#' + (value == null || value < 0.7 * max ? color_positivetext : value < 0.9 * max \
? color_neutraltext : color_negativetext) + text: modelData[0]
+ }
+ }
+ }
+}
diff --git a/plugins/skrooge/skrooge_search/skgsearchplugin.cpp \
b/plugins/skrooge/skrooge_search/skgsearchplugin.cpp index 99f28b2..092397b 100644
--- a/plugins/skrooge/skrooge_search/skgsearchplugin.cpp
+++ b/plugins/skrooge/skrooge_search/skgsearchplugin.cpp
@@ -38,6 +38,7 @@
#include "skgalarmboardwidget.h"
#include "skgdocumentbank.h"
#include "skgcategoryobject.h"
+#include "skghtmlboardwidget.h"
/**
* This plugin factory.
@@ -73,6 +74,16 @@ QString SKGSearchPlugin::getDashboardWidgetTitle(int iIndex)
SKGBoardWidget* SKGSearchPlugin::getDashboardWidget(int iIndex)
{
Q_UNUSED(iIndex);
+ // Get QML mode for dashboard
+ KConfigSkeleton* skl = SKGMainPanel::getMainPanel()->getPluginByName(QStringLiteral("Dashboard \
plugin"))->getPreferenceSkeleton(); + KConfigSkeletonItem* sklItem = \
skl->findItem(QStringLiteral("qmlmode")); + bool qml = sklItem->property().toBool();
+ if (qml) {
+ return new SKGHtmlBoardWidget(m_currentBankDocument,
+ getDashboardWidgetTitle(iIndex) ,
+ QStandardPaths::locate(QStandardPaths::GenericDataLocation, \
QStringLiteral("skrooge/html/default/alarm.qml")), + QStringList() \
<< QStringLiteral("operation") << QStringLiteral("rule")); + }
return new SKGAlarmBoardWidget(m_currentBankDocument);
}
diff --git a/skgbankmodeler/skgreportbank.cpp b/skgbankmodeler/skgreportbank.cpp
index 8a9952c..614c580 100644
--- a/skgbankmodeler/skgreportbank.cpp
+++ b/skgbankmodeler/skgreportbank.cpp
@@ -33,6 +33,7 @@
#include "skgunitobject.h"
#include "skgoperationobject.h"
#include "skgrecurrentoperationobject.h"
+#include "skgruleobject.h"
SKGReportBank::SKGReportBank(SKGDocument* iDocument) : SKGReport(iDocument)
{
@@ -45,6 +46,41 @@ SKGReportBank::~SKGReportBank()
SKGTRACEINFUNC(1);
}
+QVariantList SKGReportBank::getAlarms()
+{
+ QString cacheId = QStringLiteral("getAlarms");
+ QVariantList table = m_cache.value(cacheId).toList();
+ if (table.isEmpty()) {
+ SKGTRACEINFUNC(10);
+ SKGDocumentBank* doc = qobject_cast<SKGDocumentBank*>(m_document);
+ if (doc) {
+ SKGServices::SKGUnitInfo primary = doc->getPrimaryUnit();
+ SKGServices::SKGUnitInfo secondary = doc->getSecondaryUnit();
+
+ SKGObjectBase::SKGListSKGObjectBase rules;
+ SKGError err = doc->getObjects(QStringLiteral("v_rule"), "t_action_type='A' ORDER BY \
i_ORDER", rules); + int nb = rules.count();
+ if (nb) {
+ for (int i = 0; !err && i < nb; ++i) {
+ SKGRuleObject rule(rules.at(i));
+ SKGRuleObject::SKGAlarmInfo alarm = rule.getAlarmInfo();
+
+ QVariantList item;
+ item.push_back(alarm.Message.arg(doc->formatMoney(alarm.Amount, primary, false), \
doc->formatMoney(alarm.Limit, primary, false), doc->formatMoney(alarm.Amount - alarm.Limit, primary, \
false))); + item.push_back(alarm.Amount);
+ item.push_back(alarm.Limit);
+ item.push_back(alarm.Amount - alarm.Limit);
+ item.push_back(alarm.Raised);
+
+ table.push_back(item);
+ }
+ }
+ m_cache[cacheId] = table;
+ }
+ }
+ return table;
+}
+
QVariantList SKGReportBank::getBudgetTable()
{
QString cacheId = QStringLiteral("getBudgetTable");
diff --git a/skgbankmodeler/skgreportbank.h b/skgbankmodeler/skgreportbank.h
index d57f7f2..deaa41f 100644
--- a/skgbankmodeler/skgreportbank.h
+++ b/skgbankmodeler/skgreportbank.h
@@ -66,6 +66,12 @@ class SKGBANKMODELER_EXPORT SKGReportBank : public SKGReport
Q_PROPERTY(QVariantList bank_table READ getBankTable NOTIFY changed2)
/**
+ * The alarms
+ * WARNING: Notification is launched only when cleanCache or setPeriod are called. So do not forget \
to connect cleanCache with SKGDocument::transactionSuccessfullyEnded + */
+ Q_PROPERTY(QVariantList alarms READ getAlarms NOTIFY changed2)
+
+ /**
* The scheduled operations
* WARNING: Notification is launched only when cleanCache or setPeriod are called. So do not forget \
to connect cleanCache with SKGDocument::transactionSuccessfullyEnded
*/
@@ -251,6 +257,12 @@ public:
*/
Q_INVOKABLE virtual QVariantMap getPersonalFinanceScoreDetails(bool iTransfert = false, bool \
iTracker = true);
+ /**
+ * Get the alarms
+ * @return the alarms
+ */
+ Q_INVOKABLE virtual QVariantList getAlarms();
+
Q_SIGNALS:
/**
* Emmited when the report changed
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic