]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgProductList.cc
- Don't create layouts with parent. Qt 4.x automatically reparents
[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 #if FIXME
42     addColumn( "" );                    _statusCol      = numCol++;
43     addColumn( _( "Product"     ) );    _nameCol        = numCol++;
44     addColumn( _( "Summary"     ) );    _summaryCol     = numCol++;
45     addColumn( _( "Version"     ) );    _versionCol     = numCol++;
46     addColumn( _( "Vendor"      ) );    _vendorCol      = numCol++;
47     setAllColumnsShowFocus( true );
48     setColumnAlignment( sizeCol(), Qt::AlignRight );
49
50     setSorting( nameCol() );
51     fillList();
52     selectSomething();
53 #endif
54
55     y2debug( "Creating product list done" );
56 }
57
58
59 YQPkgProductList::~YQPkgProductList()
60 {
61     // NOP
62 }
63
64
65 void
66 YQPkgProductList::fillList()
67 {
68     clear();
69     y2debug( "Filling product list" );
70
71     for ( ZyppPoolIterator it = zyppProductsBegin();
72           it != zyppProductsEnd();
73           ++it )
74     {
75         ZyppProduct zyppProduct = tryCastToZyppProduct( (*it)->theObj() );
76
77         if ( zyppProduct )
78         {
79             addProductItem( *it, zyppProduct );
80         }
81         else
82         {
83             y2error( "Found non-product selectable" );
84         }
85     }
86
87     y2debug( "product list filled" );
88 }
89
90
91 void
92 YQPkgProductList::addProductItem( ZyppSel       selectable,
93                                   ZyppProduct   zyppProduct )
94 {
95     if ( ! selectable )
96     {
97         y2error( "NULL ZyppSel!" );
98         return;
99     }
100
101     new YQPkgProductListItem( this, selectable, zyppProduct );
102 }
103
104
105
106
107
108
109 YQPkgProductListItem::YQPkgProductListItem( YQPkgProductList *  productList,
110                                             ZyppSel             selectable,
111                                             ZyppProduct         zyppProduct )
112     : YQPkgObjListItem( productList, selectable, zyppProduct )
113     , _productList( productList )
114     , _zyppProduct( zyppProduct )
115 {
116     if ( ! _zyppProduct )
117         _zyppProduct = tryCastToZyppProduct( selectable->theObj() );
118
119     if ( ! _zyppProduct )
120         return;
121
122     setStatusIcon();
123
124     if ( vendorCol() > -1 )
125         setText( vendorCol(), zyppProduct->vendor() );
126
127 }
128
129
130 YQPkgProductListItem::~YQPkgProductListItem()
131 {
132     // NOP
133 }
134
135
136
137
138 void
139 YQPkgProductListItem::applyChanges()
140 {
141     solveResolvableCollections();
142 }
143
144
145
146 #include "YQPkgProductList.moc"