@@ -40,6 +40,16 @@ QString ConflictSolver::remoteVersionFilename() const
4040 return _remoteVersionFilename;
4141}
4242
43+ bool ConflictSolver::isBulkSolution () const
44+ {
45+ return _isBulkSolution;
46+ }
47+
48+ bool ConflictSolver::yesToAllRequested () const
49+ {
50+ return _yesToAllRequested;
51+ }
52+
4353bool ConflictSolver::exec (ConflictSolver::Solution solution)
4454{
4555 switch (solution) {
@@ -74,6 +84,26 @@ void ConflictSolver::setRemoteVersionFilename(const QString &remoteVersionFilena
7484 emit remoteVersionFilenameChanged ();
7585}
7686
87+ void ConflictSolver::setIsBulkSolution (bool isBulkSolution)
88+ {
89+ if (_isBulkSolution == isBulkSolution) {
90+ return ;
91+ }
92+
93+ _isBulkSolution = isBulkSolution;
94+ emit isBulkSolutionChanged ();
95+ }
96+
97+ void ConflictSolver::setYesToAllRequested (bool yesToAllRequested)
98+ {
99+ if (_yesToAllRequested == yesToAllRequested) {
100+ return ;
101+ }
102+
103+ _yesToAllRequested = yesToAllRequested;
104+ emit yesToAllRequestedChanged ();
105+ }
106+
77107bool ConflictSolver::deleteLocalVersion ()
78108{
79109 if (_localVersionFilename.isEmpty ()) {
@@ -84,13 +114,9 @@ bool ConflictSolver::deleteLocalVersion()
84114 return false ;
85115 }
86116
87- QFileInfo info (_localVersionFilename);
88- const auto message = FileSystem::isDir (_localVersionFilename)
89- ? tr (" Do you want to delete the directory <i>%1</i> and all its contents permanently?" ).arg (info.dir ().dirName ())
90- : tr (" Do you want to delete the file <i>%1</i> permanently?" ).arg (info.fileName ());
91- const auto result = QMessageBox::question (_parentWidget, tr (" Confirm deletion" ), message, QMessageBox::Yes, QMessageBox::No);
92- if (result != QMessageBox::Yes)
117+ if (!confirmDeletion ()) {
93118 return false ;
119+ }
94120
95121 if (FileSystem::isDir (_localVersionFilename)) {
96122 return FileSystem::removeRecursively (_localVersionFilename);
@@ -161,4 +187,31 @@ bool ConflictSolver::overwriteRemoteVersion()
161187 }
162188}
163189
190+ bool ConflictSolver::confirmDeletion ()
191+ {
192+ if (_yesToAllRequested) {
193+ return true ;
194+ }
195+
196+ QMessageBox::StandardButton yesToAllButton = _isBulkSolution ? QMessageBox::YesToAll : QMessageBox::NoButton;
197+
198+ QFileInfo info (_localVersionFilename);
199+ const auto message = FileSystem::isDir (_localVersionFilename)
200+ ? tr (" Do you want to delete the directory <i>%1</i> and all its contents permanently?" ).arg (info.dir ().dirName ())
201+ : tr (" Do you want to delete the file <i>%1</i> permanently?" ).arg (info.fileName ());
202+ const auto result = QMessageBox::question (_parentWidget, tr (" Confirm deletion" ), message, QMessageBox::Yes, QMessageBox::No, yesToAllButton);
203+ switch (result)
204+ {
205+ case QMessageBox::YesToAll:
206+ setYesToAllRequested (true );
207+ return true ;
208+ case QMessageBox::Yes:
209+ return true ;
210+ default :
211+ // any other button pressed
212+ return false ;
213+ }
214+ return false ;
215+ }
216+
164217} // namespace OCC
0 commit comments