~ubuntu-branches/ubuntu/wily/tora/wily-proposed

« back to all changes in this revision

Viewing changes to src/totabwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Albin Tonnerre
  • Date: 2007-05-29 13:13:36 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529131336-85ygaddivvmkd3xc
Tags: 1.3.21pre22-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - debian/rules: call dh_iconcache
  - Remove g++ build dependency
* Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****
 
2
*
 
3
* TOra - An Oracle Toolkit for DBA's and developers
 
4
* Copyright (C) 2003-2005 Quest Software, Inc
 
5
* Portions Copyright (C) 2005 Other Contributors
 
6
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation;  only version 2 of
 
10
* the License is valid for this program.
 
11
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
 
17
* You should have received a copy of the GNU General Public License
 
18
* along with this program; if not, write to the Free Software
 
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
20
*
 
21
*      As a special exception, you have permission to link this program
 
22
*      with the Oracle Client libraries and distribute executables, as long
 
23
*      as you follow the requirements of the GNU GPL in regard to all of the
 
24
*      software in the executable aside from Oracle client libraries.
 
25
*
 
26
*      Specifically you are not permitted to link this program with the
 
27
*      Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
 
28
*      And you are not permitted to distribute binaries compiled against
 
29
*      these libraries without written consent from Quest Software, Inc.
 
30
*      Observe that this does not disallow linking to the Qt Free Edition.
 
31
*
 
32
*      You may link this product with any GPL'd Qt library such as Qt/Free
 
33
*
 
34
* All trademarks belong to their respective owners.
 
35
*
 
36
*****/
 
37
 
 
38
#include <list>
 
39
 
 
40
#include "totabwidget.h"
 
41
 
 
42
#include <qobject.h>
 
43
#include <qtabwidget.h>
 
44
 
 
45
#include "totabwidget.moc"
 
46
 
 
47
int toTabBar::insertTab(QTab *newTab, int ix)
 
48
{
 
49
    std::list<barTab>::iterator i = Tabs.begin();
 
50
    if (ix >= 0)
 
51
    {
 
52
        for (int j = 0;j < ix && i != Tabs.end();j++)
 
53
            i++;
 
54
    }
 
55
    else
 
56
        i = Tabs.end();
 
57
    Tabs.insert(i, barTab(newTab, true));
 
58
    return QTabBar::insertTab(newTab, ix);
 
59
}
 
60
 
 
61
void toTabBar::removeTab(QTab *tab)
 
62
{
 
63
    for (std::list<barTab>::iterator i = Tabs.begin();i != Tabs.end();i++)
 
64
    {
 
65
        if ((*i).Tab == tab)
 
66
        {
 
67
            QTabBar::removeTab(tab);
 
68
            Tabs.erase(i);
 
69
            return ;
 
70
        }
 
71
    }
 
72
}
 
73
 
 
74
void toTabWidget::setTabShown(QWidget *w, bool value)
 
75
{
 
76
    int ix = indexOf(w);
 
77
    if (ix >= 0)
 
78
    {
 
79
        Tabs->setTabShown(ix, value);
 
80
        QShowEvent e;
 
81
        showEvent(&e); // Force an update
 
82
    }
 
83
}
 
84
 
 
85
void toTabBar::setTabShown(int ix, bool shown)
 
86
{
 
87
    if (ix < 0)
 
88
        return ;
 
89
 
 
90
    std::list<barTab>::iterator i = Tabs.begin();
 
91
    for (int j = 0;j < ix && i != Tabs.end();j++)
 
92
        i++;
 
93
    if (i != Tabs.end())
 
94
        (*i).Shown = shown;
 
95
    layoutTabs();
 
96
}
 
97
 
 
98
void toTabBar::layoutTabs()
 
99
{
 
100
    QTabBar::layoutTabs();
 
101
    int offset = 0;
 
102
    for (std::list<barTab>::iterator i = Tabs.begin();i != Tabs.end();i++)
 
103
    {
 
104
        if ((*i).Tab->rect().isValid())
 
105
            (*i).Rect = (*i).Tab->rect();
 
106
        else
 
107
            (*i).Tab->setRect((*i).Rect);
 
108
        if ((*i).Shown)
 
109
        {
 
110
            QRect r = (*i).Tab->rect();
 
111
            r.moveBy(offset - r.left(), 0);
 
112
            (*i).Tab->setRect(r);
 
113
            offset += r.width();
 
114
        }
 
115
        else
 
116
        {
 
117
            QRect r;
 
118
            (*i).Tab->setRect(r);
 
119
        }
 
120
    }
 
121
}