ATLAS Offline Software
Classes | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Private Attributes | List of all members
VP1TabBar Class Reference

#include <VP1TabBar.h>

Inheritance diagram for VP1TabBar:
Collaboration diagram for VP1TabBar:

Classes

class  Private
 

Signals

void contextMenu (int, const QPoint &)
 
void mouseDoubleClick (int)
 
void mouseMiddleClick (int)
 
void initiateDrag (int)
 
void testCanDecode (const QDragMoveEvent *, bool &)
 
void receivedDropEvent (int, QDropEvent *)
 
void moveTab (int, int)
 
void closeRequest (int)
 
void wheelDelta (int)
 

Public Member Functions

 VP1TabBar (QWidget *parent=0)
 
virtual ~VP1TabBar ()
 
void setTabReorderingEnabled (bool enable)
 
bool isTabReorderingEnabled () const
 
void setTabCloseActivatePrevious (bool)
 
bool tabCloseActivatePrevious () const
 
int selectTab (const QPoint &position) const
 

Protected Slots

virtual void activateDragSwitchTab ()
 

Protected Member Functions

virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void wheelEvent (QWheelEvent *event)
 
virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
virtual void tabLayoutChange ()
 

Private Attributes

Private *const m_d
 

Detailed Description

Definition at line 41 of file VP1TabBar.h.

Constructor & Destructor Documentation

◆ VP1TabBar()

VP1TabBar::VP1TabBar ( QWidget *  parent = 0)
explicit

Definition at line 66 of file VP1TabBar.cxx.

67  : QTabBar( parent ),
68  m_d( new Private )
69 {
70  setAcceptDrops( true );
71  setMouseTracking( true );
72 
73  //m_d->mEnableCloseButtonTimer = new QTimer( this );
74  //connect( m_d->mEnableCloseButtonTimer, SIGNAL( timeout() ), SLOT( enableCloseButton() ) );
75 
76  m_d->mActivateDragSwitchTabTimer = new QTimer( this );
77  m_d->mActivateDragSwitchTabTimer->setSingleShot( true );
79 
80  //connect( this, SIGNAL( layoutChanged() ), SLOT( onLayoutChange() ) );
81 }

◆ ~VP1TabBar()

VP1TabBar::~VP1TabBar ( )
virtual

Definition at line 83 of file VP1TabBar.cxx.

84 {
85  delete m_d;
86 }

Member Function Documentation

◆ activateDragSwitchTab

void VP1TabBar::activateDragSwitchTab ( )
protectedvirtualslot

Definition at line 170 of file VP1TabBar.cxx.

171 {
172  int tab = selectTab( mapFromGlobal( QCursor::pos() ) );
173  if ( tab != -1 && m_d->mDragSwitchTab == tab )
174  setCurrentIndex( m_d->mDragSwitchTab );
175 
176  m_d->mDragSwitchTab = 0;
177 }

◆ closeRequest

void VP1TabBar::closeRequest ( int  )
signal

◆ contextMenu

void VP1TabBar::contextMenu ( int  ,
const QPoint &   
)
signal

◆ dragEnterEvent()

void VP1TabBar::dragEnterEvent ( QDragEnterEvent *  event)
protectedvirtual

Definition at line 199 of file VP1TabBar.cxx.

200 {
201  event->setAccepted( true );
202  QTabBar::dragEnterEvent( event );
203 }

◆ dragMoveEvent()

void VP1TabBar::dragMoveEvent ( QDragMoveEvent *  event)
protectedvirtual

Definition at line 205 of file VP1TabBar.cxx.

206 {
207  int tab = selectTab( event->pos() );
208  if ( tab != -1 ) {
209  bool accept = false;
210  // The receivers of the testCanDecode() signal has to adjust
211  // 'accept' accordingly.
212  emit testCanDecode( event, accept );
213  if ( accept && tab != currentIndex() ) {
214  m_d->mDragSwitchTab = tab;
215  m_d->mActivateDragSwitchTabTimer->start( QApplication::doubleClickInterval() * 2 );
216  }
217 
218  event->setAccepted( accept );
219  return;
220  }
221 
222  event->setAccepted( false );
223  QTabBar::dragMoveEvent( event );
224 }

◆ dropEvent()

void VP1TabBar::dropEvent ( QDropEvent *  event)
protectedvirtual

Definition at line 226 of file VP1TabBar.cxx.

227 {
228  int tab = selectTab( event->pos() );
229  if ( tab != -1 ) {
231  m_d->mDragSwitchTab = 0;
232  emit receivedDropEvent( tab , event );
233  return;
234  }
235 
236  QTabBar::dropEvent( event );
237 }

◆ initiateDrag

void VP1TabBar::initiateDrag ( int  )
signal

◆ isTabReorderingEnabled()

bool VP1TabBar::isTabReorderingEnabled ( ) const

Definition at line 246 of file VP1TabBar.cxx.

247 {
248  return m_d->mTabReorderingEnabled;
249 }

◆ mouseDoubleClick

void VP1TabBar::mouseDoubleClick ( int  )
signal

◆ mouseDoubleClickEvent()

void VP1TabBar::mouseDoubleClickEvent ( QMouseEvent *  event)
protectedvirtual

Definition at line 88 of file VP1TabBar.cxx.

89 {
90  if ( event->button() != Qt::LeftButton )
91  return;
92 
93  int tab = selectTab( event->pos() );
94  if ( tab != -1 ) {
95  emit mouseDoubleClick( tab );
96  return;
97  }
98 
99  QTabBar::mouseDoubleClickEvent( event );
100 }

◆ mouseMiddleClick

void VP1TabBar::mouseMiddleClick ( int  )
signal

◆ mouseMoveEvent()

void VP1TabBar::mouseMoveEvent ( QMouseEvent *  event)
protectedvirtual

Definition at line 118 of file VP1TabBar.cxx.

119 {
120  if ( event->buttons() == Qt::LeftButton ) {
121  int tab = selectTab( event->pos() );
122  if ( m_d->mDragSwitchTab && tab != m_d->mDragSwitchTab ) {
124  m_d->mDragSwitchTab = 0;
125  }
126 
127  int delay = 5;//TK fixme KGlobalSettings::dndEventDelay();
128  QPoint newPos = event->pos();
129  if ( newPos.x() > m_d->mDragStart.x() + delay || newPos.x() < m_d->mDragStart.x() - delay ||
130  newPos.y() > m_d->mDragStart.y() + delay || newPos.y() < m_d->mDragStart.y() - delay ) {
131  if ( tab != -1 ) {
132  emit initiateDrag( tab );
133  return;
134  }
135  }
136  } else if ( event->buttons() == Qt::MiddleButton ) {
137  if ( m_d->mReorderStartTab == -1 ) {
138  int delay = 5;//TK fixme KGlobalSettings::dndEventDelay();
139  QPoint newPos = event->pos();
140 
141  if ( newPos.x() > m_d->mDragStart.x() + delay || newPos.x() < m_d->mDragStart.x() - delay ||
142  newPos.y() > m_d->mDragStart.y() + delay || newPos.y() < m_d->mDragStart.y() - delay ) {
143  int tab = selectTab( event->pos() );
144  if ( tab != -1 && m_d->mTabReorderingEnabled ) {
145  m_d->mReorderStartTab = tab;
146  grabMouse( Qt::SizeAllCursor );
147  return;
148  }
149  }
150  } else {
151  int tab = selectTab( event->pos() );
152  if ( tab != -1 ) {
153  int reorderStopTab = tab;
154  if ( m_d->mReorderStartTab != reorderStopTab && m_d->mReorderPreviousTab != reorderStopTab ) {
155  emit moveTab( m_d->mReorderStartTab, reorderStopTab );
156 
158  m_d->mReorderStartTab = reorderStopTab;
159 
160  return;
161  }
162  }
163  }
164  }
165 
166  QTabBar::mouseMoveEvent( event );
167 }

◆ mousePressEvent()

void VP1TabBar::mousePressEvent ( QMouseEvent *  event)
protectedvirtual

Definition at line 102 of file VP1TabBar.cxx.

103 {
104  if ( event->button() == Qt::LeftButton ) {
105  //m_d->mEnableCloseButtonTimer->stop();
106  m_d->mDragStart = event->pos();
107  } else if( event->button() == Qt::RightButton ) {
108  int tab = selectTab( event->pos() );
109  if ( tab != -1 ) {
110  emit contextMenu( tab, mapToGlobal( event->pos() ) );
111  return;
112  }
113  }
114 
115  QTabBar::mousePressEvent( event );
116 }

◆ mouseReleaseEvent()

void VP1TabBar::mouseReleaseEvent ( QMouseEvent *  event)
protectedvirtual

Definition at line 179 of file VP1TabBar.cxx.

180 {
181  if ( event->button() == Qt::MiddleButton ) {
182  if ( m_d->mReorderStartTab == -1 ) {
183  int tab = selectTab( event->pos() );
184  if ( tab != -1 ) {
185  emit mouseMiddleClick( tab );
186  return;
187  }
188  } else {
189  releaseMouse();
190  setCursor( Qt::ArrowCursor );
191  m_d->mReorderStartTab = -1;
192  m_d->mReorderPreviousTab = -1;
193  }
194  }
195 
196  QTabBar::mouseReleaseEvent( event );
197 }

◆ moveTab

void VP1TabBar::moveTab ( int  ,
int   
)
signal

◆ receivedDropEvent

void VP1TabBar::receivedDropEvent ( int  ,
QDropEvent *   
)
signal

◆ selectTab()

int VP1TabBar::selectTab ( const QPoint &  position) const

Definition at line 273 of file VP1TabBar.cxx.

274 {
275  for ( int i = 0; i < count(); ++i )
276  if ( tabRect( i ).contains( pos ) )
277  return i;
278 
279  return -1;
280 }

◆ setTabCloseActivatePrevious()

void VP1TabBar::setTabCloseActivatePrevious ( bool  on)

Definition at line 261 of file VP1TabBar.cxx.

262 {
264 }

◆ setTabReorderingEnabled()

void VP1TabBar::setTabReorderingEnabled ( bool  enable)

Definition at line 251 of file VP1TabBar.cxx.

252 {
254 }

◆ tabCloseActivatePrevious()

bool VP1TabBar::tabCloseActivatePrevious ( ) const

Definition at line 256 of file VP1TabBar.cxx.

257 {
259 }

◆ tabLayoutChange()

void VP1TabBar::tabLayoutChange ( )
protectedvirtual

Definition at line 267 of file VP1TabBar.cxx.

268 {
270  m_d->mDragSwitchTab = 0;
271 }

◆ testCanDecode

void VP1TabBar::testCanDecode ( const QDragMoveEvent *  ,
bool &   
)
signal

◆ wheelDelta

void VP1TabBar::wheelDelta ( int  )
signal

◆ wheelEvent()

void VP1TabBar::wheelEvent ( QWheelEvent *  event)
protectedvirtual

Definition at line 240 of file VP1TabBar.cxx.

241 {
242  emit( wheelDelta( event->angleDelta().y() ) );
243 }

Member Data Documentation

◆ m_d

Private* const VP1TabBar::m_d
private

Definition at line 94 of file VP1TabBar.h.


The documentation for this class was generated from the following files:
VP1TabBar::mouseDoubleClick
void mouseDoubleClick(int)
VP1TabBar::mouseMiddleClick
void mouseMiddleClick(int)
VP1TabBar::testCanDecode
void testCanDecode(const QDragMoveEvent *, bool &)
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
VP1TabBar::Private::mTabCloseActivatePrevious
bool mTabCloseActivatePrevious
Definition: VP1TabBar.cxx:62
VP1TabBar::wheelDelta
void wheelDelta(int)
VP1TabBar::Private::mTabReorderingEnabled
bool mTabReorderingEnabled
Definition: VP1TabBar.cxx:61
VP1TabBar::selectTab
int selectTab(const QPoint &position) const
Definition: VP1TabBar.cxx:273
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
VP1TabBar::activateDragSwitchTab
virtual void activateDragSwitchTab()
Definition: VP1TabBar.cxx:170
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:85
VP1TabBar::Private::mActivateDragSwitchTabTimer
QTimer * mActivateDragSwitchTabTimer
Definition: VP1TabBar.cxx:59
test_pyathena.parent
parent
Definition: test_pyathena.py:15
delay
double delay(std::size_t d)
Definition: JetTrigTimerTest.cxx:14
VP1TabBar::Private::mDragStart
QPoint mDragStart
Definition: VP1TabBar.cxx:55
VP1TabBar::receivedDropEvent
void receivedDropEvent(int, QDropEvent *)
VP1TabBar::initiateDrag
void initiateDrag(int)
VP1TabBar::Private::mReorderStartTab
int mReorderStartTab
Definition: VP1TabBar.cxx:56
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
VP1TabBar::Private::mDragSwitchTab
int mDragSwitchTab
Definition: VP1TabBar.cxx:58
VP1TabBar::Private::mReorderPreviousTab
int mReorderPreviousTab
Definition: VP1TabBar.cxx:57
VP1TabBar::contextMenu
void contextMenu(int, const QPoint &)
python.TrigInDetArtSteps.timeout
timeout
Definition: TrigInDetArtSteps.py:35
VP1TabBar::m_d
Private *const m_d
Definition: VP1TabBar.h:93
VP1TabBar::moveTab
void moveTab(int, int)