/** * @brief 마우스 커서가 MainWindow의 탭영역(1,2,3)에 올라가있는지 확인한다. * * +-------------------------------+-+-+-+ * | TITLE BAR |_|O|X| * +----------+----------+---------+-+-+-+ * |##1(Tab)##|##2(Tab)##|###3(Empty)####| * +----------+----------+---------------+ * | | * | 4 | * | | * +-------------------------------------+ * * TabBar::geometry()는 1,2영역을 나타내고, TabWidget::geometry()는 1,2,3,4영역을 나타낸다. * 이 두 geometry()를 연산해서 1,2,3 영역을 찾는다. * * @param mainWindow 대상 메인 윈도 * @return bool * */ bool CWindowManager::isCursorOnTabWithEmptyArea(MainWindow *mainWindow) { QRect barRect; QRect barRectG; QRect widgetRect; QRect widgetRectG; QTabBar* tabBar = 0; QTabWidget* tabWidget = 0; if(!mainWindow) return false; tabBar = mainWindow->getTabBar(); tabWidget = mainWindow->getTabWidget(); barRect = tabBar->geometry(); widgetRect = tabWidget->geometry(); barRectG.setTopLeft(tabBar->mapToGlobal(barRect.topLeft())); barRectG.setBottomRight(tabBar->mapToGlobal(barRect.bottomRight())); widgetRectG.setTopLeft(tabWidget->mapToGlobal(widgetRect.topLeft())); widgetRectG.setBottomRight(tabWidget->mapToGlobal(widgetRect.bottomRight())); widgetRectG.setTopLeft(QPoint(widgetRectG.topLeft().x(), barRectG.topLeft().y())); widgetRectG.setBottomRight(QPoint(widgetRectG.bottomRight().x(), barRectG.bottomRight().y())); return widgetRectG.contains(QCursor::pos()); }
QRect NativeTabItem::GetBounds() { int index = parent->IndexOf(this); QTabBar* folder = parent->GetTabFolder(); QRect localRect = folder->tabRect(index); QPoint topLeft = localRect.topLeft(); QPoint bottomRight = localRect.bottomRight(); QPoint globalTopLeft = folder->mapToGlobal(topLeft); QPoint globalBottomRight = folder->mapToGlobal(bottomRight); return QRect(globalTopLeft, globalBottomRight); }
void GTTabWidget::clickTab(GUITestOpStatus &os, QTabWidget* tabWidget, int idx, Qt::MouseButton button){ GT_CHECK(tabWidget != NULL, "tabWidget is NULL"); setCurrentIndex(os, tabWidget, idx); QTabBar* tabBar = getTabBar(os, tabWidget); QRect r = tabBar->tabRect(idx); GTMouseDriver::moveTo(os, tabBar->mapToGlobal(r.center())); GTMouseDriver::click(os, button); }
QRect QTabContainer::findDropRect(const QPoint& globalPos, int tabWidth, QTabFramework::InsertPolicy& insertPolicy, QRect& tabRectResult, int& tabIndex) { QPoint pos = mapFromGlobal(globalPos); QRect containerRect = rect(); QRect result; tabIndex = -1; if(containerRect.contains(pos)) { if(count() == 0) { insertPolicy = QTabFramework::InsertOnTop; result = containerRect; } else if(tabBar()->geometry().contains(pos)) { insertPolicy = QTabFramework::Insert; result = containerRect; QTabBar* tabBar = this->tabBar(); for(int i = 0, count = tabBar->count(); i < count; ++i) { QRect tabRect = tabBar->tabRect(i); if(tabRect.contains(pos)) { tabRectResult = tabRect; tabRectResult.setRight(tabRect.left() + tabWidth); tabRectResult.translate(tabBar->mapToGlobal(QPoint(0, 0))); tabIndex = i; break; } } } else if(pos.x() < containerRect.x() + containerRect.width() / 3) { insertPolicy = QTabFramework::InsertLeft; result = QRect(containerRect.topLeft(), QPoint(containerRect.x() + containerRect.width() / 3, containerRect.bottom())); } else if(pos.x() >= containerRect.x() + containerRect.width() * 2 / 3) { insertPolicy = QTabFramework::InsertRight; result = QRect(QPoint(containerRect.x() + containerRect.width() * 2 / 3, containerRect.y()), containerRect.bottomRight()); } else if(pos.y() < containerRect.y() + tabBar()->geometry().height()) { insertPolicy = QTabFramework::Insert; result = containerRect; tabIndex = this->tabBar()->count(); } else if(pos.y() < containerRect.y() + containerRect.height() / 3) { insertPolicy = QTabFramework::InsertTop; result = QRect(containerRect.topLeft(), QPoint(containerRect.right(), containerRect.y() + containerRect.height() / 3)); } else if(pos.y() >= containerRect.y() + containerRect.height() * 2 / 3) { insertPolicy = QTabFramework::InsertBottom; result = QRect(QPoint(containerRect.x(), containerRect.y() + containerRect.height() * 2 / 3), containerRect.bottomRight()); } else { insertPolicy = QTabFramework::InsertOnTop; result = containerRect; } } else { insertPolicy = QTabFramework::InsertFloating; return QRect(); } result.translate(mapToGlobal(QPoint(0, 0))); return result; }