libyui-qt-pkg  2.45.15.2
YQPkgProductList.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: YQPkgProductList.cc
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38  Textdomain "qt-pkg"
39 
40 /-*/
41 
42 
43 #define YUILogComponent "qt-pkg"
44 #include "YUILog.h"
45 
46 #include "YQi18n.h"
47 #include "utf8.h"
48 
49 #include "YQPkgProductList.h"
50 
51 using std::list;
52 using std::endl;
53 using std::set;
54 
55 
57  : YQPkgObjList( parent )
58  , _vendorCol( -42 )
59 {
60  yuiDebug() << "Creating product list" << endl;
61 
62  QStringList headers;
63  int numCol = 0;
64  headers << ( "" ); _statusCol = numCol++;
65  headers << _( "Product" ); _nameCol = numCol++;
66  headers << _( "Summary" ); _summaryCol = numCol++;
67  headers << _( "Version" ); _versionCol = numCol++;
68  headers << _( "Vendor" ); _vendorCol = numCol++;
69 
70  setColumnCount( numCol );
71  setHeaderLabels(headers);
72 
73  setAllColumnsShowFocus( true );
74  //setColumnAlignment( sizeCol(), Qt::AlignRight );
75 
76  setSortingEnabled( true );
77  sortByColumn( nameCol(), Qt::AscendingOrder );
78 
79 
80 
81  fillList();
82  selectSomething();
83 
84  yuiDebug() << "Creating product list done" << endl;
85 }
86 
87 
89 {
90  // NOP
91 }
92 
93 
94 void
96 {
97  clear();
98  yuiDebug() << "Filling product list" << endl;
99 
100  for ( ZyppPoolIterator it = zyppProductsBegin();
101  it != zyppProductsEnd();
102  ++it )
103  {
104  ZyppProduct zyppProduct = tryCastToZyppProduct( (*it)->theObj() );
105 
106  if ( zyppProduct )
107  {
108  addProductItem( *it, zyppProduct );
109  }
110  else
111  {
112  yuiError() << "Found non-product selectable" << endl;
113  }
114  }
115 
116  yuiDebug() << "product list filled" << endl;
117  resizeColumnToContents(_statusCol);
118 }
119 
120 
121 void
123  ZyppProduct zyppProduct )
124 {
125  if ( ! selectable )
126  {
127  yuiError() << "NULL ZyppSel!" << endl;
128  return;
129  }
130 
131  new YQPkgProductListItem( this, selectable, zyppProduct );
132 }
133 
134 
135 
136 
137 
138 
140  ZyppSel selectable,
141  ZyppProduct zyppProduct )
142  : YQPkgObjListItem( productList, selectable, zyppProduct )
143  , _productList( productList )
144  , _zyppProduct( zyppProduct )
145 {
146  if ( ! _zyppProduct )
147  _zyppProduct = tryCastToZyppProduct( selectable->theObj() );
148 
149  if ( ! _zyppProduct )
150  return;
151 
152  setStatusIcon();
153 
154  if ( vendorCol() > -1 )
155  setText( vendorCol(), zyppProduct->vendor() );
156 
157 }
158 
159 
161 {
162  // NOP
163 }
164 
165 
166 
167 
168 void
170 {
172 }
173 
174 
175 
176 #include "YQPkgProductList.moc"
virtual void applyChanges()
Propagate status changes in this list to other lists: Have the solver transact all products...
Abstract base class to display a list of zypp::ResObjects.
Definition: YQPkgObjList.h:68
void setText(int column, const string text)
Set a column text via STL string.
virtual ~YQPkgProductList()
Destructor.
virtual void clear()
Reimplemented from QY2ListView: Emit currentItemChanged() signal after clearing the list...
YQPkgProductListItem(YQPkgProductList *productList, ZyppSel selectable, ZyppProduct zyppProduct)
Constructor.
void fillList()
Fill the product list.
YQPkgProductList(QWidget *parent)
Constructor.
ZyppProduct zyppProduct() const
Returns the original zyppProduct object.
virtual ~YQPkgProductListItem()
Destructor.
ZyppSel selectable() const
Returns the original selectable within the package manager backend.
Definition: YQPkgObjList.h:466
Display a list of zypp::Product objects.
void solveResolvableCollections()
Do a "small" solver run for all "resolvable collections", i.e., for selections, patterns, languages, patches.
void addProductItem(ZyppSel selectable, ZyppProduct zyppProduct)
Add a product to the list.
virtual void setStatusIcon()
Set a status icon according to the package&#39;s status.