author | chicken <chicken> | 2004-03-01 17:53:46 (UTC) |
---|---|---|
committer | chicken <chicken> | 2004-03-01 17:53:46 (UTC) |
commit | 5b4e342004537f84fa53911a46cd00d810378da7 (patch) (unidiff) | |
tree | 763c74ad41014de91c010fb996ec527f841ef3bc /libqtaux | |
parent | 5b640d3f070b0b2de361421abf93949410546e19 (diff) | |
download | opie-5b4e342004537f84fa53911a46cd00d810378da7.zip opie-5b4e342004537f84fa53911a46cd00d810378da7.tar.gz opie-5b4e342004537f84fa53911a46cd00d810378da7.tar.bz2 |
fix includes
-rw-r--r-- | libqtaux/ocolorbutton.cpp | 3 | ||||
-rw-r--r-- | libqtaux/ocolorpopupmenu.cpp | 1 | ||||
-rw-r--r-- | libqtaux/qcolordialog.cpp | 2 | ||||
-rw-r--r-- | libqtaux/qinputdialog.cpp | 1 | ||||
-rw-r--r-- | libqtaux/qsplitter.cpp | 4 |
5 files changed, 0 insertions, 11 deletions
diff --git a/libqtaux/ocolorbutton.cpp b/libqtaux/ocolorbutton.cpp index d2ad873..fd3f963 100644 --- a/libqtaux/ocolorbutton.cpp +++ b/libqtaux/ocolorbutton.cpp | |||
@@ -1,150 +1,147 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Robert Griebl <sandman@handhelds.org> | 3 | Copyright (C) Robert Griebl <sandman@handhelds.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "ocolorpopupmenu.h" | 30 | #include "ocolorpopupmenu.h" |
31 | #include "ocolorbutton.h" | 31 | #include "ocolorbutton.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <qpe/resource.h> | ||
35 | 34 | ||
36 | /* QT */ | 35 | /* QT */ |
37 | #include <qcolor.h> | ||
38 | #include <qpixmap.h> | ||
39 | #include <qimage.h> | 36 | #include <qimage.h> |
40 | 37 | ||
41 | using namespace Opie; | 38 | using namespace Opie; |
42 | 39 | ||
43 | struct OColorButtonPrivate | 40 | struct OColorButtonPrivate |
44 | { | 41 | { |
45 | QPopupMenu *m_menu; | 42 | QPopupMenu *m_menu; |
46 | QColor m_color; | 43 | QColor m_color; |
47 | }; | 44 | }; |
48 | 45 | ||
49 | /** | 46 | /** |
50 | * This concstructs a Color Button with @param color as the start color | 47 | * This concstructs a Color Button with @param color as the start color |
51 | * It'll use a OColorPopupMenu internally | 48 | * It'll use a OColorPopupMenu internally |
52 | * | 49 | * |
53 | * @param parent The parent of the Color Button | 50 | * @param parent The parent of the Color Button |
54 | * @param color The color from where to start on | 51 | * @param color The color from where to start on |
55 | * @param name @see QObject | 52 | * @param name @see QObject |
56 | */ | 53 | */ |
57 | OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name ) | 54 | OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name ) |
58 | : QPushButton ( parent, name ) | 55 | : QPushButton ( parent, name ) |
59 | { | 56 | { |
60 | d = new OColorButtonPrivate; | 57 | d = new OColorButtonPrivate; |
61 | 58 | ||
62 | d-> m_menu = new OColorPopupMenu ( color, 0, 0 ); | 59 | d-> m_menu = new OColorPopupMenu ( color, 0, 0 ); |
63 | setPopup ( d-> m_menu ); | 60 | setPopup ( d-> m_menu ); |
64 | //setPopupDelay ( 0 ); | 61 | //setPopupDelay ( 0 ); |
65 | connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & ))); | 62 | connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & ))); |
66 | 63 | ||
67 | updateColor ( color ); | 64 | updateColor ( color ); |
68 | 65 | ||
69 | QSize s = sizeHint ( ) + QSize ( 12, 0 ); | 66 | QSize s = sizeHint ( ) + QSize ( 12, 0 ); |
70 | setMinimumSize ( s ); | 67 | setMinimumSize ( s ); |
71 | setMaximumSize ( s. width ( ) * 2, s. height ( )); | 68 | setMaximumSize ( s. width ( ) * 2, s. height ( )); |
72 | } | 69 | } |
73 | 70 | ||
74 | /** | 71 | /** |
75 | * This destructs the object | 72 | * This destructs the object |
76 | */ | 73 | */ |
77 | OColorButton::~OColorButton ( ) | 74 | OColorButton::~OColorButton ( ) |
78 | { | 75 | { |
79 | delete d; | 76 | delete d; |
80 | } | 77 | } |
81 | 78 | ||
82 | /** | 79 | /** |
83 | * @return Returns the current color of the button | 80 | * @return Returns the current color of the button |
84 | */ | 81 | */ |
85 | QColor OColorButton::color ( ) const | 82 | QColor OColorButton::color ( ) const |
86 | { | 83 | { |
87 | return d-> m_color; | 84 | return d-> m_color; |
88 | } | 85 | } |
89 | 86 | ||
90 | /** | 87 | /** |
91 | * This method sets the color of the button | 88 | * This method sets the color of the button |
92 | * @param c The color to be set. | 89 | * @param c The color to be set. |
93 | */ | 90 | */ |
94 | void OColorButton::setColor ( const QColor &c ) | 91 | void OColorButton::setColor ( const QColor &c ) |
95 | { | 92 | { |
96 | updateColor ( c ); | 93 | updateColor ( c ); |
97 | } | 94 | } |
98 | 95 | ||
99 | /** | 96 | /** |
100 | * @internal | 97 | * @internal |
101 | */ | 98 | */ |
102 | void OColorButton::updateColor ( const QColor &c ) | 99 | void OColorButton::updateColor ( const QColor &c ) |
103 | { | 100 | { |
104 | d-> m_color = c; | 101 | d-> m_color = c; |
105 | 102 | ||
106 | QImage img ( 16, 16, 32 ); | 103 | QImage img ( 16, 16, 32 ); |
107 | img. fill ( 0 ); | 104 | img. fill ( 0 ); |
108 | 105 | ||
109 | int r, g, b; | 106 | int r, g, b; |
110 | c. rgb ( &r, &g, &b ); | 107 | c. rgb ( &r, &g, &b ); |
111 | 108 | ||
112 | int w = img. width ( ); | 109 | int w = img. width ( ); |
113 | int h = img. height ( ); | 110 | int h = img. height ( ); |
114 | 111 | ||
115 | int dx = w * 20 / 100; // 15% | 112 | int dx = w * 20 / 100; // 15% |
116 | int dy = h * 20 / 100; | 113 | int dy = h * 20 / 100; |
117 | 114 | ||
118 | for ( int y = 0; y < h; y++ ) | 115 | for ( int y = 0; y < h; y++ ) |
119 | { | 116 | { |
120 | for ( int x = 0; x < w; x++ ) | 117 | for ( int x = 0; x < w; x++ ) |
121 | { | 118 | { |
122 | double alpha = 1.0; | 119 | double alpha = 1.0; |
123 | 120 | ||
124 | if ( x < dx ) | 121 | if ( x < dx ) |
125 | alpha *= ( double ( x + 1 ) / dx ); | 122 | alpha *= ( double ( x + 1 ) / dx ); |
126 | else if ( x >= w - dx ) | 123 | else if ( x >= w - dx ) |
127 | alpha *= ( double ( w - x ) / dx ); | 124 | alpha *= ( double ( w - x ) / dx ); |
128 | if ( y < dy ) | 125 | if ( y < dy ) |
129 | alpha *= ( double ( y + 1 ) / dy ); | 126 | alpha *= ( double ( y + 1 ) / dy ); |
130 | else if ( y >= h - dy ) | 127 | else if ( y >= h - dy ) |
131 | alpha *= ( double ( h - y ) / dy ); | 128 | alpha *= ( double ( h - y ) / dy ); |
132 | 129 | ||
133 | int a = int ( alpha * 255.0 ); | 130 | int a = int ( alpha * 255.0 ); |
134 | if ( a < 0 ) | 131 | if ( a < 0 ) |
135 | a = 0; | 132 | a = 0; |
136 | if ( a > 255 ) | 133 | if ( a > 255 ) |
137 | a = 255; | 134 | a = 255; |
138 | 135 | ||
139 | img. setPixel ( x, y, qRgba ( r, g, b, a )); | 136 | img. setPixel ( x, y, qRgba ( r, g, b, a )); |
140 | } | 137 | } |
141 | } | 138 | } |
142 | img. setAlphaBuffer ( true ); | 139 | img. setAlphaBuffer ( true ); |
143 | 140 | ||
144 | QPixmap pix; | 141 | QPixmap pix; |
145 | pix. convertFromImage ( img ); | 142 | pix. convertFromImage ( img ); |
146 | setPixmap ( pix ); | 143 | setPixmap ( pix ); |
147 | 144 | ||
148 | emit colorSelected ( c ); | 145 | emit colorSelected ( c ); |
149 | } | 146 | } |
150 | 147 | ||
diff --git a/libqtaux/ocolorpopupmenu.cpp b/libqtaux/ocolorpopupmenu.cpp index 6c5f99c..c5b2b88 100644 --- a/libqtaux/ocolorpopupmenu.cpp +++ b/libqtaux/ocolorpopupmenu.cpp | |||
@@ -1,176 +1,175 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net> | 4 | Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net> |
5 | Dan Williams <williamsdr@acm.org> | 5 | Dan Williams <williamsdr@acm.org> |
6 | =. | 6 | =. |
7 | .=l. | 7 | .=l. |
8 | .>+-= | 8 | .>+-= |
9 | _;:, .> :=|. This program is free software; you can | 9 | _;:, .> :=|. This program is free software; you can |
10 | .> <`_, > . <= redistribute it and/or modify it under | 10 | .> <`_, > . <= redistribute it and/or modify it under |
11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
12 | .="- .-=="i, .._ License as published by the Free Software | 12 | .="- .-=="i, .._ License as published by the Free Software |
13 | - . .-<_> .<> Foundation; either version 2 of the License, | 13 | - . .-<_> .<> Foundation; either version 2 of the License, |
14 | ._= =} : or (at your option) any later version. | 14 | ._= =} : or (at your option) any later version. |
15 | .%`+i> _;_. | 15 | .%`+i> _;_. |
16 | .i_,=:_. -<s. This program is distributed in the hope that | 16 | .i_,=:_. -<s. This program is distributed in the hope that |
17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
18 | : .. .:, . . . without even the implied warranty of | 18 | : .. .:, . . . without even the implied warranty of |
19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
21 | ..}^=.= = ; Library General Public License for more | 21 | ..}^=.= = ; Library General Public License for more |
22 | ++= -. .` .: details. | 22 | ++= -. .` .: details. |
23 | : = ...= . :.=- | 23 | : = ...= . :.=- |
24 | -. .:....=;==+<; You should have received a copy of the GNU | 24 | -. .:....=;==+<; You should have received a copy of the GNU |
25 | -_. . . )=. = Library General Public License along with | 25 | -_. . . )=. = Library General Public License along with |
26 | -- :-=` this library; see the file COPYING.LIB. | 26 | -- :-=` this library; see the file COPYING.LIB. |
27 | If not, write to the Free Software Foundation, | 27 | If not, write to the Free Software Foundation, |
28 | Inc., 59 Temple Place - Suite 330, | 28 | Inc., 59 Temple Place - Suite 330, |
29 | Boston, MA 02111-1307, USA. | 29 | Boston, MA 02111-1307, USA. |
30 | 30 | ||
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include "ocolorpopupmenu.h" | 33 | #include "ocolorpopupmenu.h" |
34 | #include "qcolordialog.h" | 34 | #include "qcolordialog.h" |
35 | 35 | ||
36 | /* QT */ | 36 | /* QT */ |
37 | #include <qaction.h> | ||
38 | #include <qlayout.h> | 37 | #include <qlayout.h> |
39 | #include <qpainter.h> | 38 | #include <qpainter.h> |
40 | 39 | ||
41 | using namespace Opie; | 40 | using namespace Opie; |
42 | 41 | ||
43 | OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, const char* name ) | 42 | OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, const char* name ) |
44 | : QFrame( parent, name ) | 43 | : QFrame( parent, name ) |
45 | { | 44 | { |
46 | m_color = color; | 45 | m_color = color; |
47 | 46 | ||
48 | setFixedSize( 16, 16 ); | 47 | setFixedSize( 16, 16 ); |
49 | setActive( FALSE ); | 48 | setActive( FALSE ); |
50 | } | 49 | } |
51 | 50 | ||
52 | OColorPanelButton::~OColorPanelButton() | 51 | OColorPanelButton::~OColorPanelButton() |
53 | { | 52 | { |
54 | } | 53 | } |
55 | 54 | ||
56 | void OColorPanelButton::setActive( bool active ) | 55 | void OColorPanelButton::setActive( bool active ) |
57 | { | 56 | { |
58 | m_active = active; | 57 | m_active = active; |
59 | 58 | ||
60 | if ( m_active ) { | 59 | if ( m_active ) { |
61 | setFrameStyle( Panel | Sunken ); | 60 | setFrameStyle( Panel | Sunken ); |
62 | } else { | 61 | } else { |
63 | setFrameStyle( NoFrame ); | 62 | setFrameStyle( NoFrame ); |
64 | } | 63 | } |
65 | } | 64 | } |
66 | 65 | ||
67 | void OColorPanelButton::enterEvent( QEvent* ) | 66 | void OColorPanelButton::enterEvent( QEvent* ) |
68 | { | 67 | { |
69 | if ( !m_active ) { | 68 | if ( !m_active ) { |
70 | setFrameStyle( Panel | Sunken ); | 69 | setFrameStyle( Panel | Sunken ); |
71 | } | 70 | } |
72 | } | 71 | } |
73 | 72 | ||
74 | void OColorPanelButton::leaveEvent( QEvent* ) | 73 | void OColorPanelButton::leaveEvent( QEvent* ) |
75 | { | 74 | { |
76 | if ( !m_active ) { | 75 | if ( !m_active ) { |
77 | setFrameStyle( NoFrame ); | 76 | setFrameStyle( NoFrame ); |
78 | } | 77 | } |
79 | } | 78 | } |
80 | 79 | ||
81 | void OColorPanelButton::paintEvent( QPaintEvent* e ) | 80 | void OColorPanelButton::paintEvent( QPaintEvent* e ) |
82 | { | 81 | { |
83 | QFrame::paintEvent( e ); | 82 | QFrame::paintEvent( e ); |
84 | 83 | ||
85 | QPainter painter; | 84 | QPainter painter; |
86 | painter.begin( this ); | 85 | painter.begin( this ); |
87 | painter.fillRect( 2, 2, 12, 12, m_color ); | 86 | painter.fillRect( 2, 2, 12, 12, m_color ); |
88 | painter.setPen( Qt::black ); | 87 | painter.setPen( Qt::black ); |
89 | painter.drawRect( 2, 2, 12, 12 ); | 88 | painter.drawRect( 2, 2, 12, 12 ); |
90 | painter.end(); | 89 | painter.end(); |
91 | } | 90 | } |
92 | 91 | ||
93 | void OColorPanelButton::mouseReleaseEvent( QMouseEvent* ) | 92 | void OColorPanelButton::mouseReleaseEvent( QMouseEvent* ) |
94 | { | 93 | { |
95 | emit selected( m_color ); | 94 | emit selected( m_color ); |
96 | } | 95 | } |
97 | 96 | ||
98 | OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name ) | 97 | OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name ) |
99 | : QPopupMenu( parent, name ) | 98 | : QPopupMenu( parent, name ) |
100 | { | 99 | { |
101 | m_color = color; | 100 | m_color = color; |
102 | 101 | ||
103 | colorPanel = new QWidget( this ); | 102 | colorPanel = new QWidget( this ); |
104 | 103 | ||
105 | colorLayout = new QGridLayout(colorPanel, 5, 6); | 104 | colorLayout = new QGridLayout(colorPanel, 5, 6); |
106 | 105 | ||
107 | addColor(QColor(255, 255, 255), 0, 1); | 106 | addColor(QColor(255, 255, 255), 0, 1); |
108 | addColor(QColor(192, 192, 192), 0, 2); | 107 | addColor(QColor(192, 192, 192), 0, 2); |
109 | addColor(QColor(128, 128, 128), 0, 3); | 108 | addColor(QColor(128, 128, 128), 0, 3); |
110 | addColor(QColor(64, 64, 64), 0, 4); | 109 | addColor(QColor(64, 64, 64), 0, 4); |
111 | addColor(QColor(0, 0, 0), 0, 5); | 110 | addColor(QColor(0, 0, 0), 0, 5); |
112 | 111 | ||
113 | addColor(QColor(255, 0, 0), 1, 0); | 112 | addColor(QColor(255, 0, 0), 1, 0); |
114 | addColor(QColor(255, 128, 0), 1, 1); | 113 | addColor(QColor(255, 128, 0), 1, 1); |
115 | addColor(QColor(255, 255, 0), 1, 2); | 114 | addColor(QColor(255, 255, 0), 1, 2); |
116 | addColor(QColor(128, 255, 0), 1, 3); | 115 | addColor(QColor(128, 255, 0), 1, 3); |
117 | addColor(QColor(0, 255, 0), 1, 4); | 116 | addColor(QColor(0, 255, 0), 1, 4); |
118 | addColor(QColor(0, 255, 128), 1, 5); | 117 | addColor(QColor(0, 255, 128), 1, 5); |
119 | 118 | ||
120 | addColor(QColor(128, 0, 0), 2, 0); | 119 | addColor(QColor(128, 0, 0), 2, 0); |
121 | addColor(QColor(128, 64, 0), 2, 1); | 120 | addColor(QColor(128, 64, 0), 2, 1); |
122 | addColor(QColor(128, 128, 0), 2, 2); | 121 | addColor(QColor(128, 128, 0), 2, 2); |
123 | addColor(QColor(64, 128, 0), 2, 3); | 122 | addColor(QColor(64, 128, 0), 2, 3); |
124 | addColor(QColor(0, 128, 0), 2, 4); | 123 | addColor(QColor(0, 128, 0), 2, 4); |
125 | addColor(QColor(0, 128, 64), 2, 5); | 124 | addColor(QColor(0, 128, 64), 2, 5); |
126 | 125 | ||
127 | addColor(QColor(0, 255, 255), 3, 0); | 126 | addColor(QColor(0, 255, 255), 3, 0); |
128 | addColor(QColor(0, 128, 255), 3, 1); | 127 | addColor(QColor(0, 128, 255), 3, 1); |
129 | addColor(QColor(0, 0, 255), 3, 2); | 128 | addColor(QColor(0, 0, 255), 3, 2); |
130 | addColor(QColor(128, 0, 255), 3, 3); | 129 | addColor(QColor(128, 0, 255), 3, 3); |
131 | addColor(QColor(255, 0, 255), 3, 4); | 130 | addColor(QColor(255, 0, 255), 3, 4); |
132 | addColor(QColor(255, 0, 128), 3, 5); | 131 | addColor(QColor(255, 0, 128), 3, 5); |
133 | 132 | ||
134 | addColor(QColor(0, 128, 128), 4, 0); | 133 | addColor(QColor(0, 128, 128), 4, 0); |
135 | addColor(QColor(0, 64, 128), 4, 1); | 134 | addColor(QColor(0, 64, 128), 4, 1); |
136 | addColor(QColor(0, 0, 128), 4, 2); | 135 | addColor(QColor(0, 0, 128), 4, 2); |
137 | addColor(QColor(64, 0, 128), 4, 3); | 136 | addColor(QColor(64, 0, 128), 4, 3); |
138 | addColor(QColor(128, 0, 128), 4, 4); | 137 | addColor(QColor(128, 0, 128), 4, 4); |
139 | addColor(QColor(128, 0, 64), 4, 5); | 138 | addColor(QColor(128, 0, 64), 4, 5); |
140 | 139 | ||
141 | insertItem( colorPanel ); | 140 | insertItem( colorPanel ); |
142 | insertSeparator(); | 141 | insertSeparator(); |
143 | insertItem(tr("More"),this,SLOT( moreColorClicked())); | 142 | insertItem(tr("More"),this,SLOT( moreColorClicked())); |
144 | /* | 143 | /* |
145 | QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" ); | 144 | QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" ); |
146 | connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) ); | 145 | connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) ); |
147 | chooseColorAction->addTo( this ); | 146 | chooseColorAction->addTo( this ); |
148 | */ | 147 | */ |
149 | activateItemAt( 0 ); | 148 | activateItemAt( 0 ); |
150 | } | 149 | } |
151 | 150 | ||
152 | OColorPopupMenu::~OColorPopupMenu() | 151 | OColorPopupMenu::~OColorPopupMenu() |
153 | { | 152 | { |
154 | } | 153 | } |
155 | 154 | ||
156 | void OColorPopupMenu::addColor( const QColor& color, int row, int col ) | 155 | void OColorPopupMenu::addColor( const QColor& color, int row, int col ) |
157 | { | 156 | { |
158 | OColorPanelButton* panelButton = new OColorPanelButton( color, colorPanel ); | 157 | OColorPanelButton* panelButton = new OColorPanelButton( color, colorPanel ); |
159 | connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) ); | 158 | connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) ); |
160 | colorLayout->addWidget( panelButton, row, col ); | 159 | colorLayout->addWidget( panelButton, row, col ); |
161 | } | 160 | } |
162 | 161 | ||
163 | void OColorPopupMenu::buttonSelected( const QColor& color ) | 162 | void OColorPopupMenu::buttonSelected( const QColor& color ) |
164 | { | 163 | { |
165 | m_color = color; | 164 | m_color = color; |
166 | emit colorSelected( color ); | 165 | emit colorSelected( color ); |
167 | hide(); | 166 | hide(); |
168 | } | 167 | } |
169 | 168 | ||
170 | void OColorPopupMenu::moreColorClicked() | 169 | void OColorPopupMenu::moreColorClicked() |
171 | { | 170 | { |
172 | QColor color = QColorDialog::getColor( m_color ); | 171 | QColor color = QColorDialog::getColor( m_color ); |
173 | m_color = color; | 172 | m_color = color; |
174 | emit colorSelected( color ); | 173 | emit colorSelected( color ); |
175 | hide(); | 174 | hide(); |
176 | } | 175 | } |
diff --git a/libqtaux/qcolordialog.cpp b/libqtaux/qcolordialog.cpp index b960b04..907c2aa 100644 --- a/libqtaux/qcolordialog.cpp +++ b/libqtaux/qcolordialog.cpp | |||
@@ -1,435 +1,433 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Implementation of QColorDialog class | 4 | ** Implementation of QColorDialog class |
5 | ** | 5 | ** |
6 | ** Created : 990222 | 6 | ** Created : 990222 |
7 | ** | 7 | ** |
8 | ** Copyright (C) 1999-2000 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 1999-2000 Trolltech AS. All rights reserved. |
9 | ** | 9 | ** |
10 | ** This file is part of the dialogs module of the Qt GUI Toolkit. | 10 | ** This file is part of the dialogs module of the Qt GUI Toolkit. |
11 | ** | 11 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 12 | ** This file may be distributed under the terms of the Q Public License |
13 | ** as defined by Trolltech AS of Norway and appearing in the file | 13 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 15 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 16 | ** This file may be distributed and/or modified under the terms of the |
17 | ** GNU General Public License version 2 as published by the Free Software | 17 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 18 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 19 | ** packaging of this file. |
20 | ** | 20 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
22 | ** licenses may use this file in accordance with the Qt Commercial License | 22 | ** licenses may use this file in accordance with the Qt Commercial License |
23 | ** Agreement provided with the Software. | 23 | ** Agreement provided with the Software. |
24 | ** | 24 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
27 | ** | 27 | ** |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
29 | ** information about Qt Commercial License Agreements. | 29 | ** information about Qt Commercial License Agreements. |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 32 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 33 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 34 | ** not clear to you. |
35 | ** | 35 | ** |
36 | **********************************************************************/ | 36 | **********************************************************************/ |
37 | 37 | ||
38 | #include "qcolordialog.h" | 38 | #include "qcolordialog.h" |
39 | 39 | ||
40 | #include "qpainter.h" | 40 | #include "qpainter.h" |
41 | #include "qlayout.h" | 41 | #include "qlayout.h" |
42 | #include "qlabel.h" | 42 | #include "qlabel.h" |
43 | #include "qpushbutton.h" | 43 | #include "qpushbutton.h" |
44 | #include "qlineedit.h" | 44 | #include "qlineedit.h" |
45 | #include "qimage.h" | 45 | #include "qimage.h" |
46 | #include "qpixmap.h" | 46 | #include "qpixmap.h" |
47 | #include "qdrawutil.h" | 47 | #include "qdrawutil.h" |
48 | #include "qvalidator.h" | 48 | #include "qvalidator.h" |
49 | #include "qdragobject.h" | ||
50 | #include "qapplication.h" | 49 | #include "qapplication.h" |
51 | #include "qdragobject.h" | ||
52 | 50 | ||
53 | //////////// QWellArray BEGIN | 51 | //////////// QWellArray BEGIN |
54 | 52 | ||
55 | #include "qobjectdict.h" | 53 | #include "qobjectdict.h" |
56 | 54 | ||
57 | // | 55 | // |
58 | // W A R N I N G | 56 | // W A R N I N G |
59 | // ------------- | 57 | // ------------- |
60 | // | 58 | // |
61 | // This file is not part of the Qt API. It exists for the convenience | 59 | // This file is not part of the Qt API. It exists for the convenience |
62 | // of qwellarray.cpp and qcolordialog.cpp. | 60 | // of qwellarray.cpp and qcolordialog.cpp. |
63 | // This header file may change from version to version without notice, | 61 | // This header file may change from version to version without notice, |
64 | // or even be removed. | 62 | // or even be removed. |
65 | // | 63 | // |
66 | // | 64 | // |
67 | 65 | ||
68 | 66 | ||
69 | #include "qtableview.h" | 67 | #include "qtableview.h" |
70 | 68 | ||
71 | 69 | ||
72 | struct QWellArrayData; | 70 | struct QWellArrayData; |
73 | 71 | ||
74 | class QWellArray : public QTableView | 72 | class QWellArray : public QTableView |
75 | { | 73 | { |
76 | Q_OBJECT | 74 | Q_OBJECT |
77 | Q_PROPERTY( int numCols READ numCols ) | 75 | Q_PROPERTY( int numCols READ numCols ) |
78 | Q_PROPERTY( int numRows READ numRows ) | 76 | Q_PROPERTY( int numRows READ numRows ) |
79 | Q_PROPERTY( int selectedColumn READ selectedColumn ) | 77 | Q_PROPERTY( int selectedColumn READ selectedColumn ) |
80 | Q_PROPERTY( int selectedRow READ selectedRow ) | 78 | Q_PROPERTY( int selectedRow READ selectedRow ) |
81 | 79 | ||
82 | public: | 80 | public: |
83 | QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE ); | 81 | QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE ); |
84 | 82 | ||
85 | ~QWellArray() {} | 83 | ~QWellArray() {} |
86 | QString cellContent( int row, int col ) const; | 84 | QString cellContent( int row, int col ) const; |
87 | // ### Paul !!! virtual void setCellContent( int row, int col, const QString &); | 85 | // ### Paul !!! virtual void setCellContent( int row, int col, const QString &); |
88 | 86 | ||
89 | // ##### Obsolete since not const | 87 | // ##### Obsolete since not const |
90 | int numCols() { return nCols; } | 88 | int numCols() { return nCols; } |
91 | int numRows() { return nRows; } | 89 | int numRows() { return nRows; } |
92 | 90 | ||
93 | int numCols() const { return nCols; } | 91 | int numCols() const { return nCols; } |
94 | int numRows() const { return nRows; } | 92 | int numRows() const { return nRows; } |
95 | 93 | ||
96 | // ##### Obsolete since not const | 94 | // ##### Obsolete since not const |
97 | int selectedColumn() { return selCol; } | 95 | int selectedColumn() { return selCol; } |
98 | int selectedRow() { return selRow; } | 96 | int selectedRow() { return selRow; } |
99 | 97 | ||
100 | int selectedColumn() const { return selCol; } | 98 | int selectedColumn() const { return selCol; } |
101 | int selectedRow() const { return selRow; } | 99 | int selectedRow() const { return selRow; } |
102 | 100 | ||
103 | virtual void setSelected( int row, int col ); | 101 | virtual void setSelected( int row, int col ); |
104 | 102 | ||
105 | void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); } | 103 | void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); } |
106 | 104 | ||
107 | QSize sizeHint() const; | 105 | QSize sizeHint() const; |
108 | 106 | ||
109 | virtual void setDimension( int rows, int cols ); | 107 | virtual void setDimension( int rows, int cols ); |
110 | virtual void setCellBrush( int row, int col, const QBrush & ); | 108 | virtual void setCellBrush( int row, int col, const QBrush & ); |
111 | QBrush cellBrush( int row, int col ); | 109 | QBrush cellBrush( int row, int col ); |
112 | 110 | ||
113 | signals: | 111 | signals: |
114 | void selected( int row, int col ); | 112 | void selected( int row, int col ); |
115 | 113 | ||
116 | protected: | 114 | protected: |
117 | virtual void setCurrent( int row, int col ); | 115 | virtual void setCurrent( int row, int col ); |
118 | 116 | ||
119 | virtual void drawContents( QPainter *, int row, int col, const QRect& ); | 117 | virtual void drawContents( QPainter *, int row, int col, const QRect& ); |
120 | void drawContents( QPainter * ); | 118 | void drawContents( QPainter * ); |
121 | 119 | ||
122 | void paintCell( QPainter*, int row, int col ); | 120 | void paintCell( QPainter*, int row, int col ); |
123 | void mousePressEvent( QMouseEvent* ); | 121 | void mousePressEvent( QMouseEvent* ); |
124 | void mouseReleaseEvent( QMouseEvent* ); | 122 | void mouseReleaseEvent( QMouseEvent* ); |
125 | void mouseMoveEvent( QMouseEvent* ); | 123 | void mouseMoveEvent( QMouseEvent* ); |
126 | void keyPressEvent( QKeyEvent* ); | 124 | void keyPressEvent( QKeyEvent* ); |
127 | void focusInEvent( QFocusEvent* ); | 125 | void focusInEvent( QFocusEvent* ); |
128 | void focusOutEvent( QFocusEvent* ); | 126 | void focusOutEvent( QFocusEvent* ); |
129 | 127 | ||
130 | private: | 128 | private: |
131 | int curRow; | 129 | int curRow; |
132 | int curCol; | 130 | int curCol; |
133 | int selRow; | 131 | int selRow; |
134 | int selCol; | 132 | int selCol; |
135 | int nCols; | 133 | int nCols; |
136 | int nRows; | 134 | int nRows; |
137 | bool smallStyle; | 135 | bool smallStyle; |
138 | QWellArrayData *d; | 136 | QWellArrayData *d; |
139 | 137 | ||
140 | private:// Disabled copy constructor and operator= | 138 | private:// Disabled copy constructor and operator= |
141 | #if defined(Q_DISABLE_COPY) | 139 | #if defined(Q_DISABLE_COPY) |
142 | QWellArray( const QWellArray & ); | 140 | QWellArray( const QWellArray & ); |
143 | QWellArray& operator=( const QWellArray & ); | 141 | QWellArray& operator=( const QWellArray & ); |
144 | #endif | 142 | #endif |
145 | }; | 143 | }; |
146 | 144 | ||
147 | 145 | ||
148 | 146 | ||
149 | // non-interface ... | 147 | // non-interface ... |
150 | 148 | ||
151 | 149 | ||
152 | 150 | ||
153 | struct QWellArrayData { | 151 | struct QWellArrayData { |
154 | QBrush *brush; | 152 | QBrush *brush; |
155 | }; | 153 | }; |
156 | 154 | ||
157 | // NOT REVISED | 155 | // NOT REVISED |
158 | /* WARNING, NOT | 156 | /* WARNING, NOT |
159 | \class QWellArray qwellarray_p.h | 157 | \class QWellArray qwellarray_p.h |
160 | \brief .... | 158 | \brief .... |
161 | 159 | ||
162 | .... | 160 | .... |
163 | 161 | ||
164 | \ingroup advanced | 162 | \ingroup advanced |
165 | */ | 163 | */ |
166 | 164 | ||
167 | QWellArray::QWellArray( QWidget *parent, const char * name, bool popup ) | 165 | QWellArray::QWellArray( QWidget *parent, const char * name, bool popup ) |
168 | : QTableView( parent, name, | 166 | : QTableView( parent, name, |
169 | popup ? (WStyle_Customize|WStyle_Tool|WStyle_NoBorder) : 0 ) | 167 | popup ? (WStyle_Customize|WStyle_Tool|WStyle_NoBorder) : 0 ) |
170 | { | 168 | { |
171 | d = 0; | 169 | d = 0; |
172 | setFocusPolicy( StrongFocus ); | 170 | setFocusPolicy( StrongFocus ); |
173 | setBackgroundMode( PaletteButton ); | 171 | setBackgroundMode( PaletteButton ); |
174 | nCols = 7; | 172 | nCols = 7; |
175 | nRows = 7; | 173 | nRows = 7; |
176 | int w = 24; // cell width | 174 | int w = 24; // cell width |
177 | int h = 21; // cell height | 175 | int h = 21; // cell height |
178 | smallStyle = popup; | 176 | smallStyle = popup; |
179 | 177 | ||
180 | if ( popup ) { | 178 | if ( popup ) { |
181 | w = h = 18; | 179 | w = h = 18; |
182 | if ( style() == WindowsStyle ) | 180 | if ( style() == WindowsStyle ) |
183 | setFrameStyle( QFrame::WinPanel | QFrame::Raised ); | 181 | setFrameStyle( QFrame::WinPanel | QFrame::Raised ); |
184 | else | 182 | else |
185 | setFrameStyle( QFrame::Panel | QFrame::Raised ); | 183 | setFrameStyle( QFrame::Panel | QFrame::Raised ); |
186 | setMargin( 1 ); | 184 | setMargin( 1 ); |
187 | setLineWidth( 2 ); | 185 | setLineWidth( 2 ); |
188 | } | 186 | } |
189 | setNumCols( nCols ); | 187 | setNumCols( nCols ); |
190 | setNumRows( nRows ); | 188 | setNumRows( nRows ); |
191 | setCellWidth( w ); | 189 | setCellWidth( w ); |
192 | setCellHeight( h ); | 190 | setCellHeight( h ); |
193 | curCol = 0; | 191 | curCol = 0; |
194 | curRow = 0; | 192 | curRow = 0; |
195 | selCol = -1; | 193 | selCol = -1; |
196 | selRow = -1; | 194 | selRow = -1; |
197 | 195 | ||
198 | if ( smallStyle ) | 196 | if ( smallStyle ) |
199 | setMouseTracking( TRUE ); | 197 | setMouseTracking( TRUE ); |
200 | setOffset( 5 , 10 ); | 198 | setOffset( 5 , 10 ); |
201 | 199 | ||
202 | resize( sizeHint() ); | 200 | resize( sizeHint() ); |
203 | 201 | ||
204 | } | 202 | } |
205 | 203 | ||
206 | 204 | ||
207 | QSize QWellArray::sizeHint() const | 205 | QSize QWellArray::sizeHint() const |
208 | { | 206 | { |
209 | constPolish(); | 207 | constPolish(); |
210 | int f = frameWidth() * 2; | 208 | int f = frameWidth() * 2; |
211 | int w = nCols * cellWidth() + f; | 209 | int w = nCols * cellWidth() + f; |
212 | int h = nRows * cellHeight() + f; | 210 | int h = nRows * cellHeight() + f; |
213 | return QSize( w, h ); | 211 | return QSize( w, h ); |
214 | } | 212 | } |
215 | 213 | ||
216 | 214 | ||
217 | void QWellArray::paintCell( QPainter* p, int row, int col ) | 215 | void QWellArray::paintCell( QPainter* p, int row, int col ) |
218 | { | 216 | { |
219 | int w = cellWidth( col ); // width of cell in pixels | 217 | int w = cellWidth( col ); // width of cell in pixels |
220 | int h = cellHeight( row ); // height of cell in pixels | 218 | int h = cellHeight( row ); // height of cell in pixels |
221 | int b = 1; | 219 | int b = 1; |
222 | 220 | ||
223 | if ( !smallStyle ) | 221 | if ( !smallStyle ) |
224 | b = 3; | 222 | b = 3; |
225 | 223 | ||
226 | const QColorGroup & g = colorGroup(); | 224 | const QColorGroup & g = colorGroup(); |
227 | p->setPen( QPen( black, 0, SolidLine ) ); | 225 | p->setPen( QPen( black, 0, SolidLine ) ); |
228 | if ( !smallStyle && row ==selRow && col == selCol && | 226 | if ( !smallStyle && row ==selRow && col == selCol && |
229 | style() != MotifStyle ) { | 227 | style() != MotifStyle ) { |
230 | int n = 2; | 228 | int n = 2; |
231 | p->drawRect( n, n, w-2*n, h-2*n ); | 229 | p->drawRect( n, n, w-2*n, h-2*n ); |
232 | } | 230 | } |
233 | 231 | ||
234 | 232 | ||
235 | if ( style() == WindowsStyle ) { | 233 | if ( style() == WindowsStyle ) { |
236 | qDrawWinPanel( p, b, b , w - 2*b, h - 2*b, | 234 | qDrawWinPanel( p, b, b , w - 2*b, h - 2*b, |
237 | g, TRUE ); | 235 | g, TRUE ); |
238 | b += 2; | 236 | b += 2; |
239 | } else { | 237 | } else { |
240 | if ( smallStyle ) { | 238 | if ( smallStyle ) { |
241 | qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, | 239 | qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, |
242 | g, TRUE, 2 ); | 240 | g, TRUE, 2 ); |
243 | b += 2; | 241 | b += 2; |
244 | } else { | 242 | } else { |
245 | int t = ( row == selRow && col == selCol ) ? 2 : 0; | 243 | int t = ( row == selRow && col == selCol ) ? 2 : 0; |
246 | b -= t; | 244 | b -= t; |
247 | qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, | 245 | qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, |
248 | g, TRUE, 2 ); | 246 | g, TRUE, 2 ); |
249 | b += 2 + t; | 247 | b += 2 + t; |
250 | } | 248 | } |
251 | } | 249 | } |
252 | 250 | ||
253 | 251 | ||
254 | if ( (row == curRow) && (col == curCol) ) { | 252 | if ( (row == curRow) && (col == curCol) ) { |
255 | if ( smallStyle ) { | 253 | if ( smallStyle ) { |
256 | p->setPen ( white ); | 254 | p->setPen ( white ); |
257 | p->drawRect( 1, 1, w-2, h-2 ); | 255 | p->drawRect( 1, 1, w-2, h-2 ); |
258 | p->setPen ( black ); | 256 | p->setPen ( black ); |
259 | p->drawRect( 0, 0, w, h ); | 257 | p->drawRect( 0, 0, w, h ); |
260 | p->drawRect( 2, 2, w-4, h-4 ); | 258 | p->drawRect( 2, 2, w-4, h-4 ); |
261 | b = 3; | 259 | b = 3; |
262 | } else if ( hasFocus() ) { | 260 | } else if ( hasFocus() ) { |
263 | style().drawFocusRect(p, QRect(0,0,w,h), g ); | 261 | style().drawFocusRect(p, QRect(0,0,w,h), g ); |
264 | } | 262 | } |
265 | } | 263 | } |
266 | drawContents( p, row, col, QRect(b, b, w - 2*b, h - 2*b) ); | 264 | drawContents( p, row, col, QRect(b, b, w - 2*b, h - 2*b) ); |
267 | } | 265 | } |
268 | 266 | ||
269 | /*! | 267 | /*! |
270 | Pass-through to QTableView::drawContents() to avoid hiding. | 268 | Pass-through to QTableView::drawContents() to avoid hiding. |
271 | */ | 269 | */ |
272 | void QWellArray::drawContents( QPainter *p ) | 270 | void QWellArray::drawContents( QPainter *p ) |
273 | { | 271 | { |
274 | QTableView::drawContents(p); | 272 | QTableView::drawContents(p); |
275 | } | 273 | } |
276 | 274 | ||
277 | /*! | 275 | /*! |
278 | Reimplement this function to change the contents of the well array. | 276 | Reimplement this function to change the contents of the well array. |
279 | */ | 277 | */ |
280 | void QWellArray::drawContents( QPainter *p, int row, int col, const QRect &r ) | 278 | void QWellArray::drawContents( QPainter *p, int row, int col, const QRect &r ) |
281 | { | 279 | { |
282 | 280 | ||
283 | if ( d ) { | 281 | if ( d ) { |
284 | p->fillRect( r, d->brush[row*nCols+col] ); | 282 | p->fillRect( r, d->brush[row*nCols+col] ); |
285 | } else { | 283 | } else { |
286 | p->fillRect( r, white ); | 284 | p->fillRect( r, white ); |
287 | p->setPen( black ); | 285 | p->setPen( black ); |
288 | p->drawLine( r.topLeft(), r.bottomRight() ); | 286 | p->drawLine( r.topLeft(), r.bottomRight() ); |
289 | p->drawLine( r.topRight(), r.bottomLeft() ); | 287 | p->drawLine( r.topRight(), r.bottomLeft() ); |
290 | } | 288 | } |
291 | } | 289 | } |
292 | 290 | ||
293 | 291 | ||
294 | /*\reimp | 292 | /*\reimp |
295 | */ | 293 | */ |
296 | void QWellArray::mousePressEvent( QMouseEvent* e ) | 294 | void QWellArray::mousePressEvent( QMouseEvent* e ) |
297 | { | 295 | { |
298 | // The current cell marker is set to the cell the mouse is pressed | 296 | // The current cell marker is set to the cell the mouse is pressed |
299 | // in. | 297 | // in. |
300 | QPoint pos = e->pos(); | 298 | QPoint pos = e->pos(); |
301 | setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); | 299 | setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); |
302 | } | 300 | } |
303 | 301 | ||
304 | /*\reimp | 302 | /*\reimp |
305 | */ | 303 | */ |
306 | void QWellArray::mouseReleaseEvent( QMouseEvent* ) | 304 | void QWellArray::mouseReleaseEvent( QMouseEvent* ) |
307 | { | 305 | { |
308 | // The current cell marker is set to the cell the mouse is clicked | 306 | // The current cell marker is set to the cell the mouse is clicked |
309 | // in. | 307 | // in. |
310 | setSelected( curRow, curCol ); | 308 | setSelected( curRow, curCol ); |
311 | } | 309 | } |
312 | 310 | ||
313 | 311 | ||
314 | /*\reimp | 312 | /*\reimp |
315 | */ | 313 | */ |
316 | void QWellArray::mouseMoveEvent( QMouseEvent* e ) | 314 | void QWellArray::mouseMoveEvent( QMouseEvent* e ) |
317 | { | 315 | { |
318 | // The current cell marker is set to the cell the mouse is | 316 | // The current cell marker is set to the cell the mouse is |
319 | // clicked in. | 317 | // clicked in. |
320 | if ( smallStyle ) { | 318 | if ( smallStyle ) { |
321 | QPoint pos = e->pos(); | 319 | QPoint pos = e->pos(); |
322 | setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); | 320 | setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); |
323 | } | 321 | } |
324 | } | 322 | } |
325 | 323 | ||
326 | /* | 324 | /* |
327 | Sets the cell currently having the focus. This is not necessarily | 325 | Sets the cell currently having the focus. This is not necessarily |
328 | the same as the currently selected cell. | 326 | the same as the currently selected cell. |
329 | */ | 327 | */ |
330 | 328 | ||
331 | void QWellArray::setCurrent( int row, int col ) | 329 | void QWellArray::setCurrent( int row, int col ) |
332 | { | 330 | { |
333 | 331 | ||
334 | if ( (curRow == row) && (curCol == col) ) | 332 | if ( (curRow == row) && (curCol == col) ) |
335 | return; | 333 | return; |
336 | 334 | ||
337 | if ( row < 0 || col < 0 ) | 335 | if ( row < 0 || col < 0 ) |
338 | row = col = -1; | 336 | row = col = -1; |
339 | 337 | ||
340 | int oldRow = curRow; | 338 | int oldRow = curRow; |
341 | int oldCol = curCol; | 339 | int oldCol = curCol; |
342 | 340 | ||
343 | curRow = row; | 341 | curRow = row; |
344 | curCol = col; | 342 | curCol = col; |
345 | 343 | ||
346 | updateCell( oldRow, oldCol ); | 344 | updateCell( oldRow, oldCol ); |
347 | updateCell( curRow, curCol ); | 345 | updateCell( curRow, curCol ); |
348 | } | 346 | } |
349 | 347 | ||
350 | 348 | ||
351 | /*! | 349 | /*! |
352 | Sets the currently selected cell to \a row, \a col. If \a row or \a | 350 | Sets the currently selected cell to \a row, \a col. If \a row or \a |
353 | col are less than zero, the current cell is unselected. | 351 | col are less than zero, the current cell is unselected. |
354 | 352 | ||
355 | Does not set the position of the focus indicator. | 353 | Does not set the position of the focus indicator. |
356 | */ | 354 | */ |
357 | 355 | ||
358 | void QWellArray::setSelected( int row, int col ) | 356 | void QWellArray::setSelected( int row, int col ) |
359 | { | 357 | { |
360 | if ( (selRow == row) && (selCol == col) ) | 358 | if ( (selRow == row) && (selCol == col) ) |
361 | return; | 359 | return; |
362 | 360 | ||
363 | int oldRow = selRow; | 361 | int oldRow = selRow; |
364 | int oldCol = selCol; | 362 | int oldCol = selCol; |
365 | 363 | ||
366 | if ( row < 0 || col < 0 ) | 364 | if ( row < 0 || col < 0 ) |
367 | row = col = -1; | 365 | row = col = -1; |
368 | 366 | ||
369 | selCol = col; | 367 | selCol = col; |
370 | selRow = row; | 368 | selRow = row; |
371 | 369 | ||
372 | updateCell( oldRow, oldCol ); | 370 | updateCell( oldRow, oldCol ); |
373 | updateCell( selRow, selCol ); | 371 | updateCell( selRow, selCol ); |
374 | if ( row >= 0 ) | 372 | if ( row >= 0 ) |
375 | emit selected( row, col ); | 373 | emit selected( row, col ); |
376 | 374 | ||
377 | if ( isVisible() && parentWidget() && parentWidget()->inherits("QPopupMenu") ) | 375 | if ( isVisible() && parentWidget() && parentWidget()->inherits("QPopupMenu") ) |
378 | parentWidget()->close(); | 376 | parentWidget()->close(); |
379 | 377 | ||
380 | } | 378 | } |
381 | 379 | ||
382 | 380 | ||
383 | 381 | ||
384 | /*!\reimp | 382 | /*!\reimp |
385 | */ | 383 | */ |
386 | void QWellArray::focusInEvent( QFocusEvent* ) | 384 | void QWellArray::focusInEvent( QFocusEvent* ) |
387 | { | 385 | { |
388 | updateCell( curRow, curCol ); | 386 | updateCell( curRow, curCol ); |
389 | } | 387 | } |
390 | 388 | ||
391 | 389 | ||
392 | /*! | 390 | /*! |
393 | Sets the size of the well array to be \c rows cells by \c cols. | 391 | Sets the size of the well array to be \c rows cells by \c cols. |
394 | Resets any brush info set by setCellBrush(). | 392 | Resets any brush info set by setCellBrush(). |
395 | 393 | ||
396 | Must be called by reimplementors. | 394 | Must be called by reimplementors. |
397 | */ | 395 | */ |
398 | void QWellArray::setDimension( int rows, int cols ) | 396 | void QWellArray::setDimension( int rows, int cols ) |
399 | { | 397 | { |
400 | nRows = rows; | 398 | nRows = rows; |
401 | nCols = cols; | 399 | nCols = cols; |
402 | if ( d ) { | 400 | if ( d ) { |
403 | if ( d->brush ) | 401 | if ( d->brush ) |
404 | delete[] d->brush; | 402 | delete[] d->brush; |
405 | delete d; | 403 | delete d; |
406 | d = 0; | 404 | d = 0; |
407 | } | 405 | } |
408 | setNumCols( nCols ); | 406 | setNumCols( nCols ); |
409 | setNumRows( nRows ); | 407 | setNumRows( nRows ); |
410 | } | 408 | } |
411 | 409 | ||
412 | void QWellArray::setCellBrush( int row, int col, const QBrush &b ) | 410 | void QWellArray::setCellBrush( int row, int col, const QBrush &b ) |
413 | { | 411 | { |
414 | if ( !d ) { | 412 | if ( !d ) { |
415 | d = new QWellArrayData; | 413 | d = new QWellArrayData; |
416 | d->brush = new QBrush[nRows*nCols]; | 414 | d->brush = new QBrush[nRows*nCols]; |
417 | } | 415 | } |
418 | if ( row >= 0 && row < nRows && col >= 0 && col < nCols ) | 416 | if ( row >= 0 && row < nRows && col >= 0 && col < nCols ) |
419 | d->brush[row*nCols+col] = b; | 417 | d->brush[row*nCols+col] = b; |
420 | #ifdef CHECK_RANGE | 418 | #ifdef CHECK_RANGE |
421 | else | 419 | else |
422 | qWarning( "QWellArray::setCellBrush( %d, %d ) out of range", row, col ); | 420 | qWarning( "QWellArray::setCellBrush( %d, %d ) out of range", row, col ); |
423 | #endif | 421 | #endif |
424 | } | 422 | } |
425 | 423 | ||
426 | 424 | ||
427 | 425 | ||
428 | /*! | 426 | /*! |
429 | Returns the brush set for the cell at \a row, \a col. If no brush is set, | 427 | Returns the brush set for the cell at \a row, \a col. If no brush is set, |
430 | \c NoBrush is returned. | 428 | \c NoBrush is returned. |
431 | */ | 429 | */ |
432 | 430 | ||
433 | QBrush QWellArray::cellBrush( int row, int col ) | 431 | QBrush QWellArray::cellBrush( int row, int col ) |
434 | { | 432 | { |
435 | if ( d && row >= 0 && row < nRows && col >= 0 && col < nCols ) | 433 | if ( d && row >= 0 && row < nRows && col >= 0 && col < nCols ) |
diff --git a/libqtaux/qinputdialog.cpp b/libqtaux/qinputdialog.cpp index 821c74d..43e243f 100644 --- a/libqtaux/qinputdialog.cpp +++ b/libqtaux/qinputdialog.cpp | |||
@@ -1,426 +1,425 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Implementation of QInputDialog class | 4 | ** Implementation of QInputDialog class |
5 | ** | 5 | ** |
6 | ** Created : 991212 | 6 | ** Created : 991212 |
7 | ** | 7 | ** |
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
9 | ** | 9 | ** |
10 | ** This file is part of the dialogs module of the Qt GUI Toolkit. | 10 | ** This file is part of the dialogs module of the Qt GUI Toolkit. |
11 | ** | 11 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 12 | ** This file may be distributed under the terms of the Q Public License |
13 | ** as defined by Trolltech AS of Norway and appearing in the file | 13 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 15 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 16 | ** This file may be distributed and/or modified under the terms of the |
17 | ** GNU General Public License version 2 as published by the Free Software | 17 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 18 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 19 | ** packaging of this file. |
20 | ** | 20 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
22 | ** licenses may use this file in accordance with the Qt Commercial License | 22 | ** licenses may use this file in accordance with the Qt Commercial License |
23 | ** Agreement provided with the Software. | 23 | ** Agreement provided with the Software. |
24 | ** | 24 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
27 | ** | 27 | ** |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
29 | ** information about Qt Commercial License Agreements. | 29 | ** information about Qt Commercial License Agreements. |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 32 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 33 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 34 | ** not clear to you. |
35 | ** | 35 | ** |
36 | **********************************************************************/ | 36 | **********************************************************************/ |
37 | 37 | ||
38 | #include "qinputdialog.h" | 38 | #include "qinputdialog.h" |
39 | 39 | ||
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qlineedit.h> | ||
43 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
44 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
45 | #include <qcombobox.h> | 44 | #include <qcombobox.h> |
46 | #include <qwidgetstack.h> | 45 | #include <qwidgetstack.h> |
47 | #include <qvalidator.h> | 46 | #include <qvalidator.h> |
48 | #include <qapplication.h> | 47 | #include <qapplication.h> |
49 | 48 | ||
50 | class QInputDialogPrivate | 49 | class QInputDialogPrivate |
51 | { | 50 | { |
52 | public: | 51 | public: |
53 | friend class QInputDialog; | 52 | friend class QInputDialog; |
54 | QLineEdit *lineEdit; | 53 | QLineEdit *lineEdit; |
55 | QSpinBox *spinBox; | 54 | QSpinBox *spinBox; |
56 | QComboBox *comboBox, *editComboBox; | 55 | QComboBox *comboBox, *editComboBox; |
57 | QPushButton *ok; | 56 | QPushButton *ok; |
58 | QWidgetStack *stack; | 57 | QWidgetStack *stack; |
59 | QInputDialog::Type type; | 58 | QInputDialog::Type type; |
60 | }; | 59 | }; |
61 | 60 | ||
62 | /*! | 61 | /*! |
63 | \class QInputDialog qinputdialog.h | 62 | \class QInputDialog qinputdialog.h |
64 | \brief A convenience dialog to get a simple input from the user | 63 | \brief A convenience dialog to get a simple input from the user |
65 | \ingroup dialogs | 64 | \ingroup dialogs |
66 | 65 | ||
67 | The QInputDialog is a simple dialog which can be used if you | 66 | The QInputDialog is a simple dialog which can be used if you |
68 | need a simple input from the user. This can be text, a number or | 67 | need a simple input from the user. This can be text, a number or |
69 | an item from a list. Also a label has to be set to tell the user | 68 | an item from a list. Also a label has to be set to tell the user |
70 | what he/she should input. | 69 | what he/she should input. |
71 | 70 | ||
72 | In this Qt version only the 4 static convenience functions | 71 | In this Qt version only the 4 static convenience functions |
73 | getText(), getInteger(), getDouble() and getItem() of QInputDialog | 72 | getText(), getInteger(), getDouble() and getItem() of QInputDialog |
74 | are available. | 73 | are available. |
75 | 74 | ||
76 | Use it like this: | 75 | Use it like this: |
77 | 76 | ||
78 | \code | 77 | \code |
79 | bool ok = FALSE; | 78 | bool ok = FALSE; |
80 | QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this ); | 79 | QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this ); |
81 | if ( ok && !text.isEmpty() ) | 80 | if ( ok && !text.isEmpty() ) |
82 | ;// user entered something and pressed ok | 81 | ;// user entered something and pressed ok |
83 | else | 82 | else |
84 | ;// user entered nothing or pressed cancel | 83 | ;// user entered nothing or pressed cancel |
85 | \endcode | 84 | \endcode |
86 | 85 | ||
87 | There are more static convenience methods! | 86 | There are more static convenience methods! |
88 | 87 | ||
89 | \sa getText(), getInteger(), getDouble(), getItem() | 88 | \sa getText(), getInteger(), getDouble(), getItem() |
90 | */ | 89 | */ |
91 | 90 | ||
92 | /*! | 91 | /*! |
93 | \enum QInputDialog::Type | 92 | \enum QInputDialog::Type |
94 | 93 | ||
95 | This enum type specifies the type of the dialog | 94 | This enum type specifies the type of the dialog |
96 | (which kind of input can be done): | 95 | (which kind of input can be done): |
97 | 96 | ||
98 | <ul> | 97 | <ul> |
99 | <li>\c LineEdit - A QLineEdit is used for taking the input, so a textual or | 98 | <li>\c LineEdit - A QLineEdit is used for taking the input, so a textual or |
100 | (e.g. using a QValidator) a numerical input can be done. Using lineEdit() | 99 | (e.g. using a QValidator) a numerical input can be done. Using lineEdit() |
101 | the QLineEdit can be accessed. | 100 | the QLineEdit can be accessed. |
102 | <li>\c SpinBox - A QSpinBox is used for taking the input, so a decimal | 101 | <li>\c SpinBox - A QSpinBox is used for taking the input, so a decimal |
103 | input can be done. Using spinBox() the QSpinBox can be accessed. | 102 | input can be done. Using spinBox() the QSpinBox can be accessed. |
104 | <li>\c ComboBox - A read-only QComboBox is used for taking the input, | 103 | <li>\c ComboBox - A read-only QComboBox is used for taking the input, |
105 | so one item of a list can be chosen. Using comboBox() the QComboBox | 104 | so one item of a list can be chosen. Using comboBox() the QComboBox |
106 | can be accessed. | 105 | can be accessed. |
107 | <li>\c EditableComboBox - An editable QComboBox is used for taking the input, | 106 | <li>\c EditableComboBox - An editable QComboBox is used for taking the input, |
108 | so either one item of a list can be chosen or a text can be entered. Using | 107 | so either one item of a list can be chosen or a text can be entered. Using |
109 | editableComboBox() the QComboBox can be accessed. | 108 | editableComboBox() the QComboBox can be accessed. |
110 | </ul> | 109 | </ul> |
111 | */ | 110 | */ |
112 | 111 | ||
113 | /*! | 112 | /*! |
114 | Constructs the dialog. \a label is the text which is shown to the user (it should mention | 113 | Constructs the dialog. \a label is the text which is shown to the user (it should mention |
115 | to the user what he/she should input), \a parent the parent widget of the dialog, \a name | 114 | to the user what he/she should input), \a parent the parent widget of the dialog, \a name |
116 | the name of it and if you set \a modal to TRUE, the dialog pops up modally, else it pops | 115 | the name of it and if you set \a modal to TRUE, the dialog pops up modally, else it pops |
117 | up modeless. With \a type you specify the type of the dialog. | 116 | up modeless. With \a type you specify the type of the dialog. |
118 | 117 | ||
119 | \sa getText(), getInteger(), getDouble(), getItem() | 118 | \sa getText(), getInteger(), getDouble(), getItem() |
120 | */ | 119 | */ |
121 | 120 | ||
122 | QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name, | 121 | QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name, |
123 | bool modal, Type type) | 122 | bool modal, Type type) |
124 | : QDialog( parent, name, modal ) | 123 | : QDialog( parent, name, modal ) |
125 | { | 124 | { |
126 | if ( parent && parent->icon() &&!parent->icon()->isNull() ) | 125 | if ( parent && parent->icon() &&!parent->icon()->isNull() ) |
127 | setIcon( *parent->icon() ); | 126 | setIcon( *parent->icon() ); |
128 | else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) | 127 | else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) |
129 | QDialog::setIcon( *qApp->mainWidget()->icon() ); | 128 | QDialog::setIcon( *qApp->mainWidget()->icon() ); |
130 | 129 | ||
131 | d = new QInputDialogPrivate; | 130 | d = new QInputDialogPrivate; |
132 | d->lineEdit = 0; | 131 | d->lineEdit = 0; |
133 | d->spinBox = 0; | 132 | d->spinBox = 0; |
134 | d->comboBox = 0; | 133 | d->comboBox = 0; |
135 | 134 | ||
136 | QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); | 135 | QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); |
137 | 136 | ||
138 | QLabel* l = new QLabel( label, this ); | 137 | QLabel* l = new QLabel( label, this ); |
139 | vbox->addWidget( l ); | 138 | vbox->addWidget( l ); |
140 | 139 | ||
141 | d->stack = new QWidgetStack( this ); | 140 | d->stack = new QWidgetStack( this ); |
142 | vbox->addWidget( d->stack ); | 141 | vbox->addWidget( d->stack ); |
143 | d->lineEdit = new QLineEdit( d->stack ); | 142 | d->lineEdit = new QLineEdit( d->stack ); |
144 | d->spinBox = new QSpinBox( d->stack ); | 143 | d->spinBox = new QSpinBox( d->stack ); |
145 | d->comboBox = new QComboBox( FALSE, d->stack ); | 144 | d->comboBox = new QComboBox( FALSE, d->stack ); |
146 | d->editComboBox = new QComboBox( TRUE, d->stack ); | 145 | d->editComboBox = new QComboBox( TRUE, d->stack ); |
147 | 146 | ||
148 | QHBoxLayout *hbox = new QHBoxLayout( 6 ); | 147 | QHBoxLayout *hbox = new QHBoxLayout( 6 ); |
149 | vbox->addLayout( hbox, AlignRight ); | 148 | vbox->addLayout( hbox, AlignRight ); |
150 | 149 | ||
151 | d->ok = new QPushButton( tr( "&OK" ), this ); | 150 | d->ok = new QPushButton( tr( "&OK" ), this ); |
152 | d->ok->setDefault( TRUE ); | 151 | d->ok->setDefault( TRUE ); |
153 | QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); | 152 | QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); |
154 | 153 | ||
155 | QSize bs( d->ok->sizeHint() ); | 154 | QSize bs( d->ok->sizeHint() ); |
156 | if ( cancel->sizeHint().width() > bs.width() ) | 155 | if ( cancel->sizeHint().width() > bs.width() ) |
157 | bs.setWidth( cancel->sizeHint().width() ); | 156 | bs.setWidth( cancel->sizeHint().width() ); |
158 | 157 | ||
159 | d->ok->setFixedSize( bs ); | 158 | d->ok->setFixedSize( bs ); |
160 | cancel->setFixedSize( bs ); | 159 | cancel->setFixedSize( bs ); |
161 | 160 | ||
162 | hbox->addWidget( new QWidget( this ) ); | 161 | hbox->addWidget( new QWidget( this ) ); |
163 | hbox->addWidget( d->ok ); | 162 | hbox->addWidget( d->ok ); |
164 | hbox->addWidget( cancel ); | 163 | hbox->addWidget( cancel ); |
165 | 164 | ||
166 | connect( d->lineEdit, SIGNAL( returnPressed() ), | 165 | connect( d->lineEdit, SIGNAL( returnPressed() ), |
167 | this, SLOT( tryAccept() ) ); | 166 | this, SLOT( tryAccept() ) ); |
168 | connect( d->lineEdit, SIGNAL( textChanged(const QString&) ), | 167 | connect( d->lineEdit, SIGNAL( textChanged(const QString&) ), |
169 | this, SLOT( textChanged(const QString&) ) ); | 168 | this, SLOT( textChanged(const QString&) ) ); |
170 | 169 | ||
171 | connect( d->ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); | 170 | connect( d->ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
172 | connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); | 171 | connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); |
173 | 172 | ||
174 | resize( QMAX( sizeHint().width(), 400 ), sizeHint().height() ); | 173 | resize( QMAX( sizeHint().width(), 400 ), sizeHint().height() ); |
175 | 174 | ||
176 | setType( type ); | 175 | setType( type ); |
177 | } | 176 | } |
178 | 177 | ||
179 | /*! | 178 | /*! |
180 | Returns the line edit, which is used in the LineEdit mode | 179 | Returns the line edit, which is used in the LineEdit mode |
181 | */ | 180 | */ |
182 | 181 | ||
183 | QLineEdit *QInputDialog::lineEdit() const | 182 | QLineEdit *QInputDialog::lineEdit() const |
184 | { | 183 | { |
185 | return d->lineEdit; | 184 | return d->lineEdit; |
186 | } | 185 | } |
187 | 186 | ||
188 | /*! | 187 | /*! |
189 | Returns the spinbox, which is used in the SpinBox mode | 188 | Returns the spinbox, which is used in the SpinBox mode |
190 | */ | 189 | */ |
191 | 190 | ||
192 | QSpinBox *QInputDialog::spinBox() const | 191 | QSpinBox *QInputDialog::spinBox() const |
193 | { | 192 | { |
194 | return d->spinBox; | 193 | return d->spinBox; |
195 | } | 194 | } |
196 | 195 | ||
197 | /*! | 196 | /*! |
198 | Returns the combobox, which is used in the ComboBox mode | 197 | Returns the combobox, which is used in the ComboBox mode |
199 | */ | 198 | */ |
200 | 199 | ||
201 | QComboBox *QInputDialog::comboBox() const | 200 | QComboBox *QInputDialog::comboBox() const |
202 | { | 201 | { |
203 | return d->comboBox; | 202 | return d->comboBox; |
204 | } | 203 | } |
205 | 204 | ||
206 | /*! | 205 | /*! |
207 | Returns the combobox, which is used in the EditableComboBox mode | 206 | Returns the combobox, which is used in the EditableComboBox mode |
208 | */ | 207 | */ |
209 | 208 | ||
210 | QComboBox *QInputDialog::editableComboBox() const | 209 | QComboBox *QInputDialog::editableComboBox() const |
211 | { | 210 | { |
212 | return d->editComboBox; | 211 | return d->editComboBox; |
213 | } | 212 | } |
214 | 213 | ||
215 | /*! | 214 | /*! |
216 | Sets the input type of the dialog to \a t. | 215 | Sets the input type of the dialog to \a t. |
217 | */ | 216 | */ |
218 | 217 | ||
219 | void QInputDialog::setType( Type t ) | 218 | void QInputDialog::setType( Type t ) |
220 | { | 219 | { |
221 | switch ( t ) { | 220 | switch ( t ) { |
222 | case LineEdit: | 221 | case LineEdit: |
223 | d->stack->raiseWidget( d->lineEdit ); | 222 | d->stack->raiseWidget( d->lineEdit ); |
224 | d->lineEdit->setFocus(); | 223 | d->lineEdit->setFocus(); |
225 | break; | 224 | break; |
226 | case SpinBox: | 225 | case SpinBox: |
227 | d->stack->raiseWidget( d->spinBox ); | 226 | d->stack->raiseWidget( d->spinBox ); |
228 | d->spinBox->setFocus(); | 227 | d->spinBox->setFocus(); |
229 | break; | 228 | break; |
230 | case ComboBox: | 229 | case ComboBox: |
231 | d->stack->raiseWidget( d->comboBox ); | 230 | d->stack->raiseWidget( d->comboBox ); |
232 | d->comboBox->setFocus(); | 231 | d->comboBox->setFocus(); |
233 | break; | 232 | break; |
234 | case EditableComboBox: | 233 | case EditableComboBox: |
235 | d->stack->raiseWidget( d->editComboBox ); | 234 | d->stack->raiseWidget( d->editComboBox ); |
236 | d->editComboBox->setFocus(); | 235 | d->editComboBox->setFocus(); |
237 | break; | 236 | break; |
238 | } | 237 | } |
239 | 238 | ||
240 | d->type = t; | 239 | d->type = t; |
241 | } | 240 | } |
242 | 241 | ||
243 | /*! | 242 | /*! |
244 | Returns the input type of the dialog. | 243 | Returns the input type of the dialog. |
245 | 244 | ||
246 | \sa setType() | 245 | \sa setType() |
247 | */ | 246 | */ |
248 | 247 | ||
249 | QInputDialog::Type QInputDialog::type() const | 248 | QInputDialog::Type QInputDialog::type() const |
250 | { | 249 | { |
251 | return d->type; | 250 | return d->type; |
252 | } | 251 | } |
253 | 252 | ||
254 | /*! | 253 | /*! |
255 | Destructor. | 254 | Destructor. |
256 | */ | 255 | */ |
257 | 256 | ||
258 | QInputDialog::~QInputDialog() | 257 | QInputDialog::~QInputDialog() |
259 | { | 258 | { |
260 | delete d; | 259 | delete d; |
261 | } | 260 | } |
262 | 261 | ||
263 | /*! | 262 | /*! |
264 | Static convenience function to get a textual input from the user. \a caption is the text | 263 | Static convenience function to get a textual input from the user. \a caption is the text |
265 | which is displayed in the title bar of the dialog. \a label is the text which | 264 | which is displayed in the title bar of the dialog. \a label is the text which |
266 | is shown to the user (it should mention to the user what he/she should input), \a text | 265 | is shown to the user (it should mention to the user what he/she should input), \a text |
267 | the default text which will be initially set to the line edit, \a ok a pointer to | 266 | the default text which will be initially set to the line edit, \a ok a pointer to |
268 | a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the | 267 | a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the |
269 | user pressed cancel, \a parent the parent widget of the dialog and \a name | 268 | user pressed cancel, \a parent the parent widget of the dialog and \a name |
270 | the name of it. The dialogs pops up modally! | 269 | the name of it. The dialogs pops up modally! |
271 | 270 | ||
272 | This method returns the text which has been entered in the line edit. | 271 | This method returns the text which has been entered in the line edit. |
273 | 272 | ||
274 | You will use this static method like this: | 273 | You will use this static method like this: |
275 | 274 | ||
276 | \code | 275 | \code |
277 | bool ok = FALSE; | 276 | bool ok = FALSE; |
278 | QString text = QInputDialog::getText( tr( "Please enter your name" ), QString::null, &ok, this ); | 277 | QString text = QInputDialog::getText( tr( "Please enter your name" ), QString::null, &ok, this ); |
279 | if ( ok && !text.isEmpty() ) | 278 | if ( ok && !text.isEmpty() ) |
280 | ;// user entered something and pressed ok | 279 | ;// user entered something and pressed ok |
281 | else | 280 | else |
282 | ;// user entered nothing or pressed cancel | 281 | ;// user entered nothing or pressed cancel |
283 | \endcode | 282 | \endcode |
284 | */ | 283 | */ |
285 | 284 | ||
286 | QString QInputDialog::getText( const QString &caption, const QString &label, const QString &text, | 285 | QString QInputDialog::getText( const QString &caption, const QString &label, const QString &text, |
287 | bool *ok, QWidget *parent, const char *name ) | 286 | bool *ok, QWidget *parent, const char *name ) |
288 | { | 287 | { |
289 | return getText( caption, label, QLineEdit::Normal, text, ok, parent, name ); | 288 | return getText( caption, label, QLineEdit::Normal, text, ok, parent, name ); |
290 | } | 289 | } |
291 | 290 | ||
292 | /*! | 291 | /*! |
293 | Like above, but accepts an a \a mode which the line edit will use to display text. | 292 | Like above, but accepts an a \a mode which the line edit will use to display text. |
294 | 293 | ||
295 | \sa getText() | 294 | \sa getText() |
296 | */ | 295 | */ |
297 | 296 | ||
298 | QString QInputDialog::getText( const QString &caption, const QString &label, QLineEdit::EchoMode mode, | 297 | QString QInputDialog::getText( const QString &caption, const QString &label, QLineEdit::EchoMode mode, |
299 | const QString &text, bool *ok, QWidget *parent, const char *name ) | 298 | const QString &text, bool *ok, QWidget *parent, const char *name ) |
300 | { | 299 | { |
301 | QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit ); | 300 | QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit ); |
302 | dlg->setCaption( caption ); | 301 | dlg->setCaption( caption ); |
303 | dlg->lineEdit()->setText( text ); | 302 | dlg->lineEdit()->setText( text ); |
304 | dlg->lineEdit()->setEchoMode( mode ); | 303 | dlg->lineEdit()->setEchoMode( mode ); |
305 | if ( !text.isEmpty() ) | 304 | if ( !text.isEmpty() ) |
306 | dlg->lineEdit()->selectAll(); | 305 | dlg->lineEdit()->selectAll(); |
307 | 306 | ||
308 | bool ok_ = FALSE; | 307 | bool ok_ = FALSE; |
309 | QString result; | 308 | QString result; |
310 | ok_ = dlg->exec() == QDialog::Accepted; | 309 | ok_ = dlg->exec() == QDialog::Accepted; |
311 | if ( ok ) | 310 | if ( ok ) |
312 | *ok = ok_; | 311 | *ok = ok_; |
313 | if ( ok_ ) | 312 | if ( ok_ ) |
314 | result = dlg->lineEdit()->text(); | 313 | result = dlg->lineEdit()->text(); |
315 | 314 | ||
316 | delete dlg; | 315 | delete dlg; |
317 | return result; | 316 | return result; |
318 | } | 317 | } |
319 | 318 | ||
320 | /*! | 319 | /*! |
321 | Static convenience function to get an integral input from the user. \a caption is the text | 320 | Static convenience function to get an integral input from the user. \a caption is the text |
322 | which is displayed in the title bar of the dialog. \a label is the text which | 321 | which is displayed in the title bar of the dialog. \a label is the text which |
323 | is shown to the user (it should mention to the user what he/she should input), \a num | 322 | is shown to the user (it should mention to the user what he/she should input), \a num |
324 | the default number which will be initially set to the spinbox, \a from and \a to the | 323 | the default number which will be initially set to the spinbox, \a from and \a to the |
325 | range in which the entered number has to be, \a step the step in which the number can | 324 | range in which the entered number has to be, \a step the step in which the number can |
326 | be increased/decreased by the spinbox, \a ok a pointer to | 325 | be increased/decreased by the spinbox, \a ok a pointer to |
327 | a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the | 326 | a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the |
328 | user pressed cancel, \a parent the parent widget of the dialog and \a name | 327 | user pressed cancel, \a parent the parent widget of the dialog and \a name |
329 | the name of it. The dialogs pops up modally! | 328 | the name of it. The dialogs pops up modally! |
330 | 329 | ||
331 | This method returns the number which has been entered by the user. | 330 | This method returns the number which has been entered by the user. |
332 | 331 | ||
333 | You will use this static method like this: | 332 | You will use this static method like this: |
334 | 333 | ||
335 | \code | 334 | \code |
336 | bool ok = FALSE; | 335 | bool ok = FALSE; |
337 | int res = QInputDialog::getInteger( tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this ); | 336 | int res = QInputDialog::getInteger( tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this ); |
338 | if ( ok ) | 337 | if ( ok ) |
339 | ;// user entered something and pressed ok | 338 | ;// user entered something and pressed ok |
340 | else | 339 | else |
341 | ;// user pressed cancel | 340 | ;// user pressed cancel |
342 | \endcode | 341 | \endcode |
343 | */ | 342 | */ |
344 | 343 | ||
345 | int QInputDialog::getInteger( const QString &caption, const QString &label, int num, int from, int to, int step, | 344 | int QInputDialog::getInteger( const QString &caption, const QString &label, int num, int from, int to, int step, |
346 | bool *ok, QWidget *parent, const char *name ) | 345 | bool *ok, QWidget *parent, const char *name ) |
347 | { | 346 | { |
348 | QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, SpinBox ); | 347 | QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, SpinBox ); |
349 | dlg->setCaption( caption ); | 348 | dlg->setCaption( caption ); |
350 | dlg->spinBox()->setRange( from, to ); | 349 | dlg->spinBox()->setRange( from, to ); |
351 | dlg->spinBox()->setSteps( step, 0 ); | 350 | dlg->spinBox()->setSteps( step, 0 ); |
352 | dlg->spinBox()->setValue( num ); | 351 | dlg->spinBox()->setValue( num ); |
353 | 352 | ||
354 | bool ok_ = FALSE; | 353 | bool ok_ = FALSE; |
355 | int result; | 354 | int result; |
356 | ok_ = dlg->exec() == QDialog::Accepted; | 355 | ok_ = dlg->exec() == QDialog::Accepted; |
357 | if ( ok ) | 356 | if ( ok ) |
358 | *ok = ok_; | 357 | *ok = ok_; |
359 | result = dlg->spinBox()->value(); | 358 | result = dlg->spinBox()->value(); |
360 | 359 | ||
361 | delete dlg; | 360 | delete dlg; |
362 | return result; | 361 | return result; |
363 | } | 362 | } |
364 | 363 | ||
365 | /*! | 364 | /*! |
366 | Static convenience function to get a decimal input from the user. \a caption is the text | 365 | Static convenience function to get a decimal input from the user. \a caption is the text |
367 | which is displayed in the title bar of the dialog. \a label is the text which | 366 | which is displayed in the title bar of the dialog. \a label is the text which |
368 | is shown to the user (it should mention to the user what he/she should input), \a num | 367 | is shown to the user (it should mention to the user what he/she should input), \a num |
369 | the default decimal number which will be initially set to the line edit, \a from and \a to the | 368 | the default decimal number which will be initially set to the line edit, \a from and \a to the |
370 | range in which the entered number has to be, \a decimals the number of decimal which | 369 | range in which the entered number has to be, \a decimals the number of decimal which |
371 | the number may have, \a ok a pointer to | 370 | the number may have, \a ok a pointer to |
372 | a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the | 371 | a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the |
373 | user pressed cancel, \a parent the parent widget of the dialog and \a name | 372 | user pressed cancel, \a parent the parent widget of the dialog and \a name |
374 | the name of it. The dialogs pops up modally! | 373 | the name of it. The dialogs pops up modally! |
375 | 374 | ||
376 | This method returns the number which has been entered by the user. | 375 | This method returns the number which has been entered by the user. |
377 | 376 | ||
378 | You will use this static method like this: | 377 | You will use this static method like this: |
379 | 378 | ||
380 | \code | 379 | \code |
381 | bool ok = FALSE; | 380 | bool ok = FALSE; |
382 | double res = QInputDialog::getDouble( tr( "Please enter a decimal number" ), 33.7, 0, 1000, 2, &ok, this ); | 381 | double res = QInputDialog::getDouble( tr( "Please enter a decimal number" ), 33.7, 0, 1000, 2, &ok, this ); |
383 | if ( ok ) | 382 | if ( ok ) |
384 | ;// user entered something and pressed ok | 383 | ;// user entered something and pressed ok |
385 | else | 384 | else |
386 | ;// user pressed cancel | 385 | ;// user pressed cancel |
387 | \endcode | 386 | \endcode |
388 | */ | 387 | */ |
389 | 388 | ||
390 | double QInputDialog::getDouble( const QString &caption, const QString &label, double num, | 389 | double QInputDialog::getDouble( const QString &caption, const QString &label, double num, |
391 | double from, double to, int decimals, | 390 | double from, double to, int decimals, |
392 | bool *ok, QWidget *parent, const char *name ) | 391 | bool *ok, QWidget *parent, const char *name ) |
393 | { | 392 | { |
394 | QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit ); | 393 | QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit ); |
395 | dlg->setCaption( caption ); | 394 | dlg->setCaption( caption ); |
396 | dlg->lineEdit()->setValidator( new QDoubleValidator( from, to, decimals, dlg->lineEdit() ) ); | 395 | dlg->lineEdit()->setValidator( new QDoubleValidator( from, to, decimals, dlg->lineEdit() ) ); |
397 | dlg->lineEdit()->setText( QString::number( num, 'f', decimals ) ); | 396 | dlg->lineEdit()->setText( QString::number( num, 'f', decimals ) ); |
398 | dlg->lineEdit()->selectAll(); | 397 | dlg->lineEdit()->selectAll(); |
399 | 398 | ||
400 | bool accepted = ( dlg->exec() == QDialog::Accepted ); | 399 | bool accepted = ( dlg->exec() == QDialog::Accepted ); |
401 | if ( ok ) | 400 | if ( ok ) |
402 | *ok = accepted; | 401 | *ok = accepted; |
403 | 402 | ||
404 | double result = dlg->lineEdit()->text().toDouble(); | 403 | double result = dlg->lineEdit()->text().toDouble(); |
405 | 404 | ||
406 | delete dlg; | 405 | delete dlg; |
407 | return result; | 406 | return result; |
408 | } | 407 | } |
409 | 408 | ||
410 | /*! | 409 | /*! |
411 | Static convenience function to let the user select an item from a string list. \a caption is the text | 410 | Static convenience function to let the user select an item from a string list. \a caption is the text |
412 | which is displayed in the title bar of the dialog. \a label is the text which | 411 | which is displayed in the title bar of the dialog. \a label is the text which |
413 | is shown to the user (it should mention to the user what he/she should input), \a list the | 412 | is shown to the user (it should mention to the user what he/she should input), \a list the |
414 | string list which is inserted into the combobox, \a current the number of the item which should | 413 | string list which is inserted into the combobox, \a current the number of the item which should |
415 | be initially the current item, \a editable specifies if the combobox should be editable (if it is TRUE) | 414 | be initially the current item, \a editable specifies if the combobox should be editable (if it is TRUE) |
416 | or read-only (if \a editable is FALSE), \a ok a pointer to | 415 | or read-only (if \a editable is FALSE), \a ok a pointer to |
417 | a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the | 416 | a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the |
418 | user pressed cancel, \a parent the parent widget of the dialog and \a name | 417 | user pressed cancel, \a parent the parent widget of the dialog and \a name |
419 | the name of it. The dialogs pops up modally! | 418 | the name of it. The dialogs pops up modally! |
420 | 419 | ||
421 | This method returns the text of the current item, or if \a editable was TRUE, the current | 420 | This method returns the text of the current item, or if \a editable was TRUE, the current |
422 | text of the combobox. | 421 | text of the combobox. |
423 | 422 | ||
424 | You will use this static method like this: | 423 | You will use this static method like this: |
425 | 424 | ||
426 | \code | 425 | \code |
diff --git a/libqtaux/qsplitter.cpp b/libqtaux/qsplitter.cpp index ab6e01b..39321f8 100644 --- a/libqtaux/qsplitter.cpp +++ b/libqtaux/qsplitter.cpp | |||
@@ -1,428 +1,424 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Splitter widget | 4 | ** Splitter widget |
5 | ** | 5 | ** |
6 | ** Created: 980105 | 6 | ** Created: 980105 |
7 | ** | 7 | ** |
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
9 | ** | 9 | ** |
10 | ** This file is part of the widgets module of the Qt GUI Toolkit. | 10 | ** This file is part of the widgets module of the Qt GUI Toolkit. |
11 | ** | 11 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 12 | ** This file may be distributed under the terms of the Q Public License |
13 | ** as defined by Trolltech AS of Norway and appearing in the file | 13 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 15 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 16 | ** This file may be distributed and/or modified under the terms of the |
17 | ** GNU General Public License version 2 as published by the Free Software | 17 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 18 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 19 | ** packaging of this file. |
20 | ** | 20 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
22 | ** licenses may use this file in accordance with the Qt Commercial License | 22 | ** licenses may use this file in accordance with the Qt Commercial License |
23 | ** Agreement provided with the Software. | 23 | ** Agreement provided with the Software. |
24 | ** | 24 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
27 | ** | 27 | ** |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
29 | ** information about Qt Commercial License Agreements. | 29 | ** information about Qt Commercial License Agreements. |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 32 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 33 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 34 | ** not clear to you. |
35 | ** | 35 | ** |
36 | **********************************************************************/ | 36 | **********************************************************************/ |
37 | #include "qsplitter.h" | 37 | #include "qsplitter.h" |
38 | 38 | ||
39 | #include "qpainter.h" | ||
40 | #include "qdrawutil.h" | 39 | #include "qdrawutil.h" |
41 | #include "qbitmap.h" | ||
42 | #include "qlayoutengine_p.h" | 40 | #include "qlayoutengine_p.h" |
43 | #include "qlist.h" | ||
44 | #include "qarray.h" | ||
45 | #include "qobjectlist.h" | 41 | #include "qobjectlist.h" |
46 | #include "qapplication.h" //sendPostedEvents | 42 | #include "qapplication.h" //sendPostedEvents |
47 | 43 | ||
48 | class QSplitterHandle : public QWidget | 44 | class QSplitterHandle : public QWidget |
49 | { | 45 | { |
50 | public: | 46 | public: |
51 | QSplitterHandle( Qt::Orientation o, | 47 | QSplitterHandle( Qt::Orientation o, |
52 | QSplitter *parent, const char* name=0 ); | 48 | QSplitter *parent, const char* name=0 ); |
53 | void setOrientation( Qt::Orientation o ); | 49 | void setOrientation( Qt::Orientation o ); |
54 | Qt::Orientation orientation() const { return orient; } | 50 | Qt::Orientation orientation() const { return orient; } |
55 | 51 | ||
56 | bool opaque() const { return s->opaqueResize(); } | 52 | bool opaque() const { return s->opaqueResize(); } |
57 | 53 | ||
58 | QSize sizeHint() const; | 54 | QSize sizeHint() const; |
59 | QSizePolicy sizePolicy() const; | 55 | QSizePolicy sizePolicy() const; |
60 | 56 | ||
61 | int id() const { return myId; } // data->list.at(id())->wid == this | 57 | int id() const { return myId; } // data->list.at(id())->wid == this |
62 | void setId( int i ) { myId = i; } | 58 | void setId( int i ) { myId = i; } |
63 | 59 | ||
64 | protected: | 60 | protected: |
65 | void paintEvent( QPaintEvent * ); | 61 | void paintEvent( QPaintEvent * ); |
66 | void mouseMoveEvent( QMouseEvent * ); | 62 | void mouseMoveEvent( QMouseEvent * ); |
67 | void mousePressEvent( QMouseEvent * ); | 63 | void mousePressEvent( QMouseEvent * ); |
68 | void mouseReleaseEvent( QMouseEvent * ); | 64 | void mouseReleaseEvent( QMouseEvent * ); |
69 | 65 | ||
70 | private: | 66 | private: |
71 | Qt::Orientation orient; | 67 | Qt::Orientation orient; |
72 | bool opaq; | 68 | bool opaq; |
73 | int myId; | 69 | int myId; |
74 | 70 | ||
75 | QSplitter *s; | 71 | QSplitter *s; |
76 | }; | 72 | }; |
77 | 73 | ||
78 | static int mouseOffset; | 74 | static int mouseOffset; |
79 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky | 75 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky |
80 | 76 | ||
81 | 77 | ||
82 | QSplitterHandle::QSplitterHandle( Qt::Orientation o, | 78 | QSplitterHandle::QSplitterHandle( Qt::Orientation o, |
83 | QSplitter *parent, const char * name ) | 79 | QSplitter *parent, const char * name ) |
84 | : QWidget( parent, name ) | 80 | : QWidget( parent, name ) |
85 | { | 81 | { |
86 | s = parent; | 82 | s = parent; |
87 | setOrientation(o); | 83 | setOrientation(o); |
88 | } | 84 | } |
89 | 85 | ||
90 | QSizePolicy QSplitterHandle::sizePolicy() const | 86 | QSizePolicy QSplitterHandle::sizePolicy() const |
91 | { | 87 | { |
92 | //### removeme 3.0 | 88 | //### removeme 3.0 |
93 | return QWidget::sizePolicy(); | 89 | return QWidget::sizePolicy(); |
94 | } | 90 | } |
95 | 91 | ||
96 | QSize QSplitterHandle::sizeHint() const | 92 | QSize QSplitterHandle::sizeHint() const |
97 | { | 93 | { |
98 | int sw = style().splitterWidth(); | 94 | int sw = style().splitterWidth(); |
99 | return QSize(sw,sw).expandedTo( QApplication::globalStrut() ); | 95 | return QSize(sw,sw).expandedTo( QApplication::globalStrut() ); |
100 | } | 96 | } |
101 | 97 | ||
102 | void QSplitterHandle::setOrientation( Qt::Orientation o ) | 98 | void QSplitterHandle::setOrientation( Qt::Orientation o ) |
103 | { | 99 | { |
104 | orient = o; | 100 | orient = o; |
105 | #ifndef QT_NO_CURSOR | 101 | #ifndef QT_NO_CURSOR |
106 | if ( o == QSplitter::Horizontal ) | 102 | if ( o == QSplitter::Horizontal ) |
107 | setCursor( splitHCursor ); | 103 | setCursor( splitHCursor ); |
108 | else | 104 | else |
109 | setCursor( splitVCursor ); | 105 | setCursor( splitVCursor ); |
110 | #endif | 106 | #endif |
111 | } | 107 | } |
112 | 108 | ||
113 | 109 | ||
114 | void QSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | 110 | void QSplitterHandle::mouseMoveEvent( QMouseEvent *e ) |
115 | { | 111 | { |
116 | if ( !(e->state()&LeftButton) ) | 112 | if ( !(e->state()&LeftButton) ) |
117 | return; | 113 | return; |
118 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 114 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
119 | - mouseOffset; | 115 | - mouseOffset; |
120 | if ( opaque() ) { | 116 | if ( opaque() ) { |
121 | s->moveSplitter( pos, id() ); | 117 | s->moveSplitter( pos, id() ); |
122 | } else { | 118 | } else { |
123 | int min = pos; int max = pos; | 119 | int min = pos; int max = pos; |
124 | s->getRange( id(), &min, &max ); | 120 | s->getRange( id(), &min, &max ); |
125 | s->setRubberband( QMAX( min, QMIN(max, pos ))); | 121 | s->setRubberband( QMAX( min, QMIN(max, pos ))); |
126 | } | 122 | } |
127 | } | 123 | } |
128 | 124 | ||
129 | void QSplitterHandle::mousePressEvent( QMouseEvent *e ) | 125 | void QSplitterHandle::mousePressEvent( QMouseEvent *e ) |
130 | { | 126 | { |
131 | if ( e->button() == LeftButton ) | 127 | if ( e->button() == LeftButton ) |
132 | mouseOffset = s->pick(e->pos()); | 128 | mouseOffset = s->pick(e->pos()); |
133 | } | 129 | } |
134 | 130 | ||
135 | void QSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | 131 | void QSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) |
136 | { | 132 | { |
137 | if ( !opaque() && e->button() == LeftButton ) { | 133 | if ( !opaque() && e->button() == LeftButton ) { |
138 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())); | 134 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())); |
139 | s->setRubberband( -1 ); | 135 | s->setRubberband( -1 ); |
140 | s->moveSplitter( pos, id() ); | 136 | s->moveSplitter( pos, id() ); |
141 | } | 137 | } |
142 | } | 138 | } |
143 | 139 | ||
144 | void QSplitterHandle::paintEvent( QPaintEvent * ) | 140 | void QSplitterHandle::paintEvent( QPaintEvent * ) |
145 | { | 141 | { |
146 | QPainter p( this ); | 142 | QPainter p( this ); |
147 | s->drawSplitter( &p, 0, 0, width(), height() ); | 143 | s->drawSplitter( &p, 0, 0, width(), height() ); |
148 | } | 144 | } |
149 | 145 | ||
150 | 146 | ||
151 | class QSplitterLayoutStruct | 147 | class QSplitterLayoutStruct |
152 | { | 148 | { |
153 | public: | 149 | public: |
154 | QSplitter::ResizeMode mode; | 150 | QSplitter::ResizeMode mode; |
155 | QCOORD sizer; | 151 | QCOORD sizer; |
156 | bool isSplitter; | 152 | bool isSplitter; |
157 | QWidget *wid; | 153 | QWidget *wid; |
158 | }; | 154 | }; |
159 | 155 | ||
160 | class QSplitterData | 156 | class QSplitterData |
161 | { | 157 | { |
162 | public: | 158 | public: |
163 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} | 159 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} |
164 | 160 | ||
165 | QList<QSplitterLayoutStruct> list; | 161 | QList<QSplitterLayoutStruct> list; |
166 | bool opaque; | 162 | bool opaque; |
167 | bool firstShow; | 163 | bool firstShow; |
168 | }; | 164 | }; |
169 | 165 | ||
170 | 166 | ||
171 | // NOT REVISED | 167 | // NOT REVISED |
172 | /*! | 168 | /*! |
173 | \class QSplitter qsplitter.h | 169 | \class QSplitter qsplitter.h |
174 | \brief The QSplitter class implements a splitter widget. | 170 | \brief The QSplitter class implements a splitter widget. |
175 | 171 | ||
176 | \ingroup organizers | 172 | \ingroup organizers |
177 | 173 | ||
178 | A splitter lets the user control the size of child widgets by | 174 | A splitter lets the user control the size of child widgets by |
179 | dragging the boundary between the children. Any number of widgets | 175 | dragging the boundary between the children. Any number of widgets |
180 | may be controlled. | 176 | may be controlled. |
181 | 177 | ||
182 | To show a QListBox, a QListView and a QMultiLineEdit side by side: | 178 | To show a QListBox, a QListView and a QMultiLineEdit side by side: |
183 | 179 | ||
184 | \code | 180 | \code |
185 | QSplitter *split = new QSplitter( parent ); | 181 | QSplitter *split = new QSplitter( parent ); |
186 | QListBox *lb = new QListBox( split ); | 182 | QListBox *lb = new QListBox( split ); |
187 | QListView *lv = new QListView( split ); | 183 | QListView *lv = new QListView( split ); |
188 | QMultiLineEdit *ed = new QMultiLineEdit( split ); | 184 | QMultiLineEdit *ed = new QMultiLineEdit( split ); |
189 | \endcode | 185 | \endcode |
190 | 186 | ||
191 | In QSplitter the boundary can be either horizontal or vertical. The | 187 | In QSplitter the boundary can be either horizontal or vertical. The |
192 | default is horizontal (the children are side by side) and you | 188 | default is horizontal (the children are side by side) and you |
193 | can use setOrientation( QSplitter::Vertical ) to set it to vertical. | 189 | can use setOrientation( QSplitter::Vertical ) to set it to vertical. |
194 | 190 | ||
195 | By default, all widgets can be as large or as small as the user | 191 | By default, all widgets can be as large or as small as the user |
196 | wishes, down to \link QWidget::minimumSizeHint() minimumSizeHint()\endlink. | 192 | wishes, down to \link QWidget::minimumSizeHint() minimumSizeHint()\endlink. |
197 | You can naturally use setMinimumSize() and/or | 193 | You can naturally use setMinimumSize() and/or |
198 | setMaximumSize() on the children. Use setResizeMode() to specify that | 194 | setMaximumSize() on the children. Use setResizeMode() to specify that |
199 | a widget should keep its size when the splitter is resized. | 195 | a widget should keep its size when the splitter is resized. |
200 | 196 | ||
201 | QSplitter normally resizes the children only at the end of a | 197 | QSplitter normally resizes the children only at the end of a |
202 | resize operation, but if you call setOpaqueResize( TRUE ), the | 198 | resize operation, but if you call setOpaqueResize( TRUE ), the |
203 | widgets are resized as often as possible. | 199 | widgets are resized as often as possible. |
204 | 200 | ||
205 | The initial distribution of size between the widgets is determined | 201 | The initial distribution of size between the widgets is determined |
206 | by the initial size of each widget. You can also use setSizes() to | 202 | by the initial size of each widget. You can also use setSizes() to |
207 | set the sizes of all the widgets. The function sizes() returns the | 203 | set the sizes of all the widgets. The function sizes() returns the |
208 | sizes set by the user. | 204 | sizes set by the user. |
209 | 205 | ||
210 | If you hide() a child, its space will be distributed among the other | 206 | If you hide() a child, its space will be distributed among the other |
211 | children. When you show() it again, it will be reinstated. | 207 | children. When you show() it again, it will be reinstated. |
212 | 208 | ||
213 | <img src=qsplitter-m.png> <img src=qsplitter-w.png> | 209 | <img src=qsplitter-m.png> <img src=qsplitter-w.png> |
214 | 210 | ||
215 | \sa QTabBar | 211 | \sa QTabBar |
216 | */ | 212 | */ |
217 | 213 | ||
218 | 214 | ||
219 | 215 | ||
220 | static QSize minSize( const QWidget *w ) | 216 | static QSize minSize( const QWidget *w ) |
221 | { | 217 | { |
222 | QSize min = w->minimumSize(); | 218 | QSize min = w->minimumSize(); |
223 | QSize s; | 219 | QSize s; |
224 | if ( min.height() <= 0 || min.width() <= 0 ) | 220 | if ( min.height() <= 0 || min.width() <= 0 ) |
225 | s = w->minimumSizeHint(); | 221 | s = w->minimumSizeHint(); |
226 | if ( min.height() > 0 ) | 222 | if ( min.height() > 0 ) |
227 | s.setHeight( min.height() ); | 223 | s.setHeight( min.height() ); |
228 | if ( min.width() > 0 ) | 224 | if ( min.width() > 0 ) |
229 | s.setWidth( min.width() ); | 225 | s.setWidth( min.width() ); |
230 | return s.expandedTo(QSize(0,0)); | 226 | return s.expandedTo(QSize(0,0)); |
231 | } | 227 | } |
232 | 228 | ||
233 | /*! | 229 | /*! |
234 | Constructs a horizontal splitter. | 230 | Constructs a horizontal splitter. |
235 | */ | 231 | */ |
236 | 232 | ||
237 | QSplitter::QSplitter( QWidget *parent, const char *name ) | 233 | QSplitter::QSplitter( QWidget *parent, const char *name ) |
238 | :QFrame(parent,name,WPaintUnclipped) | 234 | :QFrame(parent,name,WPaintUnclipped) |
239 | { | 235 | { |
240 | orient = Horizontal; | 236 | orient = Horizontal; |
241 | init(); | 237 | init(); |
242 | } | 238 | } |
243 | 239 | ||
244 | 240 | ||
245 | /*! | 241 | /*! |
246 | Constructs splitter with orientation \a o. | 242 | Constructs splitter with orientation \a o. |
247 | */ | 243 | */ |
248 | 244 | ||
249 | QSplitter::QSplitter( Orientation o, QWidget *parent, const char *name ) | 245 | QSplitter::QSplitter( Orientation o, QWidget *parent, const char *name ) |
250 | :QFrame(parent,name,WPaintUnclipped) | 246 | :QFrame(parent,name,WPaintUnclipped) |
251 | { | 247 | { |
252 | orient = o; | 248 | orient = o; |
253 | init(); | 249 | init(); |
254 | } | 250 | } |
255 | 251 | ||
256 | 252 | ||
257 | /*! | 253 | /*! |
258 | Destructs the splitter. | 254 | Destructs the splitter. |
259 | */ | 255 | */ |
260 | 256 | ||
261 | QSplitter::~QSplitter() | 257 | QSplitter::~QSplitter() |
262 | { | 258 | { |
263 | data->list.setAutoDelete( TRUE ); | 259 | data->list.setAutoDelete( TRUE ); |
264 | delete data; | 260 | delete data; |
265 | } | 261 | } |
266 | 262 | ||
267 | 263 | ||
268 | void QSplitter::init() | 264 | void QSplitter::init() |
269 | { | 265 | { |
270 | data = new QSplitterData; | 266 | data = new QSplitterData; |
271 | if ( orient == Horizontal ) | 267 | if ( orient == Horizontal ) |
272 | setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum) ); | 268 | setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum) ); |
273 | else | 269 | else |
274 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed) ); | 270 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed) ); |
275 | } | 271 | } |
276 | 272 | ||
277 | 273 | ||
278 | /*! | 274 | /*! |
279 | \fn void QSplitter::refresh() | 275 | \fn void QSplitter::refresh() |
280 | 276 | ||
281 | Updates the splitter state. You should not need to call this | 277 | Updates the splitter state. You should not need to call this |
282 | function during normal use of the splitter. | 278 | function during normal use of the splitter. |
283 | */ | 279 | */ |
284 | 280 | ||
285 | 281 | ||
286 | /*! Sets the orientation to \a o. By default the orientation is | 282 | /*! Sets the orientation to \a o. By default the orientation is |
287 | horizontal (the widgets are side by side). | 283 | horizontal (the widgets are side by side). |
288 | 284 | ||
289 | \sa orientation() | 285 | \sa orientation() |
290 | */ | 286 | */ |
291 | 287 | ||
292 | void QSplitter::setOrientation( Orientation o ) | 288 | void QSplitter::setOrientation( Orientation o ) |
293 | { | 289 | { |
294 | if ( orient == o ) | 290 | if ( orient == o ) |
295 | return; | 291 | return; |
296 | orient = o; | 292 | orient = o; |
297 | 293 | ||
298 | if ( orient == Horizontal ) | 294 | if ( orient == Horizontal ) |
299 | setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ) ); | 295 | setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ) ); |
300 | else | 296 | else |
301 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) ); | 297 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) ); |
302 | 298 | ||
303 | QSplitterLayoutStruct *s = data->list.first(); | 299 | QSplitterLayoutStruct *s = data->list.first(); |
304 | while ( s ) { | 300 | while ( s ) { |
305 | if ( s->isSplitter ) | 301 | if ( s->isSplitter ) |
306 | ((QSplitterHandle*)s->wid)->setOrientation( o ); | 302 | ((QSplitterHandle*)s->wid)->setOrientation( o ); |
307 | s = data->list.next(); // ### next at end of loop, no iterator | 303 | s = data->list.next(); // ### next at end of loop, no iterator |
308 | } | 304 | } |
309 | recalc( isVisible() ); | 305 | recalc( isVisible() ); |
310 | } | 306 | } |
311 | 307 | ||
312 | 308 | ||
313 | /*! | 309 | /*! |
314 | \fn Orientation QSplitter::orientation() const | 310 | \fn Orientation QSplitter::orientation() const |
315 | 311 | ||
316 | Returns the orientation (\c Horizontal or \c Vertical) of the splitter. | 312 | Returns the orientation (\c Horizontal or \c Vertical) of the splitter. |
317 | \sa setOrientation() | 313 | \sa setOrientation() |
318 | */ | 314 | */ |
319 | 315 | ||
320 | /*! | 316 | /*! |
321 | \reimp | 317 | \reimp |
322 | */ | 318 | */ |
323 | void QSplitter::resizeEvent( QResizeEvent * ) | 319 | void QSplitter::resizeEvent( QResizeEvent * ) |
324 | { | 320 | { |
325 | doResize(); | 321 | doResize(); |
326 | } | 322 | } |
327 | 323 | ||
328 | 324 | ||
329 | /*! | 325 | /*! |
330 | Inserts the widget \a w at the end, or at the beginning if \a first is TRUE | 326 | Inserts the widget \a w at the end, or at the beginning if \a first is TRUE |
331 | 327 | ||
332 | It is the responsibility of the caller of this function to make sure | 328 | It is the responsibility of the caller of this function to make sure |
333 | that \a w is not already in the splitter, and to call recalcId if | 329 | that \a w is not already in the splitter, and to call recalcId if |
334 | needed. (If \a first is TRUE, then recalcId is very probably | 330 | needed. (If \a first is TRUE, then recalcId is very probably |
335 | needed.) | 331 | needed.) |
336 | */ | 332 | */ |
337 | 333 | ||
338 | QSplitterLayoutStruct *QSplitter::addWidget( QWidget *w, bool first ) | 334 | QSplitterLayoutStruct *QSplitter::addWidget( QWidget *w, bool first ) |
339 | { | 335 | { |
340 | QSplitterLayoutStruct *s; | 336 | QSplitterLayoutStruct *s; |
341 | QSplitterHandle *newHandle = 0; | 337 | QSplitterHandle *newHandle = 0; |
342 | if ( data->list.count() > 0 ) { | 338 | if ( data->list.count() > 0 ) { |
343 | s = new QSplitterLayoutStruct; | 339 | s = new QSplitterLayoutStruct; |
344 | s->mode = KeepSize; | 340 | s->mode = KeepSize; |
345 | newHandle = new QSplitterHandle( orientation(), this ); | 341 | newHandle = new QSplitterHandle( orientation(), this ); |
346 | s->wid = newHandle; | 342 | s->wid = newHandle; |
347 | newHandle->setId(data->list.count()); | 343 | newHandle->setId(data->list.count()); |
348 | s->isSplitter = TRUE; | 344 | s->isSplitter = TRUE; |
349 | s->sizer = pick( newHandle->sizeHint() ); | 345 | s->sizer = pick( newHandle->sizeHint() ); |
350 | if ( first ) | 346 | if ( first ) |
351 | data->list.insert( 0, s ); | 347 | data->list.insert( 0, s ); |
352 | else | 348 | else |
353 | data->list.append( s ); | 349 | data->list.append( s ); |
354 | } | 350 | } |
355 | s = new QSplitterLayoutStruct; | 351 | s = new QSplitterLayoutStruct; |
356 | s->mode = Stretch; | 352 | s->mode = Stretch; |
357 | s->wid = w; | 353 | s->wid = w; |
358 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) | 354 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) |
359 | s->sizer = pick( w->sizeHint() ); | 355 | s->sizer = pick( w->sizeHint() ); |
360 | else | 356 | else |
361 | s->sizer = pick( w->size() ); | 357 | s->sizer = pick( w->size() ); |
362 | s->isSplitter = FALSE; | 358 | s->isSplitter = FALSE; |
363 | if ( first ) | 359 | if ( first ) |
364 | data->list.insert( 0, s ); | 360 | data->list.insert( 0, s ); |
365 | else | 361 | else |
366 | data->list.append( s ); | 362 | data->list.append( s ); |
367 | if ( newHandle && isVisible() ) | 363 | if ( newHandle && isVisible() ) |
368 | newHandle->show(); //will trigger sending of post events | 364 | newHandle->show(); //will trigger sending of post events |
369 | return s; | 365 | return s; |
370 | } | 366 | } |
371 | 367 | ||
372 | 368 | ||
373 | /*! | 369 | /*! |
374 | Tells the splitter that a child widget has been inserted/removed. | 370 | Tells the splitter that a child widget has been inserted/removed. |
375 | */ | 371 | */ |
376 | 372 | ||
377 | void QSplitter::childEvent( QChildEvent *c ) | 373 | void QSplitter::childEvent( QChildEvent *c ) |
378 | { | 374 | { |
379 | if ( c->type() == QEvent::ChildInserted ) { | 375 | if ( c->type() == QEvent::ChildInserted ) { |
380 | if ( !c->child()->isWidgetType() ) | 376 | if ( !c->child()->isWidgetType() ) |
381 | return; | 377 | return; |
382 | 378 | ||
383 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) | 379 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) |
384 | return; | 380 | return; |
385 | 381 | ||
386 | QSplitterLayoutStruct *s = data->list.first(); | 382 | QSplitterLayoutStruct *s = data->list.first(); |
387 | while ( s ) { | 383 | while ( s ) { |
388 | if ( s->wid == c->child() ) | 384 | if ( s->wid == c->child() ) |
389 | return; | 385 | return; |
390 | s = data->list.next(); | 386 | s = data->list.next(); |
391 | } | 387 | } |
392 | addWidget( (QWidget*)c->child() ); | 388 | addWidget( (QWidget*)c->child() ); |
393 | recalc( isVisible() ); | 389 | recalc( isVisible() ); |
394 | 390 | ||
395 | } else if ( c->type() == QEvent::ChildRemoved ) { | 391 | } else if ( c->type() == QEvent::ChildRemoved ) { |
396 | QSplitterLayoutStruct *p = 0; | 392 | QSplitterLayoutStruct *p = 0; |
397 | if ( data->list.count() > 1 ) | 393 | if ( data->list.count() > 1 ) |
398 | p = data->list.at(1); //remove handle _after_ first widget. | 394 | p = data->list.at(1); //remove handle _after_ first widget. |
399 | QSplitterLayoutStruct *s = data->list.first(); | 395 | QSplitterLayoutStruct *s = data->list.first(); |
400 | while ( s ) { | 396 | while ( s ) { |
401 | if ( s->wid == c->child() ) { | 397 | if ( s->wid == c->child() ) { |
402 | data->list.removeRef( s ); | 398 | data->list.removeRef( s ); |
403 | delete s; | 399 | delete s; |
404 | if ( p && p->isSplitter ) { | 400 | if ( p && p->isSplitter ) { |
405 | data->list.removeRef( p ); | 401 | data->list.removeRef( p ); |
406 | delete p->wid; //will call childEvent | 402 | delete p->wid; //will call childEvent |
407 | delete p; | 403 | delete p; |
408 | } | 404 | } |
409 | recalcId(); | 405 | recalcId(); |
410 | doResize(); | 406 | doResize(); |
411 | return; | 407 | return; |
412 | } | 408 | } |
413 | p = s; | 409 | p = s; |
414 | s = data->list.next(); | 410 | s = data->list.next(); |
415 | } | 411 | } |
416 | } | 412 | } |
417 | } | 413 | } |
418 | 414 | ||
419 | 415 | ||
420 | /*! | 416 | /*! |
421 | Shows a rubber band at position \a p. If \a p is negative, the | 417 | Shows a rubber band at position \a p. If \a p is negative, the |
422 | rubber band is removed. | 418 | rubber band is removed. |
423 | */ | 419 | */ |
424 | 420 | ||
425 | void QSplitter::setRubberband( int p ) | 421 | void QSplitter::setRubberband( int p ) |
426 | { | 422 | { |
427 | QPainter paint( this ); | 423 | QPainter paint( this ); |
428 | paint.setPen( gray ); | 424 | paint.setPen( gray ); |