summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/oseparator.cpp2
-rw-r--r--libopie2/qt3/opieui/oeditlistbox.h2
-rw-r--r--libopie2/qt3/opieui/ojanuswidget.cpp2
3 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/opieui/oseparator.cpp b/libopie2/opieui/oseparator.cpp
index bbc4381..177368b 100644
--- a/libopie2/opieui/oseparator.cpp
+++ b/libopie2/opieui/oseparator.cpp
@@ -1,129 +1,129 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
4 Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> 4 Copyright (C) 1997 Michael Roth <mroth@wirlweb.de>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32/* OPIE */ 32/* OPIE */
33 33
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <opie2/oseparator.h> 35#include <opie2/oseparator.h>
36 36
37/* QT */ 37/* QT */
38 38
39using namespace Opie::Core; 39using namespace Opie::Core;
40using namespace Opie::Ui; 40using namespace Opie::Ui;
41 41
42OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f) 42OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f)
43 : QFrame(parent, name, f) 43 : QFrame(parent, name, f)
44{ 44{
45 setLineWidth(1); 45 setLineWidth(1);
46 setMidLineWidth(0); 46 setMidLineWidth(0);
47 setOrientation( HLine ); 47 setOrientation( HLine );
48} 48}
49 49
50 50
51 51
52OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f) 52OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f)
53 : QFrame(parent, name, f) 53 : QFrame(parent, name, f)
54{ 54{
55 setLineWidth(1); 55 setLineWidth(1);
56 setMidLineWidth(0); 56 setMidLineWidth(0);
57 setOrientation( orientation ); 57 setOrientation( orientation );
58} 58}
59 59
60 60
61 61
62void OSeparator::setOrientation(int orientation) 62void OSeparator::setOrientation(int orientation)
63{ 63{
64 switch(orientation) 64 switch(orientation)
65 { 65 {
66 case Vertical: 66 case Vertical:
67 case VLine: 67 case VLine:
68 setFrameStyle( QFrame::VLine | QFrame::Sunken ); 68 setFrameStyle( QFrame::VLine | QFrame::Sunken );
69 setMinimumSize(2, 0); 69 setMinimumSize(2, 0);
70 break; 70 break;
71 71
72 default: 72 default:
73 owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl; 73 owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl;
74 74
75 case Horizontal: 75 case Horizontal:
76 case HLine: 76 case HLine:
77 setFrameStyle( QFrame::HLine | QFrame::Sunken ); 77 setFrameStyle( QFrame::HLine | QFrame::Sunken );
78 setMinimumSize(0, 2); 78 setMinimumSize(0, 2);
79 break; 79 break;
80 } 80 }
81} 81}
82 82
83 83
84 84
85int OSeparator::orientation() const 85int OSeparator::orientation() const
86{ 86{
87 if ( frameStyle() & VLine ) 87 if ( frameStyle() & VLine )
88 return VLine; 88 return VLine;
89 89
90 if ( frameStyle() & HLine ) 90 if ( frameStyle() & HLine )
91 return HLine; 91 return HLine;
92 92
93 return 0; 93 return 0;
94} 94}
95 95
96void OSeparator::drawFrame(QPainter *p) 96void OSeparator::drawFrame(QPainter *p)
97{ 97{
98 QPointp1, p2; 98 QPointp1, p2;
99 QRectr = frameRect(); 99 QRectr = frameRect();
100 const QColorGroup & g = colorGroup(); 100 const QColorGroup & g = colorGroup();
101 101
102 if ( frameStyle() & HLine ) { 102 if ( frameStyle() & HLine ) {
103 p1 = QPoint( r.x(), r.height()/2 ); 103 p1 = QPoint( r.x(), r.height()/2 );
104 p2 = QPoint( r.x()+r.width(), p1.y() ); 104 p2 = QPoint( r.x()+r.width(), p1.y() );
105 } 105 }
106 else { 106 else {
107 p1 = QPoint( r.x()+r.width()/2, 0 ); 107 p1 = QPoint( r.x()+r.width()/2, 0 );
108 p2 = QPoint( p1.x(), r.height() ); 108 p2 = QPoint( p1.x(), r.height() );
109 } 109 }
110 110
111#if QT_VERSION < 300 111#if QT_VERSION < 0x030000
112 style().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, 1, midLineWidth() ); 112 style().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, 1, midLineWidth() );
113#else 113#else
114 QStyleOption opt( lineWidth(), midLineWidth() ); 114 QStyleOption opt( lineWidth(), midLineWidth() );
115 style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g, QStyle::Style_Sunken, opt ); 115 style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g, QStyle::Style_Sunken, opt );
116#endif 116#endif
117} 117}
118 118
119 119
120QSize OSeparator::sizeHint() const 120QSize OSeparator::sizeHint() const
121{ 121{
122 if ( frameStyle() & VLine ) 122 if ( frameStyle() & VLine )
123 return QSize(2, 0); 123 return QSize(2, 0);
124 124
125 if ( frameStyle() & HLine ) 125 if ( frameStyle() & HLine )
126 return QSize(0, 2); 126 return QSize(0, 2);
127 127
128 return QSize(-1, -1); 128 return QSize(-1, -1);
129} 129}
diff --git a/libopie2/qt3/opieui/oeditlistbox.h b/libopie2/qt3/opieui/oeditlistbox.h
index 63fab11..c9c207d 100644
--- a/libopie2/qt3/opieui/oeditlistbox.h
+++ b/libopie2/qt3/opieui/oeditlistbox.h
@@ -1,222 +1,222 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org> 2 Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef OEDITLISTBOX_H 20#ifndef OEDITLISTBOX_H
21#define OEDITLISTBOX_H 21#define OEDITLISTBOX_H
22 22
23#include <qgroupbox.h> 23#include <qgroupbox.h>
24#include <qlistbox.h> 24#include <qlistbox.h>
25 25
26class OLineEdit; 26class OLineEdit;
27class OComboBox; 27class OComboBox;
28class QPushButton; 28class QPushButton;
29 29
30#if QT_VERSION < 300 30#if QT_VERSION < 0x030000
31 enum StringComparisonMode { 31 enum StringComparisonMode {
32 CaseSensitive = 0x00001, // 0 0001 32 CaseSensitive = 0x00001, // 0 0001
33 BeginsWith = 0x00002, // 0 0010 33 BeginsWith = 0x00002, // 0 0010
34 EndsWith = 0x00004, // 0 0100 34 EndsWith = 0x00004, // 0 0100
35 Contains = 0x00008, // 0 1000 35 Contains = 0x00008, // 0 1000
36 ExactMatch = 0x00010 // 1 0000 36 ExactMatch = 0x00010 // 1 0000
37 }; 37 };
38#endif 38#endif
39 39
40class OEditListBoxPrivate; 40class OEditListBoxPrivate;
41/** 41/**
42 * An editable listbox 42 * An editable listbox
43 * 43 *
44 * This class provides a editable listbox ;-), this means 44 * This class provides a editable listbox ;-), this means
45 * a listbox which is accompanied by a line edit to enter new 45 * a listbox which is accompanied by a line edit to enter new
46 * items into the listbox and pushbuttons to add and remove 46 * items into the listbox and pushbuttons to add and remove
47 * items from the listbox and two buttons to move items up and down. 47 * items from the listbox and two buttons to move items up and down.
48 */ 48 */
49class OEditListBox : public QGroupBox 49class OEditListBox : public QGroupBox
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 52
53public: 53public:
54 /// @since 3.1 54 /// @since 3.1
55 class CustomEditor 55 class CustomEditor
56 { 56 {
57 public: 57 public:
58 CustomEditor() 58 CustomEditor()
59 : m_representationWidget( 0L ), 59 : m_representationWidget( 0L ),
60 m_lineEdit( 0L ) {} 60 m_lineEdit( 0L ) {}
61 CustomEditor( QWidget *repWidget, OLineEdit *edit ) 61 CustomEditor( QWidget *repWidget, OLineEdit *edit )
62 : m_representationWidget( repWidget ), 62 : m_representationWidget( repWidget ),
63 m_lineEdit( edit ) {} 63 m_lineEdit( edit ) {}
64 CustomEditor( OComboBox *combo ); 64 CustomEditor( OComboBox *combo );
65 65
66 void setRepresentationWidget( QWidget *repWidget ) { 66 void setRepresentationWidget( QWidget *repWidget ) {
67 m_representationWidget = repWidget; 67 m_representationWidget = repWidget;
68 } 68 }
69 void setLineEdit( OLineEdit *edit ) { 69 void setLineEdit( OLineEdit *edit ) {
70 m_lineEdit = edit; 70 m_lineEdit = edit;
71 } 71 }
72 72
73 virtual QWidget *representationWidget() const { 73 virtual QWidget *representationWidget() const {
74 return m_representationWidget; 74 return m_representationWidget;
75 } 75 }
76 virtual OLineEdit *lineEdit() const { 76 virtual OLineEdit *lineEdit() const {
77 return m_lineEdit; 77 return m_lineEdit;
78 } 78 }
79 79
80 protected: 80 protected:
81 QWidget *m_representationWidget; 81 QWidget *m_representationWidget;
82 OLineEdit *m_lineEdit; 82 OLineEdit *m_lineEdit;
83 }; 83 };
84 84
85 public: 85 public:
86 86
87 /** 87 /**
88 * Enumeration of the buttons, the listbox offers. Specify them in the 88 * Enumeration of the buttons, the listbox offers. Specify them in the
89 * constructor in the buttons parameter. 89 * constructor in the buttons parameter.
90 */ 90 */
91 enum Button { Add = 1, Remove = 2, UpDown = 4, All = Add|Remove|UpDown }; 91 enum Button { Add = 1, Remove = 2, UpDown = 4, All = Add|Remove|UpDown };
92 92
93 /** 93 /**
94 * Create an editable listbox. 94 * Create an editable listbox.
95 * 95 *
96 * If @p checkAtEntering is true, after every character you type 96 * If @p checkAtEntering is true, after every character you type
97 * in the line edit OEditListBox will enable or disable 97 * in the line edit OEditListBox will enable or disable
98 * the Add-button, depending whether the current content of the 98 * the Add-button, depending whether the current content of the
99 * line edit is already in the listbox. Maybe this can become a 99 * line edit is already in the listbox. Maybe this can become a
100 * performance hit with large lists on slow machines. 100 * performance hit with large lists on slow machines.
101 * If @p checkAtEntering is false, 101 * If @p checkAtEntering is false,
102 * it will be checked if you press the Add-button. It is not 102 * it will be checked if you press the Add-button. It is not
103 * possible to enter items twice into the listbox. 103 * possible to enter items twice into the listbox.
104 */ 104 */
105 OEditListBox(QWidget *parent = 0, const char *name = 0, 105 OEditListBox(QWidget *parent = 0, const char *name = 0,
106 bool checkAtEntering=false, int buttons = All ); 106 bool checkAtEntering=false, int buttons = All );
107 /** 107 /**
108 * Create an editable listbox. 108 * Create an editable listbox.
109 * 109 *
110 * The same as the other constructor, additionally it takes 110 * The same as the other constructor, additionally it takes
111 * @title, which will be the title of the frame around the listbox. 111 * @title, which will be the title of the frame around the listbox.
112 */ 112 */
113 OEditListBox(const QString& title, QWidget *parent = 0, 113 OEditListBox(const QString& title, QWidget *parent = 0,
114 const char *name = 0, bool checkAtEntering=false, 114 const char *name = 0, bool checkAtEntering=false,
115 int buttons = All ); 115 int buttons = All );
116 116
117 /** 117 /**
118 * Another constructor, which allows to use a custom editing widget 118 * Another constructor, which allows to use a custom editing widget
119 * instead of the standard OLineEdit widget. E.g. you can use a 119 * instead of the standard OLineEdit widget. E.g. you can use a
120 * @ref OURLRequester or a @ref OComboBox as input widget. The custom 120 * @ref OURLRequester or a @ref OComboBox as input widget. The custom
121 * editor must consist of a lineedit and optionally another widget that 121 * editor must consist of a lineedit and optionally another widget that
122 * is used as representation. A OComboBox or a OURLRequester have a 122 * is used as representation. A OComboBox or a OURLRequester have a
123 * OLineEdit as child-widget for example, so the OComboBox is used as 123 * OLineEdit as child-widget for example, so the OComboBox is used as
124 * the representation widget. 124 * the representation widget.
125 * 125 *
126 * @see OURLRequester::customEditor() 126 * @see OURLRequester::customEditor()
127 * @since 3.1 127 * @since 3.1
128 */ 128 */
129 OEditListBox( const QString& title, 129 OEditListBox( const QString& title,
130 const CustomEditor &customEditor, 130 const CustomEditor &customEditor,
131 QWidget *parent = 0, const char *name = 0, 131 QWidget *parent = 0, const char *name = 0,
132 bool checkAtEntering = false, int buttons = All ); 132 bool checkAtEntering = false, int buttons = All );
133 133
134 virtual ~OEditListBox(); 134 virtual ~OEditListBox();
135 135
136 /** 136 /**
137 * Return a pointer to the embedded QListBox. 137 * Return a pointer to the embedded QListBox.
138 */ 138 */
139 QListBox* listBox() const { return m_listBox; } 139 QListBox* listBox() const { return m_listBox; }
140 /** 140 /**
141 * Return a pointer to the embedded QLineEdit. 141 * Return a pointer to the embedded QLineEdit.
142 */ 142 */
143 OLineEdit* lineEdit() const { return m_lineEdit; } 143 OLineEdit* lineEdit() const { return m_lineEdit; }
144 /** 144 /**
145 * Return a pointer to the Add button 145 * Return a pointer to the Add button
146 */ 146 */
147 QPushButton* addButton() const { return servNewButton; } 147 QPushButton* addButton() const { return servNewButton; }
148 /** 148 /**
149 * Return a pointer to the Remove button 149 * Return a pointer to the Remove button
150 */ 150 */
151 QPushButton* removeButton() const { return servRemoveButton; } 151 QPushButton* removeButton() const { return servRemoveButton; }
152 /** 152 /**
153 * Return a pointer to the Up button 153 * Return a pointer to the Up button
154 */ 154 */
155 QPushButton* upButton() const { return servUpButton; } 155 QPushButton* upButton() const { return servUpButton; }
156 /** 156 /**
157 * Return a pointer to the Down button 157 * Return a pointer to the Down button
158 */ 158 */
159 QPushButton* downButton() const { return servDownButton; } 159 QPushButton* downButton() const { return servDownButton; }
160 160
161 /** 161 /**
162 * See @ref QListBox::count() 162 * See @ref QListBox::count()
163 */ 163 */
164 int count() const { return int(m_listBox->count()); } 164 int count() const { return int(m_listBox->count()); }
165 /** 165 /**
166 * See @ref QListBox::insertStringList() 166 * See @ref QListBox::insertStringList()
167 */ 167 */
168 void insertStringList(const QStringList& list, int index=-1); 168 void insertStringList(const QStringList& list, int index=-1);
169 /** 169 /**
170 * See @ref QListBox::insertStringList() 170 * See @ref QListBox::insertStringList()
171 */ 171 */
172 void insertStrList(const QStrList* list, int index=-1); 172 void insertStrList(const QStrList* list, int index=-1);
173 /** 173 /**
174 * See @ref QListBox::insertStrList() 174 * See @ref QListBox::insertStrList()
175 */ 175 */
176 void insertStrList(const QStrList& list, int index=-1); 176 void insertStrList(const QStrList& list, int index=-1);
177 /** 177 /**
178 * See @ref QListBox::insertStrList() 178 * See @ref QListBox::insertStrList()
179 */ 179 */
180 void insertStrList(const char ** list, int numStrings=-1, int index=-1); 180 void insertStrList(const char ** list, int numStrings=-1, int index=-1);
181 /** 181 /**
182 * See @ref QListBox::insertItem() 182 * See @ref QListBox::insertItem()
183 */ 183 */
184 void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);} 184 void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);}
185 /** 185 /**
186 * Clears both the listbox and the line edit. 186 * Clears both the listbox and the line edit.
187 */ 187 */
188 void clear(); 188 void clear();
189 /** 189 /**
190 * See @ref QListBox::text() 190 * See @ref QListBox::text()
191 */ 191 */
192 QString text(int index) const { return m_listBox->text(index); } 192 QString text(int index) const { return m_listBox->text(index); }
193 /** 193 /**
194 * See @ref QListBox::currentItem() 194 * See @ref QListBox::currentItem()
195 */ 195 */
196 int currentItem() const; 196 int currentItem() const;
197 /** 197 /**
198 * See @ref QListBox::currentText() 198 * See @ref QListBox::currentText()
199 */ 199 */
200 QString currentText() const { return m_listBox->currentText(); } 200 QString currentText() const { return m_listBox->currentText(); }
201 201
202 /** 202 /**
203 * @returns a stringlist of all items in the listbox 203 * @returns a stringlist of all items in the listbox
204 */ 204 */
205 QStringList items() const; 205 QStringList items() const;
206 206
207 signals: 207 signals:
208 void changed(); 208 void changed();
209 209
210 /** 210 /**
211 * This signal is emitted when the user adds a new string to the list, 211 * This signal is emitted when the user adds a new string to the list,
212 * the parameter is the added string. 212 * the parameter is the added string.
213 * @since 3.2 213 * @since 3.2
214 */ 214 */
215 void added( const QString & text ); 215 void added( const QString & text );
216 216
217 /** 217 /**
218 * This signal is emitted when the user removes a string from the list, 218 * This signal is emitted when the user removes a string from the list,
219 * the parameter is the removed string. 219 * the parameter is the removed string.
220 * @since 3.2 220 * @since 3.2
221 */ 221 */
222 void removed( const QString & text ); 222 void removed( const QString & text );
diff --git a/libopie2/qt3/opieui/ojanuswidget.cpp b/libopie2/qt3/opieui/ojanuswidget.cpp
index 063e393..8bdbc03 100644
--- a/libopie2/qt3/opieui/ojanuswidget.cpp
+++ b/libopie2/qt3/opieui/ojanuswidget.cpp
@@ -583,385 +583,385 @@ bool OJanusWidget::showPage( int index )
583 else 583 else
584 { 584 {
585 return showPage(mPageList->at(index)); 585 return showPage(mPageList->at(index));
586 } 586 }
587} 587}
588 588
589 589
590bool OJanusWidget::showPage( QWidget *w ) 590bool OJanusWidget::showPage( QWidget *w )
591{ 591{
592 if( w == 0 || mValid == false ) 592 if( w == 0 || mValid == false )
593 { 593 {
594 return( false ); 594 return( false );
595 } 595 }
596 596
597 if( mFace == TreeList || mFace == IconList ) 597 if( mFace == TreeList || mFace == IconList )
598 { 598 {
599 mPageStack->raiseWidget( w ); 599 mPageStack->raiseWidget( w );
600 mActivePageWidget = w; 600 mActivePageWidget = w;
601 601
602 int index = mPageList->findRef( w ); 602 int index = mPageList->findRef( w );
603 mTitleLabel->setText( *mTitleList->at(index) ); 603 mTitleLabel->setText( *mTitleList->at(index) );
604 if( mFace == TreeList ) 604 if( mFace == TreeList )
605 { 605 {
606 QMap<QListViewItem *, QWidget *>::Iterator it; 606 QMap<QListViewItem *, QWidget *>::Iterator it;
607 for (it = mTreeListToPageStack.begin(); it != mTreeListToPageStack.end(); ++it){ 607 for (it = mTreeListToPageStack.begin(); it != mTreeListToPageStack.end(); ++it){
608 QListViewItem *key = it.key(); 608 QListViewItem *key = it.key();
609 QWidget *val = it.data(); 609 QWidget *val = it.data();
610 if (val == w) { 610 if (val == w) {
611 mTreeList->setSelected(key, true ); 611 mTreeList->setSelected(key, true );
612 break; 612 break;
613 } 613 }
614 } 614 }
615 } 615 }
616 else 616 else
617 { 617 {
618 QMap<QListBoxItem *, QWidget *>::Iterator it; 618 QMap<QListBoxItem *, QWidget *>::Iterator it;
619 for (it = mIconListToPageStack.begin(); it != mIconListToPageStack.end(); ++it){ 619 for (it = mIconListToPageStack.begin(); it != mIconListToPageStack.end(); ++it){
620 QListBoxItem *key = it.key(); 620 QListBoxItem *key = it.key();
621 QWidget *val = it.data(); 621 QWidget *val = it.data();
622 if (val == w) { 622 if (val == w) {
623 mIconList->setSelected( key, true ); 623 mIconList->setSelected( key, true );
624 break; 624 break;
625 } 625 }
626 } 626 }
627 627
628 // 628 //
629 // 2000-02-13 Espen Sand 629 // 2000-02-13 Espen Sand
630 // Don't ask me why (because I don't know). If I select a page 630 // Don't ask me why (because I don't know). If I select a page
631 // with the mouse the page is not updated until it receives an 631 // with the mouse the page is not updated until it receives an
632 // event. It seems this event get lost if the mouse is not moved 632 // event. It seems this event get lost if the mouse is not moved
633 // when released. The timer ensures the update 633 // when released. The timer ensures the update
634 // 634 //
635 QTimer::singleShot( 0, mActivePageWidget, SLOT(update()) ); 635 QTimer::singleShot( 0, mActivePageWidget, SLOT(update()) );
636 } 636 }
637 } 637 }
638 else if( mFace == Tabbed ) 638 else if( mFace == Tabbed )
639 { 639 {
640 mTabControl->showPage(w); 640 mTabControl->showPage(w);
641 mActivePageWidget = w; 641 mActivePageWidget = w;
642 } 642 }
643 else 643 else
644 { 644 {
645 return( false ); 645 return( false );
646 } 646 }
647 647
648 return( true ); 648 return( true );
649} 649}
650 650
651 651
652int OJanusWidget::activePageIndex() const 652int OJanusWidget::activePageIndex() const
653{ 653{
654 if( mFace == TreeList) { 654 if( mFace == TreeList) {
655 QListViewItem *node = mTreeList->selectedItem(); 655 QListViewItem *node = mTreeList->selectedItem();
656 if( node == 0 ) { return -1; } 656 if( node == 0 ) { return -1; }
657 QWidget *stackItem = mTreeListToPageStack[node]; 657 QWidget *stackItem = mTreeListToPageStack[node];
658 return mPageList->findRef(stackItem); 658 return mPageList->findRef(stackItem);
659 } 659 }
660 else if (mFace == IconList) { 660 else if (mFace == IconList) {
661 QListBoxItem *node = mIconList->item( mIconList->currentItem() ); 661 QListBoxItem *node = mIconList->item( mIconList->currentItem() );
662 if( node == 0 ) { return( false ); } 662 if( node == 0 ) { return( false ); }
663 QWidget *stackItem = mIconListToPageStack[node]; 663 QWidget *stackItem = mIconListToPageStack[node];
664 return mPageList->findRef(stackItem); 664 return mPageList->findRef(stackItem);
665 } 665 }
666 else if( mFace == Tabbed ) { 666 else if( mFace == Tabbed ) {
667 QWidget *widget = mTabControl->currentPage(); 667 QWidget *widget = mTabControl->currentPage();
668 return( widget == 0 ? -1 : mPageList->findRef( widget ) ); 668 return( widget == 0 ? -1 : mPageList->findRef( widget ) );
669 } 669 }
670 else { 670 else {
671 return( -1 ); 671 return( -1 );
672 } 672 }
673} 673}
674 674
675 675
676int OJanusWidget::pageIndex( QWidget *widget ) const 676int OJanusWidget::pageIndex( QWidget *widget ) const
677{ 677{
678 if( widget == 0 ) 678 if( widget == 0 )
679 { 679 {
680 return( -1 ); 680 return( -1 );
681 } 681 }
682 else if( mFace == TreeList || mFace == IconList ) 682 else if( mFace == TreeList || mFace == IconList )
683 { 683 {
684 return( mPageList->findRef( widget ) ); 684 return( mPageList->findRef( widget ) );
685 } 685 }
686 else if( mFace == Tabbed ) 686 else if( mFace == Tabbed )
687 { 687 {
688 // 688 //
689 // The user gets the real page widget with addVBoxPage(), addHBoxPage() 689 // The user gets the real page widget with addVBoxPage(), addHBoxPage()
690 // and addGridPage() but not with addPage() which returns a child of 690 // and addGridPage() but not with addPage() which returns a child of
691 // the toplevel page. addPage() returns a QFrame so I check for that. 691 // the toplevel page. addPage() returns a QFrame so I check for that.
692 // 692 //
693 if( widget->isA("QFrame") ) 693 if( widget->isA("QFrame") )
694 { 694 {
695 return( mPageList->findRef( widget->parentWidget() ) ); 695 return( mPageList->findRef( widget->parentWidget() ) );
696 } 696 }
697 else 697 else
698 { 698 {
699 return( mPageList->findRef( widget ) ); 699 return( mPageList->findRef( widget ) );
700 } 700 }
701 } 701 }
702 else 702 else
703 { 703 {
704 return( -1 ); 704 return( -1 );
705 } 705 }
706} 706}
707 707
708void OJanusWidget::slotFontChanged() 708void OJanusWidget::slotFontChanged()
709{ 709{
710#ifdef FIXME 710#ifdef FIXME
711 711
712 if ( mTitleLabel != 0 ) 712 if ( mTitleLabel != 0 )
713 { 713 {
714 mTitleLabel->setFont( KGlobalSettings::generalFont() ); 714 mTitleLabel->setFont( KGlobalSettings::generalFont() );
715 QFont titleFont( mTitleLabel->font() ); 715 QFont titleFont( mTitleLabel->font() );
716 titleFont.setBold( true ); 716 titleFont.setBold( true );
717 mTitleLabel->setFont( titleFont ); 717 mTitleLabel->setFont( titleFont );
718 } 718 }
719#endif 719#endif
720 720
721 if( mFace == IconList ) 721 if( mFace == IconList )
722 { 722 {
723 QFont listFont( mIconList->font() ); 723 QFont listFont( mIconList->font() );
724 listFont.setBold( true ); 724 listFont.setBold( true );
725 mIconList->setFont( listFont ); 725 mIconList->setFont( listFont );
726 mIconList->invalidateHeight(); 726 mIconList->invalidateHeight();
727 mIconList->invalidateWidth(); 727 mIconList->invalidateWidth();
728 } 728 }
729} 729}
730 730
731// makes the treelist behave like the list of kcontrol 731// makes the treelist behave like the list of kcontrol
732void OJanusWidget::slotItemClicked(QListViewItem *it) 732void OJanusWidget::slotItemClicked(QListViewItem *it)
733{ 733{
734 if(it && (it->childCount()>0)) 734 if(it && (it->childCount()>0))
735 it->setOpen(!it->isOpen()); 735 it->setOpen(!it->isOpen());
736} 736}
737 737
738void OJanusWidget::setFocus() 738void OJanusWidget::setFocus()
739{ 739{
740 if( mValid == false ) { return; } 740 if( mValid == false ) { return; }
741 if( mFace == TreeList ) 741 if( mFace == TreeList )
742 { 742 {
743 mTreeList->setFocus(); 743 mTreeList->setFocus();
744 } 744 }
745 if( mFace == IconList ) 745 if( mFace == IconList )
746 { 746 {
747 mIconList->setFocus(); 747 mIconList->setFocus();
748 } 748 }
749 else if( mFace == Tabbed ) 749 else if( mFace == Tabbed )
750 { 750 {
751 mTabControl->setFocus(); 751 mTabControl->setFocus();
752 } 752 }
753 else if( mFace == Swallow ) 753 else if( mFace == Swallow )
754 { 754 {
755 mSwallowPage->setFocus(); 755 mSwallowPage->setFocus();
756 } 756 }
757 else if( mFace == Plain ) 757 else if( mFace == Plain )
758 { 758 {
759 mPlainPage->setFocus(); 759 mPlainPage->setFocus();
760 } 760 }
761} 761}
762 762
763 763
764QSize OJanusWidget::minimumSizeHint() const 764QSize OJanusWidget::minimumSizeHint() const
765{ 765{
766 if( mFace == TreeList || mFace == IconList ) 766 if( mFace == TreeList || mFace == IconList )
767 { 767 {
768 QSize s1( ODialog::spacingHint(), ODialog::spacingHint()*2 ); 768 QSize s1( ODialog::spacingHint(), ODialog::spacingHint()*2 );
769 QSize s2(0,0); 769 QSize s2(0,0);
770 QSize s3(0,0); 770 QSize s3(0,0);
771 QSize s4( mPageStack->sizeHint() ); 771 QSize s4( mPageStack->sizeHint() );
772 772
773 if( mFace == TreeList ) 773 if( mFace == TreeList )
774 { 774 {
775#if QT_VERSION < 300 775#if QT_VERSION < 0x030000
776 s1.rwidth() += style().splitterWidth(); 776 s1.rwidth() += style().splitterWidth();
777#else 777#else
778 s1.rwidth() += style().pixelMetric( QStyle::PM_SplitterWidth ); 778 s1.rwidth() += style().pixelMetric( QStyle::PM_SplitterWidth );
779#endif 779#endif
780 s2 = mTreeList->minimumSize(); 780 s2 = mTreeList->minimumSize();
781 } 781 }
782 else 782 else
783 { 783 {
784 mIconList->updateMinimumHeight(); 784 mIconList->updateMinimumHeight();
785 mIconList->updateWidth(); 785 mIconList->updateWidth();
786 s2 = mIconList->minimumSize(); 786 s2 = mIconList->minimumSize();
787 } 787 }
788 788
789 if( mTitleLabel->isVisible() == true ) 789 if( mTitleLabel->isVisible() == true )
790 { 790 {
791 s3 += mTitleLabel->sizeHint(); 791 s3 += mTitleLabel->sizeHint();
792 s3.rheight() += mTitleSep->minimumSize().height(); 792 s3.rheight() += mTitleSep->minimumSize().height();
793 } 793 }
794 794
795 // 795 //
796 // Select the tallest item. It has only effect in IconList mode 796 // Select the tallest item. It has only effect in IconList mode
797 // 797 //
798 int h1 = s1.rheight() + s3.rheight() + s4.height(); 798 int h1 = s1.rheight() + s3.rheight() + s4.height();
799 int h2 = QMAX( h1, s2.rheight() ); 799 int h2 = QMAX( h1, s2.rheight() );
800 800
801 return( QSize( s1.width()+s2.width()+QMAX(s3.width(),s4.width()), h2 ) ); 801 return( QSize( s1.width()+s2.width()+QMAX(s3.width(),s4.width()), h2 ) );
802 } 802 }
803 else if( mFace == Tabbed ) 803 else if( mFace == Tabbed )
804 { 804 {
805 return( mTabControl->sizeHint() ); 805 return( mTabControl->sizeHint() );
806 } 806 }
807 else if( mFace == Swallow ) 807 else if( mFace == Swallow )
808 { 808 {
809 return( mSwallowPage->minimumSize() ); 809 return( mSwallowPage->minimumSize() );
810 } 810 }
811 else if( mFace == Plain ) 811 else if( mFace == Plain )
812 { 812 {
813 return( mPlainPage->sizeHint() ); 813 return( mPlainPage->sizeHint() );
814 } 814 }
815 else 815 else
816 { 816 {
817 return( QSize( 100, 100 ) ); // Should never happen though. 817 return( QSize( 100, 100 ) ); // Should never happen though.
818 } 818 }
819 819
820} 820}
821 821
822 822
823QSize OJanusWidget::sizeHint() const 823QSize OJanusWidget::sizeHint() const
824{ 824{
825 return( minimumSizeHint() ); 825 return( minimumSizeHint() );
826} 826}
827 827
828 828
829void OJanusWidget::setTreeListAutoResize( bool state ) 829void OJanusWidget::setTreeListAutoResize( bool state )
830{ 830{
831 if( mFace == TreeList ) 831 if( mFace == TreeList )
832 { 832 {
833 mTreeListResizeMode = state == false ? 833 mTreeListResizeMode = state == false ?
834 QSplitter::KeepSize : QSplitter::Stretch; 834 QSplitter::KeepSize : QSplitter::Stretch;
835 QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget()); 835 QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget());
836 splitter->setResizeMode( mTreeList, mTreeListResizeMode ); 836 splitter->setResizeMode( mTreeList, mTreeListResizeMode );
837 } 837 }
838} 838}
839 839
840 840
841void OJanusWidget::setIconListAllVisible( bool state ) 841void OJanusWidget::setIconListAllVisible( bool state )
842{ 842{
843 if( mFace == IconList ) 843 if( mFace == IconList )
844 { 844 {
845 mIconList->setShowAll( state ); 845 mIconList->setShowAll( state );
846 } 846 }
847} 847}
848 848
849void OJanusWidget::setShowIconsInTreeList( bool state ) 849void OJanusWidget::setShowIconsInTreeList( bool state )
850{ 850{
851 mShowIconsInTreeList = state; 851 mShowIconsInTreeList = state;
852} 852}
853 853
854void OJanusWidget::setRootIsDecorated( bool state ) 854void OJanusWidget::setRootIsDecorated( bool state )
855{ 855{
856 if( mFace == TreeList ) { 856 if( mFace == TreeList ) {
857 mTreeList->setRootIsDecorated(state); 857 mTreeList->setRootIsDecorated(state);
858 } 858 }
859} 859}
860 860
861void OJanusWidget::unfoldTreeList( bool persist ) 861void OJanusWidget::unfoldTreeList( bool persist )
862{ 862{
863 if( mFace == TreeList ) 863 if( mFace == TreeList )
864 { 864 {
865 if( persist ) 865 if( persist )
866 connect( mTreeList, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( slotReopen(QListViewItem*) ) ); 866 connect( mTreeList, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( slotReopen(QListViewItem*) ) );
867 else 867 else
868 disconnect( mTreeList, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( slotReopen(QListViewItem*) ) ); 868 disconnect( mTreeList, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( slotReopen(QListViewItem*) ) );
869 869
870 for( QListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() ) 870 for( QListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() )
871 item->setOpen( true ); 871 item->setOpen( true );
872 } 872 }
873} 873}
874 874
875void OJanusWidget::showEvent( QShowEvent * ) 875void OJanusWidget::showEvent( QShowEvent * )
876{ 876{
877 if( mFace == TreeList ) 877 if( mFace == TreeList )
878 { 878 {
879 QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget()); 879 QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget());
880 splitter->setResizeMode( mTreeList, mTreeListResizeMode ); 880 splitter->setResizeMode( mTreeList, mTreeListResizeMode );
881 } 881 }
882} 882}
883 883
884 884
885// 885//
886// 2000-13-02 Espen Sand 886// 2000-13-02 Espen Sand
887// It should be obvious that this eventfilter must only be 887// It should be obvious that this eventfilter must only be
888// be installed on the vertical scrollbar of the mIconList. 888// be installed on the vertical scrollbar of the mIconList.
889// 889//
890bool OJanusWidget::eventFilter( QObject *o, QEvent *e ) 890bool OJanusWidget::eventFilter( QObject *o, QEvent *e )
891{ 891{
892 if( e->type() == QEvent::Show ) 892 if( e->type() == QEvent::Show )
893 { 893 {
894 IconListItem *item = (IconListItem*)mIconList->item(0); 894 IconListItem *item = (IconListItem*)mIconList->item(0);
895 if( item != 0 ) 895 if( item != 0 )
896 { 896 {
897 int lw = item->width( mIconList ); 897 int lw = item->width( mIconList );
898 int sw = mIconList->verticalScrollBar()->sizeHint().width(); 898 int sw = mIconList->verticalScrollBar()->sizeHint().width();
899 mIconList->setFixedWidth( lw+sw+mIconList->frameWidth()*2 ); 899 mIconList->setFixedWidth( lw+sw+mIconList->frameWidth()*2 );
900 } 900 }
901 } 901 }
902 else if( e->type() == QEvent::Hide ) 902 else if( e->type() == QEvent::Hide )
903 { 903 {
904 IconListItem *item = (IconListItem*)mIconList->item(0); 904 IconListItem *item = (IconListItem*)mIconList->item(0);
905 if( item != 0 ) 905 if( item != 0 )
906 { 906 {
907 int lw = item->width( mIconList ); 907 int lw = item->width( mIconList );
908 mIconList->setFixedWidth( lw+mIconList->frameWidth()*2 ); 908 mIconList->setFixedWidth( lw+mIconList->frameWidth()*2 );
909 } 909 }
910 } 910 }
911 return QWidget::eventFilter( o, e ); 911 return QWidget::eventFilter( o, e );
912} 912}
913 913
914 914
915 915
916// 916//
917// Code for the icon list box 917// Code for the icon list box
918// 918//
919 919
920 920
921OJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name, 921OJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name,
922 WFlags f ) 922 WFlags f )
923 :QListBox( parent, name, f ), mShowAll(false), mHeightValid(false), 923 :QListBox( parent, name, f ), mShowAll(false), mHeightValid(false),
924 mWidthValid(false) 924 mWidthValid(false)
925{ 925{
926} 926}
927 927
928 928
929void OJanusWidget::IconListBox::updateMinimumHeight() 929void OJanusWidget::IconListBox::updateMinimumHeight()
930{ 930{
931 if( mShowAll == true && mHeightValid == false ) 931 if( mShowAll == true && mHeightValid == false )
932 { 932 {
933 int h = frameWidth()*2; 933 int h = frameWidth()*2;
934 for( QListBoxItem *i = item(0); i != 0; i = i->next() ) 934 for( QListBoxItem *i = item(0); i != 0; i = i->next() )
935 { 935 {
936 h += i->height( this ); 936 h += i->height( this );
937 } 937 }
938 setMinimumHeight( h ); 938 setMinimumHeight( h );
939 mHeightValid = true; 939 mHeightValid = true;
940 } 940 }
941} 941}
942 942
943 943
944void OJanusWidget::IconListBox::updateWidth() 944void OJanusWidget::IconListBox::updateWidth()
945{ 945{
946 if( mWidthValid == false ) 946 if( mWidthValid == false )
947 { 947 {
948 int maxWidth = 10; 948 int maxWidth = 10;
949 for( QListBoxItem *i = item(0); i != 0; i = i->next() ) 949 for( QListBoxItem *i = item(0); i != 0; i = i->next() )
950 { 950 {
951 int w = ((IconListItem *)i)->width(this); 951 int w = ((IconListItem *)i)->width(this);
952 maxWidth = QMAX( w, maxWidth ); 952 maxWidth = QMAX( w, maxWidth );
953 } 953 }
954 954
955 for( QListBoxItem *i = item(0); i != 0; i = i->next() ) 955 for( QListBoxItem *i = item(0); i != 0; i = i->next() )
956 { 956 {
957 ((IconListItem *)i)->expandMinimumWidth( maxWidth ); 957 ((IconListItem *)i)->expandMinimumWidth( maxWidth );
958 } 958 }
959 959
960 if( verticalScrollBar()->isVisible() ) 960 if( verticalScrollBar()->isVisible() )
961 { 961 {
962 maxWidth += verticalScrollBar()->sizeHint().width(); 962 maxWidth += verticalScrollBar()->sizeHint().width();
963 } 963 }
964 964
965 setFixedWidth( maxWidth + frameWidth()*2 ); 965 setFixedWidth( maxWidth + frameWidth()*2 );
966 mWidthValid = true; 966 mWidthValid = true;
967 } 967 }