1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPkgProductDialog.cc
15 Author: Stefan Hundhammer <sh@suse.de>
17 Textdomain "packages-qt"
23 #define y2log_component "qt-pkg"
24 #include <ycp/y2log.h>
26 #include <qapplication.h>
27 #include <QtGui/qdesktopwidget.h>
31 #include <qpushbutton.h>
32 #include <qsplitter.h>
34 #include <qtabwidget.h>
35 #include <q3valuelist.h>
37 #include <q3boxlayout.h>
39 #include "YQPkgProductDialog.h"
40 #include "YQPkgProductList.h"
41 #include "YQPkgDependenciesView.h"
42 #include "QY2LayoutUtils.h"
47 #define SPACING 2 // between subwidgets
48 #define MARGIN 4 // around the widget
51 YQPkgProductDialog::YQPkgProductDialog( QWidget * parent )
55 setCaption( _( "Products" ) );
57 // Enable dialog resizing even without window manager
58 setSizeGripEnabled( true );
60 // Layout for the dialog (can't simply insert a QVBox)
62 Q3VBoxLayout * layout = new Q3VBoxLayout( this, MARGIN, SPACING );
63 Q_CHECK_PTR( layout );
68 QSplitter * splitter = new QSplitter( Qt::Vertical, this );
69 Q_CHECK_PTR( splitter );
70 layout->addWidget( splitter );
71 splitter->setMargin( MARGIN );
76 _productList = new YQPkgProductList( splitter );
77 Q_CHECK_PTR( _productList );
78 _productList->resize( _productList->width(), 80 );
80 // Prevent status changes for now - this would require solver runs etc.
81 _productList->setEditable( false );
84 // Tab widget for details views (looks better even just with one)
86 _detailsViews = new QTabWidget( splitter );
87 Q_CHECK_PTR( _detailsViews );
88 _detailsViews->setMargin( MARGIN );
89 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
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
98 connect( _productList, SIGNAL( currentItemChanged ( ZyppSel ) ),
99 _dependenciesView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
102 // Button box (to center the single button)
104 Q3HBox * hbox = new Q3HBox( this );
106 hbox->setSpacing( SPACING );
107 hbox->setMargin ( MARGIN );
108 layout->addWidget( hbox );
115 QPushButton * button = new QPushButton( _( "&OK" ), hbox );
116 Q_CHECK_PTR( button );
117 button->setDefault( true );
119 connect( button, SIGNAL( clicked() ),
120 this, SLOT ( accept() ) );
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"