]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQSimplePatchSelector.cc
more porting and make files use qt3support one by one
[duncan/yast2-qt4.git] / src / pkg / YQSimplePatchSelector.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQSimplePatchSelector.cc
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17   Textdomain "packages-qt"
18
19 /-*/
20
21 #define QT3_SUPPORT 1
22
23 #include <qapplication.h>
24 #include <q3hbox.h>
25 #include <q3header.h>
26 #include <qpushbutton.h>
27 #include <qsplitter.h>
28
29 #define y2log_component "qt-pkg"
30 #include <ycp/y2log.h>
31
32 #include "QY2LayoutUtils.h"
33
34 #include "YQSimplePatchSelector.h"
35 #include "YQPkgConflictDialog.h"
36 #include "YQPkgDiskUsageList.h"
37 #include "YQPkgPatchFilterView.h"
38 #include "YQPkgPatchList.h"
39 #include "YQWizard.h"
40 #include "YQDialog.h"
41
42 #include "utf8.h"
43 #include "YQUI.h"
44 #include "YEvent.h"
45 #include "YQi18n.h"
46
47
48 using std::max;
49 using std::string;
50
51 #define SHOW_DISK_USAGE         0
52
53 #define SPACING                 6
54 #define MARGIN                  6
55
56
57
58 YQSimplePatchSelector::YQSimplePatchSelector( YWidget * parent, long modeFlags )
59     : YQPackageSelectorBase( parent, modeFlags )
60 {
61     _patchFilterView    = 0;
62     _patchList          = 0;
63     _diskUsageList      = 0;
64     _wizard             = findWizard();
65
66     basicLayout();
67     makeConnections();
68
69 #if 0
70     _patchList->fillList();
71     _patchList->selectSomething();
72 #endif
73
74     if ( _diskUsageList )
75         _diskUsageList->updateDiskUsage();
76 }
77
78
79
80 YQWizard *
81 YQSimplePatchSelector::findWizard() const
82 {
83     YQWizard * wizard = 0;
84
85     YQDialog * dialog = dynamic_cast<YQDialog *> ( YDialog::currentDialog() );
86
87     if ( dialog )
88         wizard = dialog->findWizard();
89
90     return wizard;
91 }
92
93
94
95 void
96 YQSimplePatchSelector::basicLayout()
97 {
98     QSplitter * splitter = new QSplitter( Qt::Vertical, this );
99     Q_CHECK_PTR( splitter );
100     splitter->setMargin( MARGIN );
101
102     //
103     // PatchFilterView
104     //
105
106     Q3VBox * upper_vbox = new Q3VBox( splitter );
107     Q_CHECK_PTR( upper_vbox );
108     splitter->setResizeMode( upper_vbox, QSplitter::Stretch );
109
110     _patchFilterView = new YQPkgPatchFilterView( upper_vbox );
111     Q_CHECK_PTR( _patchFilterView );
112     
113     _patchList = _patchFilterView->patchList();
114     Q_CHECK_PTR( _patchList );
115     
116     addVSpacing( upper_vbox, MARGIN );
117
118     //
119     // Disk Usage
120     //
121
122
123 #if SHOW_DISK_USAGE
124     Q3VBox * lower_vbox = new Q3VBox( splitter );
125     Q_CHECK_PTR( lower_vbox );
126     addVSpacing( lower_vbox, MARGIN );
127
128     _diskUsageList = new YQPkgDiskUsageList( lower_vbox );
129     Q_CHECK_PTR( _diskUsageList );
130     
131     splitter->setResizeMode( lower_vbox, QSplitter::FollowSizeHint );
132 #endif
133
134
135     //
136     // Buttons
137     //
138     
139     if ( _wizard )      // No button box - add "Details..." button here
140     {
141         //
142         // "Details" button
143         //
144
145         addVSpacing( this, SPACING );
146
147         Q3HBox * hbox = new Q3HBox( this );
148         Q_CHECK_PTR( hbox );
149
150         QPushButton * details_button = new QPushButton( _( "&Details..." ), hbox );
151         Q_CHECK_PTR( details_button );
152
153         connect( details_button, SIGNAL( clicked() ),
154                  this,           SLOT  ( detailedPackageSelection() ) );
155
156         addHStretch( hbox );
157     }
158     else // ! _wizard
159     {
160         layoutButtons( this );
161     }
162 }
163
164
165 void
166 YQSimplePatchSelector::layoutButtons( QWidget * parent )
167 {
168     Q3HBox * button_box = new Q3HBox( parent );
169     Q_CHECK_PTR( button_box );
170     button_box->setMargin ( MARGIN  );
171     button_box->setSpacing( SPACING );
172
173
174     QPushButton * details_button = new QPushButton( _( "&Details..." ), button_box );
175     Q_CHECK_PTR( details_button );
176     details_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
177
178     connect( details_button,    SIGNAL( clicked() ),
179              this,              SLOT  ( detailedPackageSelection() ) );
180
181
182     addHStretch( button_box );
183
184     QPushButton * cancel_button = new QPushButton( _( "&Cancel" ), button_box );
185     Q_CHECK_PTR( cancel_button );
186     cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
187
188     connect( cancel_button, SIGNAL( clicked() ),
189              this,          SLOT  ( reject()   ) );
190
191
192     QPushButton * accept_button = new QPushButton( _( "&Accept" ), button_box );
193     Q_CHECK_PTR( accept_button );
194     accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
195
196     connect( accept_button, SIGNAL( clicked() ),
197              this,          SLOT  ( accept()   ) );
198
199     button_box->setFixedHeight( button_box->sizeHint().height() );
200 }
201
202
203
204 void
205 YQSimplePatchSelector::makeConnections()
206 {
207     if ( _patchList && _diskUsageList )
208     {
209         connect( _patchList,     SIGNAL( updatePackages()  ),
210                  _diskUsageList, SLOT  ( updateDiskUsage() ) );
211     }
212
213     y2milestone( "Connection set up" );
214
215     if ( _wizard )
216     {
217         connect( _wizard,       SIGNAL( nextClicked()   ),
218                  this,          SLOT  ( accept()        ) );
219
220         connect( _wizard,       SIGNAL( backClicked()   ),
221                  this,          SLOT  ( reject()        ) );
222
223         connect( _wizard,       SIGNAL( abortClicked()  ),
224                  this,          SLOT  ( reject()        ) );
225     }
226 }
227
228
229 void
230 YQSimplePatchSelector::detailedPackageSelection()
231 {
232     y2milestone( "\"Details..\" button clicked" );
233     YQUI::ui()->sendEvent( new YMenuEvent( YCPSymbol( "details" ) ) );
234 }
235
236
237 void
238 YQSimplePatchSelector::debugTrace()
239 {
240     y2warning( "debugTrace" );
241 }
242
243
244
245 #include "YQSimplePatchSelector.moc"