Ticket #7091: bt-mon-refact.patch

File bt-mon-refact.patch, 4.3 KB (added by hamish, 13 years ago)

Removes superfluous code from Bluetooth's output window

  • src/servers/bluetooth/Output.cpp

     
    2121*/
    2222
    2323
    2424
    2525
    2626
    27 OutputView::OutputView()
    2827
     28OutputView::OutputView(const char* name)
    2929
    3030    :
    3131
    32     BGroupView("OutputView", B_VERTICAL, B_WILL_DRAW)
    3332
     33    BGroupView(name, B_VERTICAL, B_WILL_DRAW)
    3434
    3535{
    3636
  • src/servers/bluetooth/Output.h

     	rgb_color textColor = {255, 255, 255};
    
     	fTextView = new BTextView("Output", NULL, &textColor, B_WILL_DRAW);
    
     	fTextView->SetViewColor(0, 0, 100);
    
     	fTextView->MakeEditable(false);
    
    -	BScrollView* scrollView = new BScrollView("ScrollView", fTextView, 0, false, true);
    
    +	BScrollView* scrollView = new BScrollView("ScrollView", fTextView,
    
    +		0, false, true);
    
     	
    
     	BLayoutBuilder::Group<>(this).Add(scrollView);
    
     }
    
    @@ -41,10 +42,10 @@
     
    
     Output::Output()
    
     	:
    
    -	BWindow(BRect(200, 200, 800, 800), "Output", B_TITLED_WINDOW, B_NOT_ZOOMABLE)
    
    +	BWindow(BRect(200, 200, 800, 800), "Output",
    
    +		B_TITLED_WINDOW, B_NOT_ZOOMABLE)
    
     {
    
    -	fTabsList = new BList(20);
    
    -	fOutputViewsList = new BList(20);
    
    +	fOutputViewsList = new BList();
    
     
    
     	fReset = new BButton("reset all", "Clear", 
    
     		new BMessage(kMsgOutputReset), B_WILL_DRAW);
    
    @@ -54,8 +55,7 @@
     	fTabView = new BTabView("tab_view", B_WIDTH_FROM_LABEL,
    
     		B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW | B_NAVIGABLE_JUMP);
    
     
    
    -	fTabView->AddTab(fAll = new OutputView(), fAllTab = new BTab()); 
    
    -	fAllTab->SetLabel("All");
    
    +	fTabView->AddTab(fAll = new OutputView("All"));
    
     	
    
     	BLayoutBuilder::Group<>(this, B_VERTICAL, 5)
    
     		.Add(fTabView)
    
    @@ -74,18 +74,15 @@
     
    
     
    
     void
    
    -Output::AddTab(const char* text, int32 index) 
    
    +Output::AddTab(const char* text, uint32 index)
    
     {
    
     	OutputView* customOutput;
    
    -	BTab*		customTab;
    
     
    
     	Lock();
    
    -	fTabView->AddTab(customOutput = new OutputView(), customTab = new BTab());
    
    -	customTab->SetLabel(text);
    
    +	fTabView->AddTab(customOutput = new OutputView(text));
    
     	fTabView->Invalidate();
    
     	Unlock();
    
     
    
    -	fTabsList->AddItem(customTab, index);
    
     	fOutputViewsList->AddItem(customOutput, index);
    
     }
    
     
    
    @@ -93,8 +90,6 @@
     Output::~Output()
    
     {
    
     /*	BWindow::~BWindow();*/
    
    -	
    
    -	delete fTabsList;
    
     	delete fOutputViewsList;
    
     }
    
     
    
    @@ -121,21 +116,14 @@
     {
    
     	switch(msg->what) {
    
     		case kMsgOutputReset:
    
    -			for (int32 index = 0; index<fTabsList->CountItems(); index++) {
    
    -				if (fTabsList->ItemAt(index) != NULL && ((BTab*)fTabsList
    
    -					->ItemAt(index))->IsSelected())
    
    -					((OutputView*)fOutputViewsList->ItemAt(index))->Clear();
    
    -			}
    
    +			((OutputView*)fTabView->TabAt(fTabView->Selection())->View())
    
    +				->Clear();
    
     			break;
    
     		case kMsgOutputResetAll:
    
    -		{
    
     			fAll->Clear();
    
    -			for (int32 index = 0; index<fTabsList->CountItems(); index++) {
    
    -				if (fTabsList->ItemAt(index) != NULL )	
    
    -					((OutputView*)fOutputViewsList->ItemAt(index))->Clear();	
    
    -			}
    
    +			for (int32 index = 0; index < fTabView->CountTabs(); ++index)
    
    +				((OutputView*)fTabView->TabAt(index)->View())->Clear();
    
     			break;
    
    -		}
    
     		default:
    
     			BWindow::MessageReceived(msg);
    
     			break;
    
    @@ -173,7 +161,7 @@
     Output::Post(const char* text, uint32 index)
    
     {
    
     	Lock();
    
    -	OutputView* view = (OutputView*) fOutputViewsList->ItemAt(index);
    
    +	OutputView* view = (OutputView*)fOutputViewsList->ItemAt(index);
    
     
    
     	if (view != NULL)
    
     		Add(text, view);
    
     
    2222class OutputView : public BGroupView
    2323
    2424{
    2525
    2626public:
    2727
    28     OutputView();
    2928