FOSSredder 0.5.0
Loading...
Searching...
No Matches
ImportViewModel.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <QObject>
9#include <QString>
10#include <QStringList>
11#include <QVariantList>
12#include <QVariantMap>
13#include <qqmlintegration.h>
14
15#include "ui/shell/AppActions.h"
16#include "ui/shell/Navigation.h"
17#include "ui/shell/Settings.h"
18#include "ui/shell/Status.h"
20
21namespace ui {
22
26class WorkspaceStore;
27
32class ImportViewModel : public QObject {
33 Q_OBJECT
34 QML_NAMED_ELEMENT(ImportViewModel)
35
36 Q_PROPERTY(int contentIndex READ contentIndex NOTIFY changed)
37 Q_PROPERTY(bool hasImportWorkflow READ hasImportWorkflow NOTIFY changed)
38 Q_PROPERTY(bool hasDraft READ hasDraft NOTIFY changed)
39 Q_PROPERTY(bool hasDraftNavigation READ hasDraftNavigation NOTIFY changed)
40 Q_PROPERTY(bool canClearImport READ canClearImport NOTIFY changed)
41 Q_PROPERTY(bool canCancel READ canCancel NOTIFY changed)
42 Q_PROPERTY(bool canPause READ canPause NOTIFY changed)
43 Q_PROPERTY(bool canStart READ canStart NOTIFY changed)
44 Q_PROPERTY(bool importRunning READ importRunning NOTIFY changed)
45 Q_PROPERTY(bool importPaused READ importPaused NOTIFY changed)
46 Q_PROPERTY(QString pauseText READ pauseText NOTIFY changed)
47 Q_PROPERTY(QString progressText READ progressText NOTIFY changed)
48 Q_PROPERTY(bool progressHasError READ progressHasError NOTIFY changed)
49 Q_PROPERTY(double progressValue READ progressValue NOTIFY changed)
50 Q_PROPERTY(QString manualPathText READ manualPathText WRITE setManualPathText
51 NOTIFY changed)
52 Q_PROPERTY(QStringList importFiles READ importFiles NOTIFY changed)
53 Q_PROPERTY(QString importFileSummary READ importFileSummary NOTIFY changed)
54 Q_PROPERTY(ui::Navigation* navigation READ navigation NOTIFY changed)
55 Q_PROPERTY(int queuedCount READ queuedCount NOTIFY changed)
56 Q_PROPERTY(QVariantList importLogs READ importLogs NOTIFY changed)
57 Q_PROPERTY(QString selectedDraftId READ selectedDraftId NOTIFY changed)
58 Q_PROPERTY(QStringList importSourceLabels READ importSourceLabels CONSTANT)
59 Q_PROPERTY(
60 QStringList statementStrategyLabels READ statementStrategyLabels CONSTANT)
61
62 Q_PROPERTY(QString statementName READ statementName WRITE setStatementName
63 NOTIFY changed)
64 Q_PROPERTY(
66 Q_PROPERTY(int transactionCount READ transactionCount NOTIFY changed)
70 Q_PROPERTY(bool canSelectNextTransactionDraft READ
72
73 Q_PROPERTY(QString nameText READ nameText WRITE setNameText NOTIFY changed)
74 Q_PROPERTY(QString bookingDateText READ bookingDateText WRITE
76 Q_PROPERTY(
77 QString valutaText READ valutaText WRITE setValutaText NOTIFY changed)
78 Q_PROPERTY(
79 QString amountText READ amountText WRITE setAmountText NOTIFY changed)
80 Q_PROPERTY(QVariantList statusOptions READ statusOptions NOTIFY changed)
81 Q_PROPERTY(int statusIndex READ statusIndex NOTIFY changed)
82 Q_PROPERTY(QString metadataText READ metadataText NOTIFY changed)
83 Q_PROPERTY(QString proofSource READ proofSource NOTIFY changed)
85 Q_PROPERTY(QVariantList actorOptions READ actorOptions NOTIFY changed)
86 Q_PROPERTY(
88 Q_PROPERTY(QString actorName READ actorName WRITE setActorName NOTIFY changed)
89 Q_PROPERTY(bool canAddActor READ canAddActor NOTIFY changed)
90 Q_PROPERTY(QVariantList contractOptions READ contractOptions NOTIFY changed)
92 NOTIFY changed)
93 Q_PROPERTY(QString contractName READ contractName WRITE setContractName NOTIFY
94 changed)
95 Q_PROPERTY(QString contractType READ contractType WRITE setContractType NOTIFY
96 changed)
97 Q_PROPERTY(QString contractNamePlaceholder READ contractNamePlaceholder NOTIFY
98 changed)
100 CONSTANT)
103 Q_PROPERTY(
105 Q_PROPERTY(bool canAddContract READ canAddContract NOTIFY changed)
106 Q_PROPERTY(QVariantList propertyOptions READ propertyOptions NOTIFY changed)
107 Q_PROPERTY(QString propertyName READ propertyName WRITE setPropertyName NOTIFY
108 changed)
109 Q_PROPERTY(bool canAddProperty READ canAddProperty NOTIFY changed)
111 NOTIFY changed)
112 Q_PROPERTY(
114 Q_PROPERTY(double propertySuggestionConfidence READ
117 NOTIFY changed)
118 Q_PROPERTY(double contractSuggestionConfidence READ
121 NOTIFY changed)
122 Q_PROPERTY(double allocatableSuggestionConfidence READ
125 NOTIFY changed)
126
127public:
132 explicit ImportViewModel(QObject* parent = nullptr);
133
139
144 void setSettings(Settings* value);
145
150 void setActions(Actions* value);
151
156 void setNavigation(Navigation* value);
157
162 Navigation* navigation() const noexcept {
163 return navigation_;
164 }
165
170 void setStatus(Status* value);
171
180 WorkspaceSelection* selection,
181 WorkspaceSelectors* selectors);
182
187 int contentIndex() const noexcept;
188
193 bool hasImportWorkflow() const noexcept;
194
199 bool hasDraft() const noexcept;
200
205 bool hasDraftNavigation() const noexcept;
206
211 bool canClearImport() const noexcept;
212
217 bool canCancel() const noexcept;
218
223 bool canPause() const noexcept;
224
229 bool canStart() const noexcept;
230
235 bool importRunning() const noexcept;
236
241 bool importPaused() const noexcept;
242
247 QString pauseText() const;
248
253 QString progressText() const;
254
259 bool progressHasError() const noexcept;
260
265 double progressValue() const noexcept;
266
271 QString manualPathText() const {
272 return manualPathText_;
273 }
274
279 void setManualPathText(const QString& value);
280
285 QStringList importFiles() const;
286
291 QString importFileSummary() const;
292
297 int queuedCount() const noexcept;
298
303 QVariantList importLogs() const;
304
309 QString selectedDraftId() const;
310
315 QStringList importSourceLabels() const;
316
321 QStringList statementStrategyLabels() const;
322
327 QString statementName() const;
328
333 void setStatementName(const QString& value);
334
339 int currentTransactionNumber() const noexcept;
340
345 int transactionCount() const noexcept;
346
351 bool canDeleteTransaction() const noexcept;
352
357 bool canSelectPreviousTransactionDraft() const noexcept;
358
363 bool canSelectNextTransactionDraft() const noexcept;
364
369 QString nameText() const {
370 return nameText_;
371 }
372
377 void setNameText(const QString& value);
378
383 QString bookingDateText() const {
384 return bookingDateText_;
385 }
386
391 void setBookingDateText(const QString& value);
392
397 QString valutaText() const {
398 return valutaText_;
399 }
400
405 void setValutaText(const QString& value);
406
411 QString amountText() const {
412 return amountText_;
413 }
414
419 void setAmountText(const QString& value);
420
425 QVariantList statusOptions() const;
426
431 int statusIndex() const;
432
437 QString metadataText() const;
438
443 QString proofSource() const;
444
449 bool effectiveAllocatable() const;
450
455 QVariantList actorOptions() const;
456
461 int selectedActorOptionIndex() const;
462
467 QString actorName() const {
468 return actorName_;
469 }
470
475 void setActorName(const QString& value);
476
481 bool canAddActor() const;
482
487 QVariantList contractOptions() const;
488
493 int selectedContractOptionIndex() const;
494
499 QString contractName() const {
500 return contractName_;
501 }
502
507 void setContractName(const QString& value);
508
513 QString contractType() const {
514 return contractType_;
515 }
516
521 void setContractType(const QString& value);
522
527 QString contractNamePlaceholder() const;
528
533 QVariantList contractAllocatableModes() const;
534
540
545 void setContractAllocatableModeIndex(int index);
546
551 QString selectedContractType() const;
552
557 bool canAddContract() const;
558
563 QVariantList propertyOptions() const;
564
569 QString propertyName() const {
570 return propertyName_;
571 }
572
577 void setPropertyName(const QString& value);
578
583 bool canAddProperty() const;
584
588 Q_INVOKABLE void initializeImportView();
589
593 Q_INVOKABLE void browseImportPdf();
594
598 Q_INVOKABLE void addSelectedImportFiles();
599
603 Q_INVOKABLE void clearImport();
604
608 Q_INVOKABLE void cancelCurrentImport();
609
613 Q_INVOKABLE void cancelQueuedImports();
614
618 Q_INVOKABLE void pauseImport();
619
623 Q_INVOKABLE void resumeImport();
624
628 Q_INVOKABLE void startImport();
629
633 Q_INVOKABLE void selectPreviousDraft();
634
638 Q_INVOKABLE void selectNextDraft();
639
647 Q_INVOKABLE void openImportLog(const QString& logId, bool draftAttached,
648 const QString& statementId,
649 const QString& draftId);
650
657 Q_INVOKABLE void deleteImportLog(const QString& logId, bool draftAttached,
658 const QString& draftId);
659
663 Q_INVOKABLE void returnToImport();
664
668 Q_INVOKABLE void discard();
669
673 Q_INVOKABLE void addTransactionAfterCurrent();
674
678 Q_INVOKABLE void deleteCurrentTransaction();
679
683 Q_INVOKABLE void finalize();
684
688 Q_INVOKABLE void selectPreviousTransactionDraft();
689
693 Q_INVOKABLE void selectNextTransactionDraft();
694
698 Q_INVOKABLE void commitNameText();
699
703 Q_INVOKABLE void commitBookingDateText();
704
708 Q_INVOKABLE void commitValutaText();
709
713 Q_INVOKABLE void commitAmountText();
714
719 Q_INVOKABLE void selectStatusAtIndex(int index);
720
726 Q_INVOKABLE int suggestionTone(double confidence) const;
727
732 Q_INVOKABLE void selectActorAtIndex(int index);
733
737 Q_INVOKABLE void addActor();
738
743 Q_INVOKABLE void selectContractAtIndex(int index);
744
748 Q_INVOKABLE void addContract();
749
755 Q_INVOKABLE bool isPropertySelected(const QString& propertyId) const;
756
762 Q_INVOKABLE void setPropertySelected(const QString& propertyId,
763 bool selected);
764
768 Q_INVOKABLE void addProperty();
769
773 Q_INVOKABLE void toggleAllocatable();
774
779 double actorSuggestionConfidence() const;
780
785 QString actorSuggestionSummary() const;
786
791 double propertySuggestionConfidence() const;
792
797 QString propertySuggestionSummary() const;
798
803 double contractSuggestionConfidence() const;
804
809 QString contractSuggestionSummary() const;
810
815 double allocatableSuggestionConfidence() const;
816
821 QString allocatableSuggestionText() const;
822
823signals:
827 void changed();
828
829private:
834 void bindImportWorkflow(ImportWorkflow* value);
839 void bindSettings(Settings* value);
844 void bindActions(Actions* value);
848 void bindWorkspaceRoles(WorkspaceStore* store, WorkspaceCommands* commands,
849 WorkspaceSelection* selection,
850 WorkspaceSelectors* selectors);
854 void applyDefaultImportSelection();
858 void updateManualPathFromWorkflow();
863 void setSelectedImportFiles(const QStringList& paths);
868 void setStatusText(const QString& text);
873 void queueImportFiles(const QStringList& paths);
879 QStringList supportedImportFiles(const QStringList& paths) const;
884 int activeDraftStackIndex() const;
890 bool openDraftAtStackIndex(int index);
891
895 void syncTransactionDraftFromWorkflow();
899 void reloadCurrentTransactionView();
903 void resetTransactionDraftFields();
909 QString displaySuggestionSummary(const QString& value) const;
914 QString currentTransactionId() const;
919 QStringList currentTransactionPropertyIds() const;
924 QString currentTransactionActorId() const;
925
926 ImportWorkflow* importWorkflow_ = nullptr;
927 Settings* settings_ = nullptr;
928 Actions* actions_ = nullptr;
929 Navigation* navigation_ = nullptr;
930 Status* status_ = nullptr;
931 WorkspaceStore* store_ = nullptr;
932 WorkspaceCommands* commands_ = nullptr;
933 WorkspaceSelection* selection_ = nullptr;
934 WorkspaceSelectors* selectors_ = nullptr;
935 QString manualPathText_;
936 QStringList selectedImportFiles_;
937 QString appliedDefaultImportPath_;
938
939 TransactionDraftView currentTransactionView_;
940 QString lastTransactionId_;
941 QString nameText_;
942 QString bookingDateText_;
943 QString valutaText_;
944 QString amountText_;
945 QString actorName_;
946 QString contractName_;
947 QString contractType_;
948 QString contractAllocatableMode_;
949 QString propertyName_;
950};
951
952} // namespace ui
Declares QAction wrappers exposed to the UI layer and QML.
Coordinates asynchronous statement imports and in-memory draft sessions.
Declarations for the UI Navigation component.
Declares the centralized UI settings view model exposed to QML.
Declarations for the UI Status component.
Owns the main window actions and exposes them to QML.
Definition AppActions.h:18
ui::Navigation * navigation
Q_INVOKABLE void initializeImportView()
Initializes import view state when the view is opened.
void setSettings(Settings *value)
Sets settings used for import defaults.
Q_INVOKABLE void commitAmountText()
Commits the amount field to the workflow draft.
QString propertyName() const
Returns the quick-create property name field.
Q_INVOKABLE void startImport()
Starts importing the selected files.
Q_INVOKABLE void finalize()
Finalizes the active statement draft through the import workflow.
void setImportWorkflow(ImportWorkflow *value)
Sets the import workflow used for import runs and draft review.
void setAmountText(const QString &value)
Updates the amount field.
QStringList importSourceLabels
QString amountText() const
Returns the amount field.
Q_INVOKABLE void discard()
Discards the active statement draft.
void setWorkspaceRoles(WorkspaceStore *store, WorkspaceCommands *commands, WorkspaceSelection *selection, WorkspaceSelectors *selectors)
Sets workspace roles used for import logs, catalog and selection.
QVariantList actorOptions
Q_INVOKABLE void selectStatusAtIndex(int index)
Selects a transaction status option.
Q_INVOKABLE void toggleAllocatable()
Toggles the current draft allocatable state.
Q_INVOKABLE void selectContractAtIndex(int index)
Selects a contract option.
Q_INVOKABLE void deleteImportLog(const QString &logId, bool draftAttached, const QString &draftId)
Deletes an import log and attached draft state when requested.
Q_INVOKABLE void selectNextDraft()
Selects the next statement draft.
Q_INVOKABLE void addContract()
Creates and selects a contract for the current draft.
QVariantList statusOptions
void setStatementName(const QString &value)
Updates the active statement draft name field.
Q_INVOKABLE void addProperty()
Creates and selects a property for the current draft.
Q_INVOKABLE void commitValutaText()
Commits the valuta field to the workflow draft.
Q_INVOKABLE void returnToImport()
Returns from draft review to the import overview.
Q_INVOKABLE void pauseImport()
Pauses the current import job.
ImportViewModel(QObject *parent=nullptr)
Creates the import view model.
Q_INVOKABLE void selectPreviousTransactionDraft()
Selects the previous transaction draft.
Q_INVOKABLE void cancelCurrentImport()
Cancels the current import job.
Q_INVOKABLE void commitBookingDateText()
Commits the booking date field to the workflow draft.
QString valutaText() const
Returns the valuta field.
void setStatus(Status *value)
Sets shell status output used by import actions.
Q_INVOKABLE void openImportLog(const QString &logId, bool draftAttached, const QString &statementId, const QString &draftId)
Opens an import log from the sidebar.
Q_INVOKABLE void setPropertySelected(const QString &propertyId, bool selected)
Updates whether a property is selected for the current draft.
Q_INVOKABLE int suggestionTone(double confidence) const
Maps suggestion confidence to a presentation tone.
void setContractType(const QString &value)
Updates the quick-create contract type field.
Q_INVOKABLE void addActor()
Creates and selects an actor for the current draft.
QVariantList contractAllocatableModes
QString contractName() const
Returns the quick-create contract name field.
Q_INVOKABLE void resumeImport()
Resumes a paused import job.
Q_INVOKABLE void browseImportPdf()
Opens a file browser for import PDFs.
QString bookingDateText() const
Returns the booking date field.
void setNameText(const QString &value)
Updates the transaction name field.
Q_INVOKABLE void commitNameText()
Commits the transaction name field to the workflow draft.
void setPropertyName(const QString &value)
Updates the quick-create property name field.
bool canSelectPreviousTransactionDraft READ canSelectPreviousTransactionDraft
void changed()
Emitted when import view model state changed.
Q_INVOKABLE void addTransactionAfterCurrent()
Adds a transaction draft after the current one.
QVariantList propertyOptions
void setManualPathText(const QString &value)
Updates the manual import path field.
Q_INVOKABLE bool isPropertySelected(const QString &propertyId) const
Returns whether a property is selected for the current draft.
Q_INVOKABLE void selectNextTransactionDraft()
Selects the next transaction draft.
double propertySuggestionConfidence READ propertySuggestionConfidence
Q_INVOKABLE void selectPreviousDraft()
Selects the previous statement draft.
QStringList statementStrategyLabels
Q_INVOKABLE void addSelectedImportFiles()
Adds the manual path field to the selected import files.
double contractSuggestionConfidence READ contractSuggestionConfidence
double allocatableSuggestionConfidence READ allocatableSuggestionConfidence
QString actorName() const
Returns the quick-create actor name field.
Q_INVOKABLE void deleteCurrentTransaction()
Deletes the current transaction draft.
void setNavigation(Navigation *value)
Sets shell navigation used by import transitions.
void setContractName(const QString &value)
Updates the quick-create contract name field.
bool canSelectNextTransactionDraft READ canSelectNextTransactionDraft
void setBookingDateText(const QString &value)
Updates the booking date field.
QVariantList importLogs
Q_INVOKABLE void cancelQueuedImports()
Cancels queued import jobs.
void setValutaText(const QString &value)
Updates the valuta field.
QString contractType() const
Returns the quick-create contract type field.
Q_INVOKABLE void clearImport()
Clears the local import selection and progress display.
Q_INVOKABLE void selectActorAtIndex(int index)
Selects an actor option.
void setContractAllocatableModeIndex(int index)
Updates selected contract allocatable mode index.
QVariantList contractOptions
void setActorName(const QString &value)
Updates the quick-create actor name field.
void setActions(Actions *value)
Sets shell actions used for browsing files.
Runs PDF imports and holds the active in-memory statement draft session.
Stores the active top-level shell section and settings sub-section.
Definition Navigation.h:15
Stores and exposes globally persisted UI settings for settings-related views.
Definition Settings.h:19
Exposes the shell status text shown by the main window.
Definition Status.h:16
Maps UI intent to core workspace writer commands.
Tracks the currently selected workspace entities.
Projects workspace store data into QML-facing read models.
Owns the current UI-side workspace snapshot and revision lifecycle.
Qt-friendly projection of the currently edited import transaction.