6#include "ConflictDialog.h"
10#include <QDialogButtonBox>
20ConflictDialog::ConflictDialog(
QWidget *parent)
22 , m_mergeItem(nullptr)
24 , m_resolveAction(ConflictDialog::AskUser)
29void ConflictDialog::setMergeItem(MergeItem *item)
34void ConflictDialog::stopAutoResolve()
36 m_resolveAction = ConflictDialog::AskUser;
39void ConflictDialog::open()
41 if (m_mergeItem ==
nullptr) {
45 switch (m_resolveAction) {
46 case ConflictDialog::AskUser:
50 case ConflictDialog::PreferLocal:
51 m_mergeItem->setResolution(MergeItem::A);
52 Q_EMIT resolveConflict(m_mergeItem);
54 case ConflictDialog::PreferCloud:
55 m_mergeItem->setResolution(MergeItem::B);
56 Q_EMIT resolveConflict(m_mergeItem);
66 switch (standardButton) {
70 case ConflictDialog::Local:
71 m_mergeItem->setResolution(MergeItem::A);
72 Q_EMIT resolveConflict(m_mergeItem);
74 case ConflictDialog::Cloud:
75 m_mergeItem->setResolution(MergeItem::B);
76 Q_EMIT resolveConflict(m_mergeItem);
78 case ConflictDialog::AllLocal:
79 m_mergeItem->setResolution(MergeItem::A);
80 m_resolveAction = ConflictDialog::PreferLocal;
81 Q_EMIT resolveConflict(m_mergeItem);
83 case ConflictDialog::AllCloud:
84 m_mergeItem->setResolution(MergeItem::B);
85 m_resolveAction = ConflictDialog::PreferCloud;
86 Q_EMIT resolveConflict(m_mergeItem);
98void ConflictDialog::prepareLayout()
101 qDeleteAll(children());
104 auto localButton =
new QPushButton(tr(
"Use local"));
105 auto cloudButton =
new QPushButton(tr(
"Use cloud"));
106 auto allLocalButton =
new QPushButton(tr(
"Always use local"));
107 auto allCloudButton =
new QPushButton(tr(
"Always use cloud"));
109 localButton->setDefault(
true);
110 localButton->setProperty(
"ActionRole", ConflictDialog::Local);
111 cloudButton->setProperty(
"ActionRole", ConflictDialog::Cloud);
112 allLocalButton->setProperty(
"ActionRole", ConflictDialog::AllLocal);
113 allCloudButton->setProperty(
"ActionRole", ConflictDialog::AllCloud);
121 QString localHeaderText = tr(
"Local placemark");
123 tr(
"Path: %0 <br /> Name: %1 <br /> Description: %2 <br /> Status: %3").
arg(m_mergeItem->pathA(), m_mergeItem->nameA(), m_mergeItem->descriptionA());
124 switch (m_mergeItem->actionA()) {
125 case MergeItem::Changed:
126 localDetailText = localDetailText.
arg(tr(
"Changed"));
128 case MergeItem::Deleted:
129 localDetailText = localDetailText.
arg(tr(
"Deleted"));
135 auto localHeaderLabel =
new QLabel(localHeaderText);
136 auto localDetailLabel =
new QLabel(localDetailText);
137 leftLayout->addWidget(localHeaderLabel);
138 leftLayout->addWidget(localDetailLabel);
141 QString cloudHeaderText = tr(
"Cloud placemark");
143 tr(
"Path: %0 <br /> Name: %1 <br /> Description: %2 <br /> Status: %3").
arg(m_mergeItem->pathB(), m_mergeItem->nameB(), m_mergeItem->descriptionB());
144 switch (m_mergeItem->actionB()) {
145 case MergeItem::Changed:
146 cloudDetailText = cloudDetailText.
arg(tr(
"Changed"));
148 case MergeItem::Deleted:
149 cloudDetailText = cloudDetailText.
arg(tr(
"Deleted"));
154 auto cloudHeaderLabel =
new QLabel(cloudHeaderText);
155 auto cloudDetailLabel =
new QLabel(cloudDetailText);
156 rightLayout->addWidget(cloudHeaderLabel);
157 rightLayout->addWidget(cloudDetailLabel);
160 detailLayout->addLayout(leftLayout);
161 detailLayout->addLayout(rightLayout);
163 auto descriptionLabel =
new QLabel();
165 tr(
"A bookmark on this device conflicts "
166 "with a cloud bookmark. Which one do "
167 "you want to keep?");
168 descriptionLabel->setText(descriptionText);
171 mainLayout->addWidget(descriptionLabel);
172 mainLayout->addLayout(detailLayout);
173 mainLayout->addWidget(m_box);
175 setLayout(mainLayout);
176 setWindowTitle(tr(
"Synchronization Conflict"));
183#include "moc_ConflictDialog.cpp"
Binds a QML item to a specific geodetic location in screen coordinates.
QVariant property(const char *name) const const
QString arg(Args &&... args) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
int toInt(bool *ok) const const