Ticket #8872: 0002-Added-drag-drop-of-drive-partition-paths-drag-row-in.patch

File 0002-Added-drag-drop-of-drive-partition-paths-drag-row-in.patch, 2.6 KB (added by jwlh172, 12 years ago)

Additional patch; to be applied following 0001.

  • src/apps/drivesetup/PartitionList.cpp

    From 3c495fbc49172b511825c27439073fa05b172761 Mon Sep 17 00:00:00 2001
    From: Jacob Waterman <jwlhc172@gmail.com>
    Date: Thu, 23 Aug 2012 09:21:16 +0000
    Subject: [PATCH 2/2] Added drag & drop of drive/partition paths; drag row in
     list to terminal, text editor, etc.
    
    ---
     src/apps/drivesetup/PartitionList.cpp |   40 ++++++++++++++++++++-------------
     src/apps/drivesetup/PartitionList.h   |    2 ++
     2 files changed, 27 insertions(+), 15 deletions(-)
    
    diff --git a/src/apps/drivesetup/PartitionList.cpp b/src/apps/drivesetup/PartitionList.cpp
    index e649068..b3b76f5 100644
    a b PartitionListRow::PartitionListRow(partition_id parentID, partition_id id,  
    281281}
    282282
    283283
     284const char*
     285PartitionListRow::GetPath()
     286{
     287    char* pathString = NULL;
     288
     289    BBitmapStringField* stringField
     290        = dynamic_cast<BBitmapStringField*>(GetField(kDeviceColumn));
     291    if(stringField != NULL) {
     292        pathString = const_cast<char*>(stringField->String());
     293    }
     294
     295    return pathString;
     296}
     297
     298
    284299// #pragma mark - PartitionListView
    285300
    286301
    PartitionListView::AttachedToWindow()  
    315330bool
    316331PartitionListView::InitiateDrag(BPoint rowPoint, bool wasSelected)
    317332{
    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 
     333    PartitionListRow* draggedRow
     334        = dynamic_cast<PartitionListRow*>(RowAt(rowPoint));
     335    if(draggedRow != NULL) {
     336        BRect draggedRowRect;
     337        GetRowRect(draggedRow, &draggedRowRect);
     338
     339        const char* draggedPath = draggedRow->GetPath();
     340        if(draggedPath != NULL) {
    331341            BMessage *drag = new BMessage(B_MIME_DATA);
    332             drag->AddData("text/plain", B_MIME_TYPE, stringField->String(), strlen(stringField->String()));
     342            drag->AddData("text/plain", B_MIME_TYPE, draggedPath, strlen(draggedPath));
    333343
    334             DragMessage(drag, selectedRowRect, NULL);
     344            DragMessage(drag, draggedRowRect, NULL);
    335345
    336346            return true;
    337347        }
  • src/apps/drivesetup/PartitionList.h

    diff --git a/src/apps/drivesetup/PartitionList.h b/src/apps/drivesetup/PartitionList.h
    index 0051b38..33e8e6d 100644
    a b public:  
    7777                                    { return fOffset; }
    7878            off_t               Size() const
    7979                                    { return fSize; }
     80
     81            const char*         GetPath();
    8082private:
    8183            partition_id        fPartitionID;
    8284            partition_id        fParentID;