1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPkgProductDialog.cc
15 Author: Stefan Hundhammer <sh@suse.de>
17 Textdomain "packages-qt"
22 #define y2log_component "qt-pkg"
23 #include <ycp/y2log.h>
25 #include <qapplication.h>
26 #include <QtGui/qdesktopwidget.h>
30 #include <qpushbutton.h>
31 #include <qsplitter.h>
33 #include <qtabwidget.h>
34 #include <q3valuelist.h>
36 #include <q3boxlayout.h>
38 #include "YQPkgProductDialog.h"
39 #include "YQPkgProductList.h"
40 #include "YQPkgDependenciesView.h"
41 #include "QY2LayoutUtils.h"
46 #define SPACING 2 // between subwidgets
47 #define MARGIN 4 // around the widget
50 YQPkgProductDialog::YQPkgProductDialog( QWidget * parent )
54 setCaption( _( "Products" ) );
56 // Enable dialog resizing even without window manager
57 setSizeGripEnabled( true );
59 // Layout for the dialog (can't simply insert a QVBox)
61 Q3VBoxLayout * layout = new Q3VBoxLayout( this, MARGIN, SPACING );
62 Q_CHECK_PTR( layout );
67 QSplitter * splitter = new QSplitter( Qt::Vertical, this );
68 Q_CHECK_PTR( splitter );
69 layout->addWidget( splitter );
70 splitter->setMargin( MARGIN );
75 _productList = new YQPkgProductList( splitter );
76 Q_CHECK_PTR( _productList );
77 _productList->resize( _productList->width(), 80 );
79 // Prevent status changes for now - this would require solver runs etc.
80 _productList->setEditable( false );
83 // Tab widget for details views (looks better even just with one)
85 _detailsViews = new QTabWidget( splitter );
86 Q_CHECK_PTR( _detailsViews );
87 _detailsViews->setMargin( MARGIN );
88 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
92 _dependenciesView = new YQPkgDependenciesView( _detailsViews );
93 Q_CHECK_PTR( _dependenciesView );
94 _detailsViews->addTab( _dependenciesView, _( "Dependencies" ) );
95 _dependenciesView->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
97 connect( _productList, SIGNAL( selectionChanged ( ZyppSel ) ),
98 _dependenciesView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
101 // Button box (to center the single button)
103 Q3HBox * hbox = new Q3HBox( this );
105 hbox->setSpacing( SPACING );
106 hbox->setMargin ( MARGIN );
107 layout->addWidget( hbox );
114 QPushButton * button = new QPushButton( _( "&OK" ), hbox );
115 Q_CHECK_PTR( button );
116 button->setDefault( true );
118 connect( button, SIGNAL( clicked() ),
119 this, SLOT ( accept() ) );
126 YQPkgProductDialog::polish()
128 // Delayed initialization after widget is fully created etc.
130 // Only now send selectionChanged() signal so the details views display something
131 // (showDetailsIfVisible() shows only something if the widget is visible,
132 // as the method name implies)
133 _productList->selectSomething();
138 YQPkgProductDialog::sizeHint() const
140 QRect available = qApp->desktop()->availableGeometry( (QWidget *) this );
141 QSize size = QDialog::sizeHint();
142 size = size.boundedTo( QSize( available.width(), available.height() ) );
149 YQPkgProductDialog::showProductDialog()
151 YQPkgProductDialog dialog( 0 );
158 #include "YQPkgProductDialog.moc"