]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgProductDialog.cc
restoring the green - do not set the style by default though
[duncan/yast2-qt4.git] / src / pkg / YQPkgProductDialog.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgProductDialog.cc
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17   Textdomain "packages-qt"
18
19 /-*/
20
21 #define QT3_SUPPORT 1
22
23 #define y2log_component "qt-pkg"
24 #include <ycp/y2log.h>
25
26 #include <qapplication.h>
27 #include <QtGui/qdesktopwidget.h>
28 #include <q3hbox.h>
29 #include <qlabel.h>
30 #include <qlayout.h>
31 #include <qpushbutton.h>
32 #include <qsplitter.h>
33 #include <qstyle.h>
34 #include <qtabwidget.h>
35 #include <q3valuelist.h>
36 //Added by qt3to4:
37 #include <q3boxlayout.h>
38
39 #include "YQPkgProductDialog.h"
40 #include "YQPkgProductList.h"
41 #include "YQPkgDependenciesView.h"
42 #include "QY2LayoutUtils.h"
43 #include "YQi18n.h"
44 #include "YQUI.h"
45
46
47 #define SPACING                 2       // between subwidgets
48 #define MARGIN                  4       // around the widget
49
50
51 YQPkgProductDialog::YQPkgProductDialog( QWidget * parent )
52     : QDialog( parent )
53 {
54     // Dialog title
55     setCaption( _( "Products" ) );
56
57     // Enable dialog resizing even without window manager
58     setSizeGripEnabled( true );
59
60     // Layout for the dialog (can't simply insert a QVBox)
61
62     Q3VBoxLayout * layout = new Q3VBoxLayout( this, MARGIN, SPACING );
63     Q_CHECK_PTR( layout );
64
65
66     // VBox for splitter
67
68     QSplitter * splitter = new QSplitter( Qt::Vertical, this );
69     Q_CHECK_PTR( splitter );
70     layout->addWidget( splitter );
71     splitter->setMargin( MARGIN );
72
73
74     // Product list
75
76     _productList = new YQPkgProductList( splitter );
77     Q_CHECK_PTR( _productList );
78     _productList->resize( _productList->width(), 80 );
79
80     // Prevent status changes for now - this would require solver runs etc.
81     _productList->setEditable( false );
82
83
84     // Tab widget for details views (looks better even just with one)
85
86     _detailsViews = new QTabWidget( splitter );
87     Q_CHECK_PTR( _detailsViews );
88     _detailsViews->setMargin( MARGIN );
89     _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
90
91     // Dependencies view
92
93     _dependenciesView = new YQPkgDependenciesView( _detailsViews );
94     Q_CHECK_PTR( _dependenciesView );
95     _detailsViews->addTab( _dependenciesView, _( "Dependencies" ) );
96     _dependenciesView->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
97
98     connect( _productList,      SIGNAL( currentItemChanged    ( ZyppSel ) ),
99              _dependenciesView, SLOT  ( showDetailsIfVisible( ZyppSel ) ) );
100
101
102     // Button box (to center the single button)
103
104     Q3HBox * hbox = new Q3HBox( this );
105     Q_CHECK_PTR( hbox );
106     hbox->setSpacing( SPACING );
107     hbox->setMargin ( MARGIN  );
108     layout->addWidget( hbox );
109
110     addHStretch( hbox );
111
112
113     // "OK" button
114
115     QPushButton * button = new QPushButton( _( "&OK" ), hbox );
116     Q_CHECK_PTR( button );
117     button->setDefault( true );
118
119     connect( button,    SIGNAL( clicked() ),
120              this,      SLOT  ( accept()  ) );
121
122     addHStretch( hbox );
123 }
124
125
126 void
127 YQPkgProductDialog::polish()
128 {
129     // Delayed initialization after widget is fully created etc.
130
131     // Only now send currentItemChanged() signal so the details views display something
132     // (showDetailsIfVisible() shows only something if the widget is visible,
133     // as the method name implies)
134     _productList->selectSomething();
135 }
136
137
138 QSize
139 YQPkgProductDialog::sizeHint() const
140 {
141     QRect available = qApp->desktop()->availableGeometry( (QWidget *) this );
142     QSize size = QDialog::sizeHint();
143     size = size.boundedTo( QSize( available.width(), available.height() ) );
144
145     return size;
146 }
147
148
149 void
150 YQPkgProductDialog::showProductDialog()
151 {
152     YQPkgProductDialog dialog( 0 );
153     dialog.exec();
154 }
155
156
157
158
159 #include "YQPkgProductDialog.moc"