Skip to content

Commit

Permalink
Merge pull request #702 from mikfire/bugs/dragdrop
Browse files Browse the repository at this point in the history
Fixes #701 drag and drop is broken
  • Loading branch information
matty0ung committed Dec 31, 2022
2 parents 5c04c46 + 991b201 commit 40fc2af
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
16 changes: 11 additions & 5 deletions src/BtTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,22 @@ QMimeData * BtTreeView::mimeData(QModelIndexList indexes) {
stream << static_cast<int>(*itemType) << id << name;
}

if (!itsa) {
// Everything other than folders get dropped on the ingredients pane
name = "application/x-brewtarget-ingredient";
} else if (*itsa == BtTreeItem::Type::RECIPE || *itsa == BtTreeItem::Type::STYLE || *itsa == BtTreeItem::Type::EQUIPMENT) {
if (*itsa == BtTreeItem::Type::RECIPE || *itsa == BtTreeItem::Type::STYLE || *itsa == BtTreeItem::Type::EQUIPMENT) {
// Recipes, equipment and styles get dropped on the recipe pane
name = "application/x-brewtarget-recipe";
} else {
}
else if ( *itsa == BtTreeItem::Type::FOLDER ) {
// folders will be handled by themselves.
name = "application/x-brewtarget-folder";
}
else if ( *itsa != BtTreeItem::Type::WATER ) {
// Everything other than folders get dropped on the ingredients pane
name = "application/x-brewtarget-ingredient";
}
else {
// This isn't used yet, but maybe some day I will fix that
name = "application/x-brewtarget-water";
}

QMimeData * mimeData = new QMimeData();
mimeData->setData(name, encodedData);
Expand Down
20 changes: 9 additions & 11 deletions ui/mainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>849</width>
<height>462</height>
<width>853</width>
<height>437</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
Expand Down Expand Up @@ -1114,8 +1114,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>849</width>
<height>324</height>
<width>853</width>
<height>356</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
Expand Down Expand Up @@ -1155,6 +1155,9 @@
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -1667,7 +1670,7 @@
<x>0</x>
<y>0</y>
<width>1200</width>
<height>24</height>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuAbout">
Expand Down Expand Up @@ -1880,7 +1883,7 @@
<string>Ctrl+T</string>
</property>
</action>
<action name="actionPrint">
<action name="actionPrint">
<property name="icon">
<iconset resource="../brewtarget.qrc">
<normaloff>:/images/printer.png</normaloff>:/images/printer.png</iconset>
Expand Down Expand Up @@ -2193,11 +2196,6 @@
<signal>(PreviousScaleInfo)</signal>
</slots>
</customwidget>
<customwidget>
<class>BtGenericEdit</class>
<extends>QLineEdit</extends>
<header>BtLineEdit.h</header>
</customwidget>
<customwidget>
<class>BtPercentageEdit</class>
<extends>QLineEdit</extends>
Expand Down

0 comments on commit 40fc2af

Please sign in to comment.