From 6c85c7eec82f314274e41ca842f7c9dc8f35d3c3 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Sat, 15 Aug 2009 02:33:47 +0000 Subject: [PATCH] Revert r32402. Some problems are occuring in the attribute editor and I want to make sure they aren't caused by my patch before committing for good. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32409 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/diskprobe/DataEditor.cpp | 9 ++- src/apps/diskprobe/DataEditor.h | 5 +- src/apps/diskprobe/TypeEditors.cpp | 98 +++++------------------------- src/apps/diskprobe/TypeEditors.h | 2 +- 4 files changed, 23 insertions(+), 91 deletions(-) diff --git a/src/apps/diskprobe/DataEditor.cpp b/src/apps/diskprobe/DataEditor.cpp index 71cb058730..2fd85a28df 100644 --- a/src/apps/diskprobe/DataEditor.cpp +++ b/src/apps/diskprobe/DataEditor.cpp @@ -526,7 +526,7 @@ DataEditor::InitCheck() void -DataEditor::AddChange(DataChange *change, bool sendNotices) +DataEditor::AddChange(DataChange *change) { if (change == NULL) return; @@ -537,8 +537,7 @@ DataEditor::AddChange(DataChange *change, bool sendNotices) RemoveRedos(); change->Apply(fRealViewOffset, fView, fRealViewSize); - if (sendNotices) - SendNotices(change); + SendNotices(change); // update observers // try to join changes @@ -552,7 +551,7 @@ DataEditor::AddChange(DataChange *change, bool sendNotices) status_t -DataEditor::Replace(off_t offset, const uint8 *data, size_t length, bool sendNotices) +DataEditor::Replace(off_t offset, const uint8 *data, size_t length) { if (IsReadOnly()) return B_NOT_ALLOWED; @@ -571,7 +570,7 @@ DataEditor::Replace(off_t offset, const uint8 *data, size_t length, bool sendNot } ReplaceChange *change = new ReplaceChange(offset, data, length); - AddChange(change, sendNotices); + AddChange(change); return B_OK; } diff --git a/src/apps/diskprobe/DataEditor.h b/src/apps/diskprobe/DataEditor.h index 2e0ba6feec..1d0ef7c9c6 100644 --- a/src/apps/diskprobe/DataEditor.h +++ b/src/apps/diskprobe/DataEditor.h @@ -44,8 +44,7 @@ class DataEditor : public BLocker { status_t InitCheck(); - status_t Replace(off_t offset, const uint8 *data, size_t length, - bool sendNotices = true); + status_t Replace(off_t offset, const uint8 *data, size_t length); status_t Remove(off_t offset, off_t length); status_t Insert(off_t offset, const uint8 *data, size_t length); @@ -95,7 +94,7 @@ class DataEditor : public BLocker { void SendNotices(uint32 what, BMessage *message = NULL); void SendNotices(DataChange *change); status_t Update(); - void AddChange(DataChange *change, bool sendNotices = true); + void AddChange(DataChange *change); void ApplyChanges(); void RemoveRedos(); diff --git a/src/apps/diskprobe/TypeEditors.cpp b/src/apps/diskprobe/TypeEditors.cpp index 40dfd1cee5..f98b42ce57 100644 --- a/src/apps/diskprobe/TypeEditors.cpp +++ b/src/apps/diskprobe/TypeEditors.cpp @@ -36,24 +36,6 @@ static const uint32 kMsgScaleChanged = 'scch'; static const uint32 kMimeTypeItem = 'miti'; -class StringEditorTextView : public BTextView { - public: - StringEditorTextView(BRect rect, TypeEditorView* target); - - bool fCommit; - - protected: - virtual void InsertText(const char* text, - int32 length, int32 offset, - const text_run_array* runs = NULL); - - virtual void DeleteText(int32 start, int32 finish); - - private: - TypeEditorView* fTarget; -}; - - class StringEditor : public TypeEditorView { public: StringEditor(BRect rect, DataEditor& editor); @@ -62,13 +44,13 @@ class StringEditor : public TypeEditorView { virtual void DetachedFromWindow(); virtual void MessageReceived(BMessage* message); - virtual void CommitChanges(bool sendNotices = true); + virtual void CommitChanges(); private: void _UpdateText(); - StringEditorTextView* fTextView; - BString fPreviousText; + BTextView* fTextView; + BString fPreviousText; }; @@ -80,7 +62,7 @@ class MimeTypeEditor : public TypeEditorView { virtual void DetachedFromWindow(); virtual void MessageReceived(BMessage* message); - virtual void CommitChanges(bool sendNotices = true); + virtual void CommitChanges(); virtual bool TypeMatches(); private: @@ -99,7 +81,7 @@ class NumberEditor : public TypeEditorView { virtual void DetachedFromWindow(); virtual void MessageReceived(BMessage* message); - virtual void CommitChanges(bool sendNotices = true); + virtual void CommitChanges(); virtual bool TypeMatches(); private: @@ -121,7 +103,7 @@ class BooleanEditor : public TypeEditorView { virtual void DetachedFromWindow(); virtual void MessageReceived(BMessage* message); - virtual void CommitChanges(bool sendNotices = true); + virtual void CommitChanges(); virtual bool TypeMatches(); private: @@ -187,7 +169,7 @@ TypeEditorView::~TypeEditorView() void -TypeEditorView::CommitChanges(bool sendNotices) +TypeEditorView::CommitChanges() { // the default just does nothing here } @@ -215,7 +197,6 @@ StringEditor::StringEditor(BRect rect, DataEditor& editor) BStringView *stringView = new BStringView(BRect(5, 5, rect.right, 20), B_EMPTY_STRING, "Contents:"); - stringView->ResizeToPreferred(); AddChild(stringView); @@ -224,7 +205,9 @@ StringEditor::StringEditor(BRect rect, DataEditor& editor) rect.right -= B_V_SCROLL_BAR_WIDTH; rect.bottom -= B_H_SCROLL_BAR_HEIGHT; - fTextView = new StringEditorTextView(rect, this); + fTextView = new BTextView(rect, B_EMPTY_STRING, + rect.OffsetToCopy(B_ORIGIN).InsetByCopy(5, 5), + B_FOLLOW_ALL, B_WILL_DRAW); BScrollView* scrollView = new BScrollView("scroller", fTextView, B_FOLLOW_ALL, B_WILL_DRAW, true, true); @@ -232,43 +215,6 @@ StringEditor::StringEditor(BRect rect, DataEditor& editor) } -/* - * fCommit is true if (Insert/Delete)Text is called from interaction with the user - * (text typed..) - * It's false if it's called from _UpdateText(); - * This is to avoid a SetText feedback loop - * CommitChanges -> UpdateText -> SetText -> InsertText -> CommitChanges... - */ -StringEditorTextView::StringEditorTextView(BRect rect, TypeEditorView* target) - : - BTextView(rect, B_EMPTY_STRING, - rect.OffsetToCopy(B_ORIGIN).InsetByCopy(5, 5), - B_FOLLOW_ALL, B_WILL_DRAW), - fCommit(true), - fTarget(target) -{ -} - - -void -StringEditorTextView::InsertText(const char* text, - int32 length, int32 offset, const text_run_array* runs) -{ - BTextView::InsertText(text, length, offset, runs); - if (fCommit) - fTarget->CommitChanges(false); -} - - -void -StringEditorTextView::DeleteText(int32 start, int32 finish) -{ - BTextView::DeleteText(start, finish); - if (fCommit) - fTarget->CommitChanges(false); -} - - void StringEditor::_UpdateText() { @@ -281,9 +227,7 @@ StringEditor::_UpdateText() const char *buffer; if (fEditor.GetViewBuffer((const uint8 **)&buffer) == B_OK) { - fTextView->fCommit = false; fTextView->SetText(buffer); - fTextView->fCommit = true; fPreviousText.SetTo(buffer); } @@ -293,11 +237,11 @@ StringEditor::_UpdateText() void -StringEditor::CommitChanges(bool sendNotices) +StringEditor::CommitChanges() { if (fPreviousText != fTextView->Text()) { fEditor.Replace(0, (const uint8 *)fTextView->Text(), - fTextView->TextLength() + 1, sendNotices); + fTextView->TextLength() + 1); } } @@ -323,17 +267,7 @@ StringEditor::DetachedFromWindow() void StringEditor::MessageReceived(BMessage *message) { - switch (message->what) { - case kMsgValueChanged: - CommitChanges(); - break; - case kMsgDataEditorUpdate: - _UpdateText(); - break; - - default: - BView::MessageReceived(message); - } + BView::MessageReceived(message); } @@ -373,7 +307,7 @@ MimeTypeEditor::_UpdateText() void -MimeTypeEditor::CommitChanges(bool sendNotices) +MimeTypeEditor::CommitChanges() { if (fPreviousText != fTextControl->Text()) { fEditor.Replace(0, (const uint8*)fTextControl->Text(), @@ -554,7 +488,7 @@ NumberEditor::TypeMatches() void -NumberEditor::CommitChanges(bool sendNotices) +NumberEditor::CommitChanges() { if (fPreviousText == fTextControl->Text()) return; @@ -858,7 +792,7 @@ BooleanEditor::_UpdateMenuField() void -BooleanEditor::CommitChanges(bool sendNotices) +BooleanEditor::CommitChanges() { // we're commiting the changes as they happen } diff --git a/src/apps/diskprobe/TypeEditors.h b/src/apps/diskprobe/TypeEditors.h index dd0286e9c9..8b0c3dbe8a 100644 --- a/src/apps/diskprobe/TypeEditors.h +++ b/src/apps/diskprobe/TypeEditors.h @@ -17,7 +17,7 @@ class TypeEditorView : public BView { uint32 flags, DataEditor& editor); ~TypeEditorView(); - virtual void CommitChanges(bool sendNotices = true); + virtual void CommitChanges(); virtual bool TypeMatches(); protected: