From bced01f71fb7a635cd5109a8a952e07cb3c925a4 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Tue, 3 Mar 2009 19:02:26 +0000 Subject: [PATCH] - Use SetSelectionMessage to enable/disable the possibility to add to general list git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29388 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/bluetooth/InquiryPanel.cpp | 22 +++++++++++++++++----- src/preferences/bluetooth/InquiryPanel.h | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/preferences/bluetooth/InquiryPanel.cpp b/src/preferences/bluetooth/InquiryPanel.cpp index 697f29c9c2..c3ef7c8b68 100644 --- a/src/preferences/bluetooth/InquiryPanel.cpp +++ b/src/preferences/bluetooth/InquiryPanel.cpp @@ -36,6 +36,7 @@ static const uint32 kMsgShowDebug = 'ShDG'; static const uint32 kMsgInquiry = 'iQbt'; static const uint32 kMsgAddListDevice = 'aDdv'; +static const uint32 kMsgSelected = 'isLt'; static const uint32 kMsgSecond = 'sCMs'; @@ -112,6 +113,7 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice) fAddButton->SetEnabled(false); fRemoteList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST); + fRemoteList->SetSelectionMessage(new BMessage(kMsgSelected)); fScrollView = new BScrollView("ScrollView", fRemoteList, 0, false, true); fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); @@ -133,7 +135,7 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice) fInquiryButton->SetEnabled(false); } - fRunner = new BMessageRunner(BMessenger(this), new BMessage(kMsgSecond), 1000000L, -1); + fRunner = new BMessageRunner(BMessenger(this), new BMessage(kMsgSecond), 1000000L); AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) @@ -193,6 +195,10 @@ InquiryPanel::MessageReceived(BMessage *message) // TODO: all others listitems can be deleted } break; + + case kMsgSelected: + UpdateListStatus(); + break; case kMsgStart: fRemoteList->MakeEmpty(); @@ -208,6 +214,7 @@ InquiryPanel::MessageReceived(BMessage *message) fScanning = false; fRetrieving = true; + UpdateListStatus(); UpdateUIStatus(); break; @@ -227,7 +234,7 @@ InquiryPanel::MessageReceived(BMessage *message) if (fRetrieving) { if (retrievalIndex < fDiscoveryAgent->RetrieveDevices(0).CountItems()) { - + ((DeviceListItem*)fRemoteList->ItemAt(retrievalIndex))-> SetDevice((BluetoothDevice*)fDiscoveryAgent->RetrieveDevices(0).ItemAt(retrievalIndex)); @@ -262,6 +269,7 @@ InquiryPanel::UpdateUIStatus(void) fAddButton->SetEnabled(false); fInquiryButton->SetEnabled(false); fScanProgress->SetBarColor(activeColor); + fAddButton->SetEnabled(false); } else if (fRetrieving) { fInquiryButton->SetEnabled(true); @@ -270,12 +278,16 @@ InquiryPanel::UpdateUIStatus(void) } else { } - - if (fRemoteList->CurrentSelection() < 0 || fScanning) +} + + +void +InquiryPanel::UpdateListStatus(void) +{ + if (fRemoteList->CurrentSelection() < 0 || fScanning || fRetrieving) fAddButton->SetEnabled(false); else fAddButton->SetEnabled(true); - } diff --git a/src/preferences/bluetooth/InquiryPanel.h b/src/preferences/bluetooth/InquiryPanel.h index 33c522eb36..ca2eee9827 100644 --- a/src/preferences/bluetooth/InquiryPanel.h +++ b/src/preferences/bluetooth/InquiryPanel.h @@ -44,6 +44,7 @@ private: void UpdateUIStatus(void); + void UpdateListStatus(void); rgb_color activeColor; };