aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/taskbar.cpp
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2018-07-27 23:51:12 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2018-07-27 23:51:12 -0400
commitfeda8a7db8d1d7c5439aa8f8feef7cc0dd2b59a0 (patch)
tree1e50f5f666f419143f510d5ded00fe2006b7bd85 /SQLiteStudio3/guiSQLiteStudio/taskbar.cpp
parentd9aa870e5d509cc7309ab82dd102a937ab58613a (diff)
New upstream version 3.2.1+dfsg1upstream/3.2.1+dfsg1
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/taskbar.cpp')
-rw-r--r--SQLiteStudio3/guiSQLiteStudio/taskbar.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/taskbar.cpp b/SQLiteStudio3/guiSQLiteStudio/taskbar.cpp
index b63c58d..fd0c338 100644
--- a/SQLiteStudio3/guiSQLiteStudio/taskbar.cpp
+++ b/SQLiteStudio3/guiSQLiteStudio/taskbar.cpp
@@ -158,7 +158,7 @@ QAction* TaskBar::getNextClosestAction(const QPoint& position)
QToolButton* btn = nullptr;
if (orientation() == Qt::Horizontal)
{
- foreach (QAction* action, tasks)
+ for (QAction* action : tasks)
{
btn = getToolButton(action);
if (btn && btn->x() >= position.x())
@@ -167,7 +167,7 @@ QAction* TaskBar::getNextClosestAction(const QPoint& position)
}
else
{
- foreach (QAction* action, tasks)
+ for (QAction* action : tasks)
{
btn = getToolButton(action);
if (btn && btn->y() >= position.y())
@@ -260,15 +260,33 @@ void TaskBar::dragTaskTo(QAction* task, int positionIndex)
if (positionIndex < 0)
return;
+ dragCurrentIndex = positionIndex;
+
removeAction(task);
if (positionIndex >= tasks.size())
+ {
addAction(task);
+ tasks.removeOne(task);
+ tasks << task;
+ }
else
+ {
+ int oldIdx = tasks.indexOf(task);
+
+ // If we move from left to right, the positionIndex actually points to 1 position after,
+ // so insertAction() can expect its "before action" first argument.
+ // Although at this step we want precise position index to move the task on the list,
+ // so if this is movement from left to right, we deduct 1 from the index.
+ int newTaskIdx = (positionIndex > oldIdx) ? (positionIndex - 1) : positionIndex;
+ if (oldIdx == newTaskIdx)
+ return;
+
insertAction(tasks.at(positionIndex), task);
+ tasks.move(oldIdx, newTaskIdx);
+ }
connect(getToolButton(task), SIGNAL(pressed()), this, SLOT(mousePressed()));
- dragCurrentIndex = positionIndex;
}
QMimeData* TaskBar::generateMimeData()