From 351769fc7c0dd8886cf4d0332a3af4017f3a7ab0 Mon Sep 17 00:00:00 2001
From: Jacob Waterman <jwlhc172@gmail.com>
Date: Thu, 23 Aug 2012 16:11:33 +0000
Subject: [PATCH] Added drag & drop of disk/partition paths; drag a list item
to terminal, pe, etc. and release to copy the path. (ticket
#8872)
---
src/apps/drivesetup/PartitionList.cpp | 41 +++++++++++++++++++++++++++++++--
src/apps/drivesetup/PartitionList.h | 4 ++++
2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/src/apps/drivesetup/PartitionList.cpp b/src/apps/drivesetup/PartitionList.cpp
index 49b9b84..b2e2a60 100644
a
|
b
|
PartitionListRow::PartitionListRow(BPartition* partition)
|
224 | 224 | if (partition->ContainsFileSystem()) |
225 | 225 | SetField(new BStringField(partition->Type()), kFilesystemColumn); |
226 | 226 | else |
227 | | SetField(new BStringField(kUnavailableString), kFilesystemColumn); |
| 227 | SetField(new BStringField(kUnavailableString), kFilesystemColumn); |
228 | 228 | SetField(new BStringField(kUnavailableString), kVolumeNameColumn); |
229 | 229 | } |
230 | 230 | |
… |
… |
PartitionListRow::PartitionListRow(BPartition* partition)
|
250 | 250 | |
251 | 251 | delete_driver_settings(handle); |
252 | 252 | } |
253 | | |
| 253 | |
254 | 254 | SetField(new BStringField(parameters), kParametersColumn); |
255 | 255 | } else { |
256 | 256 | SetField(new BStringField(kUnavailableString), kParametersColumn); |
… |
… |
PartitionListRow::PartitionListRow(partition_id parentID, partition_id id,
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
| 284 | const char* |
| 285 | PartitionListRow::DevicePath() |
| 286 | { |
| 287 | BBitmapStringField* stringField |
| 288 | = dynamic_cast<BBitmapStringField*>(GetField(kDeviceColumn)); |
| 289 | |
| 290 | if (stringField == NULL) |
| 291 | return ""; |
| 292 | |
| 293 | return stringField->String(); |
| 294 | } |
| 295 | |
| 296 | |
284 | 297 | // #pragma mark - PartitionListView |
285 | 298 | |
286 | 299 | |
… |
… |
PartitionListView::AttachedToWindow()
|
312 | 325 | } |
313 | 326 | |
314 | 327 | |
| 328 | bool |
| 329 | PartitionListView::InitiateDrag(BPoint rowPoint, bool wasSelected) |
| 330 | { |
| 331 | PartitionListRow* draggedRow |
| 332 | = dynamic_cast<PartitionListRow*>(RowAt(rowPoint)); |
| 333 | if (draggedRow != NULL) { |
| 334 | BRect draggedRowRect; |
| 335 | GetRowRect(draggedRow, &draggedRowRect); |
| 336 | |
| 337 | const char* draggedPath = draggedRow->DevicePath(); |
| 338 | if (draggedPath != NULL) { |
| 339 | BMessage *drag = new BMessage(B_MIME_DATA); |
| 340 | drag->AddData("text/plain", B_MIME_TYPE, draggedPath, strlen(draggedPath)); |
| 341 | |
| 342 | DragMessage(drag, draggedRowRect, NULL); |
| 343 | |
| 344 | return true; |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | return false; |
| 349 | } |
| 350 | |
| 351 | |
315 | 352 | PartitionListRow* |
316 | 353 | PartitionListView::FindRow(partition_id id, PartitionListRow* parent) |
317 | 354 | { |
diff --git a/src/apps/drivesetup/PartitionList.h b/src/apps/drivesetup/PartitionList.h
index c3319ce..f4e504e 100644
a
|
b
|
public:
|
77 | 77 | { return fOffset; } |
78 | 78 | off_t Size() const |
79 | 79 | { return fSize; } |
| 80 | |
| 81 | const char* DevicePath(); |
80 | 82 | private: |
81 | 83 | partition_id fPartitionID; |
82 | 84 | partition_id fParentID; |
… |
… |
public:
|
93 | 95 | |
94 | 96 | virtual void AttachedToWindow(); |
95 | 97 | |
| 98 | virtual bool InitiateDrag(BPoint rowPoint, bool wasSelected); |
| 99 | |
96 | 100 | PartitionListRow* FindRow(partition_id id, |
97 | 101 | PartitionListRow* parent = NULL); |
98 | 102 | PartitionListRow* AddPartition(BPartition* partition); |