OSDN Git Service

BUG: [ 1882019 ] Read-only does not disable Delete in main menu
authorKimmo Varis <kimmov@gmail.com>
Fri, 1 Feb 2008 14:34:51 +0000 (14:34 +0000)
committerKimmo Varis <kimmov@gmail.com>
Fri, 1 Feb 2008 14:34:51 +0000 (14:34 +0000)
Docs/Users/ChangeLog.txt
Src/DirActions.cpp
Src/DirView.cpp
Src/Languages/English.pot

index d462d27..a38577a 100644 (file)
@@ -9,6 +9,7 @@ WinMerge 2.7.7.4
   Use radio symbol for current EOL menu item (#1869755)
   Ask and create pair for unique folder and open them (#1881454)
   BugFix: Always return 0 to command line (#1854419)
+  BugFix: Merge/Delete deleted items from read-only sides (#1882019)
   Translation updates:
   - Croatian (r4952)
   - Japanese (r4962)
index b1f91f1..765b384 100644 (file)
@@ -414,6 +414,10 @@ void CDirView::DoDelBoth()
 
 /**
  * @brief Delete left, right or both items.
+ * @note Usually we don't need to check for read-only in this level of code.
+ *   Usually we can disable handling read-only items/sides by disabling GUI
+ *   element. But in this case the GUI element effects to both sides and can
+ *   be selected when another side is read-only.
  */
 void CDirView::DoDelAll()
 {
@@ -435,46 +439,57 @@ void CDirView::DoDelAll()
 
                        int leftFlags = ALLOW_DONT_CARE;
                        int rightFlags = ALLOW_DONT_CARE;
+                       BOOL leftRO = GetDocument()->GetReadOnly(TRUE);
+                       BOOL rightRO = GetDocument()->GetReadOnly(FALSE);
                        FileActionItem act;
-                       if (IsItemDeletableOnBoth(di))
+                       if (IsItemDeletableOnBoth(di) && !leftRO && !rightRO)
                        {
                                leftFlags = ALLOW_ALL;
                                rightFlags = ALLOW_ALL;
                                act.src = srFile;
                                act.dest = slFile;
+                               act.UIResult = FileActionItem::UI_DEL_BOTH;
                        }
-                       else if (IsItemDeletableOnLeft(di))
+                       else if (IsItemDeletableOnLeft(di) && !leftRO)
                        {
                                leftFlags = ALLOW_ALL;
                                act.src = slFile;
+                               act.UIResult = FileActionItem::UI_DEL_LEFT;
                        }
-                       else if (IsItemDeletableOnRight(di))
+                       else if (IsItemDeletableOnRight(di) && !rightRO)
                        {
                                rightFlags = ALLOW_ALL;
                                act.src = srFile;
+                               act.UIResult = FileActionItem::UI_DEL_RIGHT;
                        }
 
-                       // We must first check that paths still exists
-                       CString failpath;
-                       BOOL succeed = CheckPathsExist(slFile.c_str(), srFile.c_str(), leftFlags,
-                                       rightFlags, failpath);
-                       if (succeed == FALSE)
+                       // Check one of sides is actually being added to removal list
+                       if (leftFlags != ALLOW_DONT_CARE || rightFlags != ALLOW_DONT_CARE)
                        {
-                               WarnContentsChanged(failpath);
-                               return;
-                       }
+                               // We must first check that paths still exists
+                               CString failpath;
+                               BOOL succeed = CheckPathsExist(slFile.c_str(), srFile.c_str(), leftFlags,
+                                               rightFlags, failpath);
+                               if (succeed == FALSE)
+                               {
+                                       WarnContentsChanged(failpath);
+                                       return;
+                               }
 
-                       act.dirflag = di.diffcode.isDirectory();
-                       act.context = sel;
-                       act.atype = actType;
-                       act.UIResult = FileActionItem::UI_DEL_BOTH;
-                       actionScript.AddActionItem(act);
+                               act.dirflag = di.diffcode.isDirectory();
+                               act.context = sel;
+                               act.atype = actType;
+                               actionScript.AddActionItem(act);
+                               ++selCount;
+                       }
                }
-               ++selCount;
        }
 
-       // Now we prompt, and execute actions
-       ConfirmAndPerformActions(actionScript, selCount);
+       if (selCount > 0)
+       {
+               // Now we prompt, and execute actions
+               ConfirmAndPerformActions(actionScript, selCount);
+       }
 }
 
 /**
index d5f89d3..2cae683 100644 (file)
@@ -1713,10 +1713,18 @@ void CDirView::DoUpdateOpenRightWith(CCmdUI* pCmdUI)
 }
 
 /**
- * @brief Update main menu "Merge | Delete" item
+ * @brief Update main menu "Merge | Delete" item.
+ * @param [in] pCmdUI Item to modify.
  */
 void CDirView::DoUpdateDelete(CCmdUI* pCmdUI)
 {
+       // If both sides are read-only, then there is nothing to delete
+       if (GetDocument()->GetReadOnly(TRUE) && GetDocument()->GetReadOnly(FALSE))
+       {
+               pCmdUI->Enable(FALSE);
+               return;
+       }
+
        // If no selected items, disable
        int count = GetSelectedCount();
        if (count == 0)
index 3c7777a..a6ab404 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: WinMerge\n"
 "Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?group_id=13216&atid=113216\n"
-"POT-Creation-Date: 2008-02-01 16:18+0000\n"
+"POT-Creation-Date: 2008-02-01 16:34+0000\n"
 "PO-Revision-Date: \n"
 "Last-Translator: \n"
 "Language-Team: English <winmerge-translate@lists.sourceforge.net>\n"