ATLAS Offline Software
Loading...
Searching...
No Matches
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 );
78 connect( m_d->mActivateDragSwitchTabTimer, &QTimer::timeout , this, &VP1TabBar::activateDragSwitchTab );
79
80 //connect( this, SIGNAL( layoutChanged() ), SLOT( onLayoutChange() ) );
81}
virtual void activateDragSwitchTab()
Private *const m_d
Definition VP1TabBar.h:94

◆ ~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}
int selectTab(const QPoint &position) const

◆ 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}
void testCanDecode(const QDragMoveEvent *, bool &)
StatusCode accept(const xAOD::Muon *mu)

◆ 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 ) {
230 m_d->mActivateDragSwitchTabTimer->stop();
231 m_d->mDragSwitchTab = 0;
232 emit receivedDropEvent( tab , event );
233 return;
234 }
235
236 QTabBar::dropEvent( event );
237}
void receivedDropEvent(int, QDropEvent *)

◆ 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}
void mouseDoubleClick(int)

◆ 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 ) {
123 m_d->mActivateDragSwitchTabTimer->stop();
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
157 m_d->mReorderPreviousTab = m_d->mReorderStartTab;
158 m_d->mReorderStartTab = reorderStopTab;
159
160 return;
161 }
162 }
163 }
164 }
165
166 QTabBar::mouseMoveEvent( event );
167}
double delay(std::size_t d)
void moveTab(int, int)
void initiateDrag(int)

◆ 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}
void contextMenu(int, const QPoint &)

◆ 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}
void mouseMiddleClick(int)

◆ 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}
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146

◆ setTabCloseActivatePrevious()

void VP1TabBar::setTabCloseActivatePrevious ( bool on)

Definition at line 261 of file VP1TabBar.cxx.

262{
263 m_d->mTabCloseActivatePrevious = on;
264}

◆ setTabReorderingEnabled()

void VP1TabBar::setTabReorderingEnabled ( bool enable)

Definition at line 251 of file VP1TabBar.cxx.

252{
253 m_d->mTabReorderingEnabled = on;
254}

◆ tabCloseActivatePrevious()

bool VP1TabBar::tabCloseActivatePrevious ( ) const

Definition at line 256 of file VP1TabBar.cxx.

257{
258 return m_d->mTabCloseActivatePrevious;
259}

◆ tabLayoutChange()

void VP1TabBar::tabLayoutChange ( )
protectedvirtual

Definition at line 267 of file VP1TabBar.cxx.

268{
269 m_d->mActivateDragSwitchTabTimer->stop();
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}
void wheelDelta(int)

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: