Ticket #8872: 0001-Added-ability-to-drag-drive-partition-from-list-to-t.patch

File 0001-Added-ability-to-drag-drive-partition-from-list-to-t.patch, 2.7 KB (added by jwlh172, 12 years ago)

Patch with drag and drop functionality.

  • src/apps/drivesetup/PartitionList.cpp

    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)  
    224224        if (partition->ContainsFileSystem())
    225225            SetField(new BStringField(partition->Type()), kFilesystemColumn);
    226226        else
    227             SetField(new BStringField(kUnavailableString), kFilesystemColumn);     
     227            SetField(new BStringField(kUnavailableString), kFilesystemColumn);
    228228        SetField(new BStringField(kUnavailableString), kVolumeNameColumn);
    229229    }
    230230
    PartitionListRow::PartitionListRow(BPartition* partition)  
    250250
    251251            delete_driver_settings(handle);
    252252        }
    253        
     253
    254254        SetField(new BStringField(parameters), kParametersColumn);
    255255    } else {
    256256        SetField(new BStringField(kUnavailableString), kParametersColumn);
    PartitionListView::AttachedToWindow()  
    312312}
    313313
    314314
     315bool
     316PartitionListView::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
    315344PartitionListRow*
    316345PartitionListView::FindRow(partition_id id, PartitionListRow* parent)
    317346{
  • src/apps/drivesetup/PartitionList.h

    diff --git a/src/apps/drivesetup/PartitionList.h b/src/apps/drivesetup/PartitionList.h
    index c3319ce..0051b38 100644
    a b public:  
    9393
    9494    virtual void                AttachedToWindow();
    9595
     96    virtual bool                InitiateDrag(BPoint rowPoint, bool wasSelected);
     97
    9698            PartitionListRow*   FindRow(partition_id id,
    9799                                    PartitionListRow* parent = NULL);
    98100            PartitionListRow*   AddPartition(BPartition* partition);