From 3c495fbc49172b511825c27439073fa05b172761 Mon Sep 17 00:00:00 2001
From: Jacob Waterman <jwlhc172@gmail.com>
Date: Thu, 23 Aug 2012 09:21:16 +0000
Subject: [PATCH 2/2] Added drag & drop of drive/partition paths; drag row in
list to terminal, text editor, etc.
---
src/apps/drivesetup/PartitionList.cpp | 40 ++++++++++++++++++++-------------
src/apps/drivesetup/PartitionList.h | 2 ++
2 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/src/apps/drivesetup/PartitionList.cpp b/src/apps/drivesetup/PartitionList.cpp
index e649068..b3b76f5 100644
a
|
b
|
PartitionListRow::PartitionListRow(partition_id parentID, partition_id id,
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
| 284 | const char* |
| 285 | PartitionListRow::GetPath() |
| 286 | { |
| 287 | char* pathString = NULL; |
| 288 | |
| 289 | BBitmapStringField* stringField |
| 290 | = dynamic_cast<BBitmapStringField*>(GetField(kDeviceColumn)); |
| 291 | if(stringField != NULL) { |
| 292 | pathString = const_cast<char*>(stringField->String()); |
| 293 | } |
| 294 | |
| 295 | return pathString; |
| 296 | } |
| 297 | |
| 298 | |
284 | 299 | // #pragma mark - PartitionListView |
285 | 300 | |
286 | 301 | |
… |
… |
PartitionListView::AttachedToWindow()
|
315 | 330 | bool |
316 | 331 | PartitionListView::InitiateDrag(BPoint rowPoint, bool wasSelected) |
317 | 332 | { |
318 | | BRow* _selectedRow = RowAt(rowPoint); |
319 | | if(_selectedRow) { |
320 | | PartitionListRow* selectedRow |
321 | | = dynamic_cast<PartitionListRow*>(_selectedRow); |
322 | | |
323 | | BRect selectedRowRect; |
324 | | GetRowRect(selectedRow, &selectedRowRect); |
325 | | |
326 | | BField* _stringField = selectedRow->GetField(kDeviceColumn); |
327 | | if(_stringField) { |
328 | | BBitmapStringField* stringField |
329 | | = dynamic_cast<BBitmapStringField*>(_stringField); |
330 | | |
| 333 | PartitionListRow* draggedRow |
| 334 | = dynamic_cast<PartitionListRow*>(RowAt(rowPoint)); |
| 335 | if(draggedRow != NULL) { |
| 336 | BRect draggedRowRect; |
| 337 | GetRowRect(draggedRow, &draggedRowRect); |
| 338 | |
| 339 | const char* draggedPath = draggedRow->GetPath(); |
| 340 | if(draggedPath != NULL) { |
331 | 341 | BMessage *drag = new BMessage(B_MIME_DATA); |
332 | | drag->AddData("text/plain", B_MIME_TYPE, stringField->String(), strlen(stringField->String())); |
| 342 | drag->AddData("text/plain", B_MIME_TYPE, draggedPath, strlen(draggedPath)); |
333 | 343 | |
334 | | DragMessage(drag, selectedRowRect, NULL); |
| 344 | DragMessage(drag, draggedRowRect, NULL); |
335 | 345 | |
336 | 346 | return true; |
337 | 347 | } |
diff --git a/src/apps/drivesetup/PartitionList.h b/src/apps/drivesetup/PartitionList.h
index 0051b38..33e8e6d 100644
a
|
b
|
public:
|
77 | 77 | { return fOffset; } |
78 | 78 | off_t Size() const |
79 | 79 | { return fSize; } |
| 80 | |
| 81 | const char* GetPath(); |
80 | 82 | private: |
81 | 83 | partition_id fPartitionID; |
82 | 84 | partition_id fParentID; |