Ticket #8872: 0001-Added-drag-drop-of-disk-partition-paths-drag-a-list-.patch

File 0001-Added-drag-drop-of-disk-partition-paths-drag-a-list-.patch, 3.1 KB (added by jwlh172, 12 years ago)

New patch; replaces all above patches; all together in this one.

  • src/apps/drivesetup/PartitionList.cpp

    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)  
    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);
    PartitionListRow::PartitionListRow(partition_id parentID, partition_id id,  
    281281}
    282282
    283283
     284const char*
     285PartitionListRow::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
    284297// #pragma mark - PartitionListView
    285298
    286299
    PartitionListView::AttachedToWindow()  
    312325}
    313326
    314327
     328bool
     329PartitionListView::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
    315352PartitionListRow*
    316353PartitionListView::FindRow(partition_id id, PartitionListRow* parent)
    317354{
  • src/apps/drivesetup/PartitionList.h

    diff --git a/src/apps/drivesetup/PartitionList.h b/src/apps/drivesetup/PartitionList.h
    index c3319ce..f4e504e 100644
    a b public:  
    7777                                    { return fOffset; }
    7878            off_t               Size() const
    7979                                    { return fSize; }
     80
     81            const char*         DevicePath();
    8082private:
    8183            partition_id        fPartitionID;
    8284            partition_id        fParentID;
    public:  
    9395
    9496    virtual void                AttachedToWindow();
    9597
     98    virtual bool                InitiateDrag(BPoint rowPoint, bool wasSelected);
     99
    96100            PartitionListRow*   FindRow(partition_id id,
    97101                                    PartitionListRow* parent = NULL);
    98102            PartitionListRow*   AddPartition(BPartition* partition);