@@ -31,6 +31,16 @@ QString ConflictSolver::remoteVersionFilename() const
3131 return _remoteVersionFilename;
3232}
3333
34+ bool ConflictSolver::isBulkSolution () const
35+ {
36+ return _isBulkSolution;
37+ }
38+
39+ bool ConflictSolver::yesToAllRequested () const
40+ {
41+ return _yesToAllRequested;
42+ }
43+
3444bool ConflictSolver::exec (ConflictSolver::Solution solution)
3545{
3646 switch (solution) {
@@ -65,6 +75,26 @@ void ConflictSolver::setRemoteVersionFilename(const QString &remoteVersionFilena
6575 emit remoteVersionFilenameChanged ();
6676}
6777
78+ void ConflictSolver::setIsBulkSolution (bool isBulkSolution)
79+ {
80+ if (_isBulkSolution == isBulkSolution) {
81+ return ;
82+ }
83+
84+ _isBulkSolution = isBulkSolution;
85+ emit isBulkSolutionChanged ();
86+ }
87+
88+ void ConflictSolver::setYesToAllRequested (bool yesToAllRequested)
89+ {
90+ if (_yesToAllRequested == yesToAllRequested) {
91+ return ;
92+ }
93+
94+ _yesToAllRequested = yesToAllRequested;
95+ emit yesToAllRequestedChanged ();
96+ }
97+
6898bool ConflictSolver::deleteLocalVersion ()
6999{
70100 if (_localVersionFilename.isEmpty ()) {
@@ -75,13 +105,9 @@ bool ConflictSolver::deleteLocalVersion()
75105 return false ;
76106 }
77107
78- QFileInfo info (_localVersionFilename);
79- const auto message = FileSystem::isDir (_localVersionFilename)
80- ? tr (" Do you want to delete the directory <i>%1</i> and all its contents permanently?" ).arg (info.dir ().dirName ())
81- : tr (" Do you want to delete the file <i>%1</i> permanently?" ).arg (info.fileName ());
82- const auto result = QMessageBox::question (_parentWidget, tr (" Confirm deletion" ), message, QMessageBox::Yes, QMessageBox::No);
83- if (result != QMessageBox::Yes)
108+ if (!confirmDeletion ()) {
84109 return false ;
110+ }
85111
86112 if (FileSystem::isDir (_localVersionFilename)) {
87113 return FileSystem::removeRecursively (_localVersionFilename);
@@ -152,4 +178,34 @@ bool ConflictSolver::overwriteRemoteVersion()
152178 }
153179}
154180
181+ bool ConflictSolver::confirmDeletion ()
182+ {
183+ if (_yesToAllRequested) {
184+ return true ;
185+ }
186+
187+ QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No;
188+ if (_isBulkSolution) {
189+ buttons |= QMessageBox::YesToAll;
190+ }
191+
192+ QFileInfo info (_localVersionFilename);
193+ const auto message = FileSystem::isDir (_localVersionFilename)
194+ ? tr (" Do you want to delete the directory <i>%1</i> and all its contents permanently?" ).arg (info.dir ().dirName ())
195+ : tr (" Do you want to delete the file <i>%1</i> permanently?" ).arg (info.fileName ());
196+ const auto result = QMessageBox::question (_parentWidget, tr (" Confirm deletion" ), message, buttons);
197+ switch (result)
198+ {
199+ case QMessageBox::YesToAll:
200+ setYesToAllRequested (true );
201+ return true ;
202+ case QMessageBox::Yes:
203+ return true ;
204+ default :
205+ // any other button pressed
206+ return false ;
207+ }
208+ return false ;
209+ }
210+
155211} // namespace OCC
0 commit comments