[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [skrooge] /: Regular expressions for CSV import are now translatable
From: Stephane Mankowski <null () kde ! org>
Date: 2017-05-31 19:57:14
Message-ID: E1dG9k2-00032E-0K () code ! kde ! org
[Download RAW message or body]
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_settings.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 creation date
+ *Correction: Regular expressions for CSV import are now translatable
*New feature: Skrooge is now able to export only the selected accounts or \
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/plugins/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* iImporter, const \
QVariantList& i SKGTRACEINFUNC(10);
Q_UNUSED(iArg);
- m_importParameters[QStringLiteral("mapping_date")] = QStringLiteral("^date");
- m_importParameters[QStringLiteral("mapping_account")] = \
QStringLiteral("^account");
- m_importParameters[QStringLiteral("mapping_number")] = \
QStringLiteral("^number|^num?ro");
- m_importParameters[QStringLiteral("mapping_mode")] = \
QStringLiteral("^mode|^type");
- m_importParameters[QStringLiteral("mapping_payee")] = \
QStringLiteral("^payee|^tiers");
- m_importParameters[QStringLiteral("mapping_comment")] = \
QStringLiteral("^comment|^libell?|^d?tail|^info");
- m_importParameters[QStringLiteral("mapping_status")] = \
QStringLiteral("^status|^pointage");
- m_importParameters[QStringLiteral("mapping_bookmarked")] = \
QStringLiteral("^bookmarked");
- m_importParameters[QStringLiteral("mapping_category")] = \
QStringLiteral("^cat\\w*gor\\w*");
- m_importParameters[QStringLiteral("mapping_amount")] = \
QStringLiteral("^value|^amount|^valeur|^montant|^credit|^debit");
- m_importParameters[QStringLiteral("mapping_quantity")] = \
QStringLiteral("^quantity");
- m_importParameters[QStringLiteral("mapping_unit")] = QStringLiteral("^unit");
- m_importParameters[QStringLiteral("mapping_sign")] = \
QStringLiteral("^sign|^sens");
- m_importParameters[QStringLiteral("mapping_debit")] = \
QStringLiteral("^-|^debit|^withdrawal");
- m_importParameters[QStringLiteral("mapping_idgroup")] = \
QStringLiteral("^idgroup");
- m_importParameters[QStringLiteral("mapping_idtransaction")] = \
QStringLiteral("^idtransaction"); + \
m_importParameters[QStringLiteral("mapping_date")] = 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")] = \
i18nc("This is a regular expression to find the column in a csv file. You should keep \
the ^ and translate the word", "^account"); + \
m_importParameters[QStringLiteral("mapping_number")] = i18nc("This is a regular \
expression to find the column in a csv file. You should keep the ^ and | and \
translate the words", "^number|^num?ro"); + \
m_importParameters[QStringLiteral("mapping_mode")] = 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")] = 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")] = i18nc("This is a regular \
expression to find the column in a csv file. You should keep the ^ and | and \
translate the words", "^comment|^libell?|^d?tail|^info"); + \
m_importParameters[QStringLiteral("mapping_status")] = i18nc("This is a regular \
expression to find the column in a csv file. You should keep the ^ and | and \
translate the words", "^status|^pointage"); + \
m_importParameters[QStringLiteral("mapping_bookmarked")] = i18nc("This is a regular \
expression to find the column in a csv file. You should keep the ^ and translate the \
word", "^bookmarked"); + m_importParameters[QStringLiteral("mapping_category")] = \
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")] = i18nc("This is a regular \
expression to find the column in a csv file. You should keep the ^ and | and \
translate the words", "^value|^amount|^valeur|^montant|^credit|^debit"); + \
m_importParameters[QStringLiteral("mapping_quantity")] = 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")] = \
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")] = 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")] = 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")] = i18nc("This is a regular \
expression to find the column in a csv file. You should keep the ^ and translate the \
word", "^idgroup"); + m_importParameters[QStringLiteral("mapping_idtransaction")] \
= 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")] = QStringLiteral("");
m_importParameters[QStringLiteral("automatic_search_header")] = 'Y';
@@ -204,11 +204,11 @@ SKGError SKGImportPluginCsv::setCSVMapping(const QStringList* \
iCSVMapping) // Check if mandatory attributes have been found
if (m_importParameters.value(QStringLiteral("mode_csv_rule")) == \
QStringLiteral("Y")) {
if (!m_csvMapping.contains(QStringLiteral("payee")) || \
!m_csvMapping.contains(QStringLiteral("category"))) {
- err = SKGError(ERR_FAIL, i18nc("Error message", "Columns payee and \
category not found. Set import parameters in settings.")); + err = \
SKGError(ERR_FAIL, i18nc("Error message", "Columns payee and category not found. Set \
import parameters in settings (Configure Skrooge... / Import/Export / CSV / Edit \
regular expressions...).")); }
} else {
if (!m_csvMapping.contains(QStringLiteral("date")) || \
!m_csvMapping.contains(QStringLiteral("amount"))) {
- err = SKGError(ERR_FAIL, i18nc("Error message", "Columns date and \
amount not found. Set import parameters in settings.")); + err = \
SKGError(ERR_FAIL, i18nc("Error message", "Columns date and amount not found. Set \
import parameters in settings (Configure Skrooge... / 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="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <include>skgimportexportmanager.h</include>
<kcfgfile/>
<group name="skrooge_importexport">
<entry name="automatic_validation" type="Bool">
@@ -39,67 +40,67 @@
</entry>
<entry name="mapping_date" type="String">
<label>Date</label>
- <default>^date</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_date")</default>
</entry>
<entry name="mapping_number" type="String">
<label>Number</label>
- <default>^number|^num?ro</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_number")</default>
</entry>
<entry name="mapping_mode" type="String">
<label>Mode</label>
- <default>^mode|^type</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_mode")</default>
</entry>
<entry name="mapping_payee" type="String">
<label>Payee</label>
- <default>^payee|^tiers</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_payee")</default>
</entry>
<entry name="mapping_comment" type="String">
<label>Comment</label>
- <default>^comment|^libell?|^d?tail|^info</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_comment")</default>
</entry>
<entry name="mapping_status" type="String">
<label>Status</label>
- <default>^status|^pointage</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_status")</default>
</entry>
<entry name="mapping_bookmarked" type="String">
<label>Bookmarked</label>
- <default>^bookmarked</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_bookmarked")</default>
</entry>
<entry name="mapping_account" type="String">
<label>Account</label>
- <default>^account</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_account")</default>
</entry>
<entry name="mapping_category" type="String">
<label>Category</label>
- <default>^cat\w*gor\w*</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_category")</default>
</entry>
<entry name="mapping_amount" type="String">
<label>Amount</label>
- <default>^value|^amount|^valeur|^montant|^credit|^debit</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_amount")</default>
</entry>
<entry name="mapping_quantity" type="String">
<label>Quantity</label>
- <default>^quantity</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_quantity")</default>
</entry>
<entry name="mapping_sign" type="String">
<label>Sign</label>
- <default>^sign|^sens</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_sign")</default>
</entry>
<entry name="mapping_debit" type="String">
<label>Debit</label>
- <default>^-|^debit|^withdrawal</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_debit")</default>
</entry>
<entry name="mapping_unit" type="String">
<label>Unit</label>
- <default>^unit</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_unit")</default>
</entry>
<entry name="mapping_idtransaction" type="String">
<label>Idtransaction</label>
- <default>^idtransaction</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_idtransaction")</default>
</entry>
<entry name="mapping_idgroup" type="String">
<label>Idgroup</label>
- <default>^idgroup</default>
+ <default code="true">SKGImportExportManager::getParameterDefaultValue("mapping_idgroup")</default>
</entry>
<entry name="mapping_property" type="String">
<label>Property</label>
diff --git a/skgbankmodeler/skgimportexportmanager.cpp \
b/skgbankmodeler/skgimportexportmanager.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& iParameter)
+{
+ // Search the first plugin having a value for this parameter
+ KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("SKG \
IMPORT/Plugin")); + int nb = offers.count();
+ for (int i = 0; i < nb; ++i) {
+ KService::Ptr service = offers.at(i);
+ QString id = service->property(QStringLiteral("X-Krunner-ID"), \
QVariant::String).toString(); + KPluginLoader loader(service->library());
+ KPluginFactory* factory = loader.factory();
+ if (factory) {
+ SKGImportPlugin* pluginInterface = factory->create<SKGImportPlugin> \
(nullptr); + if (pluginInterface) {
+ auto val = pluginInterface->getImportParameters().value(iParameter);
+ if (!val.isEmpty()) {
+ return val;
+ }
+ val = pluginInterface->getExportParameters().value(iParameter);
+ if (!val.isEmpty()) {
+ return val;
+ }
+ }
+ }
+ }
+ return "";
+}
+
QMap< QString, QString > SKGImportExportManager::getImportParameters()
{
QMap< QString, QString > output;
diff --git a/skgbankmodeler/skgimportexportmanager.h \
b/skgbankmodeler/skgimportexportmanager.h index 18f3a9d4..807625a2 100644
--- a/skgbankmodeler/skgimportexportmanager.h
+++ b/skgbankmodeler/skgimportexportmanager.h
@@ -151,6 +151,12 @@ public:
virtual void setImportParameters(const QMap<QString, QString>& iParameters);
/**
+ * 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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic