@@ -54,13 +54,10 @@ namespace ads
5454struct DockAreaTabBarPrivate
5555{
5656 CDockAreaTabBar* _this;
57- QPoint DragStartMousePos;
5857 CDockAreaWidget* DockArea;
59- IFloatingWidget* FloatingWidget = nullptr ;
6058 QWidget* TabsContainerWidget;
6159 QBoxLayout* TabsLayout;
6260 int CurrentIndex = -1 ;
63- eDragState DragState = DraggingInactive;
6461
6562 /* *
6663 * Private data constructor
@@ -72,14 +69,6 @@ struct DockAreaTabBarPrivate
7269 * The function reassigns the stylesheet to update the tabs
7370 */
7471 void updateTabs ();
75-
76- /* *
77- * Test function for current drag state
78- */
79- bool isDraggingState (eDragState dragState) const
80- {
81- return this ->DragState == dragState;
82- }
8372};
8473// struct DockAreaTabBarPrivate
8574
@@ -164,149 +153,6 @@ void CDockAreaTabBar::wheelEvent(QWheelEvent* Event)
164153}
165154
166155
167- // ============================================================================
168- void CDockAreaTabBar::mousePressEvent (QMouseEvent* ev)
169- {
170- if (ev->button () == Qt::LeftButton)
171- {
172- ev->accept ();
173- d->DragStartMousePos = ev->pos ();
174- d->DragState = DraggingMousePressed;
175- return ;
176- }
177- Super::mousePressEvent (ev);
178- }
179-
180-
181- // ============================================================================
182- void CDockAreaTabBar::mouseReleaseEvent (QMouseEvent* ev)
183- {
184- if (ev->button () == Qt::LeftButton)
185- {
186- ADS_PRINT (" CDockAreaTabBar::mouseReleaseEvent" );
187- ev->accept ();
188- auto CurrentDragState = d->DragState ;
189- d->DragStartMousePos = QPoint ();
190- d->DragState = DraggingInactive;
191- if (DraggingFloatingWidget == CurrentDragState)
192- {
193- d->FloatingWidget ->finishDragging ();
194- }
195- return ;
196- }
197- Super::mouseReleaseEvent (ev);
198- }
199-
200-
201- // ============================================================================
202- void CDockAreaTabBar::mouseMoveEvent (QMouseEvent* ev)
203- {
204- Super::mouseMoveEvent (ev);
205- if (!(ev->buttons () & Qt::LeftButton) || d->isDraggingState (DraggingInactive))
206- {
207- d->DragState = DraggingInactive;
208- return ;
209- }
210-
211- // move floating window
212- if (d->isDraggingState (DraggingFloatingWidget))
213- {
214- d->FloatingWidget ->moveFloating ();
215- return ;
216- }
217-
218- // If this is the last dock area in a dock container it does not make
219- // sense to move it to a new floating widget and leave this one
220- // empty
221- if (d->DockArea ->dockContainer ()->isFloating ()
222- && d->DockArea ->dockContainer ()->visibleDockAreaCount () == 1 )
223- {
224- return ;
225- }
226-
227- // If one single dock widget in this area is not floatable then the whole
228- // area is not floatable
229- if (!d->DockArea ->features ().testFlag (CDockWidget::DockWidgetFloatable))
230- {
231- return ;
232- }
233-
234- int DragDistance = (d->DragStartMousePos - ev->pos ()).manhattanLength ();
235- if (DragDistance >= CDockManager::startDragDistance ())
236- {
237- ADS_PRINT (" CTabsScrollArea::startFloating" );
238- startFloating (d->DragStartMousePos );
239- auto Overlay = d->DockArea ->dockManager ()->containerOverlay ();
240- Overlay->setAllowedAreas (OuterDockAreas);
241- }
242-
243- return ;
244- }
245-
246-
247- // ============================================================================
248- void CDockAreaTabBar::mouseDoubleClickEvent (QMouseEvent *event)
249- {
250- // If this is the last dock area in a dock container it does not make
251- // sense to move it to a new floating widget and leave this one
252- // empty
253- if (d->DockArea ->dockContainer ()->isFloating () && d->DockArea ->dockContainer ()->dockAreaCount () == 1 )
254- {
255- return ;
256- }
257-
258- if (!d->DockArea ->features ().testFlag (CDockWidget::DockWidgetFloatable))
259- {
260- return ;
261- }
262- makeAreaFloating (event->pos (), DraggingInactive);
263- }
264-
265-
266- // ============================================================================
267- IFloatingWidget* CDockAreaTabBar::makeAreaFloating (const QPoint& Offset, eDragState DragState)
268- {
269- QSize Size = d->DockArea ->size ();
270- d->DragState = DragState;
271- bool OpaqueUndocking = CDockManager::configFlags ().testFlag (CDockManager::OpaqueUndocking) ||
272- (DraggingFloatingWidget != DragState);
273- CFloatingDockContainer* FloatingDockContainer = nullptr ;
274- IFloatingWidget* FloatingWidget;
275- if (OpaqueUndocking)
276- {
277- FloatingWidget = FloatingDockContainer = new CFloatingDockContainer (d->DockArea );
278- }
279- else
280- {
281- auto w = new CFloatingDragPreview (d->DockArea );
282- connect (w, &CFloatingDragPreview::draggingCanceled, [=]()
283- {
284- d->DragState = DraggingInactive;
285- });
286- FloatingWidget = w;
287- }
288-
289- FloatingWidget->startFloating (Offset, Size, DragState, nullptr );
290- if (FloatingDockContainer)
291- {
292- auto TopLevelDockWidget = FloatingDockContainer->topLevelDockWidget ();
293- if (TopLevelDockWidget)
294- {
295- TopLevelDockWidget->emitTopLevelChanged (true );
296- }
297- }
298-
299- return FloatingWidget;
300- }
301-
302-
303- // ============================================================================
304- void CDockAreaTabBar::startFloating (const QPoint& Offset)
305- {
306- d->FloatingWidget = makeAreaFloating (Offset, DraggingFloatingWidget);
307- }
308-
309-
310156// ============================================================================
311157void CDockAreaTabBar::setCurrentIndex (int index)
312158{
@@ -625,7 +471,6 @@ bool CDockAreaTabBar::isTabOpen(int Index) const
625471QSize CDockAreaTabBar::minimumSizeHint () const
626472{
627473 QSize Size = sizeHint ();
628- // Size.setWidth(Super::minimumSizeHint().width());// this defines the minimum width of a dock area
629474 Size.setWidth (10 );
630475 return Size;
631476}
@@ -637,13 +482,6 @@ QSize CDockAreaTabBar::sizeHint() const
637482 return d->TabsContainerWidget ->sizeHint ();
638483}
639484
640-
641- // ===========================================================================
642- eDragState CDockAreaTabBar::dragState () const
643- {
644- return d->DragState ;
645- }
646-
647485} // namespace ads
648486
649487
0 commit comments