@@ -29,9 +29,11 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
2929
3030using namespace MOBase ;
3131
32- OverwriteInfoDialog::OverwriteInfoDialog (ModInfo::Ptr modInfo, QWidget* parent)
33- : QDialog(parent), ui(new Ui::OverwriteInfoDialog), m_FileSystemModel(nullptr ),
34- m_DeleteAction(nullptr ), m_RenameAction(nullptr ), m_OpenAction(nullptr )
32+ OverwriteInfoDialog::OverwriteInfoDialog (ModInfo::Ptr modInfo, OrganizerCore &organizer,
33+ QWidget* parent)
34+ : QDialog(parent), m_Organizer(organizer), ui(new Ui::OverwriteInfoDialog),
35+ m_FileSystemModel(nullptr ), m_DeleteAction(nullptr ), m_RenameAction(nullptr ),
36+ m_OpenAction(nullptr )
3537{
3638 ui->setupUi (this );
3739
@@ -137,10 +139,17 @@ void OverwriteInfoDialog::delete_activated()
137139 QItemSelectionModel* selection = ui->filesView ->selectionModel ();
138140
139141 if (selection->hasSelection () && selection->selectedRows ().count () >= 1 ) {
142+ auto root = m_FileSystemModel->rootDirectory ();
140143
141144 if (selection->selectedRows ().count () == 0 ) {
142145 return ;
143146 } else if (selection->selectedRows ().count () == 1 ) {
147+ for (auto modDir : m_Organizer.managedGame ()->getModMappings ().keys ()) {
148+ if (root.absoluteFilePath (modDir).compare (m_FileSystemModel->filePath (selection->selectedRows ().at (0 )), Qt::CaseInsensitive) == 0 ) {
149+ return ;
150+ }
151+ }
152+
144153 QString fileName = m_FileSystemModel->fileName (selection->selectedRows ().at (0 ));
145154 if (QMessageBox::question (
146155 this , tr (" Confirm" ),
@@ -158,6 +167,13 @@ void OverwriteInfoDialog::delete_activated()
158167 }
159168
160169 foreach (QModelIndex index, selection->selectedRows ()) {
170+ for (auto modDir : m_Organizer.managedGame ()->getModMappings ().keys ()) {
171+ if (root.absoluteFilePath (modDir).compare (
172+ m_FileSystemModel->filePath (index),
173+ Qt::CaseInsensitive) == 0 ) {
174+ return ;
175+ }
176+ }
161177 deleteFile (index);
162178 }
163179 }
@@ -166,9 +182,17 @@ void OverwriteInfoDialog::delete_activated()
166182
167183void OverwriteInfoDialog::deleteTriggered ()
168184{
185+ auto root = m_FileSystemModel->rootDirectory ();
169186 if (m_FileSelection.count () == 0 ) {
170187 return ;
171188 } else if (m_FileSelection.count () == 1 ) {
189+ for (auto modDir : m_Organizer.managedGame ()->getModMappings ().keys ()) {
190+ if (root.absoluteFilePath (modDir).compare (
191+ m_FileSystemModel->filePath (m_FileSelection.at (0 )),
192+ Qt::CaseInsensitive) == 0 ) {
193+ return ;
194+ }
195+ }
172196 QString fileName = m_FileSystemModel->fileName (m_FileSelection.at (0 ));
173197 if (QMessageBox::question (
174198 this , tr (" Confirm" ),
@@ -185,18 +209,31 @@ void OverwriteInfoDialog::deleteTriggered()
185209 }
186210
187211 foreach (QModelIndex index, m_FileSelection) {
212+ for (auto modDir : m_Organizer.managedGame ()->getModMappings ().keys ()) {
213+ if (root.absoluteFilePath (modDir).compare (
214+ m_FileSystemModel->filePath (index),
215+ Qt::CaseInsensitive) == 0 ) {
216+ return ;
217+ }
218+ }
188219 deleteFile (index);
189220 }
190221}
191222
192223void OverwriteInfoDialog::renameTriggered ()
193224{
225+ auto root = m_FileSystemModel->rootDirectory ();
194226 QModelIndex selection = m_FileSelection.at (0 );
195227 QModelIndex index = selection.sibling (selection.row (), 0 );
196228 if (!index.isValid () || m_FileSystemModel->isReadOnly ()) {
197229 return ;
198230 }
199-
231+ for (auto modDir : m_Organizer.managedGame ()->getModMappings ().keys ()) {
232+ if (root.absoluteFilePath (modDir).compare (m_FileSystemModel->filePath (selection),
233+ Qt::CaseInsensitive) == 0 ) {
234+ return ;
235+ }
236+ }
200237 ui->filesView ->edit (index);
201238}
202239
0 commit comments