[office/skrooge] /: UI: Allow to change the template mode of a scheduled operation

Nikita Krupenko null at kde.org
Sat Dec 9 21:32:07 GMT 2023


Git commit a7aad1653a73b6d12147e30abaef9d83a007329d by Nikita Krupenko.
Committed on 09/12/2023 at 13:46.
Pushed by smankowski into branch 'master'.

UI: Allow to change the template mode of a scheduled operation

This will create/remove a template if needed.

BUG:455428

M  +4    -0    doc/index.docbook
M  +-    --    doc/scheduled.png
M  +26   -1    plugins/skrooge/skrooge_scheduled/skgscheduledpluginwidget.cpp
M  +8    -0    plugins/skrooge/skrooge_scheduled/skgscheduledpluginwidget_base.ui

https://invent.kde.org/office/skrooge/-/commit/a7aad1653a73b6d12147e30abaef9d83a007329d

diff --git a/doc/index.docbook b/doc/index.docbook
index e849c16c2..3bcb46b99 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -2102,6 +2102,10 @@ file is opened. It is also recommended to create a different account (⪚ "ETF"
 	    <term>Automatically Write</term>
 	    <listitem><para>If you want &skrooge; to automatically write the upcoming scheduled operation, you may check this option and set the number of days before term when it will be written.</para></listitem>
 	  </varlistentry>
+          <varlistentry>
+            <term>Template</term>
+            <listitem><para>You can convert a schedule to template or non-template mode. This will create/remove a corresponding template operation.</para></listitem>
+          </varlistentry>
 	</variablelist>
 	<para>To modify the operation (category, amount, etc.), you have to click on <guilabel>Jump to the operation</guilabel>.</para>
 	
diff --git a/doc/scheduled.png b/doc/scheduled.png
index ac2e12086..18d98b15d 100644
Binary files a/doc/scheduled.png and b/doc/scheduled.png differ
diff --git a/plugins/skrooge/skrooge_scheduled/skgscheduledpluginwidget.cpp b/plugins/skrooge/skrooge_scheduled/skgscheduledpluginwidget.cpp
index b8dc455c0..a43271b06 100644
--- a/plugins/skrooge/skrooge_scheduled/skgscheduledpluginwidget.cpp
+++ b/plugins/skrooge/skrooge_scheduled/skgscheduledpluginwidget.cpp
@@ -187,6 +187,22 @@ void SKGScheduledPluginWidget::onSelectionChanged()
     if (nb == 1) {
         SKGRecurrentOperationObject recOp(ui.kView->getView()->getFirstSelectedObject());
 
+        const auto isTemplate = recOp.isTemplate();
+        ui.kIsTemplate->setCheckState(isTemplate ? Qt::Checked : Qt::Unchecked);
+        if (isTemplate) {
+            SKGError err;
+            SKGObjectBase::SKGListSKGObjectBase operations;
+            err = recOp.getRecurredOperations(operations);
+            IFOK(err) ui.kIsTemplate->setEnabled(!operations.isEmpty());
+            IFOK(err) ui.kIsTemplate->setToolTip(operations.isEmpty() ?
+                i18nc("Information message", "A non-template schedule requires at least one operation") :
+                i18nc("Information message", "Convert to a non-template schedule"));
+        } else {
+            ui.kIsTemplate->setEnabled(true);
+            ui.kIsTemplate->setToolTip(
+                i18nc("Information message", "Convert to a template schedule"));
+        }
+
         ui.kFirstOccurenceDate->setDate(recOp.getDate());
         ui.kOnceEveryVal->setValue(recOp.getPeriodIncrement());
         ui.kOnceEveryUnit->setCurrentIndex(static_cast<int>(recOp.getPeriodUnit()));
@@ -268,9 +284,18 @@ void SKGScheduledPluginWidget::onUpdate()
             // Get the real object, not the object from the view
             SKGRecurrentOperationObject recOp = SKGRecurrentOperationObject(selection.at(i).getDocument(), selection.at(i).getID());
 
+            // Convert to/from template if needed
+            const auto isTemplate = recOp.isTemplate();
+            if (isTemplate && ui.kIsTemplate->checkState() == Qt::Unchecked) {
+                err = recOp.setTemplate(false);
+            }
+            else if (!isTemplate && ui.kIsTemplate->checkState() == Qt::Checked) {
+                err = recOp.setTemplate(true);
+            }
+
             // Update it
             if (ui.kFirstOccurenceDate->currentText() != NOUPDATE) {
-                err = recOp.setDate(ui.kFirstOccurenceDate->date());
+                IFOKDO(err, recOp.setDate(ui.kFirstOccurenceDate->date()))
             }
             IFOKDO(err, recOp.setPeriodIncrement(ui.kOnceEveryVal->value()))
             IFOKDO(err, recOp.setPeriodUnit(static_cast<SKGRecurrentOperationObject::PeriodUnit>(ui.kOnceEveryUnit->currentIndex())))
diff --git a/plugins/skrooge/skrooge_scheduled/skgscheduledpluginwidget_base.ui b/plugins/skrooge/skrooge_scheduled/skgscheduledpluginwidget_base.ui
index 66fec4b8c..e4d55b155 100644
--- a/plugins/skrooge/skrooge_scheduled/skgscheduledpluginwidget_base.ui
+++ b/plugins/skrooge/skrooge_scheduled/skgscheduledpluginwidget_base.ui
@@ -242,6 +242,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
      </item>
     </layout>
    </item>
+   <item row="9" column="5">
+    <widget class="QCheckBox" name="kIsTemplate">
+     <property name="text">
+      <string>Template</string>
+     </property>
+    </widget>
+   </item>
    <item row="10" column="0" colspan="9">
     <layout class="QHBoxLayout" name="horizontalLayout_5">
      <property name="spacing">
@@ -370,6 +377,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
   <tabstop>kRemindMeVal</tabstop>
   <tabstop>kAutoWrite</tabstop>
   <tabstop>kAutoWriteVal</tabstop>
+  <tabstop>kIsTemplate</tabstop>
   <tabstop>kModifyBtn</tabstop>
   <tabstop>kProcessBtn</tabstop>
  </tabstops>



More information about the kde-doc-english mailing list