[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [skrooge] /: Rework of SKGSimplePeriodEdit
From: Stephane Mankowski <stephane () mankowski ! fr>
Date: 2015-12-28 19:55:34
Message-ID: E1aDdtG-00062K-D1 () scm ! kde ! org
[Download RAW message or body]
Git commit 4818411770aea09870d31dcf8f77eb1241282d99 by Stephane Mankowski.
Committed on 28/12/2015 at 19:55.
Pushed by smankowski into branch 'master'.
Rework of SKGSimplePeriodEdit
M +2 -2 plugins/skrooge/skrooge_bank/skgbankplugin.cpp
M +3 -3 plugins/skrooge/skrooge_categories/skgcategoriesplugin.cpp
M +1 -1 plugins/skrooge/skrooge_report/skgreportplugin.cpp
M +5 -6 skgbasegui/skghtmlboardwidget.cpp
M +2 -10 skgbasegui/skghtmlboardwidget.h
M +11 -12 skgbasegui/skgsimpleperiodedit.cpp
M +22 -9 skgbasegui/skgsimpleperiodedit.h
http://commits.kde.org/skrooge/4818411770aea09870d31dcf8f77eb1241282d99
diff --git a/plugins/skrooge/skrooge_bank/skgbankplugin.cpp \
b/plugins/skrooge/skrooge_bank/skgbankplugin.cpp index 7da1adc..e6a46f1 100644
--- a/plugins/skrooge/skrooge_bank/skgbankplugin.cpp
+++ b/plugins/skrooge/skrooge_bank/skgbankplugin.cpp
@@ -102,7 +102,7 @@ SKGBoardWidget* SKGBankPlugin::getDashboardWidget(int iIndex)
} else if (iIndex == 1) return new SKGHtmlBoardWidget(m_currentBankDocument,
getDashboardWidgetTitle(iIndex),
\
QStandardPaths::locate(QStandardPaths::GenericDataLocation, \
QStringLiteral("skrooge/html/default/account_table.html")),
- QStringList() << \
QStringLiteral("v_account_display"), SKGHtmlBoardWidget::PERIOD_ALL); + \
QStringList() << QStringLiteral("v_account_display"), \
SKGSimplePeriodEdit::ALL_PERIODS); else if (iIndex == 2) {
auto w = new SKGHtmlBoardWidget(m_currentBankDocument,
getDashboardWidgetTitle(iIndex),
@@ -125,7 +125,7 @@ SKGBoardWidget* SKGBankPlugin::getDashboardWidget(int iIndex)
return new SKGHtmlBoardWidget(m_currentBankDocument,
getDashboardWidgetTitle(iIndex),
\
QStandardPaths::locate(QStandardPaths::GenericDataLocation, \
QStringLiteral("skrooge/html/default/bank_table.html")),
- QStringList() << \
QStringLiteral("v_account_display"), SKGHtmlBoardWidget::PERIOD_ALL); + \
QStringList() << QStringLiteral("v_account_display"), \
SKGSimplePeriodEdit::ALL_PERIODS); }
SKGTabPage* SKGBankPlugin::getWidget()
diff --git a/plugins/skrooge/skrooge_categories/skgcategoriesplugin.cpp \
b/plugins/skrooge/skrooge_categories/skgcategoriesplugin.cpp index a44aaad..90912da \
100644
--- a/plugins/skrooge/skrooge_categories/skgcategoriesplugin.cpp
+++ b/plugins/skrooge/skrooge_categories/skgcategoriesplugin.cpp
@@ -150,17 +150,17 @@ SKGBoardWidget* SKGCategoriesPlugin::getDashboardWidget(int \
iIndex) return new SKGHtmlBoardWidget(m_currentBankDocument,
getDashboardWidgetTitle(iIndex),
\
QStandardPaths::locate(QStandardPaths::GenericDataLocation, \
QStringLiteral("skrooge/html/default/categories_period_table.html")),
- QStringList() << \
QStringLiteral("v_suboperation_consolidated"), SKGHtmlBoardWidget::PERIOD_ALL); + \
QStringList() << QStringLiteral("v_suboperation_consolidated"), \
SKGSimplePeriodEdit::ALL_PERIODS); } else if (iIndex == 1) {
return new SKGHtmlBoardWidget(m_currentBankDocument,
getDashboardWidgetTitle(iIndex),
\
QStandardPaths::locate(QStandardPaths::GenericDataLocation, \
QStringLiteral("skrooge/html/default/categories_variations.html")),
- QStringList() << \
QStringLiteral("v_suboperation_consolidated"), SKGHtmlBoardWidget::PERIOD_ALL); + \
QStringList() << QStringLiteral("v_suboperation_consolidated"), \
SKGSimplePeriodEdit::ALL_PERIODS); }
return new SKGHtmlBoardWidget(m_currentBankDocument,
getDashboardWidgetTitle(iIndex),
\
QStandardPaths::locate(QStandardPaths::GenericDataLocation, \
QStringLiteral("skrooge/html/default/budget_table.html")),
- QStringList() << QStringLiteral("v_budget"), \
SKGHtmlBoardWidget::PERIOD_ONLY_MONTHS); + \
QStringList() << QStringLiteral("v_budget"), \
SKGSimplePeriodEdit::PREVIOUS_AND_CURRENT_MONTHS); }
void SKGCategoriesPlugin::refresh()
diff --git a/plugins/skrooge/skrooge_report/skgreportplugin.cpp \
b/plugins/skrooge/skrooge_report/skgreportplugin.cpp index d534a3e..941f315 100644
--- a/plugins/skrooge/skrooge_report/skgreportplugin.cpp
+++ b/plugins/skrooge/skrooge_report/skgreportplugin.cpp
@@ -133,7 +133,7 @@ SKGBoardWidget* SKGReportPlugin::getDashboardWidget(int iIndex)
return new SKGHtmlBoardWidget(m_currentBankDocument,
getDashboardWidgetTitle(iIndex),
\
QStandardPaths::locate(QStandardPaths::GenericDataLocation, \
QStringLiteral("skrooge/html/default/personal_finance_score.html")),
- QStringList() << \
QStringLiteral("v_suboperation_consolidated"), SKGHtmlBoardWidget::PERIOD_ALL); + \
QStringList() << QStringLiteral("v_suboperation_consolidated"), \
SKGSimplePeriodEdit::PREVIOUS_AND_CURRENT_PERIODS); }
SKGTabPage* SKGReportPlugin::getWidget()
diff --git a/skgbasegui/skghtmlboardwidget.cpp b/skgbasegui/skghtmlboardwidget.cpp
index a085e43..eee5531 100644
--- a/skgbasegui/skghtmlboardwidget.cpp
+++ b/skgbasegui/skghtmlboardwidget.cpp
@@ -33,13 +33,12 @@
#include "skgtraces.h"
#include "skgreport.h"
#include "skgmainpanel.h"
-#include "skgsimpleperiodedit.h"
-SKGHtmlBoardWidget::SKGHtmlBoardWidget(SKGDocument* iDocument, const QString& \
iTitle, const QString& iTemplate, const QStringList& iTablesRefreshing, \
AdditionalOption iOptions) +SKGHtmlBoardWidget::SKGHtmlBoardWidget(SKGDocument* \
iDocument, const QString& iTitle, const QString& iTemplate, const QStringList& \
iTablesRefreshing, SKGSimplePeriodEdit::Modes iOptions) : SKGBoardWidget(iDocument, \
iTitle), m_Text(nullptr), m_Quick(nullptr), m_Template(iTemplate), \
m_TablesRefreshing(iTablesRefreshing), m_refreshNeeded(false), m_period(nullptr) {
SKGTRACEINFUNC(10);
- if(QFileInfo(iTemplate).suffix().toLower() == QStringLiteral("qml")) {
+ if (QFileInfo(iTemplate).suffix().toLower() == QStringLiteral("qml")) {
m_Quick = new QQuickWidget();
m_Quick->setObjectName(QStringLiteral("m_Quick"));
m_Quick->setSource(QUrl::fromLocalFile(m_Template));
@@ -59,11 +58,11 @@ SKGHtmlBoardWidget::SKGHtmlBoardWidget(SKGDocument* iDocument, \
const QString& iT }
// Create menu
- if (iOptions == PERIOD_ONLY_MONTHS || iOptions == PERIOD_ALL) {
+ if (iOptions) {
setContextMenuPolicy(Qt::ActionsContextMenu);
m_period = new SKGSimplePeriodEdit(this);
- m_period->setMode(iOptions == PERIOD_ONLY_MONTHS ? \
SKGSimplePeriodEdit::PREVIOUS_AND_CURRENT_MONTHS : \
SKGSimplePeriodEdit::PREVIOUS_AND_CURRENT_PERIODS); + \
m_period->setMode(iOptions);
QDate date = QDate::currentDate();
QStringList list;
@@ -172,7 +171,7 @@ void SKGHtmlBoardWidget::dataModified(const QString& iTableName, \
int iIdTransact
SKGError err = SKGReport::getReportFromTemplate(report, m_Template, \
stream); IFKO(err) stream = err.getFullMessage();
stream = stream.remove(QRegExp(QStringLiteral("<img[^>]*/>")));
- if(m_Text != nullptr) {
+ if (m_Text != nullptr) {
m_Text->setText(stream);
}
diff --git a/skgbasegui/skghtmlboardwidget.h b/skgbasegui/skghtmlboardwidget.h
index 9820bf2..36e924e 100644
--- a/skgbasegui/skghtmlboardwidget.h
+++ b/skgbasegui/skghtmlboardwidget.h
@@ -23,11 +23,11 @@
* @author Stephane MANKOWSKI / Guillaume DE BURE
*/
#include "skgboardwidget.h"
+#include "skgsimpleperiodedit.h"
#include "skgbasegui_export.h"
class QLabel;
class QQuickWidget;
-class SKGSimplePeriodEdit;
/**
* This file is a generic Skrooge plugin for html/qml reports
@@ -41,14 +41,6 @@ class SKGBASEGUI_EXPORT SKGHtmlBoardWidget : public SKGBoardWidget
Q_ENUMS(AdditionalOption)
public:
/**
- * This enumerate for additional options in menu
- */
- enum AdditionalOption {NONE, /**< No additional option */
- PERIOD_ONLY_MONTHS, /**< Add period selector with only \
months*/
- PERIOD_ALL /**< Add period selector with months, \
quarters, semesters and years*/
- };
-
- /**
* Default Constructor
* @param iDocument the document
* @param iTitle the title
@@ -56,7 +48,7 @@ public:
* @param iTablesRefreshing the list of table refreshing the report when the \
table is updated. (empty means all)
* @param iOptions to enable options in menu
*/
- explicit SKGHtmlBoardWidget(SKGDocument* iDocument, const QString& iTitle, const \
QString& iTemplate, const QStringList& iTablesRefreshing = QStringList(), \
AdditionalOption iOptions = SKGHtmlBoardWidget::NONE); + explicit \
SKGHtmlBoardWidget(SKGDocument* iDocument, const QString& iTitle, const QString& \
iTemplate, const QStringList& iTablesRefreshing = QStringList(), \
SKGSimplePeriodEdit::Modes iOptions = SKGSimplePeriodEdit::NONE);
/**
* Default Destructor
diff --git a/skgbasegui/skgsimpleperiodedit.cpp b/skgbasegui/skgsimpleperiodedit.cpp
index 2a37974..131fad8 100644
--- a/skgbasegui/skgsimpleperiodedit.cpp
+++ b/skgbasegui/skgsimpleperiodedit.cpp
@@ -39,11 +39,11 @@ void SKGSimplePeriodEdit::setFirstDate(const QDate iDate)
refreshList();
}
-SKGSimplePeriodEdit::Mode SKGSimplePeriodEdit::mode() const
+SKGSimplePeriodEdit::Modes SKGSimplePeriodEdit::mode() const
{
return m_Mode;
}
-void SKGSimplePeriodEdit::setMode(SKGSimplePeriodEdit::Mode iMode)
+void SKGSimplePeriodEdit::setMode(SKGSimplePeriodEdit::Modes iMode)
{
m_Mode = iMode;
refreshList();
@@ -80,23 +80,22 @@ void SKGSimplePeriodEdit::refreshList()
QString cquarter = SKGServices::dateToPeriod(c, QStringLiteral("Q"));
QString csemester = SKGServices::dateToPeriod(c, QStringLiteral("S"));
QString cyear = SKGServices::dateToPeriod(c, QStringLiteral("Y"));
- if (cmonth != smonth || (m_Mode == PREVIOUS_AND_CURRENT_MONTHS || m_Mode == \
PREVIOUS_AND_CURRENT_PERIODS)) { + if ((cmonth != smonth && m_Mode & \
PREVIOUS_MONTHS) || + (cmonth == smonth && m_Mode & CURRENT_MONTHS)) {
list.insert(0, cmonth);
}
-
- if ((c.month() % 3 == 0 && cquarter != squarter && (m_Mode == \
PREVIOUS_PERIODS || m_Mode == PREVIOUS_AND_CURRENT_PERIODS)) ||
- (cmonth == smonth && m_Mode == PREVIOUS_AND_CURRENT_PERIODS)) {
+ if (c.month() % 3 == 0 && ((cquarter != squarter && m_Mode & \
PREVIOUS_PERIODS) || + (cquarter == squarter && \
m_Mode & CURRENT_PERIOD))) { list.insert(0, cquarter);
}
- if ((c.month() % 6 == 0 && csemester != ssemester && (m_Mode == \
PREVIOUS_PERIODS || m_Mode == PREVIOUS_AND_CURRENT_PERIODS)) ||
- (cmonth == smonth && m_Mode == PREVIOUS_AND_CURRENT_PERIODS)) {
+ if (c.month() % 6 == 0 && ((csemester != ssemester && m_Mode & \
PREVIOUS_PERIODS) || + (csemester == ssemester && \
m_Mode & CURRENT_PERIOD))) { list.insert(0, csemester);
}
- if ((c.month() == 12 && cyear != syear && (m_Mode == PREVIOUS_PERIODS || \
m_Mode == PREVIOUS_AND_CURRENT_PERIODS)) ||
- (cmonth == smonth && m_Mode == PREVIOUS_AND_CURRENT_PERIODS)) {
+ if (c.month() == 12 && ((cyear != syear && m_Mode & PREVIOUS_PERIODS) ||
+ (cyear == syear && m_Mode & CURRENT_PERIOD))) {
list.insert(0, cyear);
}
-
if (cmonth == smonth || c >= today) {
break;
}
@@ -109,7 +108,7 @@ void SKGSimplePeriodEdit::refreshList()
clear();
// Add dynamic items
- if (list.contains(smonth) && m_Mode == PREVIOUS_AND_CURRENT_PERIODS) {
+ if (list.contains(smonth) && m_Mode & ALL) {
addItem(i18nc("A period including all dates", "All dates"), "ALL");
}
diff --git a/skgbasegui/skgsimpleperiodedit.h b/skgbasegui/skgsimpleperiodedit.h
index 0956345..b2d4dee 100644
--- a/skgbasegui/skgsimpleperiodedit.h
+++ b/skgbasegui/skgsimpleperiodedit.h
@@ -23,6 +23,7 @@
*/
#include <QDate>
+#include <qflags.h>
#include "skgcombobox.h"
#include "skgbasegui_export.h"
@@ -40,7 +41,7 @@ class SKGBASEGUI_EXPORT SKGSimplePeriodEdit : public SKGComboBox
/**
* Previous mode
*/
- Q_PROPERTY(Mode mode READ mode WRITE setMode)
+ Q_PROPERTY(Modes mode READ mode WRITE setMode)
/**
* Period
@@ -51,15 +52,25 @@ class SKGBASEGUI_EXPORT SKGSimplePeriodEdit : public SKGComboBox
* This enumerate for additional options in menu
*/
Q_ENUMS(Mode)
+
public:
/**
* This enumerate for mode
*/
- enum Mode {PREVIOUS_MONTHS, /**< Only previous months */
- PREVIOUS_PERIODS, /**< All previous periods including quarters, \
semesters and years*/
- PREVIOUS_AND_CURRENT_MONTHS, /**< Previous and current months*/
- PREVIOUS_AND_CURRENT_PERIODS /**< Previous and current periods \
including quarters, semesters and years*/
- };
+ enum Mode {
+ NONE = 0, /**< None */
+ PREVIOUS_MONTHS = 1, /**< Only previous \
months */ + PREVIOUS_PERIODS = 1 | 2, /**< All \
previous periods including quarters, semesters and years*/ + CURRENT_MONTHS = \
4, /**< Current month */ + CURRENT_PERIOD = \
4 | 8, /**< Current period including quarter, semester \
and year */ + ALL = 16, /**< The \
ALL period */ + PREVIOUS_AND_CURRENT_MONTHS = 1 | 4, /**< \
Previous and current months*/ + PREVIOUS_AND_CURRENT_PERIODS = 1 | 2 | 4 | 8, \
/**< Previous and current periods including quarters, semesters and years*/ + \
ALL_PERIODS = 1 | 2 | 4 | 8 | 16 /**< All periods*/ + };
+
+ Q_DECLARE_FLAGS(Modes, Mode)
+
/**
* Default Constructor
* @param iParent the parent
@@ -94,19 +105,21 @@ public:
* To know if the mode of widget (default: PREVIOUS_MONTHS)
* @return previous mode
*/
- virtual Mode mode() const;
+ virtual Modes mode() const;
/**
* Set the widget mode
* @param iMode the mode
*/
- virtual void setMode(Mode iMode);
+ virtual void setMode(Modes iMode);
private:
QDate m_FirstDate;
- Mode m_Mode;
+ Modes m_Mode;
void refreshList();
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(SKGSimplePeriodEdit::Modes)
+
#endif // SKGSIMPLEPERIODEDIT_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic