Ticket #1349: patch
File patch, 7.0 KB (added by , 13 years ago) |
---|
-
PoseView.cpp
2402 2402 be_clipboard->Unlock(); 2403 2403 } 2404 2404 break; 2405 2406 case kArrangeBy: 2407 { 2408 uint32 attrHash; 2409 if (message->FindInt32("attr_hash", (int32*)&attrHash) == B_OK) { 2410 if (ColumnFor(attrHash) == NULL) 2411 HandleAttrMenuItemSelected(message); 2412 2413 if (PrimarySort() == attrHash) 2414 attrHash = 0; 2415 2416 SetPrimarySort(attrHash); 2417 SetSecondarySort(0); 2418 Cleanup(true); 2419 } 2420 break; 2421 } 2422 case kArrangeReverseOrder: 2423 SetReverseSort(!fViewState->ReverseSort()); 2424 Cleanup(true); 2425 break; 2426 2405 2427 case kAttributeItem: 2406 2428 HandleAttrMenuItemSelected(message); 2407 2429 break; … … 2981 3003 AddToVSList(pose); 2982 3004 } 2983 3005 2984 // sort poselist if we are switching to list mode 2985 if (newMode == kListMode) 2986 SortPoses(); 2987 else 3006 SortPoses(); 3007 if (newMode != kListMode) 2988 3008 RecalcExtent(); 2989 3009 2990 3010 UpdateScrollRange(); -
ContainerWindow.cpp
567 567 fAttrMenu(NULL), 568 568 fWindowMenu(NULL), 569 569 fFileMenu(NULL), 570 fArrangeByMenu(NULL), 570 571 fSelectionWindow(NULL), 571 572 fTaskLoop(NULL), 572 573 fIsTrash(false), … … 886 887 if (PoseView()->ViewMode() == kListMode) 887 888 ShowAttributeMenu(); 888 889 890 PopulateArrangeByMenu(fArrangeByMenu); 891 889 892 int32 selectCount = PoseView()->SelectionList()->CountItems(); 890 893 891 894 SetupOpenWithMenu(fFileMenu); … … 1748 1751 1749 1752 1750 1753 void 1751 BContainerWindow::Set CleanUpItem(BMenu *menu)1754 BContainerWindow::SetArrangeMenu(BMenu *menu) 1752 1755 { 1753 1756 BMenuItem *item; 1754 1757 if ((item = menu->FindItem(kCleanup)) == NULL 1755 1758 && (item = menu->FindItem(kCleanupAll)) == NULL) 1756 1759 return; 1757 1760 1758 item-> SetEnabled(PoseView()->CountItems() > 01761 item->Menu()->SetEnabled(PoseView()->CountItems() > 0 1759 1762 && (PoseView()->ViewMode() != kListMode)); 1760 1763 1764 BMenu* arrangeMenu; 1765 1761 1766 if (modifiers() & B_SHIFT_KEY) { 1762 1767 item->SetLabel(B_TRANSLATE("Clean up all")); 1763 1768 item->SetShortcut('K', B_COMMAND_KEY | B_SHIFT_KEY); 1764 1769 item->SetMessage(new BMessage(kCleanupAll)); 1770 arrangeMenu = item->Menu(); 1765 1771 } else { 1766 1772 item->SetLabel(B_TRANSLATE("Clean up")); 1767 1773 item->SetShortcut('K', B_COMMAND_KEY); 1768 1774 item->SetMessage(new BMessage(kCleanup)); 1775 arrangeMenu = item->Menu(); 1769 1776 } 1777 MarkArrangeByMenu(arrangeMenu); 1770 1778 } 1771 1779 1772 1780 … … 1818 1826 // just create the attribute, decide to add it later 1819 1827 fAttrMenu = new BMenu(B_TRANSLATE("Attributes")); 1820 1828 NewAttributeMenu(fAttrMenu); 1829 PopulateArrangeByMenu(fArrangeByMenu); 1821 1830 } 1822 1831 1823 1832 … … 1977 1986 item->SetTarget(this); 1978 1987 menu->AddItem(item); 1979 1988 1980 item = new BMenuItem(B_TRANSLATE("Clean up"), new BMessage(kCleanup), 'K'); 1981 item->SetTarget(PoseView()); 1982 menu->AddItem(item); 1989 fArrangeByMenu = new BMenu(B_TRANSLATE("Arrange by")); 1990 menu->AddItem(fArrangeByMenu); 1983 1991 1984 1992 item = new BMenuItem(B_TRANSLATE("Select"B_UTF8_ELLIPSIS), 1985 1993 new BMessage(kShowSelectionWindow), 'A', B_SHIFT_KEY); … … 2744 2752 menu->AddItem(pasteItem); 2745 2753 menu->AddSeparatorItem(); 2746 2754 #endif 2747 menu->AddItem(new BMenuItem(B_TRANSLATE("Clean up"), 2748 new BMessage(kCleanup), 'K')); 2755 BMenu* arrangeBy = new BMenu(B_TRANSLATE("Arrange by")); 2756 PopulateArrangeByMenu(arrangeBy); 2757 2758 menu->AddItem(arrangeBy); 2759 2749 2760 menu->AddItem(new BMenuItem(B_TRANSLATE("Select"B_UTF8_ELLIPSIS), 2750 2761 new BMessage(kShowSelectionWindow), 'A', B_SHIFT_KEY)); 2751 2762 menu->AddItem(new BMenuItem(B_TRANSLATE("Select all"), … … 3055 3066 MarkNamedMenuItem(menu, kMiniIconMode, viewMode == kMiniIconMode); 3056 3067 3057 3068 SetCloseItem(menu); 3058 Set CleanUpItem(menu);3069 SetArrangeMenu(menu); 3059 3070 SetPasteItem(menu); 3060 3071 3061 3072 EnableNamedMenuItem(menu, kOpenParentDir, !TargetModel()->IsRoot()); … … 3258 3269 3259 3270 3260 3271 void 3272 BContainerWindow::MarkArrangeByMenu(BMenu* menu) 3273 { 3274 if (!menu) 3275 return; 3276 3277 int32 count = menu->CountItems(); 3278 for (int32 index = 0; index < count; index++) { 3279 BMenuItem* item = menu->ItemAt(index); 3280 if (item->Message()) { 3281 uint32 attrHash; 3282 if (item->Message()->FindInt32("attr_hash", (int32*)&attrHash) == B_OK) 3283 item->SetMarked(PoseView()->PrimarySort() == attrHash); 3284 else if (item->Command() == kArrangeReverseOrder) 3285 item->SetMarked(PoseView()->ReverseSort()); 3286 } 3287 } 3288 } 3289 3290 3291 void 3261 3292 BContainerWindow::AddMimeTypesToMenu() 3262 3293 { 3263 3294 AddMimeTypesToMenu(fAttrMenu); … … 3991 4022 } 3992 4023 3993 4024 4025 void 4026 BContainerWindow::PopulateArrangeByMenu(BMenu* menu) 4027 { 4028 if (!fAttrMenu || !menu) 4029 return; 4030 // empty fArrangeByMenu... 4031 BMenuItem* item; 4032 while ((item = menu->RemoveItem((int32)0)) != NULL) 4033 delete item; 4034 4035 int32 itemCount = fAttrMenu->CountItems(); 4036 for (int32 i = 0; i < itemCount; i++) { 4037 item = fAttrMenu->ItemAt(i); 4038 if (item->Command() == kAttributeItem) { 4039 BMessage* message = new BMessage(*(item->Message())); 4040 message->what = kArrangeBy; 4041 BMenuItem* newItem = new BMenuItem(item->Label(), message); 4042 newItem->SetTarget(PoseView()); 4043 menu->AddItem(newItem); 4044 } 4045 } 4046 4047 menu->AddSeparatorItem(); 4048 4049 item = new BMenuItem(B_TRANSLATE("Reverse order"), 4050 new BMessage(kArrangeReverseOrder)); 4051 4052 item->SetTarget(PoseView()); 4053 menu->AddItem(item); 4054 menu->AddSeparatorItem(); 4055 4056 4057 item = new BMenuItem(B_TRANSLATE("Clean up"), new BMessage(kCleanup), 'K'); 4058 item->SetTarget(PoseView()); 4059 menu->AddItem(item); 4060 } 4061 4062 3994 4063 // #pragma mark - 3995 4064 3996 4065 -
ContainerWindow.h
150 150 void AddMimeTypesToMenu(); 151 151 virtual void MarkAttributeMenu(BMenu *); 152 152 void MarkAttributeMenu(); 153 void MarkArrangeByMenu(BMenu *); 153 154 BMenuItem *NewAttributeMenuItem(const char *label, const char *name, 154 155 int32 type, float width, int32 align, bool editable, bool statField); 155 156 BMenuItem *NewAttributeMenuItem(const char *label, const char *name, … … 216 217 virtual void AddTrashContextMenus(BMenu *); 217 218 218 219 virtual void RepopulateMenus(); 220 void PopulateArrangeByMenu(BMenu* ); 219 221 220 222 virtual void SetCutItem(BMenu *); 221 223 virtual void SetCopyItem(BMenu *); 222 224 virtual void SetPasteItem(BMenu *); 223 virtual void Set CleanUpItem(BMenu *);225 virtual void SetArrangeMenu(BMenu *); 224 226 virtual void SetCloseItem(BMenu *); 225 227 virtual void SetupNavigationMenu(const entry_ref *, BMenu *); 226 228 virtual void SetupMoveCopyMenus(const entry_ref *, BMenu *); … … 268 270 BMenu *fAttrMenu; 269 271 BMenu *fWindowMenu; 270 272 BMenu *fFileMenu; 273 BMenu *fArrangeByMenu; 271 274 272 275 SelectionWindow *fSelectionWindow; 273 276 -
Commands.h
85 85 const uint32 kOpenDir = 'Topd'; 86 86 const uint32 kCleanup = 'Tcln'; 87 87 const uint32 kCleanupAll = 'Tcla'; 88 89 const uint32 kArrangeBy = 'ARBY'; 90 const uint32 kArrangeReverseOrder = 'ARRO'; 91 88 92 const uint32 kResizeToFit = 'Trtf'; 89 93 const uint32 kSelectMatchingEntries = 'Tsme'; 90 94 const uint32 kShowSelectionWindow = 'Tssw';