1#pragma once
2
3/****************************************************************************************
4 ** GitQlient is an application to manage and operate one or several Git repositories. With
5 ** GitQlient you will be able to add commits, branches and manage all the options Git provides.
6 ** Copyright (C) 2021 Francesc Martinez
7 **
8 ** LinkedIn: www.linkedin.com/in/cescmm/
9 ** Web: www.francescmm.com
10 **
11 ** This library is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU Lesser General Public
13 ** License as published by the Free Software Foundation; either
14 ** version 2 of the License, or (at your option) any later version.
15 **
16 ** This program is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** Lesser General Public License for more details.
20 **
21 ** You should have received a copy of the GNU Lesser General Public
22 ** License along with this library; if not, write to the Free Software
23 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 ***************************************************************************************/
25
26#include <QFrame>
27
28class GitBase;
29class QPushButton;
30
31/**
32 * @brief The ConflictButton class creates buttons that are used by the MergeWidget. The button is composed by three
33 * different QPushButtons. The first one shows the file name and allows the user to change the selection when clicks
34 * over it. Next to it there is the update button that allows the user to refresh the view in the merge widget. The last
35 * button is the resolve button. This button allows the user to mark the merge conflict in the the file as solved and
36 * adds the file to the commit.
37 *
38 */
39class ConflictButton : public QFrame
40{
41 Q_OBJECT
42
43signals:
44 /**
45 * @brief Signal triggered when the name is clicked.
46 *
47 * @param checked True if the button is selected, otherwise false.
48 */
49 void clicked();
50 /**
51 * @brief Signal triggered when the user solves the merge conflict.
52 *
53 */
54 void resolved();
55 /**
56 * @brief Signal triggered when the user requests an update of the file content.
57 *
58 */
59 void updateRequested();
60
61 /**
62 * @brief signalEditFile Signal triggered when the user wants to edit a file and is running GitQlient from QtCreator.
63 * @param fileName The file name
64 * @param line The line
65 * @param column The column
66 */
67 void signalEditFile(const QString &fileName, int line, int column);
68
69public:
70 /**
71 * @brief Default constructor.
72 *
73 * @param filename The file name.
74 * @param inConflict Indicates if the file has conflicts.
75 * @param git The git object to perform Git operations.
76 * @param parent The parent wiget if needed.
77 */
78 explicit ConflictButton(const QString &filename, bool inConflict, const QSharedPointer<GitBase> &git,
79 QWidget *parent = nullptr);
80
81 /**
82 * @brief Sets the button as selected.
83 *
84 * @param checked The new check state.
85 */
86 void setChecked(bool checked);
87
88 /**
89 * @brief getFileName
90 * @return
91 */
92 QString getFileName() const;
93
94private:
95 QSharedPointer<GitBase> mGit;
96 QString mFileName;
97 QPushButton *mFile = nullptr;
98 QPushButton *mEdit = nullptr;
99 QPushButton *mResolve = nullptr;
100 QPushButton *mUpdate = nullptr;
101
102 /**
103 * @brief Sets the button and the file as merge conflict.
104 *
105 * @param inConflict True if it is in conflict, otherwise false.
106 */
107 void setInConflict(bool inConflict);
108 /**
109 * @brief Resolves the conflict of the file and adds the file to the merge commit.
110 *
111 */
112 void resolveConflict();
113};
114