2 * Copyright 2013-2015 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * John Scipione, jscipione@gmail.com
7 * Ingo Weinhold, ingo_weinhold@gmx.de
14 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
16 Permission is hereby granted, free of charge, to any person obtaining a copy of
17 this software and associated documentation files (the "Software"), to deal in
18 the Software without restriction, including without limitation the rights to
19 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
20 of the Software, and to permit persons to whom the Software is furnished to do
21 so, subject to the following conditions:
23 The above copyright notice and this permission notice applies to all licensees
24 and shall be included in all copies or substantial portions of the Software.
26 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
28 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
29 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
30 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
31 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 Except as contained in this notice, the name of Be Incorporated shall not be
34 used in advertising or otherwise to promote the sale, use or other dealings in
35 this Software without prior written authorization from Be Incorporated.
37 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
38 of Be Incorporated in the United States and other countries. Other brand product
39 names are registered trademarks or trademarks of their respective holders.
44 #include "VirtualDirectoryWindow.h"
49 #include <AutoLocker.h>
52 #include "VirtualDirectoryManager.h"
53 #include "VirtualDirectoryPoseView.h"
56 #undef B_TRANSLATION_CONTEXT
57 #define B_TRANSLATION_CONTEXT "VirtualDirectoryWindow"
62 // #pragma mark - VirtualDirectoryWindow
65 VirtualDirectoryWindow::VirtualDirectoryWindow(LockingList
<BWindow
>* windowList
,
66 uint32 containerWindowFlags
, window_look look
, window_feel feel
,
67 uint32 flags
, uint32 workspace
)
69 BContainerWindow(windowList
, containerWindowFlags
, look
, feel
, flags
,
76 VirtualDirectoryWindow::CreatePoseView(Model
* model
)
78 fPoseView
= NewPoseView(model
, kListMode
);
79 if (fPoseView
== NULL
)
82 fBorderedView
->GroupLayout()->AddView(fPoseView
);
83 fBorderedView
->EnableBorderHighlight(false);
84 fBorderedView
->GroupLayout()->SetInsets(0, 0, 1, 1);
89 VirtualDirectoryWindow::NewPoseView(Model
* model
, uint32 viewMode
)
91 // If the model (or rather the entry_ref to it) came from another
92 // application, it may refer to a subdirectory we cannot use directly. The
93 // manager resolves the given refs to new ones, if necessary.
94 VirtualDirectoryManager
* manager
= VirtualDirectoryManager::Instance();
99 AutoLocker
<VirtualDirectoryManager
> managerLocker(manager
);
100 BStringList directoryPaths
;
103 if (manager
->ResolveDirectoryPaths(*model
->NodeRef(),
104 *model
->EntryRef(), directoryPaths
, &nodeRef
, &entryRef
)
109 if (nodeRef
!= *model
->NodeRef()) {
110 // Indeed a new file. Create a new model.
111 Model
* newModel
= new(std::nothrow
) Model(&entryRef
);
112 if (newModel
== NULL
|| newModel
->InitCheck() != B_OK
) {
122 return new VirtualDirectoryPoseView(model
);
126 VirtualDirectoryPoseView
*
127 VirtualDirectoryWindow::PoseView() const
129 return static_cast<VirtualDirectoryPoseView
*>(fPoseView
);
134 VirtualDirectoryWindow::AddWindowMenu(BMenu
* menu
)
139 BMenu
* listViewMenu
= new BMenu(B_TRANSLATE("List view"));
141 message
= new BMessage(kListMode
);
142 message
->AddInt32("icon_size", B_MINI_ICON
);
143 item
= new BMenuItem(listViewMenu
, message
);
144 item
->SetShortcut('3', B_COMMAND_KEY
);
145 item
->SetTarget(PoseView());
148 message
= new BMessage(kListMode
);
149 message
->AddInt32("icon_size", B_MINI_ICON
);
150 item
= new BMenuItem(B_TRANSLATE("Mini"), message
);
151 item
->SetTarget(PoseView());
152 listViewMenu
->AddItem(item
);
154 message
= new BMessage(kListMode
);
155 message
->AddInt32("icon_size", B_LARGE_ICON
);
156 item
= new BMenuItem(B_TRANSLATE("Large"), message
);
157 item
->SetTarget(PoseView());
158 listViewMenu
->AddItem(item
);
160 listViewMenu
->SetTargetForItems(PoseView());
162 menu
->AddSeparatorItem();
164 item
= new BMenuItem(B_TRANSLATE("Resize to fit"),
165 new BMessage(kResizeToFit
), 'Y');
166 item
->SetTarget(this);
169 item
= new BMenuItem(B_TRANSLATE("Select" B_UTF8_ELLIPSIS
),
170 new BMessage(kShowSelectionWindow
), 'A', B_SHIFT_KEY
);
171 item
->SetTarget(PoseView());
174 item
= new BMenuItem(B_TRANSLATE("Select all"),
175 new BMessage(B_SELECT_ALL
), 'A');
176 item
->SetTarget(PoseView());
179 item
= new BMenuItem(B_TRANSLATE("Invert selection"),
180 new BMessage(kInvertSelection
), 'S');
181 item
->SetTarget(PoseView());
184 item
= new BMenuItem(B_TRANSLATE("Open parent"),
185 new BMessage(kOpenParentDir
), B_UP_ARROW
);
186 item
->SetTarget(PoseView());
189 item
= new BMenuItem(B_TRANSLATE("Close"),
190 new BMessage(B_QUIT_REQUESTED
), 'W');
191 item
->SetTarget(this);
197 VirtualDirectoryWindow::AddWindowContextMenus(BMenu
* menu
)
199 BMenuItem
* resizeItem
= new BMenuItem(B_TRANSLATE("Resize to fit"),
200 new BMessage(kResizeToFit
), 'Y');
201 menu
->AddItem(resizeItem
);
202 menu
->AddItem(new BMenuItem(B_TRANSLATE("Select" B_UTF8_ELLIPSIS
),
203 new BMessage(kShowSelectionWindow
), 'A', B_SHIFT_KEY
));
204 menu
->AddItem(new BMenuItem(B_TRANSLATE("Select all"),
205 new BMessage(B_SELECT_ALL
), 'A'));
206 BMenuItem
* closeItem
= new BMenuItem(B_TRANSLATE("Close"),
207 new BMessage(B_QUIT_REQUESTED
), 'W');
208 menu
->AddItem(closeItem
);
209 // target items as needed
210 menu
->SetTargetForItems(PoseView());
211 closeItem
->SetTarget(this);
212 resizeItem
->SetTarget(this);
215 } // namespace BPrivate