- 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
This commit is contained in:
Oliver Ruiz Dorantes
2009-03-03 19:02:26 +00:00
parent b82ed10b05
commit bced01f71f
2 changed files with 18 additions and 5 deletions
+17 -5
View File
@@ -36,6 +36,7 @@ static const uint32 kMsgShowDebug = 'ShDG';
static const uint32 kMsgInquiry = 'iQbt'; static const uint32 kMsgInquiry = 'iQbt';
static const uint32 kMsgAddListDevice = 'aDdv'; static const uint32 kMsgAddListDevice = 'aDdv';
static const uint32 kMsgSelected = 'isLt';
static const uint32 kMsgSecond = 'sCMs'; static const uint32 kMsgSecond = 'sCMs';
@@ -112,6 +113,7 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
fAddButton->SetEnabled(false); fAddButton->SetEnabled(false);
fRemoteList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST); fRemoteList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST);
fRemoteList->SetSelectionMessage(new BMessage(kMsgSelected));
fScrollView = new BScrollView("ScrollView", fRemoteList, 0, false, true); fScrollView = new BScrollView("ScrollView", fRemoteList, 0, false, true);
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -133,7 +135,7 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
fInquiryButton->SetEnabled(false); 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) AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
@@ -193,6 +195,10 @@ InquiryPanel::MessageReceived(BMessage *message)
// TODO: all others listitems can be deleted // TODO: all others listitems can be deleted
} }
break; break;
case kMsgSelected:
UpdateListStatus();
break;
case kMsgStart: case kMsgStart:
fRemoteList->MakeEmpty(); fRemoteList->MakeEmpty();
@@ -208,6 +214,7 @@ InquiryPanel::MessageReceived(BMessage *message)
fScanning = false; fScanning = false;
fRetrieving = true; fRetrieving = true;
UpdateListStatus();
UpdateUIStatus(); UpdateUIStatus();
break; break;
@@ -227,7 +234,7 @@ InquiryPanel::MessageReceived(BMessage *message)
if (fRetrieving) { if (fRetrieving) {
if (retrievalIndex < fDiscoveryAgent->RetrieveDevices(0).CountItems()) { if (retrievalIndex < fDiscoveryAgent->RetrieveDevices(0).CountItems()) {
((DeviceListItem*)fRemoteList->ItemAt(retrievalIndex))-> ((DeviceListItem*)fRemoteList->ItemAt(retrievalIndex))->
SetDevice((BluetoothDevice*)fDiscoveryAgent->RetrieveDevices(0).ItemAt(retrievalIndex)); SetDevice((BluetoothDevice*)fDiscoveryAgent->RetrieveDevices(0).ItemAt(retrievalIndex));
@@ -262,6 +269,7 @@ InquiryPanel::UpdateUIStatus(void)
fAddButton->SetEnabled(false); fAddButton->SetEnabled(false);
fInquiryButton->SetEnabled(false); fInquiryButton->SetEnabled(false);
fScanProgress->SetBarColor(activeColor); fScanProgress->SetBarColor(activeColor);
fAddButton->SetEnabled(false);
} else if (fRetrieving) { } else if (fRetrieving) {
fInquiryButton->SetEnabled(true); fInquiryButton->SetEnabled(true);
@@ -270,12 +278,16 @@ InquiryPanel::UpdateUIStatus(void)
} else { } else {
} }
}
if (fRemoteList->CurrentSelection() < 0 || fScanning)
void
InquiryPanel::UpdateListStatus(void)
{
if (fRemoteList->CurrentSelection() < 0 || fScanning || fRetrieving)
fAddButton->SetEnabled(false); fAddButton->SetEnabled(false);
else else
fAddButton->SetEnabled(true); fAddButton->SetEnabled(true);
} }
+1
View File
@@ -44,6 +44,7 @@ private:
void UpdateUIStatus(void); void UpdateUIStatus(void);
void UpdateListStatus(void);
rgb_color activeColor; rgb_color activeColor;
}; };