Git commit 26661fe1935e25e6071689e6de20fbee502bf9e4 by Stephane Mankowski.
Committed on 31/05/2017 at 19:56.
Pushed by smankowski into branch 'master'.
Regular expressions for CSV import are now translatable
M +1 -0 CHANGELOG
M +18 -18 plugins/import/skrooge_import_csv/skgimportplugincsv.cpp
M +17 -16 plugins/skrooge/skrooge_importexport/skgimportexport_setting=
s.kcfg
M +27 -0 skgbankmodeler/skgimportexportmanager.cpp
M +6 -0 skgbankmodeler/skgimportexportmanager.h
https://commits.kde.org/skrooge/26661fe1935e25e6071689e6de20fbee502bf9e4
diff --git a/CHANGELOG b/CHANGELOG
index bbc0005d..833ec137 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@ skrooge (2.9.0)
*Correction: Replacement of missing icons
*Correction: Auto apply on advice duplicates remaining advice
*Correction: The "duplicate" function creates operation with invalid cre=
ation date
+ *Correction: Regular expressions for CSV import are now translatable =
*New feature: Skrooge is now able to export only the selected accounts o=
r operations
*Performances: Avoid advice computation in dashboard when the dashboard =
is not the current page =
=
diff --git a/plugins/import/skrooge_import_csv/skgimportplugincsv.cpp b/plu=
gins/import/skrooge_import_csv/skgimportplugincsv.cpp
index ecabc312..afd7f192 100644
--- a/plugins/import/skrooge_import_csv/skgimportplugincsv.cpp
+++ b/plugins/import/skrooge_import_csv/skgimportplugincsv.cpp
@@ -46,22 +46,22 @@ SKGImportPluginCsv::SKGImportPluginCsv(QObject* iImport=
er, const QVariantList& i
SKGTRACEINFUNC(10);
Q_UNUSED(iArg);
=
- m_importParameters[QStringLiteral("mapping_date")] =3D QStringLiteral(=
"^date");
- m_importParameters[QStringLiteral("mapping_account")] =3D QStringLiter=
al("^account");
- m_importParameters[QStringLiteral("mapping_number")] =3D QStringLitera=
l("^number|^num?ro");
- m_importParameters[QStringLiteral("mapping_mode")] =3D QStringLiteral(=
"^mode|^type");
- m_importParameters[QStringLiteral("mapping_payee")] =3D QStringLiteral=
("^payee|^tiers");
- m_importParameters[QStringLiteral("mapping_comment")] =3D QStringLiter=
al("^comment|^libell?|^d?tail|^info");
- m_importParameters[QStringLiteral("mapping_status")] =3D QStringLitera=
l("^status|^pointage");
- m_importParameters[QStringLiteral("mapping_bookmarked")] =3D QStringLi=
teral("^bookmarked");
- m_importParameters[QStringLiteral("mapping_category")] =3D QStringLite=
ral("^cat\\w*gor\\w*");
- m_importParameters[QStringLiteral("mapping_amount")] =3D QStringLitera=
l("^value|^amount|^valeur|^montant|^credit|^debit");
- m_importParameters[QStringLiteral("mapping_quantity")] =3D QStringLite=
ral("^quantity");
- m_importParameters[QStringLiteral("mapping_unit")] =3D QStringLiteral(=
"^unit");
- m_importParameters[QStringLiteral("mapping_sign")] =3D QStringLiteral(=
"^sign|^sens");
- m_importParameters[QStringLiteral("mapping_debit")] =3D QStringLiteral=
("^-|^debit|^withdrawal");
- m_importParameters[QStringLiteral("mapping_idgroup")] =3D QStringLiter=
al("^idgroup");
- m_importParameters[QStringLiteral("mapping_idtransaction")] =3D QStrin=
gLiteral("^idtransaction");
+ m_importParameters[QStringLiteral("mapping_date")] =3D i18nc("This is =
a regular expression to find the column in a csv file. You should keep the =
^ and translate the word", "^date");
+ m_importParameters[QStringLiteral("mapping_account")] =3D i18nc("This =
is a regular expression to find the column in a csv file. You should keep t=
he ^ and translate the word", "^account");
+ m_importParameters[QStringLiteral("mapping_number")] =3D i18nc("This i=
s a regular expression to find the column in a csv file. You should keep th=
e ^ and | and translate the words", "^number|^num?ro");
+ m_importParameters[QStringLiteral("mapping_mode")] =3D i18nc("This is =
a regular expression to find the column in a csv file. You should keep the =
^ and | and translate the words", "^mode|^type");
+ m_importParameters[QStringLiteral("mapping_payee")] =3D i18nc("This is=
a regular expression to find the column in a csv file. You should keep the=
^ and | and translate the words", "^payee|^tiers");
+ m_importParameters[QStringLiteral("mapping_comment")] =3D i18nc("This =
is a regular expression to find the column in a csv file. You should keep t=
he ^ and | and translate the words", "^comment|^libell?|^d?tail|^info");
+ m_importParameters[QStringLiteral("mapping_status")] =3D i18nc("This i=
s a regular expression to find the column in a csv file. You should keep th=
e ^ and | and translate the words", "^status|^pointage");
+ m_importParameters[QStringLiteral("mapping_bookmarked")] =3D i18nc("Th=
is is a regular expression to find the column in a csv file. You should kee=
p the ^ and translate the word", "^bookmarked");
+ m_importParameters[QStringLiteral("mapping_category")] =3D i18nc("This=
is a regular expression to find the column in a csv file. You should keep =
the ^ and translate the word", "^cat\\w*gor\\w*");
+ m_importParameters[QStringLiteral("mapping_amount")] =3D i18nc("This i=
s a regular expression to find the column in a csv file. You should keep th=
e ^ and | and translate the words", "^value|^amount|^valeur|^montant|^credi=
t|^debit");
+ m_importParameters[QStringLiteral("mapping_quantity")] =3D i18nc("This=
is a regular expression to find the column in a csv file. You should keep =
the ^ and translate the word", "^quantity");
+ m_importParameters[QStringLiteral("mapping_unit")] =3D i18nc("This is =
a regular expression to find the column in a csv file. You should keep the =
^ and translate the word", "^unit");
+ m_importParameters[QStringLiteral("mapping_sign")] =3D i18nc("This is =
a regular expression to find the column in a csv file. You should keep the =
^ and | and translate the words", "^sign|^sens");
+ m_importParameters[QStringLiteral("mapping_debit")] =3D i18nc("This is=
a regular expression to find the column in a csv file. You should keep the=
^ and | and translate the words", "^-|^debit|^withdrawal");
+ m_importParameters[QStringLiteral("mapping_idgroup")] =3D i18nc("This =
is a regular expression to find the column in a csv file. You should keep t=
he ^ and translate the word", "^idgroup");
+ m_importParameters[QStringLiteral("mapping_idtransaction")] =3D i18nc(=
"This is a regular expression to find the column in a csv file. You should =
keep the ^ and translate the word", "^idtransaction");
m_importParameters[QStringLiteral("mapping_property")] =3D QStringLite=
ral("");
=
m_importParameters[QStringLiteral("automatic_search_header")] =3D 'Y';
@@ -204,11 +204,11 @@ SKGError SKGImportPluginCsv::setCSVMapping(const QStr=
ingList* iCSVMapping)
// Check if mandatory attributes have been found
if (m_importParameters.value(QStringLiteral("mode_csv_rule")) =3D=
=3D QStringLiteral("Y")) {
if (!m_csvMapping.contains(QStringLiteral("payee")) || !m_csvM=
apping.contains(QStringLiteral("category"))) {
- err =3D SKGError(ERR_FAIL, i18nc("Error message", "Column=
s payee and category not found. Set import parameters in settings."));
+ err =3D SKGError(ERR_FAIL, i18nc("Error message", "Column=
s payee and category not found. Set import parameters in settings (Configur=
e Skrooge... / Import/Export / CSV / Edit regular expressions...)."));
}
} else {
if (!m_csvMapping.contains(QStringLiteral("date")) || !m_csvMa=
pping.contains(QStringLiteral("amount"))) {
- err =3D SKGError(ERR_FAIL, i18nc("Error message", "Column=
s date and amount not found. Set import parameters in settings."));
+ err =3D SKGError(ERR_FAIL, i18nc("Error message", "Column=
s date and amount not found. Set import parameters in settings (Configure S=
krooge... / Import/Export / CSV / Edit regular expressions...)."));
}
}
}
diff --git a/plugins/skrooge/skrooge_importexport/skgimportexport_settings.=
kcfg b/plugins/skrooge/skrooge_importexport/skgimportexport_settings.kcfg
index 8914fd18..54d80074 100644
--- a/plugins/skrooge/skrooge_importexport/skgimportexport_settings.kcfg
+++ b/plugins/skrooge/skrooge_importexport/skgimportexport_settings.kcfg
@@ -3,6 +3,7 @@
xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=3D"http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ skgimportexportmanager.h
@@ -39,67 +40,67 @@
- ^date
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_date")
- ^number|^num?ro
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_number")
- ^mode|^type
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_mode")
- ^payee|^tiers
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_payee")
- ^comment|^libell?|^d?tail|^info
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_comment")
- ^status|^pointage
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_status")
- ^bookmarked
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_bookmarked")
- ^account
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_account")
- ^cat\w*gor\w*
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_category")
- ^value|^amount|^valeur|^montant|^credit|^debit
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_amount")
- ^quantity
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_quantity")
- ^sign|^sens
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_sign")
- ^-|^debit|^withdrawal
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_debit") =
- ^unit
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_unit")
- ^idtransaction
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_idtransaction")
- ^idgroup
+ SKGImportExportManager::getParameterDefaultV=
alue("mapping_idgroup")
diff --git a/skgbankmodeler/skgimportexportmanager.cpp b/skgbankmodeler/skg=
importexportmanager.cpp
index a16faf88..4d36e06b 100644
--- a/skgbankmodeler/skgimportexportmanager.cpp
+++ b/skgbankmodeler/skgimportexportmanager.cpp
@@ -396,6 +396,33 @@ void SKGImportExportManager::setImportParameters(const=
QMap< QString, QString >&
}
}
=
+QString SKGImportExportManager::getParameterDefaultValue(const QString& iP=
arameter)
+{
+ // Search the first plugin having a value for this parameter
+ KService::List offers =3D KServiceTypeTrader::self()->query(QStringLit=
eral("SKG IMPORT/Plugin"));
+ int nb =3D offers.count();
+ for (int i =3D 0; i < nb; ++i) {
+ KService::Ptr service =3D offers.at(i);
+ QString id =3D service->property(QStringLiteral("X-Krunner-ID"), Q=
Variant::String).toString();
+ KPluginLoader loader(service->library());
+ KPluginFactory* factory =3D loader.factory();
+ if (factory) {
+ SKGImportPlugin* pluginInterface =3D factory->create (nullptr);
+ if (pluginInterface) {
+ auto val =3D pluginInterface->getImportParameters().value(=
iParameter);
+ if (!val.isEmpty()) {
+ return val;
+ }
+ val =3D pluginInterface->getExportParameters().value(iPara=
meter);
+ if (!val.isEmpty()) {
+ return val;
+ }
+ }
+ }
+ }
+ return "";
+}
+
QMap< QString, QString > SKGImportExportManager::getImportParameters()
{
QMap< QString, QString > output;
diff --git a/skgbankmodeler/skgimportexportmanager.h b/skgbankmodeler/skgim=
portexportmanager.h
index 18f3a9d4..807625a2 100644
--- a/skgbankmodeler/skgimportexportmanager.h
+++ b/skgbankmodeler/skgimportexportmanager.h
@@ -151,6 +151,12 @@ public:
virtual void setImportParameters(const QMap& iParame=
ters);
=
/**
+ * Get the default value of a parameter
+ * @param iParameter the parameter
+ */
+ static QString getParameterDefaultValue(const QString& iParameter);
+
+ /**
* Get the mime type filter for import
* @param iIncludingAll to include the "All supported format"
* @return the mime type filter