1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPkgProductDialog.cc
15 Author: Stefan Hundhammer <sh@suse.de>
17 Textdomain "packages-qt"
21 #define y2log_component "qt-pkg"
22 #include <ycp/y2log.h>
24 #include <QApplication>
25 #include <QtGui/qdesktopwidget.h>
26 #include <QHBoxLayout>
29 #include <QPushButton>
36 #include "YQPkgProductDialog.h"
37 #include "YQPkgProductList.h"
38 #include "YQPkgDependenciesView.h"
39 #include "QY2LayoutUtils.h"
44 #define SPACING 2 // between subwidgets
45 #define MARGIN 4 // around the widget
48 YQPkgProductDialog::YQPkgProductDialog( QWidget * parent )
52 setWindowTitle( _( "Products" ) );
54 // Enable dialog resizing even without window manager
55 setSizeGripEnabled( true );
57 // Layout for the dialog (can't simply insert a QVBox)
59 QVBoxLayout * layout = new QVBoxLayout( this );
60 layout->setSpacing( SPACING );
61 layout->setMargin ( MARGIN );
62 Q_CHECK_PTR( layout );
67 QSplitter * splitter = new QSplitter( Qt::Vertical, this );
68 Q_CHECK_PTR( splitter );
69 layout->addWidget( splitter );
70 layout->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( currentItemChanged ( ZyppSel ) ),
98 _dependenciesView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
101 // Button box (to center the single button)
103 QHBoxLayout * hbox = new QHBoxLayout( this );
105 hbox->setSpacing( SPACING );
106 hbox->setMargin ( MARGIN );
107 layout->addLayout( hbox );
109 //addHStretch( hbox );
114 QPushButton * button = new QPushButton( _( "&OK" ), this );
115 hbox->addWidget(button);
116 Q_CHECK_PTR( button );
117 button->setDefault( true );
119 connect( button, SIGNAL( clicked() ),
120 this, SLOT ( accept() ) );
122 //addHStretch( hbox );
127 YQPkgProductDialog::polish()
129 // Delayed initialization after widget is fully created etc.
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();
139 YQPkgProductDialog::sizeHint() const
141 QRect available = qApp->desktop()->availableGeometry( (QWidget *) this );
142 QSize size = QDialog::sizeHint();
143 size = size.boundedTo( QSize( available.width(), available.height() ) );
150 YQPkgProductDialog::showProductDialog()
152 YQPkgProductDialog dialog( 0 );
159 #include "YQPkgProductDialog.moc"