Added drag & drop of disk/partition paths; drag a list item to terminal, pe, etc. and release to copy the path. (ticket #8872)

Signed-off-by: Stephan Aßmus <[email protected]>
This commit is contained in:
Jacob Waterman
2012-09-16 10:37:38 +02:00
committed by Stephan Aßmus
parent 151b6997c0
commit 5d871e578d
2 changed files with 43 additions and 2 deletions
+37
View File
@@ -281,6 +281,19 @@ PartitionListRow::PartitionListRow(partition_id parentID, partition_id id,
} }
const char*
PartitionListRow::DevicePath()
{
BBitmapStringField* stringField
= dynamic_cast<BBitmapStringField*>(GetField(kDeviceColumn));
if (stringField == NULL)
return "";
return stringField->String();
}
// #pragma mark - PartitionListView // #pragma mark - PartitionListView
@@ -312,6 +325,30 @@ PartitionListView::AttachedToWindow()
} }
bool
PartitionListView::InitiateDrag(BPoint rowPoint, bool wasSelected)
{
PartitionListRow* draggedRow
= dynamic_cast<PartitionListRow*>(RowAt(rowPoint));
if (draggedRow != NULL) {
BRect draggedRowRect;
GetRowRect(draggedRow, &draggedRowRect);
const char* draggedPath = draggedRow->DevicePath();
if (draggedPath != NULL) {
BMessage *drag = new BMessage(B_MIME_DATA);
drag->AddData("text/plain", B_MIME_TYPE, draggedPath, strlen(draggedPath));
DragMessage(drag, draggedRowRect, NULL);
return true;
}
}
return false;
}
PartitionListRow* PartitionListRow*
PartitionListView::FindRow(partition_id id, PartitionListRow* parent) PartitionListView::FindRow(partition_id id, PartitionListRow* parent)
{ {
+4
View File
@@ -77,6 +77,8 @@ public:
{ return fOffset; } { return fOffset; }
off_t Size() const off_t Size() const
{ return fSize; } { return fSize; }
const char* DevicePath();
private: private:
partition_id fPartitionID; partition_id fPartitionID;
partition_id fParentID; partition_id fParentID;
@@ -93,6 +95,8 @@ public:
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual bool InitiateDrag(BPoint rowPoint, bool wasSelected);
PartitionListRow* FindRow(partition_id id, PartitionListRow* FindRow(partition_id id,
PartitionListRow* parent = NULL); PartitionListRow* parent = NULL);
PartitionListRow* AddPartition(BPartition* partition); PartitionListRow* AddPartition(BPartition* partition);