Limo
A simple mod manager
Loading...
Searching...
No Matches
editautotagsdialog.h
Go to the documentation of this file.
1
5
6#pragma once
7
9#include "core/tagcondition.h"
10#include <QAction>
11#include <QDialog>
12#include <map>
13#include <set>
14
15
16namespace Ui
17{
18class EditAutoTagsDialog;
19}
20
24class EditAutoTagsDialog : public QDialog
25{
26 Q_OBJECT
27
28public:
33 explicit EditAutoTagsDialog(QWidget* parent = nullptr);
36
41 void setupDialog(
42 int app_id,
43 const std::map<std::string, std::pair<std::string, std::vector<TagCondition>>>& auto_tags);
48 void closeEvent(QCloseEvent* event) override;
50 void reject() override;
51
52private:
54 Ui::EditAutoTagsDialog* ui;
56 static constexpr int connection_cb_any_index = 0;
58 static constexpr int connection_cb_all_index = 1;
60 static constexpr int connection_cb_advanced_index = 2;
61
63 static constexpr int action_col = 0;
65 static constexpr int id_col = 1;
67 static constexpr int target_col = 2;
69 static constexpr int invert_col = 3;
71 static constexpr int matcher_col = 4;
73 static constexpr int string_col = 5;
74
76 static constexpr int target_file_index = 0;
78 static constexpr int target_path_index = 1;
79
81 static constexpr int invert_false_index = 0;
83 static constexpr int invert_true_index = 1;
84
86 static constexpr int matcher_string_index = 0;
88 static constexpr int matcher_regex_index = 1;
89
91 std::map<std::string, std::pair<std::string, std::vector<TagCondition>>> auto_tags_;
93 std::set<std::string> tags_with_updated_conditions_;
95 std::unique_ptr<QAction> add_tag_action_;
97 std::unique_ptr<QAction> remove_tag_action_;
99 std::unique_ptr<QAction> rename_tag_action_;
101 std::map<QString, int> connection_index_map_;
105 std::vector<EditAutoTagAction> edit_actions_;
109 bool dialog_completed_ = false;
110
115 void enableInteraction(bool enable);
122 bool eventFilter(QObject* object, QEvent* event) override;
130 QString createExpression(QString op, int length);
132 void updateExpressionBox();
134 void updateOkButton();
135
136private slots:
145 void onConditionRemoved(int row, int col);
147 void onConditionAdded();
152 void onConditionEdited();
159 void onTagRemoved();
161 void on_tag_cb_currentIndexChanged(int index);
163 void onTagAdded();
165 void onTagRenamed();
170 void on_expression_line_edit_textEdited(const QString& expression);
175
176signals:
181 void tagsEdited(int app_id, std::vector<EditAutoTagAction> actions);
184};
static constexpr int invert_col
Invert column in the condition table.
Definition editautotagsdialog.h:69
void onConditionEdited()
Updates the conditions for the current tag in the auto_tags_ map according to the settings in the con...
Definition editautotagsdialog.cpp:271
static constexpr int string_col
String column in the condition table.
Definition editautotagsdialog.h:73
void on_buttonBox_rejected()
Emits dialogClosed.
Definition editautotagsdialog.cpp:445
void setupDialog(int app_id, const std::map< std::string, std::pair< std::string, std::vector< TagCondition > > > &auto_tags)
Initializes the dialog with the given tags.
Definition editautotagsdialog.cpp:59
void tagsEdited(int app_id, std::vector< EditAutoTagAction > actions)
Signals dialog completion.
void dialogClosed()
Signales dialog has been closed without performing any actions.
void on_tag_cb_currentIndexChanged(int index)
Updates the ui to show data for the new tag.
Definition editautotagsdialog.cpp:344
static constexpr int target_col
Target column in the condition table.
Definition editautotagsdialog.h:67
void enableInteraction(bool enable)
Enables/ disables interactive elements in the ui.
Definition editautotagsdialog.cpp:118
EditAutoTagsDialog(QWidget *parent=nullptr)
Initializes the ui and generates actions and combo box entries.
Definition editautotagsdialog.cpp:13
static constexpr int target_file_index
File name index of the checkbox for target selection.
Definition editautotagsdialog.h:76
static constexpr int matcher_col
Matcher column in the condition table.
Definition editautotagsdialog.h:71
static constexpr int action_col
Action column in the condition table.
Definition editautotagsdialog.h:63
static constexpr int connection_cb_any_index
Any index for the connection type check box.
Definition editautotagsdialog.h:56
void on_connection_cb_currentIndexChanged(int index)
Updates the help label and hides/ shows the expression line edit if needed.
Definition editautotagsdialog.cpp:300
bool eventFilter(QObject *object, QEvent *event) override
Catches mouse wheel events if the target is a combo box.
Definition editautotagsdialog.cpp:205
std::vector< EditAutoTagAction > edit_actions_
Contains all editing actions performed in this dialog.
Definition editautotagsdialog.h:105
void onTagAdded()
Shows a dialog for adding a new tag. Creates the new tag if the dialog was accepted.
Definition editautotagsdialog.cpp:355
void reject() override
Closes the dialog and emits a signal indicating the dialog has been closed.
Definition editautotagsdialog.cpp:89
static constexpr int matcher_regex_index
Regex index of the checkbox for matcher selection.
Definition editautotagsdialog.h:88
void closeEvent(QCloseEvent *event) override
Emits dialogClosed.
Definition editautotagsdialog.cpp:80
Ui::EditAutoTagsDialog * ui
Contains auto generated ui elements.
Definition editautotagsdialog.h:54
void updateConditionTable()
Updates the currently displayed expression and conditions to match the selected tag.
Definition editautotagsdialog.cpp:127
static constexpr int connection_cb_advanced_index
Advanced index for the connection type check box.
Definition editautotagsdialog.h:60
std::unique_ptr< QAction > rename_tag_action_
Action for renaming a tag.
Definition editautotagsdialog.h:99
int app_id_
Target ModdedApplication.
Definition editautotagsdialog.h:107
std::set< std::string > tags_with_updated_conditions_
Contains all tags for which the conditions have been modified.
Definition editautotagsdialog.h:93
static constexpr int target_path_index
Full path index of the checkbox for target selection.
Definition editautotagsdialog.h:78
std::unique_ptr< QAction > remove_tag_action_
Action for removing a tag.
Definition editautotagsdialog.h:97
std::unique_ptr< QAction > add_tag_action_
Action for adding a new tag.
Definition editautotagsdialog.h:95
void onConditionAdded()
Adds a new condition to the condition table.
Definition editautotagsdialog.cpp:260
static constexpr int connection_cb_all_index
All index for the connection type check box.
Definition editautotagsdialog.h:58
std::map< std::string, std::pair< std::string, std::vector< TagCondition > > > auto_tags_
Maps tags to a pair of expression and conditions.
Definition editautotagsdialog.h:91
void on_buttonBox_accepted()
Constructs all missing editing actions and emits tagsEdited.
Definition editautotagsdialog.cpp:409
void updateOkButton()
Enables/ disables the Ok button, depending on the current ui state.
Definition editautotagsdialog.cpp:98
QString createExpression(QString op, int length)
Creates a boolean expression where variables are every integer in [0, length) and every operator is o...
Definition editautotagsdialog.cpp:212
std::map< QString, int > connection_index_map_
Maps tags to their selected connection type.
Definition editautotagsdialog.h:101
static constexpr int invert_true_index
True index of the checkbox for inverting a condition.
Definition editautotagsdialog.h:83
bool ignore_index_changes_
If true: Connection box index changes will not count as condition updates.
Definition editautotagsdialog.h:103
~EditAutoTagsDialog()
Deletes the ui.
Definition editautotagsdialog.cpp:54
bool dialog_completed_
Indicates whether the dialog has been completed.
Definition editautotagsdialog.h:109
void on_expression_line_edit_textEdited(const QString &expression)
Checks if the given expression is valid and disables/ enables the Ok button.
Definition editautotagsdialog.cpp:399
void onTagRenamed()
Show a dialog for renaming a tag. Renames the tag if the dialog was accepted.
Definition editautotagsdialog.cpp:372
void updateExpressionBox()
Updates the expresssion line edit and combo box for the currently selected tag.
Definition editautotagsdialog.cpp:221
void onConditionRemoved(int row, int col)
Called when a remove button inside the condition table has been pressed. Removes the respective condi...
Definition editautotagsdialog.cpp:248
void onTagRemoved()
Removes the currently active tag.
Definition editautotagsdialog.cpp:333
static constexpr int id_col
Id column in the condition table.
Definition editautotagsdialog.h:65
static constexpr int matcher_string_index
String index of the checkbox for matcher selection.
Definition editautotagsdialog.h:86
static constexpr int invert_false_index
False index of the checkbox for inverting a condition.
Definition editautotagsdialog.h:81
Header for the EditAutoTagAction class.
Contains the TagCondition struct.