libyui-qt-pkg  2.44.7
 All Classes Functions Variables Enumerations
YQPkgProductDialog.cc
1 /**************************************************************************
2 Copyright (C) 2000 - 2010 Novell, Inc.
3 All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 
19 **************************************************************************/
20 
21 
22 /*---------------------------------------------------------------------\
23 | |
24 | __ __ ____ _____ ____ |
25 | \ \ / /_ _/ ___|_ _|___ \ |
26 | \ V / _` \___ \ | | __) | |
27 | | | (_| |___) || | / __/ |
28 | |_|\__,_|____/ |_| |_____| |
29 | |
30 | core system |
31 | (C) SuSE GmbH |
32 \----------------------------------------------------------------------/
33 
34  File: YQPkgProductDialog.cc
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38  Textdomain "qt-pkg"
39 
40 /-*/
41 
42 #define YUILogComponent "qt-pkg"
43 #include "YUILog.h"
44 
45 #include <QApplication>
46 #include <qdesktopwidget.h>
47 #include <QHBoxLayout>
48 #include <QLabel>
49 #include <QLayout>
50 #include <QPushButton>
51 #include <QSplitter>
52 #include <QStyle>
53 #include <QTabWidget>
54 #include <QList>
55 #include <QBoxLayout>
56 
57 #include "YQPkgProductDialog.h"
58 #include "YQPkgProductList.h"
59 #include "YQPkgDependenciesView.h"
60 #include "QY2LayoutUtils.h"
61 #include "YQi18n.h"
62 #include "YQUI.h"
63 
64 
65 #define SPACING 2 // between subwidgets
66 #define MARGIN 4 // around the widget
67 
68 
70  : QDialog( parent )
71 {
72  // Dialog title
73  setWindowTitle( _( "Products" ) );
74 
75  // Enable dialog resizing even without window manager
76  setSizeGripEnabled( true );
77 
78  // Layout for the dialog (can't simply insert a QVBox)
79 
80  QVBoxLayout * layout = new QVBoxLayout();
81  Q_CHECK_PTR( layout );
82  setLayout(layout);
83  layout->setSpacing( SPACING );
84  layout->setMargin ( MARGIN );
85 
86  // VBox for splitter
87 
88  QSplitter * splitter = new QSplitter( Qt::Vertical, this );
89  Q_CHECK_PTR( splitter );
90  layout->addWidget( splitter );
91  layout->setMargin( MARGIN );
92 
93 
94  // Product list
95 
96  _productList = new YQPkgProductList( splitter );
97  Q_CHECK_PTR( _productList );
98  _productList->resize( _productList->width(), 80 );
99 
100  // Prevent status changes for now - this would require solver runs etc.
101  _productList->setEditable( false );
102 
103 
104  // Tab widget for details views (looks better even just with one)
105 
106  _detailsViews = new QTabWidget( splitter );
107  Q_CHECK_PTR( _detailsViews );
108  //_detailsViews->setMargin( MARGIN );
109  _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
110 
111  // Dependencies view
112 
113  _dependenciesView = new YQPkgDependenciesView( _detailsViews );
114  Q_CHECK_PTR( _dependenciesView );
115  _detailsViews->addTab( _dependenciesView, _( "Dependencies" ) );
116  _dependenciesView->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
117 
118  connect( _productList, SIGNAL( currentItemChanged ( ZyppSel ) ),
119  _dependenciesView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
120 
121 
122  // Button box (to center the single button)
123 
124  QHBoxLayout * hbox = new QHBoxLayout();
125  Q_CHECK_PTR( hbox );
126  hbox->setSpacing( SPACING );
127  hbox->setMargin ( MARGIN );
128  layout->addLayout( hbox );
129 
130  //addHStretch( hbox );
131 
132 
133  // "OK" button
134 
135  QPushButton * button = new QPushButton( _( "&OK" ), this );
136  hbox->addWidget(button);
137  Q_CHECK_PTR( button );
138  button->setDefault( true );
139 
140  connect( button, SIGNAL( clicked() ),
141  this, SLOT ( accept() ) );
142 
143  //addHStretch( hbox );
144 }
145 
146 
147 void
149 {
150  // Delayed initialization after widget is fully created etc.
151 
152  // Only now send currentItemChanged() signal so the details views display something
153  // (showDetailsIfVisible() shows only something if the widget is visible,
154  // as the method name implies)
155  _productList->selectSomething();
156 }
157 
158 
159 QSize
161 {
162  QRect available = qApp->desktop()->availableGeometry( (QWidget *) this );
163  QSize size = QDialog::sizeHint();
164  size = size.boundedTo( QSize( available.width(), available.height() ) );
165 
166  return size;
167 }
168 
169 
170 void
172 {
173  YQPkgProductDialog dialog( parent );
174  dialog.exec();
175 }
176 
177 
178 
179 
180 #include "YQPkgProductDialog.moc"
YQPkgProductDialog(QWidget *parent)
Constructor: Creates a description dialog for all packages that match 'pkgName'.
void setEditable(bool editable=true)
Set the list's editable status.
Definition: YQPkgObjList.h:115
virtual void polish()
Delayed initialization after the dialog is fully created.
virtual QSize sizeHint() const
Returns the preferred size.
Products list with dependencies details view.
Display a list of zypp::Product objects.
static void showProductDialog(QWidget *parent=0)
Static convenience method: Post a dialog with all products.
Display technical details ( very much like 'rpm -qi' ) for a zypp::Package object - the installed ins...