]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgProductList.cc
2f26a51846f864a545012236736e7c88168477c1
[duncan/yast2-qt4.git] / src / pkg / YQPkgProductList.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgProductList.cc
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17   Textdomain "packages-qt"
18
19 /-*/
20
21
22 #define y2log_component "qt-pkg"
23 #include <ycp/y2log.h>
24
25 #include "YQi18n.h"
26 #include "utf8.h"
27
28 #include "YQPkgProductList.h"
29
30 using std::list;
31 using std::set;
32
33
34 YQPkgProductList::YQPkgProductList( QWidget * parent )
35     : YQPkgObjList( parent )
36     , _vendorCol( -42 )
37 {
38     y2debug( "Creating product list" );
39
40     int numCol = 0;
41     addColumn( "" );                    _statusCol      = numCol++;
42     addColumn( _( "Product"     ) );    _nameCol        = numCol++;
43     addColumn( _( "Summary"     ) );    _summaryCol     = numCol++;
44     addColumn( _( "Version"     ) );    _versionCol     = numCol++;
45     addColumn( _( "Vendor"      ) );    _vendorCol      = numCol++;
46     setAllColumnsShowFocus( true );
47     setColumnAlignment( sizeCol(), Qt::AlignRight );
48
49     setSorting( nameCol() );
50     fillList();
51     selectSomething();
52
53     y2debug( "Creating product list done" );
54 }
55
56
57 YQPkgProductList::~YQPkgProductList()
58 {
59     // NOP
60 }
61
62
63 void
64 YQPkgProductList::fillList()
65 {
66     clear();
67     y2debug( "Filling product list" );
68
69     for ( ZyppPoolIterator it = zyppProductsBegin();
70           it != zyppProductsEnd();
71           ++it )
72     {
73         ZyppProduct zyppProduct = tryCastToZyppProduct( (*it)->theObj() );
74
75         if ( zyppProduct )
76         {
77             addProductItem( *it, zyppProduct );
78         }
79         else
80         {
81             y2error( "Found non-product selectable" );
82         }
83     }
84
85     y2debug( "product list filled" );
86 }
87
88
89 void
90 YQPkgProductList::addProductItem( ZyppSel       selectable,
91                                   ZyppProduct   zyppProduct )
92 {
93     if ( ! selectable )
94     {
95         y2error( "NULL ZyppSel!" );
96         return;
97     }
98
99     new YQPkgProductListItem( this, selectable, zyppProduct );
100 }
101
102
103
104
105
106
107 YQPkgProductListItem::YQPkgProductListItem( YQPkgProductList *  productList,
108                                             ZyppSel             selectable,
109                                             ZyppProduct         zyppProduct )
110     : YQPkgObjListItem( productList, selectable, zyppProduct )
111     , _productList( productList )
112     , _zyppProduct( zyppProduct )
113 {
114     if ( ! _zyppProduct )
115         _zyppProduct = tryCastToZyppProduct( selectable->theObj() );
116
117     if ( ! _zyppProduct )
118         return;
119
120     setStatusIcon();
121
122     if ( vendorCol() > -1 )
123         setText( vendorCol(), zyppProduct->vendor() );
124
125 }
126
127
128 YQPkgProductListItem::~YQPkgProductListItem()
129 {
130     // NOP
131 }
132
133
134
135
136 void
137 YQPkgProductListItem::applyChanges()
138 {
139     solveResolvableCollections();
140 }
141
142
143
144 #include "YQPkgProductList.moc"