Tracker: style fixes to FindPanel

This commit is contained in:
John Scipione
2014-06-20 21:01:46 -04:00
parent 9f7b8c72a2
commit 58203edfc7
2 changed files with 33 additions and 19 deletions
+28 -15
View File
@@ -33,6 +33,8 @@ All rights reserved.
*/ */
#include "FindPanel.h"
#include <Application.h> #include <Application.h>
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
@@ -74,7 +76,6 @@ All rights reserved.
#include "AutoLock.h" #include "AutoLock.h"
#include "Commands.h" #include "Commands.h"
#include "ContainerWindow.h" #include "ContainerWindow.h"
#include "FindPanel.h"
#include "FSUtils.h" #include "FSUtils.h"
#include "FunctionObject.h" #include "FunctionObject.h"
#include "IconMenuItem.h" #include "IconMenuItem.h"
@@ -120,6 +121,7 @@ const int32 operators[] = {
B_GE, B_GE,
B_LE B_LE
}; };
static const char* operatorLabels[] = { static const char* operatorLabels[] = {
B_TRANSLATE_MARK("contains"), B_TRANSLATE_MARK("contains"),
B_TRANSLATE_MARK("is"), B_TRANSLATE_MARK("is"),
@@ -168,6 +170,9 @@ class MostUsedNames {
MostUsedNames gMostUsedMimeTypes("MostUsedMimeTypes", "Tracker"); MostUsedNames gMostUsedMimeTypes("MostUsedMimeTypes", "Tracker");
// #pragma mark - MoreOptionsStruct
void void
MoreOptionsStruct::EndianSwap(void*) MoreOptionsStruct::EndianSwap(void*)
{ {
@@ -204,7 +209,7 @@ MoreOptionsStruct::QueryTemporary(const BNode* node)
} }
// #pragma mark - // #pragma mark - FindWindow
FindWindow::FindWindow(const entry_ref* newRef, bool editIfTemplateOnly) FindWindow::FindWindow(const entry_ref* newRef, bool editIfTemplateOnly)
@@ -312,6 +317,7 @@ FindWindow::SwitchToTemplate(const entry_ref* ref)
ThrowOnInitCheckError(&templateFile); ThrowOnInitCheckError(&templateFile);
fBackground->SwitchToTemplate(&templateFile); fBackground->SwitchToTemplate(&templateFile);
} catch (...) { } catch (...) {
;
} }
} }
@@ -415,15 +421,18 @@ FindWindow::SaveQueryAttributes(BNode* file, bool queryTemplate)
status_t status_t
FindWindow::SaveQueryAsAttributes(BNode* file, BEntry* entry, FindWindow::SaveQueryAsAttributes(BNode* file, BEntry* entry,
bool queryTemplate, const BMessage* oldAttributes, const BPoint* oldLocation) bool queryTemplate, const BMessage* oldAttributes,
const BPoint* oldLocation)
{ {
if (oldAttributes) if (oldAttributes != NULL) {
// revive old window settings // revive old window settings
BContainerWindow::SetLayoutState(file, oldAttributes); BContainerWindow::SetLayoutState(file, oldAttributes);
}
if (oldLocation) if (oldLocation != NULL) {
// and the file's location // and the file's location
FSSetPoseLocation(entry, *oldLocation); FSSetPoseLocation(entry, *oldLocation);
}
BNodeInfo(file).SetType(queryTemplate BNodeInfo(file).SetType(queryTemplate
? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE); ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE);
@@ -433,9 +442,10 @@ FindWindow::SaveQueryAsAttributes(BNode* file, BEntry* entry,
GetPredicateString(predicate, dynamicDate); GetPredicateString(predicate, dynamicDate);
file->WriteAttrString(kAttrQueryString, &predicate); file->WriteAttrString(kAttrQueryString, &predicate);
if (dynamicDate) if (dynamicDate) {
file->WriteAttr(kAttrDynamicDateQuery, B_BOOL_TYPE, 0, &dynamicDate, file->WriteAttr(kAttrDynamicDateQuery, B_BOOL_TYPE, 0, &dynamicDate,
sizeof(dynamicDate)); sizeof(dynamicDate));
}
int32 tmp = 1; int32 tmp = 1;
file->WriteAttr("_trk/recentQuery", B_INT32_TYPE, 0, &tmp, sizeof(int32)); file->WriteAttr("_trk/recentQuery", B_INT32_TYPE, 0, &tmp, sizeof(int32));
@@ -651,9 +661,10 @@ FindWindow::MessageReceived(BMessage* message)
entry_ref tmpRef; entry_ref tmpRef;
entry.GetRef(&tmpRef); entry.GetRef(&tmpRef);
fFile = TryOpening(&tmpRef); fFile = TryOpening(&tmpRef);
if (fFile) { if (fFile != NULL) {
fRef = tmpRef; fRef = tmpRef;
SaveQueryAsAttributes(fFile, &entry, queryTemplate, 0, 0); SaveQueryAsAttributes(fFile, &entry, queryTemplate,
0, 0);
// try to save whatever state we aleady have // try to save whatever state we aleady have
// to the new query so that if the user // to the new query so that if the user
// opens it before runing it from the find panel, // opens it before runing it from the find panel,
@@ -693,7 +704,7 @@ FindWindow::MessageReceived(BMessage* message)
} }
// #pragma mark - // #pragma mark - FindPanel
FindPanel::FindPanel(BFile* node, FindWindow* parent, bool fromTemplate, FindPanel::FindPanel(BFile* node, FindWindow* parent, bool fromTemplate,
@@ -759,7 +770,8 @@ FindPanel::FindPanel(BFile* node, FindWindow* parent, bool fromTemplate,
BRect draggableRect = DraggableIcon::PreferredRect(draggableIconOrigin, BRect draggableRect = DraggableIcon::PreferredRect(draggableIconOrigin,
B_LARGE_ICON); B_LARGE_ICON);
fDraggableIcon = new DraggableQueryIcon(draggableRect, fDraggableIcon = new DraggableQueryIcon(draggableRect,
"saveHere", &dragNDropMessage, self, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); "saveHere", &dragNDropMessage, self,
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
fDraggableIcon->SetExplicitMaxSize( fDraggableIcon->SetExplicitMaxSize(
BSize(draggableRect.right - draggableRect.left, BSize(draggableRect.right - draggableRect.left,
draggableRect.bottom - draggableRect.top)); draggableRect.bottom - draggableRect.top));
@@ -824,7 +836,8 @@ FindPanel::FindPanel(BFile* node, FindWindow* parent, bool fromTemplate,
BBox* queryBox = new BBox("Outer Controls"); BBox* queryBox = new BBox("Outer Controls");
queryBox->SetLabel(new BMenuField("RecentQueries", NULL, fRecentQueries)); queryBox->SetLabel(new BMenuField("RecentQueries", NULL, fRecentQueries));
BGroupView* queryBoxView = new BGroupView(B_VERTICAL, B_USE_DEFAULT_SPACING); BGroupView* queryBoxView = new BGroupView(B_VERTICAL,
B_USE_DEFAULT_SPACING);
queryBoxView->GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING); queryBoxView->GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING);
queryBox->AddChild(queryBoxView); queryBox->AddChild(queryBoxView);
@@ -837,7 +850,7 @@ FindPanel::FindPanel(BFile* node, FindWindow* parent, bool fromTemplate,
.Add(fMimeTypeField) .Add(fMimeTypeField)
.Add(mimeTypeFieldSpacer) .Add(mimeTypeFieldSpacer)
.Add(searchModeField) .Add(searchModeField)
.Add(BSpaceLayoutItem::CreateHorizontalStrut(B_USE_DEFAULT_SPACING)) .AddStrut(B_USE_DEFAULT_SPACING)
.Add(volumeField) .Add(volumeField)
.End() .End()
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER)) .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
@@ -902,11 +915,11 @@ FindPanel::AttachedToWindow()
} }
BButton* button = dynamic_cast<BButton*>(FindView("remove button")); BButton* button = dynamic_cast<BButton*>(FindView("remove button"));
if (button) if (button != NULL)
button->SetTarget(this); button->SetTarget(this);
button = dynamic_cast<BButton*>(FindView("add button")); button = dynamic_cast<BButton*>(FindView("add button"));
if (button) if (button != NULL)
button->SetTarget(this); button->SetTarget(this);
fVolMenu->SetTargetForItems(this); fVolMenu->SetTargetForItems(this);
@@ -919,7 +932,7 @@ FindPanel::AttachedToWindow()
} }
fMimeTypeMenu->SetTargetForItems(this); fMimeTypeMenu->SetTargetForItems(this);
if (fDraggableIcon) if (fDraggableIcon != NULL)
fDraggableIcon->SetTarget(BMessenger(this)); fDraggableIcon->SetTarget(BMessenger(this));
fRecentQueries->SetTargetForItems(Window()); fRecentQueries->SetTargetForItems(Window());
+3 -2
View File
@@ -36,11 +36,11 @@ All rights reserved.
#include <ByteOrder.h> #include <ByteOrder.h>
#include <ObjectList.h>
#include <Window.h> #include <Window.h>
#include <View.h> #include <View.h>
#include "DialogPane.h" #include "DialogPane.h"
#include "ObjectList.h"
#include "MimeTypeList.h" #include "MimeTypeList.h"
#include "Utilities.h" #include "Utilities.h"
#include "NodeWalker.h" #include "NodeWalker.h"
@@ -352,4 +352,5 @@ class DraggableQueryIcon : public DraggableIcon {
using namespace BPrivate; using namespace BPrivate;
#endif
#endif // _FIND_PANEL_H