From 01de4ccb33f7b4c945030485f4d46121b3adc60a Mon Sep 17 00:00:00 2001
From: Jacob Waterman <jwlhc172@gmail.com>
Date: Wed, 22 Aug 2012 12:26:06 +0000
Subject: [PATCH] Added ability to drag drive/partition from list to terminal,
pe, etc. and drop, resulting in the corresponding path
being inserted. (#8872)
---
src/apps/drivesetup/PartitionList.cpp | 33 +++++++++++++++++++++++++++++++--
src/apps/drivesetup/PartitionList.h | 2 ++
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/apps/drivesetup/PartitionList.cpp b/src/apps/drivesetup/PartitionList.cpp
index 49b9b84..e649068 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); |
… |
… |
PartitionListView::AttachedToWindow()
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
| 315 | bool |
| 316 | PartitionListView::InitiateDrag(BPoint rowPoint, bool wasSelected) |
| 317 | { |
| 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 | |
| 331 | BMessage *drag = new BMessage(B_MIME_DATA); |
| 332 | drag->AddData("text/plain", B_MIME_TYPE, stringField->String(), strlen(stringField->String())); |
| 333 | |
| 334 | DragMessage(drag, selectedRowRect, NULL); |
| 335 | |
| 336 | return true; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | return false; |
| 341 | } |
| 342 | |
| 343 | |
315 | 344 | PartitionListRow* |
316 | 345 | PartitionListView::FindRow(partition_id id, PartitionListRow* parent) |
317 | 346 | { |
diff --git a/src/apps/drivesetup/PartitionList.h b/src/apps/drivesetup/PartitionList.h
index c3319ce..0051b38 100644
a
|
b
|
public:
|
93 | 93 | |
94 | 94 | virtual void AttachedToWindow(); |
95 | 95 | |
| 96 | virtual bool InitiateDrag(BPoint rowPoint, bool wasSelected); |
| 97 | |
96 | 98 | PartitionListRow* FindRow(partition_id id, |
97 | 99 | PartitionListRow* parent = NULL); |
98 | 100 | PartitionListRow* AddPartition(BPartition* partition); |