My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vtabbeddockwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2006 by Gopala Krishna A <krishna.ggk@gmail.com> *
3  * *
4  * This is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2, or (at your option) *
7  * any later version. *
8  * *
9  * This software is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this package; see the file COPYING. If not, write to *
16  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, *
17  * Boston, MA 02110-1301, USA. *
18  ***************************************************************************/
19 
20 #include "vtabbeddockwidget.h"
21 #include "vtabwidget.h"
22 #include <qapplication.h>
23 #include <qmainwindow.h>
24 
25 VTabbedDockWidget::VTabbedDockWidget(Place p, QWidget* parent, const char* name): QDockWindow(p, parent, name)
26 {
27  setOrientation(Vertical);
28  m_tabWidget = 0l;
29  setCloseMode(QDockWindow::Always);
30 }
31 
33 {}
34 
36 {
37  QDockWindow::setWidget(w);
38  if(!(w->inherits("VTabWidget")))
39  return;
40  m_tabWidget = (VTabWidget*)w;
41  setResizeEnabled(false);
42  setHorizontallyStretchable(false);
43  connect(m_tabWidget,SIGNAL(widgetStackHidden()),this,SLOT(slotStackHidden()));
44  connect(m_tabWidget,SIGNAL(widgetStackShown()),this,SLOT(slotStackShown()));
45  connect(this,SIGNAL(placeChanged( QDockWindow::Place )),SLOT(updatePosition(QDockWindow::Place)));
46 }
47 
51 void VTabbedDockWidget::slotStackShown()
52 {
53  setFixedExtentWidth(m_tabWidget->sizeHint().width());
54  setHorizontallyStretchable(true);
55  setResizeEnabled(true);
56 }
57 
61 void VTabbedDockWidget::slotStackHidden()
62 {
63  setFixedExtentWidth(m_tabWidget->sizeHint().width());
64  setHorizontallyStretchable(false);
65  setResizeEnabled(false);
66 }
67 
71 void VTabbedDockWidget::updatePosition(QDockWindow::Place p)
72 {
73  if(p==OutsideDock)
74  return;
75  if(!(qApp->mainWidget()->inherits("QMainWindow")))
76  return;
77  QMainWindow *mainWin = (QMainWindow*)(qApp->mainWidget());
78  Dock dock;
79  int ind,eo;//Not needed really
80  bool nl;//Not needed really
81 
82  bool res = mainWin->getLocation ( this, dock, ind, nl, eo );
83  if(res == false)
84  return;
85  if(dock == QDockWindow::DockLeft)
86  m_tabWidget->setPosition(TabLeft);
87  else if(dock == QDockWindow::DockRight)
88  m_tabWidget->setPosition(TabRight);
89  mainWin->lineUpDockWindows();
90 }