1 | /* |
2 | Copyright (c) 2009 Volker Krause <vkrause@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or modify it |
5 | under the terms of the GNU Library General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or (at your |
7 | option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, but WITHOUT |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
12 | License for more details. |
13 | |
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 the |
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | 02110-1301, USA. |
18 | */ |
19 | |
20 | #include "dynamicpage.h" |
21 | |
22 | #include <KDebug> |
23 | |
24 | #include <QUiLoader> |
25 | #include <QFile> |
26 | #include <qboxlayout.h> |
27 | #include <qscrollarea.h> |
28 | |
29 | DynamicPage::DynamicPage(const QString& uiFile, KAssistantDialog* parent) : Page( parent ) |
30 | { |
31 | QVBoxLayout *layout = new QVBoxLayout; |
32 | layout->setMargin( 0 ); |
33 | setLayout( layout ); |
34 | |
35 | #ifdef KDEPIM_MOBILE_UI |
36 | // for mobile ui we put the page into a scroll area in case it's too big |
37 | QScrollArea *pageParent = new QScrollArea( this ); |
38 | pageParent->setFrameShape( QFrame::NoFrame ); |
39 | pageParent->setWidgetResizable( true ); |
40 | layout->addWidget( pageParent ); |
41 | #else |
42 | QWidget *pageParent = this; |
43 | #endif |
44 | |
45 | QUiLoader loader; |
46 | QFile file( uiFile ); |
47 | file.open( QFile::ReadOnly ); |
48 | kDebug() << uiFile; |
49 | m_dynamicWidget = loader.load( &file, pageParent ); |
50 | file.close(); |
51 | |
52 | #ifdef KDEPIM_MOBILE_UI |
53 | pageParent->setWidget( m_dynamicWidget ); |
54 | #else |
55 | layout->addWidget( m_dynamicWidget ); |
56 | #endif |
57 | |
58 | setValid( true ); |
59 | } |
60 | |
61 | QObject* DynamicPage::widget() const |
62 | { |
63 | return m_dynamicWidget; |
64 | } |
65 | |
66 | |