author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdeui/kjanuswidget.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kdeui/kjanuswidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/kjanuswidget.cpp | 140 |
1 files changed, 74 insertions, 66 deletions
diff --git a/microkde/kdeui/kjanuswidget.cpp b/microkde/kdeui/kjanuswidget.cpp index 462c44f..3d9173d 100644 --- a/microkde/kdeui/kjanuswidget.cpp +++ b/microkde/kdeui/kjanuswidget.cpp | |||
@@ -9,41 +9,49 @@ | |||
9 | * | 9 | * |
10 | * This library is distributed in the hope that it will be useful, | 10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. | 13 | * Library General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU Library General Public License | 15 | * You should have received a copy of the GNU Library General Public License |
16 | * along with this library; see the file COPYING.LIB. If not, write to | 16 | * along with this library; see the file COPYING.LIB. If not, write to |
17 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
22 | #include <qbitmap.h> | 22 | #include <qbitmap.h> |
23 | #include <qlayout.h> | 23 | #include <qlayout.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qwidgetstack.h> | 25 | #include <q3widgetstack.h> |
26 | #include <qtabwidget.h> | 26 | #include <qtabwidget.h> |
27 | #include <qlistview.h> | 27 | #include <q3listview.h> |
28 | #include <qhbox.h> | 28 | #include <q3hbox.h> |
29 | #include <qvbox.h> | 29 | #include <q3vbox.h> |
30 | #include <qgrid.h> | 30 | #include <q3grid.h> |
31 | #include <qpainter.h> | 31 | #include <qpainter.h> |
32 | #include <qobjectlist.h> | 32 | #include <qobject.h> |
33 | #include <qstringlist.h> | 33 | #include <qstringlist.h> |
34 | //Added by qt3to4: | ||
35 | #include <Q3HBoxLayout> | ||
36 | #include <Q3GridLayout> | ||
37 | #include <Q3PtrList> | ||
38 | #include <Q3Frame> | ||
39 | #include <QEvent> | ||
40 | #include <Q3VBoxLayout> | ||
41 | #include <QShowEvent> | ||
34 | /*US | 42 | /*US |
35 | #include <qbitmap.h> | 43 | #include <qbitmap.h> |
36 | #include <qgrid.h> | 44 | #include <qgrid.h> |
37 | #include <qhbox.h> | 45 | #include <qhbox.h> |
38 | #include <qheader.h> | 46 | #include <qheader.h> |
39 | #include <qlabel.h> | 47 | #include <qlabel.h> |
40 | #include <qlayout.h> | 48 | #include <qlayout.h> |
41 | #include <qobjectlist.h> | 49 | #include <qobjectlist.h> |
42 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
43 | #include <qsplitter.h> | 51 | #include <qsplitter.h> |
44 | #include <qtabwidget.h> | 52 | #include <qtabwidget.h> |
45 | #include <qvbox.h> | 53 | #include <qvbox.h> |
46 | #include <qwidgetstack.h> | 54 | #include <qwidgetstack.h> |
47 | #include <qpainter.h> | 55 | #include <qpainter.h> |
48 | #include <qstyle.h> | 56 | #include <qstyle.h> |
49 | 57 | ||
@@ -52,167 +60,167 @@ | |||
52 | #include <kglobal.h> | 60 | #include <kglobal.h> |
53 | #include <kglobalsettings.h> | 61 | #include <kglobalsettings.h> |
54 | #include <kseparator.h> | 62 | #include <kseparator.h> |
55 | #include <kdebug.h> | 63 | #include <kdebug.h> |
56 | #include "kjanuswidget.h" | 64 | #include "kjanuswidget.h" |
57 | #include <klistview.h> | 65 | #include <klistview.h> |
58 | 66 | ||
59 | */ | 67 | */ |
60 | 68 | ||
61 | #include <kseparator.h> | 69 | #include <kseparator.h> |
62 | #include <kdialog.h> // Access to some static members | 70 | #include <kdialog.h> // Access to some static members |
63 | #include <kdebug.h> | 71 | #include <kdebug.h> |
64 | #include <klistview.h> | 72 | #include <klistview.h> |
65 | 73 | ||
66 | #include "kjanuswidget.h" | 74 | #include "kjanuswidget.h" |
67 | 75 | ||
68 | class KJanusWidget::IconListItem : public QListBoxItem | 76 | class KJanusWidget::IconListItem : public Q3ListBoxItem |
69 | { | 77 | { |
70 | public: | 78 | public: |
71 | IconListItem( QListBox *listbox, const QPixmap &pixmap, | 79 | IconListItem( Q3ListBox *listbox, const QPixmap &pixmap, |
72 | const QString &text ); | 80 | const QString &text ); |
73 | virtual int height( const QListBox *lb ) const; | 81 | virtual int height( const Q3ListBox *lb ) const; |
74 | virtual int width( const QListBox *lb ) const; | 82 | virtual int width( const Q3ListBox *lb ) const; |
75 | int expandMinimumWidth( int width ); | 83 | int expandMinimumWidth( int width ); |
76 | 84 | ||
77 | protected: | 85 | protected: |
78 | const QPixmap &defaultPixmap(); | 86 | const QPixmap &defaultPixmap(); |
79 | void paint( QPainter *painter ); | 87 | void paint( QPainter *painter ); |
80 | 88 | ||
81 | private: | 89 | private: |
82 | QPixmap mPixmap; | 90 | QPixmap mPixmap; |
83 | int mMinimumWidth; | 91 | int mMinimumWidth; |
84 | }; | 92 | }; |
85 | 93 | ||
86 | class KJanusWidget::KJanusWidgetPrivate | 94 | class KJanusWidget::KJanusWidgetPrivate |
87 | { | 95 | { |
88 | public: | 96 | public: |
89 | KJanusWidgetPrivate() : mNextPageIndex(0) { } | 97 | KJanusWidgetPrivate() : mNextPageIndex(0) { } |
90 | 98 | ||
91 | int mNextPageIndex; // The next page index. | 99 | int mNextPageIndex; // The next page index. |
92 | 100 | ||
93 | // Dictionary for multipage modes. | 101 | // Dictionary for multipage modes. |
94 | QMap<int,QWidget*> mIntToPage; | 102 | QMap<int,QWidget*> mIntToPage; |
95 | // Reverse dictionary. Used because showPage() may be performance critical. | 103 | // Reverse dictionary. Used because showPage() may be performance critical. |
96 | QMap<QWidget*,int> mPageToInt; | 104 | QMap<QWidget*,int> mPageToInt; |
97 | // Dictionary of title string associated with page. | 105 | // Dictionary of title string associated with page. |
98 | QMap<int, QString> mIntToTitle; | 106 | QMap<int, QString> mIntToTitle; |
99 | }; | 107 | }; |
100 | 108 | ||
101 | template class QPtrList<QListViewItem>; | 109 | template class Q3PtrList<Q3ListViewItem>; |
102 | 110 | ||
103 | 111 | ||
104 | KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) | 112 | KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) |
105 | : QWidget( parent, name ), | 113 | : QWidget( parent, name ), |
106 | mValid(false), mPageList(0), | 114 | mValid(false), mPageList(0), |
107 | mTitleList(0), mFace(face), mTitleLabel(0), mActivePageWidget(0), | 115 | mTitleList(0), mFace(face), mTitleLabel(0), mActivePageWidget(0), |
108 | mShowIconsInTreeList(false), d(0) | 116 | mShowIconsInTreeList(false), d(0) |
109 | { | 117 | { |
110 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 118 | Q3VBoxLayout *topLayout = new Q3VBoxLayout( this ); |
111 | if( mFace == TreeList || mFace == IconList ) | 119 | if( mFace == TreeList || mFace == IconList ) |
112 | { | 120 | { |
113 | d = new KJanusWidgetPrivate; | 121 | d = new KJanusWidgetPrivate; |
114 | 122 | ||
115 | QFrame *page = 0; | 123 | Q3Frame *page = 0; |
116 | if( mFace == TreeList ) | 124 | if( mFace == TreeList ) |
117 | { | 125 | { |
118 | //US | 126 | //US |
119 | qDebug("KJanusWidget::KJanusWidget TreeList not implemented yet"); | 127 | qDebug("KJanusWidget::KJanusWidget TreeList not implemented yet"); |
120 | /*US | 128 | /*US |
121 | QSplitter *splitter = new QSplitter( this ); | 129 | QSplitter *splitter = new QSplitter( this ); |
122 | topLayout->addWidget( splitter, 10 ); | 130 | topLayout->addWidget( splitter, 10 ); |
123 | mTreeListResizeMode = QSplitter::KeepSize; | 131 | mTreeListResizeMode = QSplitter::KeepSize; |
124 | 132 | ||
125 | mTreeList = new KListView( splitter ); | 133 | mTreeList = new KListView( splitter ); |
126 | mTreeList->addColumn( QString::null ); | 134 | mTreeList->addColumn( QString::null ); |
127 | mTreeList->header()->hide(); | 135 | mTreeList->header()->hide(); |
128 | mTreeList->setRootIsDecorated(true); | 136 | mTreeList->setRootIsDecorated(true); |
129 | mTreeList->setSorting( -1 ); | 137 | mTreeList->setSorting( -1 ); |
130 | connect( mTreeList, SIGNAL(selectionChanged()), SLOT(slotShowPage()) ); | 138 | connect( mTreeList, SIGNAL(selectionChanged()), SLOT(slotShowPage()) ); |
131 | connect( mTreeList, SIGNAL(clicked(QListViewItem *)), SLOT(slotItemClicked(QListViewItem *))); | 139 | connect( mTreeList, SIGNAL(clicked(QListViewItem *)), SLOT(slotItemClicked(QListViewItem *))); |
132 | 140 | ||
133 | // | 141 | // |
134 | // Page area. Title at top with a separator below and a pagestack using | 142 | // Page area. Title at top with a separator below and a pagestack using |
135 | // all available space at bottom. | 143 | // all available space at bottom. |
136 | // | 144 | // |
137 | QFrame *p = new QFrame( splitter ); | 145 | QFrame *p = new QFrame( splitter ); |
138 | 146 | ||
139 | QHBoxLayout *hbox = new QHBoxLayout( p, 0, 0 ); | 147 | QHBoxLayout *hbox = new QHBoxLayout( p, 0, 0 ); |
140 | hbox->addSpacing( KDialog::marginHint() ); | 148 | hbox->addSpacing( KDialog::marginHint() ); |
141 | 149 | ||
142 | page = new QFrame( p ); | 150 | page = new QFrame( p ); |
143 | hbox->addWidget( page, 10 ); | 151 | hbox->addWidget( page, 10 ); |
144 | */ | 152 | */ |
145 | } | 153 | } |
146 | else | 154 | else |
147 | { | 155 | { |
148 | QHBoxLayout *hbox = new QHBoxLayout( topLayout ); | 156 | Q3HBoxLayout *hbox = new Q3HBoxLayout( topLayout ); |
149 | mIconList = new IconListBox( this ); | 157 | mIconList = new IconListBox( this ); |
150 | 158 | ||
151 | QFont listFont( mIconList->font() ); | 159 | QFont listFont( mIconList->font() ); |
152 | listFont.setBold( true ); | 160 | listFont.setBold( true ); |
153 | mIconList->setFont( listFont ); | 161 | mIconList->setFont( listFont ); |
154 | 162 | ||
155 | mIconList->verticalScrollBar()->installEventFilter( this ); | 163 | mIconList->verticalScrollBar()->installEventFilter( this ); |
156 | hbox->addWidget( mIconList ); | 164 | hbox->addWidget( mIconList ); |
157 | connect( mIconList, SIGNAL(selectionChanged()), SLOT(slotShowPage())); | 165 | connect( mIconList, SIGNAL(selectionChanged()), SLOT(slotShowPage())); |
158 | hbox->addSpacing( KDialog::marginHint() ); | 166 | hbox->addSpacing( KDialog::marginHint() ); |
159 | page = new QFrame( this ); | 167 | page = new Q3Frame( this ); |
160 | hbox->addWidget( page, 10 ); | 168 | hbox->addWidget( page, 10 ); |
161 | } | 169 | } |
162 | 170 | ||
163 | // | 171 | // |
164 | // Rest of page area. Title at top with a separator below and a | 172 | // Rest of page area. Title at top with a separator below and a |
165 | // pagestack using all available space at bottom. | 173 | // pagestack using all available space at bottom. |
166 | // | 174 | // |
167 | 175 | ||
168 | QVBoxLayout *vbox = new QVBoxLayout( page, 0, KDialog::spacingHint() ); | 176 | Q3VBoxLayout *vbox = new Q3VBoxLayout( page, 0, KDialog::spacingHint() ); |
169 | 177 | ||
170 | mTitleLabel = new QLabel( QString::fromLatin1("Empty page"), page, "KJanusWidgetTitleLabel" ); | 178 | mTitleLabel = new QLabel( QString::fromLatin1("Empty page"), page, "KJanusWidgetTitleLabel" ); |
171 | vbox->addWidget( mTitleLabel ); | 179 | vbox->addWidget( mTitleLabel ); |
172 | 180 | ||
173 | QFont titleFont( mTitleLabel->font() ); | 181 | QFont titleFont( mTitleLabel->font() ); |
174 | titleFont.setBold( true ); | 182 | titleFont.setBold( true ); |
175 | mTitleLabel->setFont( titleFont ); | 183 | mTitleLabel->setFont( titleFont ); |
176 | 184 | ||
177 | mTitleSep = new KSeparator( page ); | 185 | mTitleSep = new KSeparator( page ); |
178 | mTitleSep->setFrameStyle( QFrame::HLine|QFrame::Plain ); | 186 | mTitleSep->setFrameStyle( Q3Frame::HLine|Q3Frame::Plain ); |
179 | vbox->addWidget( mTitleSep ); | 187 | vbox->addWidget( mTitleSep ); |
180 | 188 | ||
181 | mPageStack = new QWidgetStack( page ); | 189 | mPageStack = new Q3WidgetStack( page ); |
182 | connect(mPageStack, SIGNAL(aboutToShow(QWidget *)), | 190 | connect(mPageStack, SIGNAL(aboutToShow(QWidget *)), |
183 | SIGNAL(aboutToShowPage(QWidget *))); | 191 | SIGNAL(aboutToShowPage(QWidget *))); |
184 | vbox->addWidget( mPageStack, 10 ); | 192 | vbox->addWidget( mPageStack, 10 ); |
185 | } | 193 | } |
186 | else if( mFace == Tabbed ) | 194 | else if( mFace == Tabbed ) |
187 | { | 195 | { |
188 | d = new KJanusWidgetPrivate; | 196 | d = new KJanusWidgetPrivate; |
189 | 197 | ||
190 | mTabControl = new QTabWidget( this ); | 198 | mTabControl = new QTabWidget( this ); |
191 | mTabControl->setMargin (KDialog::marginHint()); | 199 | mTabControl->setMargin (KDialog::marginHint()); |
192 | topLayout->addWidget( mTabControl, 10 ); | 200 | topLayout->addWidget( mTabControl, 10 ); |
193 | } | 201 | } |
194 | else if( mFace == Swallow ) | 202 | else if( mFace == Swallow ) |
195 | { | 203 | { |
196 | mSwallowPage = new QWidget( this ); | 204 | mSwallowPage = new QWidget( this ); |
197 | topLayout->addWidget( mSwallowPage, 10 ); | 205 | topLayout->addWidget( mSwallowPage, 10 ); |
198 | } | 206 | } |
199 | else | 207 | else |
200 | { | 208 | { |
201 | mFace = Plain; | 209 | mFace = Plain; |
202 | mPlainPage = new QFrame( this ); | 210 | mPlainPage = new Q3Frame( this ); |
203 | topLayout->addWidget( mPlainPage, 10 ); | 211 | topLayout->addWidget( mPlainPage, 10 ); |
204 | } | 212 | } |
205 | /*US | 213 | /*US |
206 | if ( kapp ) | 214 | if ( kapp ) |
207 | connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged())); | 215 | connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged())); |
208 | */ | 216 | */ |
209 | mValid = true; | 217 | mValid = true; |
210 | setSwallowedWidget(0); // Set default size if 'mFace' is Swallow. | 218 | setSwallowedWidget(0); // Set default size if 'mFace' is Swallow. |
211 | } | 219 | } |
212 | 220 | ||
213 | 221 | ||
214 | KJanusWidget::~KJanusWidget() | 222 | KJanusWidget::~KJanusWidget() |
215 | { | 223 | { |
216 | 224 | ||
217 | /*US the destroyed signal caused a segmentation fault while closing the dialog and destructing | 225 | /*US the destroyed signal caused a segmentation fault while closing the dialog and destructing |
218 | all pages. Why not just remove all pages in the destructor?? | 226 | all pages. Why not just remove all pages in the destructor?? |
@@ -232,247 +240,247 @@ KJanusWidget::~KJanusWidget() | |||
232 | qDebug("KJanusWidget::~KJanusWidget so far "); | 240 | qDebug("KJanusWidget::~KJanusWidget so far "); |
233 | */ | 241 | */ |
234 | //US end | 242 | //US end |
235 | 243 | ||
236 | delete d; | 244 | delete d; |
237 | 245 | ||
238 | 246 | ||
239 | } | 247 | } |
240 | 248 | ||
241 | 249 | ||
242 | bool KJanusWidget::isValid() const | 250 | bool KJanusWidget::isValid() const |
243 | { | 251 | { |
244 | return( mValid ); | 252 | return( mValid ); |
245 | } | 253 | } |
246 | 254 | ||
247 | 255 | ||
248 | QFrame *KJanusWidget::plainPage() | 256 | Q3Frame *KJanusWidget::plainPage() |
249 | { | 257 | { |
250 | return( mPlainPage ); | 258 | return( mPlainPage ); |
251 | } | 259 | } |
252 | 260 | ||
253 | 261 | ||
254 | int KJanusWidget::face() const | 262 | int KJanusWidget::face() const |
255 | { | 263 | { |
256 | return( mFace ); | 264 | return( mFace ); |
257 | } | 265 | } |
258 | 266 | ||
259 | QWidget *KJanusWidget::FindParent() | 267 | QWidget *KJanusWidget::FindParent() |
260 | { | 268 | { |
261 | if( mFace == Tabbed ) { | 269 | if( mFace == Tabbed ) { |
262 | return mTabControl; | 270 | return mTabControl; |
263 | } | 271 | } |
264 | else { | 272 | else { |
265 | return this; | 273 | return this; |
266 | } | 274 | } |
267 | } | 275 | } |
268 | 276 | ||
269 | QFrame *KJanusWidget::addPage( const QStringList &items, const QString &header, | 277 | Q3Frame *KJanusWidget::addPage( const QStringList &items, const QString &header, |
270 | const QPixmap &pixmap ) | 278 | const QPixmap &pixmap ) |
271 | { | 279 | { |
272 | if( mValid == false ) | 280 | if( mValid == false ) |
273 | { | 281 | { |
274 | kdDebug() << "addPage: Invalid object" << endl; | 282 | kdDebug() << "addPage: Invalid object" << endl; |
275 | return( 0 ); | 283 | return( 0 ); |
276 | } | 284 | } |
277 | 285 | ||
278 | QFrame *page = new QFrame( FindParent(), "page" ); | 286 | Q3Frame *page = new Q3Frame( FindParent(), "page" ); |
279 | addPageWidget( page, items, header, pixmap ); | 287 | addPageWidget( page, items, header, pixmap ); |
280 | 288 | ||
281 | return page; | 289 | return page; |
282 | } | 290 | } |
283 | 291 | ||
284 | void KJanusWidget::pageGone( QObject *obj ) | 292 | void KJanusWidget::pageGone( QObject *obj ) |
285 | { | 293 | { |
286 | // QObject* obj = (QObject*)sender(); | 294 | // QObject* obj = (QObject*)sender(); |
287 | removePage( static_cast<QWidget*>( obj ) ); | 295 | removePage( static_cast<QWidget*>( obj ) ); |
288 | } | 296 | } |
289 | 297 | ||
290 | void KJanusWidget::slotReopen( QListViewItem * item ) | 298 | void KJanusWidget::slotReopen( Q3ListViewItem * item ) |
291 | { | 299 | { |
292 | if( item ) | 300 | if( item ) |
293 | item->setOpen( true ); | 301 | item->setOpen( true ); |
294 | } | 302 | } |
295 | 303 | ||
296 | QFrame *KJanusWidget::addPage( const QString &itemName, const QString &header, | 304 | Q3Frame *KJanusWidget::addPage( const QString &itemName, const QString &header, |
297 | const QPixmap &pixmap ) | 305 | const QPixmap &pixmap ) |
298 | { | 306 | { |
299 | 307 | ||
300 | QStringList items; | 308 | QStringList items; |
301 | items << itemName; | 309 | items << itemName; |
302 | return addPage(items, header, pixmap); | 310 | return addPage(items, header, pixmap); |
303 | } | 311 | } |
304 | 312 | ||
305 | 313 | ||
306 | 314 | ||
307 | QVBox *KJanusWidget::addVBoxPage( const QStringList &items, | 315 | Q3VBox *KJanusWidget::addVBoxPage( const QStringList &items, |
308 | const QString &header, | 316 | const QString &header, |
309 | const QPixmap &pixmap ) | 317 | const QPixmap &pixmap ) |
310 | { | 318 | { |
311 | if( mValid == false ) | 319 | if( mValid == false ) |
312 | { | 320 | { |
313 | qDebug("addPage: Invalid object "); | 321 | qDebug("addPage: Invalid object "); |
314 | 322 | ||
315 | return( 0 ); | 323 | return( 0 ); |
316 | } | 324 | } |
317 | 325 | ||
318 | QVBox *page = new QVBox(FindParent() , "vbox_page" ); | 326 | Q3VBox *page = new Q3VBox(FindParent() , "vbox_page" ); |
319 | page->setSpacing( KDialog::spacingHintSmall() ); | 327 | page->setSpacing( KDialog::spacingHintSmall() ); |
320 | addPageWidget( page, items, header, pixmap ); | 328 | addPageWidget( page, items, header, pixmap ); |
321 | 329 | ||
322 | return page; | 330 | return page; |
323 | } | 331 | } |
324 | 332 | ||
325 | QVBox *KJanusWidget::addVBoxPage( const QString &itemName, | 333 | Q3VBox *KJanusWidget::addVBoxPage( const QString &itemName, |
326 | const QString &header, | 334 | const QString &header, |
327 | const QPixmap &pixmap ) | 335 | const QPixmap &pixmap ) |
328 | { | 336 | { |
329 | QStringList items; | 337 | QStringList items; |
330 | items << itemName; | 338 | items << itemName; |
331 | return addVBoxPage(items, header, pixmap); | 339 | return addVBoxPage(items, header, pixmap); |
332 | } | 340 | } |
333 | 341 | ||
334 | QHBox *KJanusWidget::addHBoxPage( const QStringList &items, | 342 | Q3HBox *KJanusWidget::addHBoxPage( const QStringList &items, |
335 | const QString &header, | 343 | const QString &header, |
336 | const QPixmap &pixmap ) | 344 | const QPixmap &pixmap ) |
337 | { | 345 | { |
338 | if( mValid == false ) { | 346 | if( mValid == false ) { |
339 | kdDebug() << "addPage: Invalid object" << endl; | 347 | kdDebug() << "addPage: Invalid object" << endl; |
340 | return( 0 ); | 348 | return( 0 ); |
341 | } | 349 | } |
342 | 350 | ||
343 | QHBox *page = new QHBox(FindParent(), "hbox_page"); | 351 | Q3HBox *page = new Q3HBox(FindParent(), "hbox_page"); |
344 | page->setSpacing( KDialog::spacingHint() ); | 352 | page->setSpacing( KDialog::spacingHint() ); |
345 | addPageWidget( page, items, header, pixmap ); | 353 | addPageWidget( page, items, header, pixmap ); |
346 | 354 | ||
347 | return page; | 355 | return page; |
348 | } | 356 | } |
349 | 357 | ||
350 | QHBox *KJanusWidget::addHBoxPage( const QString &itemName, | 358 | Q3HBox *KJanusWidget::addHBoxPage( const QString &itemName, |
351 | const QString &header, | 359 | const QString &header, |
352 | const QPixmap &pixmap ) | 360 | const QPixmap &pixmap ) |
353 | { | 361 | { |
354 | QStringList items; | 362 | QStringList items; |
355 | items << itemName; | 363 | items << itemName; |
356 | return addHBoxPage(items, header, pixmap); | 364 | return addHBoxPage(items, header, pixmap); |
357 | } | 365 | } |
358 | 366 | ||
359 | QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, | 367 | Q3Grid *KJanusWidget::addGridPage( int n, Qt::Orientation dir, |
360 | const QStringList &items, | 368 | const QStringList &items, |
361 | const QString &header, | 369 | const QString &header, |
362 | const QPixmap &pixmap ) | 370 | const QPixmap &pixmap ) |
363 | { | 371 | { |
364 | if( mValid == false ) | 372 | if( mValid == false ) |
365 | { | 373 | { |
366 | kdDebug() << "addPage: Invalid object" << endl; | 374 | kdDebug() << "addPage: Invalid object" << endl; |
367 | return( 0 ); | 375 | return( 0 ); |
368 | } | 376 | } |
369 | 377 | ||
370 | QGrid *page = new QGrid( n, dir, FindParent(), "page" ); | 378 | Q3Grid *page = new Q3Grid( n, dir, FindParent(), "page" ); |
371 | page->setSpacing( KDialog::spacingHint() ); | 379 | page->setSpacing( KDialog::spacingHint() ); |
372 | addPageWidget( page, items, header, pixmap ); | 380 | addPageWidget( page, items, header, pixmap ); |
373 | 381 | ||
374 | return page; | 382 | return page; |
375 | } | 383 | } |
376 | 384 | ||
377 | 385 | ||
378 | QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, | 386 | Q3Grid *KJanusWidget::addGridPage( int n, Qt::Orientation dir, |
379 | const QString &itemName, | 387 | const QString &itemName, |
380 | const QString &header, | 388 | const QString &header, |
381 | const QPixmap &pixmap ) | 389 | const QPixmap &pixmap ) |
382 | { | 390 | { |
383 | QStringList items; | 391 | QStringList items; |
384 | items << itemName; | 392 | items << itemName; |
385 | return addGridPage(n, dir, items, header, pixmap); | 393 | return addGridPage(n, dir, items, header, pixmap); |
386 | } | 394 | } |
387 | 395 | ||
388 | void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, QFrame *page) | 396 | void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, Q3Frame *page) |
389 | { | 397 | { |
390 | bool isTop = true; | 398 | bool isTop = true; |
391 | QListViewItem *curTop = 0, *child, *last, *newChild; | 399 | Q3ListViewItem *curTop = 0, *child, *last, *newChild; |
392 | unsigned int index = 1; | 400 | unsigned int index = 1; |
393 | QStringList curPath; | 401 | QStringList curPath; |
394 | 402 | ||
395 | for ( QStringList::ConstIterator it = items.begin(); it != items.end(); ++it, index++ ) { | 403 | for ( QStringList::ConstIterator it = items.begin(); it != items.end(); ++it, index++ ) { |
396 | QString name = (*it); | 404 | QString name = (*it); |
397 | bool isPath = ( index != items.count() ); | 405 | bool isPath = ( index != items.count() ); |
398 | 406 | ||
399 | // Find the first child. | 407 | // Find the first child. |
400 | if (isTop) { | 408 | if (isTop) { |
401 | child = mTreeList->firstChild(); | 409 | child = mTreeList->firstChild(); |
402 | } | 410 | } |
403 | else { | 411 | else { |
404 | child = curTop->firstChild(); | 412 | child = curTop->firstChild(); |
405 | } | 413 | } |
406 | 414 | ||
407 | // Now search for a child with the current Name, and if it we doesn't | 415 | // Now search for a child with the current Name, and if it we doesn't |
408 | // find it, then remember the location of the last child. | 416 | // find it, then remember the location of the last child. |
409 | for (last = 0; child && child->text(0) != name ; last = child, child = child->nextSibling()); | 417 | for (last = 0; child && child->text(0) != name ; last = child, child = child->nextSibling()); |
410 | 418 | ||
411 | if (last == 0 && child == 0) { | 419 | if (last == 0 && child == 0) { |
412 | // This node didn't have any children at all, lets just insert the | 420 | // This node didn't have any children at all, lets just insert the |
413 | // new child. | 421 | // new child. |
414 | if (isTop) | 422 | if (isTop) |
415 | newChild = new QListViewItem(mTreeList, name); | 423 | newChild = new Q3ListViewItem(mTreeList, name); |
416 | else | 424 | else |
417 | newChild = new QListViewItem(curTop, name); | 425 | newChild = new Q3ListViewItem(curTop, name); |
418 | 426 | ||
419 | } | 427 | } |
420 | else if (child != 0) { | 428 | else if (child != 0) { |
421 | // we found the given name in this child. | 429 | // we found the given name in this child. |
422 | if (!isPath) { | 430 | if (!isPath) { |
423 | kdDebug() << "The element inserted was already in the TreeList box!" << endl; | 431 | kdDebug() << "The element inserted was already in the TreeList box!" << endl; |
424 | return; | 432 | return; |
425 | } | 433 | } |
426 | else { | 434 | else { |
427 | // Ok we found the folder | 435 | // Ok we found the folder |
428 | newChild = child; | 436 | newChild = child; |
429 | } | 437 | } |
430 | } | 438 | } |
431 | else { | 439 | else { |
432 | // the node had some children, but we didn't find the given name | 440 | // the node had some children, but we didn't find the given name |
433 | if (isTop) | 441 | if (isTop) |
434 | newChild = new QListViewItem(mTreeList, last, name); | 442 | newChild = new Q3ListViewItem(mTreeList, last, name); |
435 | else | 443 | else |
436 | newChild = new QListViewItem(curTop, last, name); | 444 | newChild = new Q3ListViewItem(curTop, last, name); |
437 | } | 445 | } |
438 | 446 | ||
439 | // Now make the element expandable if it is a path component, and make | 447 | // Now make the element expandable if it is a path component, and make |
440 | // ready for next loop | 448 | // ready for next loop |
441 | if (isPath) { | 449 | if (isPath) { |
442 | newChild->setExpandable(true); | 450 | newChild->setExpandable(true); |
443 | curTop = newChild; | 451 | curTop = newChild; |
444 | isTop = false; | 452 | isTop = false; |
445 | curPath << name; | 453 | curPath << name; |
446 | 454 | ||
447 | QString key = curPath.join("_/_"); | 455 | QString key = curPath.join("_/_"); |
448 | if (mFolderIconMap.contains(key)) { | 456 | if (mFolderIconMap.contains(key)) { |
449 | QPixmap p = mFolderIconMap[key]; | 457 | QPixmap p = mFolderIconMap[key]; |
450 | newChild->setPixmap(0,p); | 458 | newChild->setPixmap(0,p); |
451 | } | 459 | } |
452 | } | 460 | } |
453 | else { | 461 | else { |
454 | if (mShowIconsInTreeList) { | 462 | if (mShowIconsInTreeList) { |
455 | newChild->setPixmap(0, pixmap); | 463 | newChild->setPixmap(0, pixmap); |
456 | } | 464 | } |
457 | mTreeListToPageStack.insert(newChild, page); | 465 | mTreeListToPageStack.insert(newChild, page); |
458 | } | 466 | } |
459 | } | 467 | } |
460 | } | 468 | } |
461 | 469 | ||
462 | void KJanusWidget::addPageWidget( QFrame *page, const QStringList &items, | 470 | void KJanusWidget::addPageWidget( Q3Frame *page, const QStringList &items, |
463 | const QString &header,const QPixmap &pixmap ) | 471 | const QString &header,const QPixmap &pixmap ) |
464 | { | 472 | { |
465 | /*US the following signal causes a segmentation fault while closing the dialog. | 473 | /*US the following signal causes a segmentation fault while closing the dialog. |
466 | Why not just remove all pages in the destructor?? | 474 | Why not just remove all pages in the destructor?? |
467 | */ | 475 | */ |
468 | //US connect(page, SIGNAL(destroyed(QObject*)), this, SLOT(pageGone(QObject*))); | 476 | //US connect(page, SIGNAL(destroyed(QObject*)), this, SLOT(pageGone(QObject*))); |
469 | // we have the SIGNAL(destroyed(QObject*) only in Qt3 | 477 | // we have the SIGNAL(destroyed(QObject*) only in Qt3 |
470 | #ifdef DESKTOP_VERSION | 478 | #ifdef DESKTOP_VERSION |
471 | // connect(page, SIGNAL(destroyed(QObject*)), this, SLOT(pageGone(QObject*))); | 479 | // connect(page, SIGNAL(destroyed(QObject*)), this, SLOT(pageGone(QObject*))); |
472 | #endif | 480 | #endif |
473 | if( mFace == Tabbed ) | 481 | if( mFace == Tabbed ) |
474 | { | 482 | { |
475 | mTabControl->addTab (page, items.last()); | 483 | mTabControl->addTab (page, items.last()); |
476 | d->mIntToPage[d->mNextPageIndex] = static_cast<QWidget*>(page); | 484 | d->mIntToPage[d->mNextPageIndex] = static_cast<QWidget*>(page); |
477 | d->mPageToInt[static_cast<QWidget*>(page)] = d->mNextPageIndex; | 485 | d->mPageToInt[static_cast<QWidget*>(page)] = d->mNextPageIndex; |
478 | d->mNextPageIndex++; | 486 | d->mNextPageIndex++; |
@@ -537,41 +545,41 @@ void KJanusWidget::setFolderIcon(const QStringList &path, const QPixmap &pixmap) | |||
537 | 545 | ||
538 | 546 | ||
539 | bool KJanusWidget::setSwallowedWidget( QWidget *widget ) | 547 | bool KJanusWidget::setSwallowedWidget( QWidget *widget ) |
540 | { | 548 | { |
541 | if( mFace != Swallow || mValid == false ) | 549 | if( mFace != Swallow || mValid == false ) |
542 | { | 550 | { |
543 | return( false ); | 551 | return( false ); |
544 | } | 552 | } |
545 | 553 | ||
546 | // | 554 | // |
547 | // Remove current layout and make a new. | 555 | // Remove current layout and make a new. |
548 | // | 556 | // |
549 | if( mSwallowPage->layout() != 0 ) | 557 | if( mSwallowPage->layout() != 0 ) |
550 | { | 558 | { |
551 | delete mSwallowPage->layout(); | 559 | delete mSwallowPage->layout(); |
552 | } | 560 | } |
553 | QGridLayout *gbox = new QGridLayout( mSwallowPage, 1, 1, 0 ); | 561 | Q3GridLayout *gbox = new Q3GridLayout( mSwallowPage, 1, 1, 0 ); |
554 | 562 | ||
555 | // | 563 | // |
556 | // Hide old children | 564 | // Hide old children |
557 | // | 565 | // |
558 | QObjectList *l = (QObjectList*)mSwallowPage->children(); // silence please | 566 | QObjectList l = mSwallowPage->children(); // silence please |
559 | for( uint i=0; i < l->count(); i++ ) | 567 | for( uint i=0; i < l.count(); i++ ) |
560 | { | 568 | { |
561 | QObject *o = l->at(i); | 569 | QObject *o = l.at(i); |
562 | if( o->isWidgetType() ) | 570 | if( o->isWidgetType() ) |
563 | { | 571 | { |
564 | ((QWidget*)o)->hide(); | 572 | ((QWidget*)o)->hide(); |
565 | } | 573 | } |
566 | } | 574 | } |
567 | 575 | ||
568 | // | 576 | // |
569 | // Add new child or make default size | 577 | // Add new child or make default size |
570 | // | 578 | // |
571 | if( widget == 0 ) | 579 | if( widget == 0 ) |
572 | { | 580 | { |
573 | gbox->addRowSpacing(0,100); | 581 | gbox->addRowSpacing(0,100); |
574 | gbox->addColSpacing(0,100); | 582 | gbox->addColSpacing(0,100); |
575 | mSwallowPage->setMinimumSize(100,100); | 583 | mSwallowPage->setMinimumSize(100,100); |
576 | } | 584 | } |
577 | else | 585 | else |
@@ -584,42 +592,42 @@ bool KJanusWidget::setSwallowedWidget( QWidget *widget ) | |||
584 | gbox->activate(); | 592 | gbox->activate(); |
585 | mSwallowPage->setMinimumSize( widget->minimumSize() ); | 593 | mSwallowPage->setMinimumSize( widget->minimumSize() ); |
586 | } | 594 | } |
587 | 595 | ||
588 | return( true ); | 596 | return( true ); |
589 | } | 597 | } |
590 | 598 | ||
591 | bool KJanusWidget::slotShowPage() | 599 | bool KJanusWidget::slotShowPage() |
592 | { | 600 | { |
593 | if( mValid == false ) | 601 | if( mValid == false ) |
594 | { | 602 | { |
595 | return( false ); | 603 | return( false ); |
596 | } | 604 | } |
597 | 605 | ||
598 | if( mFace == TreeList ) | 606 | if( mFace == TreeList ) |
599 | { | 607 | { |
600 | QListViewItem *node = mTreeList->selectedItem(); | 608 | Q3ListViewItem *node = mTreeList->selectedItem(); |
601 | if( node == 0 ) { return( false ); } | 609 | if( node == 0 ) { return( false ); } |
602 | 610 | ||
603 | QWidget *stackItem = mTreeListToPageStack[node]; | 611 | QWidget *stackItem = mTreeListToPageStack[node]; |
604 | // Make sure to call through the virtual function showPage(int) | 612 | // Make sure to call through the virtual function showPage(int) |
605 | return showPage(d->mPageToInt[stackItem]); | 613 | return showPage(d->mPageToInt[stackItem]); |
606 | } | 614 | } |
607 | else if( mFace == IconList ) | 615 | else if( mFace == IconList ) |
608 | { | 616 | { |
609 | QListBoxItem *node = mIconList->item( mIconList->currentItem() ); | 617 | Q3ListBoxItem *node = mIconList->item( mIconList->currentItem() ); |
610 | if( node == 0 ) { return( false ); } | 618 | if( node == 0 ) { return( false ); } |
611 | QWidget *stackItem = mIconListToPageStack[node]; | 619 | QWidget *stackItem = mIconListToPageStack[node]; |
612 | // Make sure to call through the virtual function showPage(int) | 620 | // Make sure to call through the virtual function showPage(int) |
613 | return showPage(d->mPageToInt[stackItem]); | 621 | return showPage(d->mPageToInt[stackItem]); |
614 | } | 622 | } |
615 | 623 | ||
616 | return( false ); | 624 | return( false ); |
617 | } | 625 | } |
618 | 626 | ||
619 | 627 | ||
620 | bool KJanusWidget::showPage( int index ) | 628 | bool KJanusWidget::showPage( int index ) |
621 | { | 629 | { |
622 | if( d == 0 || mValid == false ) | 630 | if( d == 0 || mValid == false ) |
623 | { | 631 | { |
624 | return( false ); | 632 | return( false ); |
625 | } | 633 | } |
@@ -633,79 +641,79 @@ bool KJanusWidget::showPage( int index ) | |||
633 | bool KJanusWidget::showPage( QWidget *w ) | 641 | bool KJanusWidget::showPage( QWidget *w ) |
634 | { | 642 | { |
635 | if( w == 0 || mValid == false ) | 643 | if( w == 0 || mValid == false ) |
636 | { | 644 | { |
637 | return( false ); | 645 | return( false ); |
638 | } | 646 | } |
639 | 647 | ||
640 | if( mFace == TreeList || mFace == IconList ) | 648 | if( mFace == TreeList || mFace == IconList ) |
641 | { | 649 | { |
642 | mPageStack->raiseWidget( w ); | 650 | mPageStack->raiseWidget( w ); |
643 | mActivePageWidget = w; | 651 | mActivePageWidget = w; |
644 | 652 | ||
645 | int index = d->mPageToInt[w]; | 653 | int index = d->mPageToInt[w]; |
646 | mTitleLabel->setText( d->mIntToTitle[index] ); | 654 | mTitleLabel->setText( d->mIntToTitle[index] ); |
647 | if( mFace == TreeList ) | 655 | if( mFace == TreeList ) |
648 | { | 656 | { |
649 | QMap<QListViewItem *, QWidget *>::Iterator it; | 657 | QMap<Q3ListViewItem *, QWidget *>::Iterator it; |
650 | for (it = mTreeListToPageStack.begin(); it != mTreeListToPageStack.end(); ++it){ | 658 | for (it = mTreeListToPageStack.begin(); it != mTreeListToPageStack.end(); ++it){ |
651 | QListViewItem *key = it.key(); | 659 | Q3ListViewItem *key = it.key(); |
652 | QWidget *val = it.data(); | 660 | QWidget *val = it.data(); |
653 | if (val == w) { | 661 | if (val == w) { |
654 | mTreeList->setSelected(key, true ); | 662 | mTreeList->setSelected(key, true ); |
655 | break; | 663 | break; |
656 | } | 664 | } |
657 | } | 665 | } |
658 | } | 666 | } |
659 | else | 667 | else |
660 | { | 668 | { |
661 | QMap<QListBoxItem *, QWidget *>::Iterator it; | 669 | QMap<Q3ListBoxItem *, QWidget *>::Iterator it; |
662 | for (it = mIconListToPageStack.begin(); it != mIconListToPageStack.end(); ++it){ | 670 | for (it = mIconListToPageStack.begin(); it != mIconListToPageStack.end(); ++it){ |
663 | QListBoxItem *key = it.key(); | 671 | Q3ListBoxItem *key = it.key(); |
664 | QWidget *val = it.data(); | 672 | QWidget *val = it.data(); |
665 | if (val == w) { | 673 | if (val == w) { |
666 | mIconList->setSelected( key, true ); | 674 | mIconList->setSelected( key, true ); |
667 | break; | 675 | break; |
668 | } | 676 | } |
669 | } | 677 | } |
670 | } | 678 | } |
671 | } | 679 | } |
672 | else if( mFace == Tabbed ) | 680 | else if( mFace == Tabbed ) |
673 | { | 681 | { |
674 | mTabControl->showPage(w); | 682 | mTabControl->showPage(w); |
675 | mActivePageWidget = w; | 683 | mActivePageWidget = w; |
676 | } | 684 | } |
677 | else | 685 | else |
678 | { | 686 | { |
679 | return( false ); | 687 | return( false ); |
680 | } | 688 | } |
681 | 689 | ||
682 | return( true ); | 690 | return( true ); |
683 | } | 691 | } |
684 | 692 | ||
685 | 693 | ||
686 | int KJanusWidget::activePageIndex() const | 694 | int KJanusWidget::activePageIndex() const |
687 | { | 695 | { |
688 | if( mFace == TreeList) { | 696 | if( mFace == TreeList) { |
689 | QListViewItem *node = mTreeList->selectedItem(); | 697 | Q3ListViewItem *node = mTreeList->selectedItem(); |
690 | if( node == 0 ) { return -1; } | 698 | if( node == 0 ) { return -1; } |
691 | QWidget *stackItem = mTreeListToPageStack[node]; | 699 | QWidget *stackItem = mTreeListToPageStack[node]; |
692 | return d->mPageToInt[stackItem]; | 700 | return d->mPageToInt[stackItem]; |
693 | } | 701 | } |
694 | else if (mFace == IconList) { | 702 | else if (mFace == IconList) { |
695 | QListBoxItem *node = mIconList->item( mIconList->currentItem() ); | 703 | Q3ListBoxItem *node = mIconList->item( mIconList->currentItem() ); |
696 | if( node == 0 ) { return( false ); } | 704 | if( node == 0 ) { return( false ); } |
697 | QWidget *stackItem = mIconListToPageStack[node]; | 705 | QWidget *stackItem = mIconListToPageStack[node]; |
698 | return d->mPageToInt[stackItem]; | 706 | return d->mPageToInt[stackItem]; |
699 | } | 707 | } |
700 | else if( mFace == Tabbed ) { | 708 | else if( mFace == Tabbed ) { |
701 | QWidget *widget = mTabControl->currentPage(); | 709 | QWidget *widget = mTabControl->currentPage(); |
702 | return( widget == 0 ? -1 : d->mPageToInt[widget] ); | 710 | return( widget == 0 ? -1 : d->mPageToInt[widget] ); |
703 | } | 711 | } |
704 | else { | 712 | else { |
705 | return( -1 ); | 713 | return( -1 ); |
706 | } | 714 | } |
707 | } | 715 | } |
708 | 716 | ||
709 | 717 | ||
710 | int KJanusWidget::pageIndex( QWidget *widget ) const | 718 | int KJanusWidget::pageIndex( QWidget *widget ) const |
711 | { | 719 | { |
@@ -748,33 +756,33 @@ void KJanusWidget::slotFontChanged() | |||
748 | titleFont.setBold( true ); | 756 | titleFont.setBold( true ); |
749 | mTitleLabel->setFont( titleFont ); | 757 | mTitleLabel->setFont( titleFont ); |
750 | } | 758 | } |
751 | 759 | ||
752 | if( mFace == IconList ) | 760 | if( mFace == IconList ) |
753 | { | 761 | { |
754 | QFont listFont( mIconList->font() ); | 762 | QFont listFont( mIconList->font() ); |
755 | listFont.setBold( true ); | 763 | listFont.setBold( true ); |
756 | mIconList->setFont( listFont ); | 764 | mIconList->setFont( listFont ); |
757 | mIconList->invalidateHeight(); | 765 | mIconList->invalidateHeight(); |
758 | mIconList->invalidateWidth(); | 766 | mIconList->invalidateWidth(); |
759 | } | 767 | } |
760 | } | 768 | } |
761 | */ | 769 | */ |
762 | 770 | ||
763 | // makes the treelist behave like the list of kcontrol | 771 | // makes the treelist behave like the list of kcontrol |
764 | void KJanusWidget::slotItemClicked(QListViewItem *it) | 772 | void KJanusWidget::slotItemClicked(Q3ListViewItem *it) |
765 | { | 773 | { |
766 | if(it && (it->childCount()>0)) | 774 | if(it && (it->childCount()>0)) |
767 | it->setOpen(!it->isOpen()); | 775 | it->setOpen(!it->isOpen()); |
768 | } | 776 | } |
769 | 777 | ||
770 | void KJanusWidget::setFocus() | 778 | void KJanusWidget::setFocus() |
771 | { | 779 | { |
772 | if( mValid == false ) { return; } | 780 | if( mValid == false ) { return; } |
773 | if( mFace == TreeList ) | 781 | if( mFace == TreeList ) |
774 | { | 782 | { |
775 | mTreeList->setFocus(); | 783 | mTreeList->setFocus(); |
776 | } | 784 | } |
777 | if( mFace == IconList ) | 785 | if( mFace == IconList ) |
778 | { | 786 | { |
779 | mIconList->setFocus(); | 787 | mIconList->setFocus(); |
780 | } | 788 | } |
@@ -882,37 +890,37 @@ void KJanusWidget::setShowIconsInTreeList( bool state ) | |||
882 | { | 890 | { |
883 | mShowIconsInTreeList = state; | 891 | mShowIconsInTreeList = state; |
884 | } | 892 | } |
885 | 893 | ||
886 | void KJanusWidget::setRootIsDecorated( bool state ) | 894 | void KJanusWidget::setRootIsDecorated( bool state ) |
887 | { | 895 | { |
888 | if( mFace == TreeList ) { | 896 | if( mFace == TreeList ) { |
889 | mTreeList->setRootIsDecorated(state); | 897 | mTreeList->setRootIsDecorated(state); |
890 | } | 898 | } |
891 | } | 899 | } |
892 | 900 | ||
893 | void KJanusWidget::unfoldTreeList( bool persist ) | 901 | void KJanusWidget::unfoldTreeList( bool persist ) |
894 | { | 902 | { |
895 | if( mFace == TreeList ) | 903 | if( mFace == TreeList ) |
896 | { | 904 | { |
897 | if( persist ) | 905 | if( persist ) |
898 | connect( mTreeList, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( slotReopen( QListViewItem * ) ) ); | 906 | connect( mTreeList, SIGNAL( collapsed( Q3ListViewItem * ) ), this, SLOT( slotReopen( Q3ListViewItem * ) ) ); |
899 | else | 907 | else |
900 | disconnect( mTreeList, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( slotReopen( QListViewItem * ) ) ); | 908 | disconnect( mTreeList, SIGNAL( collapsed( Q3ListViewItem * ) ), this, SLOT( slotReopen( Q3ListViewItem * ) ) ); |
901 | 909 | ||
902 | for( QListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() ) | 910 | for( Q3ListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() ) |
903 | item->setOpen( true ); | 911 | item->setOpen( true ); |
904 | } | 912 | } |
905 | } | 913 | } |
906 | 914 | ||
907 | void KJanusWidget::showEvent( QShowEvent * ) | 915 | void KJanusWidget::showEvent( QShowEvent * ) |
908 | { | 916 | { |
909 | if( mFace == TreeList ) | 917 | if( mFace == TreeList ) |
910 | { | 918 | { |
911 | /*US | 919 | /*US |
912 | QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget()); | 920 | QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget()); |
913 | splitter->setResizeMode( mTreeList, mTreeListResizeMode ); | 921 | splitter->setResizeMode( mTreeList, mTreeListResizeMode ); |
914 | */ | 922 | */ |
915 | } | 923 | } |
916 | } | 924 | } |
917 | 925 | ||
918 | 926 | ||
@@ -940,66 +948,66 @@ bool KJanusWidget::eventFilter( QObject *o, QEvent *e ) | |||
940 | { | 948 | { |
941 | int lw = item->width( mIconList ); | 949 | int lw = item->width( mIconList ); |
942 | mIconList->setFixedWidth( lw+mIconList->frameWidth()*2 ); | 950 | mIconList->setFixedWidth( lw+mIconList->frameWidth()*2 ); |
943 | } | 951 | } |
944 | } | 952 | } |
945 | return QWidget::eventFilter( o, e ); | 953 | return QWidget::eventFilter( o, e ); |
946 | } | 954 | } |
947 | 955 | ||
948 | 956 | ||
949 | 957 | ||
950 | // | 958 | // |
951 | // Code for the icon list box | 959 | // Code for the icon list box |
952 | // | 960 | // |
953 | 961 | ||
954 | 962 | ||
955 | KJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name, | 963 | KJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name, |
956 | WFlags f ) | 964 | Qt::WFlags f ) |
957 | :KListBox( parent, name, f ), mShowAll(false), mHeightValid(false), | 965 | :KListBox( parent, name, f ), mShowAll(false), mHeightValid(false), |
958 | mWidthValid(false) | 966 | mWidthValid(false) |
959 | { | 967 | { |
960 | } | 968 | } |
961 | 969 | ||
962 | 970 | ||
963 | void KJanusWidget::IconListBox::updateMinimumHeight() | 971 | void KJanusWidget::IconListBox::updateMinimumHeight() |
964 | { | 972 | { |
965 | if( mShowAll == true && mHeightValid == false ) | 973 | if( mShowAll == true && mHeightValid == false ) |
966 | { | 974 | { |
967 | int h = frameWidth()*2; | 975 | int h = frameWidth()*2; |
968 | for( QListBoxItem *i = item(0); i != 0; i = i->next() ) | 976 | for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() ) |
969 | { | 977 | { |
970 | h += i->height( this ); | 978 | h += i->height( this ); |
971 | } | 979 | } |
972 | setMinimumHeight( h ); | 980 | setMinimumHeight( h ); |
973 | mHeightValid = true; | 981 | mHeightValid = true; |
974 | } | 982 | } |
975 | } | 983 | } |
976 | 984 | ||
977 | 985 | ||
978 | void KJanusWidget::IconListBox::updateWidth() | 986 | void KJanusWidget::IconListBox::updateWidth() |
979 | { | 987 | { |
980 | if( mWidthValid == false ) | 988 | if( mWidthValid == false ) |
981 | { | 989 | { |
982 | int maxWidth = 10; | 990 | int maxWidth = 10; |
983 | for( QListBoxItem *i = item(0); i != 0; i = i->next() ) | 991 | for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() ) |
984 | { | 992 | { |
985 | int w = ((IconListItem *)i)->width(this); | 993 | int w = ((IconListItem *)i)->width(this); |
986 | maxWidth = QMAX( w, maxWidth ); | 994 | maxWidth = QMAX( w, maxWidth ); |
987 | } | 995 | } |
988 | 996 | ||
989 | for( QListBoxItem *i = item(0); i != 0; i = i->next() ) | 997 | for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() ) |
990 | { | 998 | { |
991 | ((IconListItem *)i)->expandMinimumWidth( maxWidth ); | 999 | ((IconListItem *)i)->expandMinimumWidth( maxWidth ); |
992 | } | 1000 | } |
993 | 1001 | ||
994 | if( verticalScrollBar()->isVisible() ) | 1002 | if( verticalScrollBar()->isVisible() ) |
995 | { | 1003 | { |
996 | maxWidth += verticalScrollBar()->sizeHint().width(); | 1004 | maxWidth += verticalScrollBar()->sizeHint().width(); |
997 | } | 1005 | } |
998 | 1006 | ||
999 | setFixedWidth( maxWidth + frameWidth()*2 ); | 1007 | setFixedWidth( maxWidth + frameWidth()*2 ); |
1000 | mWidthValid = true; | 1008 | mWidthValid = true; |
1001 | } | 1009 | } |
1002 | } | 1010 | } |
1003 | 1011 | ||
1004 | 1012 | ||
1005 | void KJanusWidget::IconListBox::invalidateHeight() | 1013 | void KJanusWidget::IconListBox::invalidateHeight() |
@@ -1009,35 +1017,35 @@ void KJanusWidget::IconListBox::invalidateHeight() | |||
1009 | 1017 | ||
1010 | 1018 | ||
1011 | void KJanusWidget::IconListBox::invalidateWidth() | 1019 | void KJanusWidget::IconListBox::invalidateWidth() |
1012 | { | 1020 | { |
1013 | mWidthValid = false; | 1021 | mWidthValid = false; |
1014 | } | 1022 | } |
1015 | 1023 | ||
1016 | 1024 | ||
1017 | void KJanusWidget::IconListBox::setShowAll( bool showAll ) | 1025 | void KJanusWidget::IconListBox::setShowAll( bool showAll ) |
1018 | { | 1026 | { |
1019 | mShowAll = showAll; | 1027 | mShowAll = showAll; |
1020 | mHeightValid = false; | 1028 | mHeightValid = false; |
1021 | } | 1029 | } |
1022 | 1030 | ||
1023 | 1031 | ||
1024 | 1032 | ||
1025 | KJanusWidget::IconListItem::IconListItem( QListBox *listbox, const QPixmap &pixmap, | 1033 | KJanusWidget::IconListItem::IconListItem( Q3ListBox *listbox, const QPixmap &pixmap, |
1026 | const QString &text ) | 1034 | const QString &text ) |
1027 | : QListBoxItem( listbox ) | 1035 | : Q3ListBoxItem( listbox ) |
1028 | { | 1036 | { |
1029 | mPixmap = pixmap; | 1037 | mPixmap = pixmap; |
1030 | if( mPixmap.isNull() == true ) | 1038 | if( mPixmap.isNull() == true ) |
1031 | { | 1039 | { |
1032 | mPixmap = defaultPixmap(); | 1040 | mPixmap = defaultPixmap(); |
1033 | } | 1041 | } |
1034 | setText( text ); | 1042 | setText( text ); |
1035 | mMinimumWidth = 0; | 1043 | mMinimumWidth = 0; |
1036 | } | 1044 | } |
1037 | 1045 | ||
1038 | 1046 | ||
1039 | int KJanusWidget::IconListItem::expandMinimumWidth( int width ) | 1047 | int KJanusWidget::IconListItem::expandMinimumWidth( int width ) |
1040 | { | 1048 | { |
1041 | mMinimumWidth = QMAX( mMinimumWidth, width ); | 1049 | mMinimumWidth = QMAX( mMinimumWidth, width ); |
1042 | return( mMinimumWidth ); | 1050 | return( mMinimumWidth ); |
1043 | } | 1051 | } |
@@ -1070,87 +1078,87 @@ const QPixmap &KJanusWidget::IconListItem::defaultPixmap() | |||
1070 | 1078 | ||
1071 | void KJanusWidget::IconListItem::paint( QPainter *painter ) | 1079 | void KJanusWidget::IconListItem::paint( QPainter *painter ) |
1072 | { | 1080 | { |
1073 | QFontMetrics fm = painter->fontMetrics(); | 1081 | QFontMetrics fm = painter->fontMetrics(); |
1074 | //int wt = fm.boundingRect(text()).width(); | 1082 | //int wt = fm.boundingRect(text()).width(); |
1075 | int wp = mPixmap.width(); | 1083 | int wp = mPixmap.width(); |
1076 | int ht = fm.lineSpacing(); | 1084 | int ht = fm.lineSpacing(); |
1077 | int hp = mPixmap.height(); | 1085 | int hp = mPixmap.height(); |
1078 | 1086 | ||
1079 | painter->drawPixmap( (mMinimumWidth-wp)/2, 5, mPixmap ); | 1087 | painter->drawPixmap( (mMinimumWidth-wp)/2, 5, mPixmap ); |
1080 | if( text().isEmpty() == false ) | 1088 | if( text().isEmpty() == false ) |
1081 | { | 1089 | { |
1082 | painter->drawText( 0, hp+7, mMinimumWidth, ht, Qt::AlignCenter, text() ); | 1090 | painter->drawText( 0, hp+7, mMinimumWidth, ht, Qt::AlignCenter, text() ); |
1083 | } | 1091 | } |
1084 | } | 1092 | } |
1085 | 1093 | ||
1086 | int KJanusWidget::IconListItem::height( const QListBox *lb ) const | 1094 | int KJanusWidget::IconListItem::height( const Q3ListBox *lb ) const |
1087 | { | 1095 | { |
1088 | if( text().isEmpty() == true ) | 1096 | if( text().isEmpty() == true ) |
1089 | { | 1097 | { |
1090 | return( mPixmap.height() ); | 1098 | return( mPixmap.height() ); |
1091 | } | 1099 | } |
1092 | else | 1100 | else |
1093 | { | 1101 | { |
1094 | return( mPixmap.height() + lb->fontMetrics().lineSpacing()+10 ); | 1102 | return( mPixmap.height() + lb->fontMetrics().lineSpacing()+10 ); |
1095 | } | 1103 | } |
1096 | } | 1104 | } |
1097 | 1105 | ||
1098 | 1106 | ||
1099 | int KJanusWidget::IconListItem::width( const QListBox *lb ) const | 1107 | int KJanusWidget::IconListItem::width( const Q3ListBox *lb ) const |
1100 | { | 1108 | { |
1101 | int wt = lb->fontMetrics().boundingRect(text()).width()+10; | 1109 | int wt = lb->fontMetrics().boundingRect(text()).width()+10; |
1102 | int wp = mPixmap.width() + 10; | 1110 | int wp = mPixmap.width() + 10; |
1103 | int w = QMAX( wt, wp ); | 1111 | int w = QMAX( wt, wp ); |
1104 | return( QMAX( w, mMinimumWidth ) ); | 1112 | return( QMAX( w, mMinimumWidth ) ); |
1105 | } | 1113 | } |
1106 | 1114 | ||
1107 | 1115 | ||
1108 | void KJanusWidget::virtual_hook( int, void* ) | 1116 | void KJanusWidget::virtual_hook( int, void* ) |
1109 | { /*BASE::virtual_hook( id, data );*/ } | 1117 | { /*BASE::virtual_hook( id, data );*/ } |
1110 | 1118 | ||
1111 | // TODO: In TreeList, if the last child of a node is removed, and there is no corrsponding widget for that node, allow the caller to | 1119 | // TODO: In TreeList, if the last child of a node is removed, and there is no corrsponding widget for that node, allow the caller to |
1112 | // delete the node. | 1120 | // delete the node. |
1113 | void KJanusWidget::removePage( QWidget *page ) | 1121 | void KJanusWidget::removePage( QWidget *page ) |
1114 | { | 1122 | { |
1115 | //US qDebug("KJanusWidget::removePage 1 %lu , %lu, %lu", d, page, &(d->mPageToInt)); | 1123 | //US qDebug("KJanusWidget::removePage 1 %lu , %lu, %lu", d, page, &(d->mPageToInt)); |
1116 | if (!d || !(d->mPageToInt.contains(page))) | 1124 | if (!d || !(d->mPageToInt.contains(page))) |
1117 | { | 1125 | { |
1118 | return; | 1126 | return; |
1119 | } | 1127 | } |
1120 | 1128 | ||
1121 | int index = d->mPageToInt[page]; | 1129 | int index = d->mPageToInt[page]; |
1122 | 1130 | ||
1123 | if ( mFace == TreeList ) | 1131 | if ( mFace == TreeList ) |
1124 | { | 1132 | { |
1125 | QMap<QListViewItem*, QWidget *>::Iterator i; | 1133 | QMap<Q3ListViewItem*, QWidget *>::Iterator i; |
1126 | for( i = mTreeListToPageStack.begin(); i != mTreeListToPageStack.end(); ++i ) | 1134 | for( i = mTreeListToPageStack.begin(); i != mTreeListToPageStack.end(); ++i ) |
1127 | if (i.data()==page) | 1135 | if (i.data()==page) |
1128 | { | 1136 | { |
1129 | delete i.key(); | 1137 | delete i.key(); |
1130 | mPageStack->removeWidget(page); | 1138 | mPageStack->removeWidget(page); |
1131 | mTreeListToPageStack.remove(i); | 1139 | mTreeListToPageStack.remove(i); |
1132 | d->mIntToTitle.remove(index); | 1140 | d->mIntToTitle.remove(index); |
1133 | d->mPageToInt.remove(page); | 1141 | d->mPageToInt.remove(page); |
1134 | d->mIntToPage.remove(index); | 1142 | d->mIntToPage.remove(index); |
1135 | break; | 1143 | break; |
1136 | } | 1144 | } |
1137 | } | 1145 | } |
1138 | else if ( mFace == IconList ) | 1146 | else if ( mFace == IconList ) |
1139 | { | 1147 | { |
1140 | QMap<QListBoxItem*, QWidget *>::Iterator i; | 1148 | QMap<Q3ListBoxItem*, QWidget *>::Iterator i; |
1141 | for( i = mIconListToPageStack.begin(); i != mIconListToPageStack.end(); ++i ) | 1149 | for( i = mIconListToPageStack.begin(); i != mIconListToPageStack.end(); ++i ) |
1142 | if (i.data()==page) | 1150 | if (i.data()==page) |
1143 | { | 1151 | { |
1144 | delete i.key(); | 1152 | delete i.key(); |
1145 | mPageStack->removeWidget(page); | 1153 | mPageStack->removeWidget(page); |
1146 | mIconListToPageStack.remove(i); | 1154 | mIconListToPageStack.remove(i); |
1147 | d->mIntToTitle.remove(index); | 1155 | d->mIntToTitle.remove(index); |
1148 | d->mPageToInt.remove(page); | 1156 | d->mPageToInt.remove(page); |
1149 | d->mIntToPage.remove(index); | 1157 | d->mIntToPage.remove(index); |
1150 | break; | 1158 | break; |
1151 | } | 1159 | } |
1152 | } | 1160 | } |
1153 | else // Tabbed | 1161 | else // Tabbed |
1154 | { | 1162 | { |
1155 | mTabControl->removePage(page); | 1163 | mTabControl->removePage(page); |
1156 | d->mPageToInt.remove(page); | 1164 | d->mPageToInt.remove(page); |