The "Show Header" option is no longer persistent, and will only affect the

currently shown mail when checked.
It just didn't make any sense the way it was before, and was inconsistent, too,
as it only affected mails opened after the current one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26112 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-06-23 21:00:48 +00:00
parent 40bbe4ecf9
commit 8f0dc0c0d8
3 changed files with 67 additions and 122 deletions

View File

@ -119,7 +119,6 @@ TMailApp::TMailApp()
fPrintHelpAndExit(false), fPrintHelpAndExit(false),
fWrapMode(true), fWrapMode(true),
fShowHeader(false),
fAttachAttributes(true), fAttachAttributes(true),
fColoredQuotes(true), fColoredQuotes(true),
fShowButtonBar(true), fShowButtonBar(true),
@ -819,7 +818,7 @@ TMailApp::LoadOldSettings()
fContentFont.SetFamilyAndStyle(fontFamily, fontStyle); fContentFont.SetFamilyAndStyle(fontFamily, fontStyle);
file.Read(&fSignatureWindowFrame, sizeof(BRect)); file.Read(&fSignatureWindowFrame, sizeof(BRect));
file.Read(&fShowHeader, sizeof(bool)); file.Seek(1, SEEK_CUR); // ignore (bool) show header
file.Read(&fWrapMode, sizeof(bool)); file.Read(&fWrapMode, sizeof(bool));
file.Read(&fPrefsWindowPos, sizeof(BPoint)); file.Read(&fPrefsWindowPos, sizeof(BPoint));
@ -915,7 +914,6 @@ TMailApp::SaveSettings()
settings.AddFloat("FontSize", fContentFont.Size()); settings.AddFloat("FontSize", fContentFont.Size());
settings.AddRect("SignatureWindowSize", fSignatureWindowFrame); settings.AddRect("SignatureWindowSize", fSignatureWindowFrame);
settings.AddBool("ShowHeadersMode", fShowHeader);
settings.AddBool("WordWrapMode", fWrapMode); settings.AddBool("WordWrapMode", fWrapMode);
settings.AddPoint("PreferencesWindowLocation", fPrefsWindowPos); settings.AddPoint("PreferencesWindowLocation", fPrefsWindowPos);
settings.AddString("SignatureText", fSignature); settings.AddString("SignatureText", fSignature);
@ -999,9 +997,6 @@ TMailApp::LoadSettings()
fSignatureWindowFrame = rect; fSignatureWindowFrame = rect;
bool boolValue; bool boolValue;
if (settings.FindBool("ShowHeadersMode", &boolValue) == B_OK)
fShowHeader = boolValue;
if (settings.FindBool("WordWrapMode", &boolValue) == B_OK) if (settings.FindBool("WordWrapMode", &boolValue) == B_OK)
fWrapMode = boolValue; fWrapMode = boolValue;
@ -1157,22 +1152,6 @@ TMailApp::WrapMode()
} }
void
TMailApp::SetShowHeader(bool show)
{
BAutolock _(this);
fShowHeader = show;
}
bool
TMailApp::ShowHeader()
{
BAutolock _(this);
return fShowHeader;
}
bool bool
TMailApp::AttachAttributes() TMailApp::AttachAttributes()
{ {

View File

@ -76,8 +76,6 @@ class TMailApp : public BApplication {
BString Signature(); BString Signature();
BString ReplyPreamble(); BString ReplyPreamble();
bool WrapMode(); bool WrapMode();
void SetShowHeader(bool show);
bool ShowHeader();
bool AttachAttributes(); bool AttachAttributes();
bool ColoredQuotes(); bool ColoredQuotes();
uint8 ShowButtonBar(); uint8 ShowButtonBar();
@ -120,7 +118,6 @@ class TMailApp : public BApplication {
char* fSignature; char* fSignature;
char* fReplyPreamble; char* fReplyPreamble;
bool fWrapMode; bool fWrapMode;
bool fShowHeader;
bool fAttachAttributes; bool fAttachAttributes;
bool fColoredQuotes; bool fColoredQuotes;
uint8 fShowButtonBar; uint8 fShowButtonBar;

View File

@ -171,11 +171,10 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
char status[272]; char status[272];
uint32 message; uint32 message;
float height; float height;
BMenu *menu; BMenu* menu;
BMenu *subMenu; BMenu* subMenu;
BMenuBar *menu_bar; BMenuItem* item;
BMenuItem *item; BMessage* msg;
BMessage *msg;
attr_info info; attr_info info;
BFile file(ref, B_READ_ONLY); BFile file(ref, B_READ_ONLY);
@ -190,13 +189,10 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
} }
BRect r(0, 0, RIGHT_BOUNDARY, 15); BRect r(0, 0, RIGHT_BOUNDARY, 15);
fMenuBar = new BMenuBar(r, "");
// Create real menu bar
fMenuBar = menu_bar = new BMenuBar(r, "");
//
// File Menu // File Menu
//
menu = new BMenu(MDR_DIALECT_CHOICE ("File","F) ファイル")); menu = new BMenu(MDR_DIALECT_CHOICE ("File","F) ファイル"));
msg = new BMessage(M_NEW); msg = new BMessage(M_NEW);
@ -225,13 +221,13 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
menu->AddItem(queryMenu); menu->AddItem(queryMenu);
} }
if(!fIncoming || resending) { if (!fIncoming || resending) {
menu->AddItem(fSendLater = new BMenuItem( menu->AddItem(fSendLater = new BMenuItem(
MDR_DIALECT_CHOICE ("Save as Draft", "S)ドラフトとして保存"), MDR_DIALECT_CHOICE ("Save as Draft", "S)ドラフトとして保存"),
new BMessage(M_SAVE_AS_DRAFT), 'S')); new BMessage(M_SAVE_AS_DRAFT), 'S'));
} }
if(!resending && fIncoming) { if (!resending && fIncoming) {
menu->AddSeparatorItem(); menu->AddSeparatorItem();
subMenu = new BMenu(MDR_DIALECT_CHOICE ("Close and ","C) 閉じる")); subMenu = new BMenu(MDR_DIALECT_CHOICE ("Close and ","C) 閉じる"));
@ -297,7 +293,7 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
menu->AddItem(fPrint = new BMenuItem( menu->AddItem(fPrint = new BMenuItem(
MDR_DIALECT_CHOICE ("Print", "P) 印刷") B_UTF8_ELLIPSIS, MDR_DIALECT_CHOICE ("Print", "P) 印刷") B_UTF8_ELLIPSIS,
new BMessage(M_PRINT), 'P')); new BMessage(M_PRINT), 'P'));
menu_bar->AddItem(menu); fMenuBar->AddItem(menu);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem( menu->AddItem(item = new BMenuItem(
@ -311,9 +307,8 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
new BMessage(B_QUIT_REQUESTED), 'Q')); new BMessage(B_QUIT_REQUESTED), 'Q'));
item->SetTarget(be_app); item->SetTarget(be_app);
//
// Edit Menu // Edit Menu
//
menu = new BMenu(MDR_DIALECT_CHOICE ("Edit","E) 編集")); menu = new BMenu(MDR_DIALECT_CHOICE ("Edit","E) 編集"));
menu->AddItem(fUndo = new BMenuItem(MDR_DIALECT_CHOICE ("Undo","Z) 元に戻す"), new BMessage(B_UNDO), 'Z', 0)); menu->AddItem(fUndo = new BMenuItem(MDR_DIALECT_CHOICE ("Undo","Z) 元に戻す"), new BMessage(B_UNDO), 'Z', 0));
fUndo->SetTarget(NULL, this); fUndo->SetTarget(NULL, this);
@ -353,28 +348,23 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
MDR_DIALECT_CHOICE ("Preferences","P) Mailの設定") B_UTF8_ELLIPSIS, MDR_DIALECT_CHOICE ("Preferences","P) Mailの設定") B_UTF8_ELLIPSIS,
new BMessage(M_PREFS),',')); new BMessage(M_PREFS),','));
item->SetTarget(be_app); item->SetTarget(be_app);
menu_bar->AddItem(menu); fMenuBar->AddItem(menu);
menu->AddItem(item = new BMenuItem( menu->AddItem(item = new BMenuItem(
MDR_DIALECT_CHOICE ("Accounts","Accounts") B_UTF8_ELLIPSIS, MDR_DIALECT_CHOICE ("Accounts","Accounts") B_UTF8_ELLIPSIS,
new BMessage(M_ACCOUNTS),'-')); new BMessage(M_ACCOUNTS),'-'));
item->SetTarget(be_app); item->SetTarget(be_app);
//
// View Menu // View Menu
//
if (!resending && fIncoming) { if (!resending && fIncoming) {
menu = new BMenu("View"); menu = new BMenu("View");
menu->AddItem(fHeader = new BMenuItem(MDR_DIALECT_CHOICE ("Show Header","H) ヘッダーを表示"), new BMessage(M_HEADER), 'H')); menu->AddItem(fHeader = new BMenuItem(MDR_DIALECT_CHOICE ("Show Header","H) ヘッダーを表示"), new BMessage(M_HEADER), 'H'));
if (fApp->ShowHeader())
fHeader->SetMarked(true);
menu->AddItem(fRaw = new BMenuItem(MDR_DIALECT_CHOICE ("Show Raw Message"," メッセージを生で表示"), new BMessage(M_RAW))); menu->AddItem(fRaw = new BMenuItem(MDR_DIALECT_CHOICE ("Show Raw Message"," メッセージを生で表示"), new BMessage(M_RAW)));
menu_bar->AddItem(menu); fMenuBar->AddItem(menu);
} }
//
// Message Menu // Message Menu
//
menu = new BMenu(MDR_DIALECT_CHOICE ("Message", "M) メッセージ")); menu = new BMenu(MDR_DIALECT_CHOICE ("Message", "M) メッセージ"));
if (!resending && fIncoming) { if (!resending && fIncoming) {
@ -438,7 +428,7 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
} }
menu->AddItem(subMenu); menu->AddItem(subMenu);
menu_bar->AddItem(menu); fMenuBar->AddItem(menu);
// Spam Menu // Spam Menu
@ -454,14 +444,14 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Mark as Genuine", menu->AddItem(new BMenuItem("Mark as Genuine",
new BMessage(M_TRAIN_GENUINE), 'K', B_SHIFT_KEY)); new BMessage(M_TRAIN_GENUINE), 'K', B_SHIFT_KEY));
menu_bar->AddItem(menu); fMenuBar->AddItem(menu);
} }
} else { } else {
menu->AddItem(fSendNow = new BMenuItem( menu->AddItem(fSendNow = new BMenuItem(
MDR_DIALECT_CHOICE ("Send Message", "M) メッセージを送信"), MDR_DIALECT_CHOICE ("Send Message", "M) メッセージを送信"),
new BMessage(M_SEND_NOW), 'M')); new BMessage(M_SEND_NOW), 'M'));
if(!fIncoming) { if (!fIncoming) {
menu->AddSeparatorItem(); menu->AddSeparatorItem();
fSignature = new TMenu( fSignature = new TMenu(
MDR_DIALECT_CHOICE ("Add Signature", "D) 署名を追加"), MDR_DIALECT_CHOICE ("Add Signature", "D) 署名を追加"),
@ -475,26 +465,23 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
menu->AddItem(fAdd = new BMenuItem(MDR_DIALECT_CHOICE ("Add Enclosure","E) 追加")B_UTF8_ELLIPSIS, new BMessage(M_ADD), 'E')); menu->AddItem(fAdd = new BMenuItem(MDR_DIALECT_CHOICE ("Add Enclosure","E) 追加")B_UTF8_ELLIPSIS, new BMessage(M_ADD), 'E'));
menu->AddItem(fRemove = new BMenuItem(MDR_DIALECT_CHOICE ("Remove Enclosure","T) 削除"), new BMessage(M_REMOVE), 'T')); menu->AddItem(fRemove = new BMenuItem(MDR_DIALECT_CHOICE ("Remove Enclosure","T) 削除"), new BMessage(M_REMOVE), 'T'));
} }
menu_bar->AddItem(menu); fMenuBar->AddItem(menu);
} }
//
// Queries Menu // Queries Menu
//
fQueryMenu = new BMenu(MDR_DIALECT_CHOICE("Queries","???")); fQueryMenu = new BMenu(MDR_DIALECT_CHOICE("Queries","???"));
menu_bar->AddItem(fQueryMenu); fMenuBar->AddItem(fQueryMenu);
_RebuildQueryMenu(true); _RebuildQueryMenu(true);
//
// Menu Bar // Menu Bar
//
AddChild(menu_bar);
height = menu_bar->Bounds().bottom + 1;
// AddChild(fMenuBar);
height = fMenuBar->Bounds().bottom + 1;
// Button Bar // Button Bar
//
float bbwidth = 0, bbheight = 0; float bbwidth = 0, bbheight = 0;
bool showButtonBar = fApp->ShowButtonBar(); bool showButtonBar = fApp->ShowButtonBar();
@ -522,7 +509,7 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
r.OffsetTo(0, 0); r.OffsetTo(0, 0);
r.top = fHeaderView->Frame().bottom - 1; r.top = fHeaderView->Frame().bottom - 1;
fContentView = new TContentView(r, fIncoming, fMail, fContentView = new TContentView(r, fIncoming, fMail,
const_cast<BFont *>(font), fApp->ShowHeader(), fApp->ColoredQuotes()); const_cast<BFont *>(font), false, fApp->ColoredQuotes());
// TContentView needs to be properly const, for now cast away constness // TContentView needs to be properly const, for now cast away constness
AddChild(fHeaderView); AddChild(fHeaderView);
@ -530,15 +517,12 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
AddChild(fEnclosuresView); AddChild(fEnclosuresView);
AddChild(fContentView); AddChild(fContentView);
if (to) { if (to)
fHeaderView->fTo->SetText(to); fHeaderView->fTo->SetText(to);
}
AddShortcut('n', B_COMMAND_KEY, new BMessage(M_NEW)); AddShortcut('n', B_COMMAND_KEY, new BMessage(M_NEW));
//
// If auto-signature, add signature to the text here. // If auto-signature, add signature to the text here.
//
BString signature = fApp->Signature(); BString signature = fApp->Signature();
@ -546,9 +530,7 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
if (strcmp(signature.String(), SIG_RANDOM) == 0) if (strcmp(signature.String(), SIG_RANDOM) == 0)
PostMessage(M_RANDOM_SIG); PostMessage(M_RANDOM_SIG);
else { else {
//
// Create a query to find this signature // Create a query to find this signature
//
BVolume volume; BVolume volume;
BVolumeRoster().GetBootVolume(&volume); BVolumeRoster().GetBootVolume(&volume);
@ -559,9 +541,7 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app,
query.PushOp(B_EQ); query.PushOp(B_EQ);
query.Fetch(); query.Fetch();
//
// If we find the named query, add it to the text. // If we find the named query, add it to the text.
//
BEntry entry; BEntry entry;
if (query.GetNextEntry(&entry) == B_NO_ERROR) { if (query.GetNextEntry(&entry) == B_NO_ERROR) {
off_t size; off_t size;
@ -713,13 +693,11 @@ bool
TMailWindow::GetTrackerWindowFile(entry_ref *ref, bool next) const TMailWindow::GetTrackerWindowFile(entry_ref *ref, bool next) const
{ {
// Position was already saved // Position was already saved
if (next && fNextTrackerPositionSaved) if (next && fNextTrackerPositionSaved) {
{
*ref = fNextRef; *ref = fNextRef;
return true; return true;
} }
if (!next && fPrevTrackerPositionSaved) if (!next && fPrevTrackerPositionSaved) {
{
*ref = fPrevRef; *ref = fPrevRef;
return true; return true;
} }
@ -727,15 +705,12 @@ TMailWindow::GetTrackerWindowFile(entry_ref *ref, bool next) const
if (!fTrackerMessenger.IsValid()) if (!fTrackerMessenger.IsValid())
return false; return false;
//
// Ask the tracker what the next/prev file in the window is. // Ask the tracker what the next/prev file in the window is.
// Continue asking for the next reference until a valid // Continue asking for the next reference until a valid
// email file is found (ignoring other types). // email file is found (ignoring other types).
//
entry_ref nextRef = *ref; entry_ref nextRef = *ref;
bool foundRef = false; bool foundRef = false;
while (!foundRef) while (!foundRef) {
{
BMessage request(B_GET_PROPERTY); BMessage request(B_GET_PROPERTY);
BMessage spc; BMessage spc;
if (next) if (next)
@ -808,12 +783,10 @@ void
TMailWindow::SetCurrentMessageRead() TMailWindow::SetCurrentMessageRead()
{ {
BNode node(fRef); BNode node(fRef);
if (node.InitCheck() == B_NO_ERROR) if (node.InitCheck() == B_NO_ERROR) {
{
BString status; BString status;
if (ReadAttrString(&node, B_MAIL_ATTR_STATUS, &status) == B_NO_ERROR if (ReadAttrString(&node, B_MAIL_ATTR_STATUS, &status) == B_NO_ERROR
&& !status.ICompare("New")) && !status.ICompare("New")) {
{
node.RemoveAttr(B_MAIL_ATTR_STATUS); node.RemoveAttr(B_MAIL_ATTR_STATUS);
WriteAttrString(&node, B_MAIL_ATTR_STATUS, "Read"); WriteAttrString(&node, B_MAIL_ATTR_STATUS, "Read");
} }
@ -1217,7 +1190,6 @@ TMailWindow::MessageReceived(BMessage *msg)
case M_HEADER: case M_HEADER:
{ {
bool showHeader = !fHeader->IsMarked(); bool showHeader = !fHeader->IsMarked();
fApp->SetShowHeader(showHeader);
fHeader->SetMarked(showHeader); fHeader->SetMarked(showHeader);
BMessage message(M_HEADER); BMessage message(M_HEADER);
@ -1573,8 +1545,7 @@ TMailWindow::MessageReceived(BMessage *msg)
void void
TMailWindow::AddEnclosure(BMessage *msg) TMailWindow::AddEnclosure(BMessage *msg)
{ {
if (fEnclosuresView == NULL && !fIncoming) if (fEnclosuresView == NULL && !fIncoming) {
{
BRect r; BRect r;
r.left = 0; r.left = 0;
r.top = fHeaderView->Frame().bottom - 1; r.top = fHeaderView->Frame().bottom - 1;
@ -2978,7 +2949,6 @@ TMailWindow::_RebuildQueryMenu(bool firstTime)
// If we find the named query, add it to the menu. // If we find the named query, add it to the menu.
BEntry entry; BEntry entry;
while (queryDir.GetNextEntry(&entry) == B_OK) { while (queryDir.GetNextEntry(&entry) == B_OK) {
char name[B_FILE_NAME_LENGTH + 1]; char name[B_FILE_NAME_LENGTH + 1];
entry.GetName(name); entry.GetName(name);
@ -3015,7 +2985,7 @@ TMailWindow::_BuildQueryString(BEntry* entry) const
} }
BString queryString; BString queryString;
switch(mode) { switch (mode) {
case kByForumlaItem: case kByForumlaItem:
{ {
BString buffer; BString buffer;
@ -3053,13 +3023,12 @@ TMailWindow::_BuildQueryString(BEntry* entry) const
BMessage message; BMessage message;
if (message.Unflatten(buffer) == B_OK) { if (message.Unflatten(buffer) == B_OK) {
for (int32 index = 0; /*index < count*/; index++) { for (int32 index = 0; /*index < count*/; index++) {
const char *field; const char *field;
const char *value; const char *value;
if (message.FindString("menuSelection", if (message.FindString("menuSelection", index, &field)
index, &field) != B_OK != B_OK
|| message.FindString("attrViewText", || message.FindString("attrViewText", index, &value)
index, &value) != B_OK) { != B_OK) {
break; break;
} }