Renamed PeopleWindow/View to PersonWindow/View, since they only show one person at a time.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40462 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2011-02-12 17:40:58 +00:00
parent 8f5c65ecfa
commit 968ec77e1f
9 changed files with 61 additions and 75 deletions

View File

@ -5,8 +5,8 @@ UsePrivateHeaders shared ;
Application People : main.cpp Application People : main.cpp
AttributeTextControl.cpp AttributeTextControl.cpp
PeopleApp.cpp PeopleApp.cpp
PeopleView.cpp PersonView.cpp
PeopleWindow.cpp PersonWindow.cpp
: libbe.so libtracker.so $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) : libbe.so libtracker.so $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS)
: People.rdef : People.rdef
; ;
@ -15,6 +15,6 @@ DoCatalogs People :
x-vnd.Be-PEPL x-vnd.Be-PEPL
: :
PeopleApp.cpp PeopleApp.cpp
PeopleView.cpp PersonView.cpp
PeopleWindow.cpp PersonWindow.cpp
; ;

View File

@ -10,7 +10,7 @@ resource app_version {
internal = 0, internal = 0,
short_info = "People", short_info = "People",
long_info = "People ©1999 Be, Inc. ©2005-2009 Haiku, Inc." long_info = "People ©1999 Be, Inc. ©2005-2011 Haiku, Inc."
}; };
resource app_flags B_SINGLE_LAUNCH; resource app_flags B_SINGLE_LAUNCH;

View File

@ -12,6 +12,8 @@
*/ */
#include "PeopleApp.h"
#include <Alert.h> #include <Alert.h>
#include <AutoDeleter.h> #include <AutoDeleter.h>
#include <Bitmap.h> #include <Bitmap.h>
@ -25,8 +27,7 @@
#include <Volume.h> #include <Volume.h>
#include <VolumeRoster.h> #include <VolumeRoster.h>
#include "PeopleApp.h" #include "PersonWindow.h"
#include "PeopleWindow.h"
#include "PersonIcons.h" #include "PersonIcons.h"
#include <string.h> #include <string.h>
@ -250,7 +251,7 @@ TPeopleApp::RefsReceived(BMessage* message)
entry_ref ref; entry_ref ref;
message->FindRef("refs", index++, &ref); message->FindRef("refs", index++, &ref);
TPeopleWindow* window = _FindWindow(ref); PersonWindow* window = _FindWindow(ref);
if (window != NULL) if (window != NULL)
window->Activate(true); window->Activate(true);
else { else {
@ -273,10 +274,10 @@ TPeopleApp::ReadyToRun()
// #pragma mark - // #pragma mark -
TPeopleWindow* PersonWindow*
TPeopleApp::_NewWindow(entry_ref* ref) TPeopleApp::_NewWindow(entry_ref* ref)
{ {
TPeopleWindow* window = new TPeopleWindow(fPosition, PersonWindow* window = new PersonWindow(fPosition,
B_TRANSLATE("New person"), kNameAttribute, B_TRANSLATE("New person"), kNameAttribute,
kCategoryAttribute, ref); kCategoryAttribute, ref);
@ -300,7 +301,7 @@ TPeopleApp::_NewWindow(entry_ref* ref)
void void
TPeopleApp::_AddAttributes(TPeopleWindow* window) const TPeopleApp::_AddAttributes(PersonWindow* window) const
{ {
int32 count = fAttributes.CountItems(); int32 count = fAttributes.CountItems();
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
@ -314,11 +315,11 @@ TPeopleApp::_AddAttributes(TPeopleWindow* window) const
} }
TPeopleWindow* PersonWindow*
TPeopleApp::_FindWindow(const entry_ref& ref) const TPeopleApp::_FindWindow(const entry_ref& ref) const
{ {
for (int32 i = 0; BWindow* window = WindowAt(i); i++) { for (int32 i = 0; BWindow* window = WindowAt(i); i++) {
TPeopleWindow* personWindow = dynamic_cast<TPeopleWindow*>(window); PersonWindow* personWindow = dynamic_cast<PersonWindow*>(window);
if (personWindow == NULL) if (personWindow == NULL)
continue; continue;
if (personWindow->RefersPersonFile(ref)) if (personWindow->RefersPersonFile(ref))

View File

@ -30,7 +30,7 @@ enum {
M_WINDOW_QUITS = 'wndq' M_WINDOW_QUITS = 'wndq'
}; };
class TPeopleWindow; class PersonWindow;
class TPeopleApp : public BApplication { class TPeopleApp : public BApplication {
public: public:
@ -44,9 +44,9 @@ public:
virtual void ReadyToRun(); virtual void ReadyToRun();
private: private:
TPeopleWindow* _FindWindow(const entry_ref&) const; PersonWindow* _FindWindow(const entry_ref&) const;
TPeopleWindow* _NewWindow(entry_ref* = NULL); PersonWindow* _NewWindow(entry_ref* = NULL);
void _AddAttributes(TPeopleWindow* window) const; void _AddAttributes(PersonWindow* window) const;
void _SavePreferences(BMessage* message) const; void _SavePreferences(BMessage* message) const;
private: private:

View File

@ -11,7 +11,7 @@
*/ */
#include "PeopleView.h" #include "PersonView.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -37,7 +37,7 @@
#define B_TRANSLATE_CONTEXT "People" #define B_TRANSLATE_CONTEXT "People"
TPeopleView::TPeopleView(const char* name, const char* categoryAttribute, PersonView::PersonView(const char* name, const char* categoryAttribute,
const entry_ref *ref) const entry_ref *ref)
: :
BGridView(), BGridView(),
@ -55,14 +55,14 @@ TPeopleView::TPeopleView(const char* name, const char* categoryAttribute,
} }
TPeopleView::~TPeopleView() PersonView::~PersonView()
{ {
delete fFile; delete fFile;
} }
void void
TPeopleView::AddAttribute(const char* label, const char* attribute) PersonView::AddAttribute(const char* label, const char* attribute)
{ {
// TODO: We could check if this attribute has already been added. // TODO: We could check if this attribute has already been added.
@ -95,7 +95,7 @@ TPeopleView::AddAttribute(const char* label, const char* attribute)
void void
TPeopleView::MakeFocus(bool focus) PersonView::MakeFocus(bool focus)
{ {
if (focus && fControls.CountItems() > 0) if (focus && fControls.CountItems() > 0)
fControls.ItemAt(0)->MakeFocus(); fControls.ItemAt(0)->MakeFocus();
@ -105,7 +105,7 @@ TPeopleView::MakeFocus(bool focus)
void void
TPeopleView::MessageReceived(BMessage* msg) PersonView::MessageReceived(BMessage* msg)
{ {
switch (msg->what) { switch (msg->what) {
case M_SAVE: case M_SAVE:
@ -140,7 +140,7 @@ TPeopleView::MessageReceived(BMessage* msg)
void void
TPeopleView::BuildGroupMenu() PersonView::BuildGroupMenu()
{ {
BMenuItem* item; BMenuItem* item;
while ((item = fGroups->ItemAt(0)) != NULL) { while ((item = fGroups->ItemAt(0)) != NULL) {
@ -219,7 +219,7 @@ TPeopleView::BuildGroupMenu()
void void
TPeopleView::CreateFile(const entry_ref* ref) PersonView::CreateFile(const entry_ref* ref)
{ {
delete fFile; delete fFile;
fFile = new BFile(ref, B_READ_WRITE); fFile = new BFile(ref, B_READ_WRITE);
@ -228,7 +228,7 @@ TPeopleView::CreateFile(const entry_ref* ref)
bool bool
TPeopleView::IsSaved() const PersonView::IsSaved() const
{ {
for (int32 i = fControls.CountItems() - 1; i >= 0; i--) { for (int32 i = fControls.CountItems() - 1; i >= 0; i--) {
if (fControls.ItemAt(i)->HasChanged()) if (fControls.ItemAt(i)->HasChanged())
@ -240,7 +240,7 @@ TPeopleView::IsSaved() const
void void
TPeopleView::Save() PersonView::Save()
{ {
int32 count = fControls.CountItems(); int32 count = fControls.CountItems();
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
@ -254,7 +254,7 @@ TPeopleView::Save()
const char* const char*
TPeopleView::AttributeValue(const char* attribute) const PersonView::AttributeValue(const char* attribute) const
{ {
for (int32 i = fControls.CountItems() - 1; i >= 0; i--) { for (int32 i = fControls.CountItems() - 1; i >= 0; i--) {
if (fControls.ItemAt(i)->Attribute() == attribute) if (fControls.ItemAt(i)->Attribute() == attribute)
@ -266,7 +266,7 @@ TPeopleView::AttributeValue(const char* attribute) const
void void
TPeopleView::SetAttribute(const char* attribute, bool update) PersonView::SetAttribute(const char* attribute, bool update)
{ {
char* value = NULL; char* value = NULL;
attr_info info; attr_info info;
@ -282,7 +282,7 @@ TPeopleView::SetAttribute(const char* attribute, bool update)
void void
TPeopleView::SetAttribute(const char* attribute, const char* value, PersonView::SetAttribute(const char* attribute, const char* value,
bool update) bool update)
{ {
if (!LockLooper()) if (!LockLooper())
@ -324,7 +324,7 @@ TPeopleView::SetAttribute(const char* attribute, const char* value,
bool bool
TPeopleView::IsTextSelected() const PersonView::IsTextSelected() const
{ {
for (int32 i = fControls.CountItems() - 1; i >= 0; i--) { for (int32 i = fControls.CountItems() - 1; i >= 0; i--) {
BTextView* text = fControls.ItemAt(i)->TextView(); BTextView* text = fControls.ItemAt(i)->TextView();

View File

@ -9,8 +9,8 @@
* Copyright 1999, Be Incorporated. All Rights Reserved. * Copyright 1999, Be Incorporated. All Rights Reserved.
* This file may be used under the terms of the Be Sample Code License. * This file may be used under the terms of the Be Sample Code License.
*/ */
#ifndef PEOPLE_VIEW_H #ifndef PERSON_VIEW_H
#define PEOPLE_VIEW_H #define PERSON_VIEW_H
#include <GridView.h> #include <GridView.h>
@ -30,12 +30,12 @@ enum {
}; };
class TPeopleView : public BGridView { class PersonView : public BGridView {
public: public:
TPeopleView(const char* name, PersonView(const char* name,
const char* categoryAttribute, const char* categoryAttribute,
const entry_ref* ref); const entry_ref* ref);
virtual ~TPeopleView(); virtual ~PersonView();
virtual void MakeFocus(bool focus = true); virtual void MakeFocus(bool focus = true);
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
@ -66,4 +66,4 @@ private:
BString fCategoryAttribute; BString fCategoryAttribute;
}; };
#endif // PEOPLE_VIEW_H #endif // PERSON_VIEW_H

View File

@ -10,7 +10,7 @@
* This file may be used under the terms of the Be Sample Code License. * This file may be used under the terms of the Be Sample Code License.
*/ */
#include "PeopleWindow.h" #include "PersonWindow.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -34,14 +34,14 @@
#include <Volume.h> #include <Volume.h>
#include "PeopleApp.h" #include "PeopleApp.h"
#include "PeopleView.h" #include "PersonView.h"
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "People" #define B_TRANSLATE_CONTEXT "People"
TPeopleWindow::TPeopleWindow(BRect frame, const char* title, PersonWindow::PersonWindow(BRect frame, const char* title,
const char* nameAttribute, const char* categoryAttribute, const char* nameAttribute, const char* categoryAttribute,
const entry_ref* ref) const entry_ref* ref)
: :
@ -100,7 +100,7 @@ TPeopleWindow::TPeopleWindow(BRect frame, const char* title,
} else } else
_SetToRef(NULL); _SetToRef(NULL);
fView = new TPeopleView("PeopleView", categoryAttribute, fRef); fView = new PersonView("PeopleView", categoryAttribute, fRef);
BLayoutBuilder::Group<>(this, B_VERTICAL, 0) BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(0, 0, 0, 0) .SetInsets(0, 0, 0, 0)
@ -112,14 +112,14 @@ TPeopleWindow::TPeopleWindow(BRect frame, const char* title,
} }
TPeopleWindow::~TPeopleWindow() PersonWindow::~PersonWindow()
{ {
_SetToRef(NULL); _SetToRef(NULL);
} }
void void
TPeopleWindow::MenusBeginning() PersonWindow::MenusBeginning()
{ {
bool enabled = !fView->IsSaved(); bool enabled = !fView->IsSaved();
fSave->SetEnabled(enabled); fSave->SetEnabled(enabled);
@ -147,7 +147,7 @@ TPeopleWindow::MenusBeginning()
void void
TPeopleWindow::MessageReceived(BMessage* msg) PersonWindow::MessageReceived(BMessage* msg)
{ {
char str[256]; char str[256];
BDirectory directory; BDirectory directory;
@ -263,7 +263,7 @@ TPeopleWindow::MessageReceived(BMessage* msg)
bool bool
TPeopleWindow::QuitRequested() PersonWindow::QuitRequested()
{ {
status_t result; status_t result;
@ -296,7 +296,7 @@ TPeopleWindow::QuitRequested()
void void
TPeopleWindow::Show() PersonWindow::Show()
{ {
fView->MakeFocus(); fView->MakeFocus();
BWindow::Show(); BWindow::Show();
@ -304,14 +304,14 @@ TPeopleWindow::Show()
void void
TPeopleWindow::AddAttribute(const char* label, const char* attribute) PersonWindow::AddAttribute(const char* label, const char* attribute)
{ {
fView->AddAttribute(label, attribute); fView->AddAttribute(label, attribute);
} }
void void
TPeopleWindow::SaveAs() PersonWindow::SaveAs()
{ {
char name[B_FILE_NAME_LENGTH]; char name[B_FILE_NAME_LENGTH];
_GetDefaultFileName(name); _GetDefaultFileName(name);
@ -346,7 +346,7 @@ TPeopleWindow::SaveAs()
bool bool
TPeopleWindow::RefersPersonFile(const entry_ref& ref) const PersonWindow::RefersPersonFile(const entry_ref& ref) const
{ {
if (fRef == NULL) if (fRef == NULL)
return false; return false;
@ -355,7 +355,7 @@ TPeopleWindow::RefersPersonFile(const entry_ref& ref) const
void void
TPeopleWindow::_GetDefaultFileName(char* name) PersonWindow::_GetDefaultFileName(char* name)
{ {
strncpy(name, fView->AttributeValue(fNameAttribute), B_FILE_NAME_LENGTH); strncpy(name, fView->AttributeValue(fNameAttribute), B_FILE_NAME_LENGTH);
while (*name) { while (*name) {
@ -367,7 +367,7 @@ TPeopleWindow::_GetDefaultFileName(char* name)
void void
TPeopleWindow::_SetToRef(entry_ref* ref) PersonWindow::_SetToRef(entry_ref* ref)
{ {
if (fRef != NULL) { if (fRef != NULL) {
_WatchChanges(false); _WatchChanges(false);
@ -381,7 +381,7 @@ TPeopleWindow::_SetToRef(entry_ref* ref)
void void
TPeopleWindow::_WatchChanges(bool enable) PersonWindow::_WatchChanges(bool enable)
{ {
if (fRef == NULL) if (fRef == NULL)
return; return;

View File

@ -8,8 +8,8 @@
* Copyright 1999, Be Incorporated. All Rights Reserved. * Copyright 1999, Be Incorporated. All Rights Reserved.
* This file may be used under the terms of the Be Sample Code License. * This file may be used under the terms of the Be Sample Code License.
*/ */
#ifndef PEOPLE_WINDOW_H #ifndef PERSON_WINDOW_H
#define PEOPLE_WINDOW_H #define PERSON_WINDOW_H
#include <String.h> #include <String.h>
@ -21,19 +21,19 @@
#define WIND_HEIGHT 340 #define WIND_HEIGHT 340
class TPeopleView; class PersonView;
class BFilePanel; class BFilePanel;
class BMenuItem; class BMenuItem;
class TPeopleWindow : public BWindow { class PersonWindow : public BWindow {
public: public:
TPeopleWindow(BRect frame, const char* title, PersonWindow(BRect frame, const char* title,
const char* nameAttribute, const char* nameAttribute,
const char* categoryAttribute, const char* categoryAttribute,
const entry_ref* ref); const entry_ref* ref);
virtual ~TPeopleWindow(); virtual ~PersonWindow();
virtual void MenusBeginning(); virtual void MenusBeginning();
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
@ -62,10 +62,10 @@ private:
BMenuItem* fRevert; BMenuItem* fRevert;
BMenuItem* fSave; BMenuItem* fSave;
BMenuItem* fUndo; BMenuItem* fUndo;
TPeopleView* fView; PersonView* fView;
BString fNameAttribute; BString fNameAttribute;
}; };
#endif // PEOPLE_WINDOW_H #endif // PERSON_WINDOW_H

View File

@ -1,15 +0,0 @@
People -- README
This directory contains the source code for building
the standard People application that ships with BeOS.
You can use this application to create Person records,
which can be dropped into BeMail headers (see the
BeOS User's Guide Chap. 4: Sending Mail) and other
applications.
Ostensibly, this application reveals how the Person
record is stored, but it also demonstrates how to
use the BeOS file type database in an application.
Owen Smith <orpheus@be.com>
July 1998