

Classes | |
| struct | Tab |
Public Types | |
| enum | MovementAction { PressAction, MoveAction, DragAction, DropAction } |
Public Member Functions | |
| QxtTabBarPrivate () | |
| int | tabAt (const QPoint &position, MovementAction action) const |
| bool | contains (const QRect &rect, const QPoint &position, MovementAction action) const |
| bool | shouldMove (const QPoint &pos, int fromIndex, int toIndex, MovementAction action) const |
| bool | moveTab (const QPoint &pos, int fromIndex, int toIndex, MovementAction action) |
| Tab | saveTab (int index) const |
| void | restoreTab (int index, const Tab &tab) |
Public Attributes | |
| int | movingTab |
| QPoint | pressPoint |
| QxtTabBar::TabMovementMode | mode |
Friends | |
| class | QxtTabBar |
Definition at line 32 of file qxttabbar.cpp.
Definition at line 39 of file qxttabbar.cpp.
{
PressAction,
MoveAction,
DragAction,
DropAction,
};
| QxtTabBarPrivate::QxtTabBarPrivate | ( | ) |
Definition at line 70 of file qxttabbar.cpp.
: movingTab(-1), mode(QxtTabBar::NoMovement) { }
| bool QxtTabBarPrivate::contains | ( | const QRect & | rect, |
| const QPoint & | position, | ||
| MovementAction | action | ||
| ) | const |
Definition at line 87 of file qxttabbar.cpp.
References PressAction, and QxtPrivate< QxtTabBar >::qxt_p().
Referenced by shouldMove(), and tabAt().
{
if (action != PressAction)
{
switch (qxt_p().shape())
{
case QTabBar::RoundedNorth:
case QTabBar::RoundedSouth:
case QTabBar::TriangularNorth:
case QTabBar::TriangularSouth:
return position.x() >= rect.x() && position.x() <= rect.x() + rect.width();
case QTabBar::RoundedWest:
case QTabBar::RoundedEast:
case QTabBar::TriangularWest:
case QTabBar::TriangularEast:
return position.y() >= rect.y() && position.y() <= rect.y() + rect.height();
default:
qWarning("QTabBarPrivate: unknown QTabBar::Shape %i", qxt_p().shape());
return false;
}
}
else // (action == PressAction)
{
return rect.contains(position);
}
}
| bool QxtTabBarPrivate::moveTab | ( | const QPoint & | pos, |
| int | fromIndex, | ||
| int | toIndex, | ||
| MovementAction | action | ||
| ) |
Definition at line 163 of file qxttabbar.cpp.
References QxtPrivate< QxtTabBar >::qxt_p(), restoreTab(), saveTab(), and shouldMove().
{
QxtTabBar* tabBar = &qxt_p();
if (shouldMove(pos, fromIndex, toIndex, action))
{
Tab tab = saveTab(fromIndex);
// if parent is a QTabWidget we can use it to move the tabs and widgets
QTabWidget* tabWidget = qobject_cast<QTabWidget*>(tabBar->parent());
if (tabWidget)
{
QWidget* widget = tabWidget->widget(fromIndex);
tabWidget->removeTab(fromIndex);
tabWidget->insertTab(toIndex, widget, "");
tabWidget->setCurrentIndex(toIndex);
}
else // tabbar is standalone (not embedded into a QTabWidget)
{
tabBar->removeTab(fromIndex);
tabBar->insertTab(toIndex, "");
tabBar->setCurrentIndex(toIndex);
}
restoreTab(toIndex, tab);
return true;
}
return false;
}
| void QxtTabBarPrivate::restoreTab | ( | int | index, |
| const Tab & | tab | ||
| ) |
Definition at line 207 of file qxttabbar.cpp.
References QxtTabBarPrivate::Tab::data, QxtTabBarPrivate::Tab::icon, QxtPrivate< QxtTabBar >::qxt_p(), QxtTabBarPrivate::Tab::text, QxtTabBarPrivate::Tab::textColor, QxtTabBarPrivate::Tab::toolTip, and QxtTabBarPrivate::Tab::whatsThis.
Referenced by moveTab().
{
QTabBar* tabBar = &qxt_p();
tabBar->setTabIcon(index, tab.icon);
tabBar->setTabData(index, tab.data);
tabBar->setTabText(index, tab.text);
tabBar->setTabTextColor(index, tab.textColor);
tabBar->setTabToolTip(index, tab.toolTip);
tabBar->setTabWhatsThis(index, tab.whatsThis);
}
| QxtTabBarPrivate::Tab QxtTabBarPrivate::saveTab | ( | int | index ) | const |
Definition at line 194 of file qxttabbar.cpp.
References QxtTabBarPrivate::Tab::data, QxtTabBarPrivate::Tab::icon, QxtPrivate< QxtTabBar >::qxt_p(), QxtTabBarPrivate::Tab::text, QxtTabBarPrivate::Tab::textColor, QxtTabBarPrivate::Tab::toolTip, and QxtTabBarPrivate::Tab::whatsThis.
Referenced by moveTab().
{
Tab tab;
const QTabBar* tabBar = &qxt_p();
tab.icon = tabBar->tabIcon(index);
tab.data = tabBar->tabData(index);
tab.text = tabBar->tabText(index);
tab.textColor = tabBar->tabTextColor(index);
tab.toolTip = tabBar->tabToolTip(index);
tab.whatsThis = tabBar->tabWhatsThis(index);
return tab;
}
| bool QxtTabBarPrivate::shouldMove | ( | const QPoint & | pos, |
| int | fromIndex, | ||
| int | toIndex, | ||
| MovementAction | action | ||
| ) | const |
Definition at line 116 of file qxttabbar.cpp.
References contains(), DropAction, and QxtPrivate< QxtTabBar >::qxt_p().
Referenced by moveTab().
{
if (fromIndex == -1 || toIndex == -1 || fromIndex == toIndex)
return false;
QRect sourceRect = qxt_p().tabRect(fromIndex);
QRect targetRect = qxt_p().tabRect(toIndex);
QRect finalRect;
if (action == DropAction)
{
finalRect = targetRect;
}
else
{
finalRect = sourceRect;
switch (qxt_p().shape())
{
case QTabBar::RoundedNorth:
case QTabBar::RoundedSouth:
case QTabBar::TriangularNorth:
case QTabBar::TriangularSouth:
if (qxt_p().layoutDirection() == Qt::LeftToRight && sourceRect.x() < targetRect.x())
finalRect.moveRight(targetRect.right());
else
finalRect.moveLeft(targetRect.left());
break;
case QTabBar::RoundedWest:
case QTabBar::RoundedEast:
case QTabBar::TriangularWest:
case QTabBar::TriangularEast:
if (sourceRect.y() < targetRect.y())
finalRect.moveBottom(targetRect.bottom());
else
finalRect.moveTop(targetRect.top());
break;
default:
qWarning("QTabBarPrivate: unknown QTabBar::Shape %i", qxt_p().shape());
return false;
}
}
return contains(finalRect, pos, action);
}
| int QxtTabBarPrivate::tabAt | ( | const QPoint & | position, |
| MovementAction | action | ||
| ) | const |
Definition at line 74 of file qxttabbar.cpp.
References contains(), and QxtPrivate< QxtTabBar >::qxt_p().
friend class QxtTabBar [friend] |
Definition at line 35 of file qxttabbar.cpp.
Definition at line 67 of file qxttabbar.cpp.
Definition at line 65 of file qxttabbar.cpp.
| QPoint QxtTabBarPrivate::pressPoint |
Definition at line 66 of file qxttabbar.cpp.
1.7.2