]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgTechnicalDetailsView.cc
make the layout half way working at least
[duncan/yast2-qt4.git] / src / pkg / YQPkgTechnicalDetailsView.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgTechnicalDetailsView.cc
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17   Textdomain "packages-qt"
18
19 /-*/
20
21 #define QT3_SUPPORT 1
22
23 #define y2log_component "qt-pkg"
24 #include <ycp/y2log.h>
25
26 #include "YQPkgTechnicalDetailsView.h"
27 #include "YQi18n.h"
28 #include "utf8.h"
29 //Added by qt3to4:
30 #include <q3valuelist.h>
31
32 using std::list;
33 using std::string;
34
35
36 YQPkgTechnicalDetailsView::YQPkgTechnicalDetailsView( QWidget * parent )
37     : YQPkgGenericDetailsView( parent )
38 {
39 }
40
41
42 YQPkgTechnicalDetailsView::~YQPkgTechnicalDetailsView()
43 {
44     // NOP
45 }
46
47
48 void
49 YQPkgTechnicalDetailsView::showDetails( ZyppSel selectable )
50 {
51     _selectable = selectable;
52
53     if ( ! selectable )
54     {
55         clear();
56         return;
57     }
58
59     QString html_text = htmlHeading( selectable );
60
61     ZyppPkg candidate = tryCastToZyppPkg( selectable->candidateObj() );
62     ZyppPkg installed = tryCastToZyppPkg( selectable->installedObj() );
63
64     if ( candidate && installed && candidate != installed )
65     {
66         html_text += complexTable( selectable, installed, candidate );
67     }
68     else
69     {
70         if ( candidate )
71             html_text += simpleTable( selectable, candidate );
72
73         if ( installed )
74             html_text += simpleTable( selectable, installed );
75     }
76
77     setTextFormat( Qt::RichText );
78     setText( html_text );
79 }
80
81
82 QString
83 YQPkgTechnicalDetailsView::authorsListCell( ZyppPkg pkg ) const
84 {
85     QString html = "<td align=top>";
86     QString line;
87     list<string> authors = pkg->authors();
88     list<string>::const_iterator it = authors.begin();
89
90     while ( it != authors.end() )
91     {
92         line = fromUTF8( *it );
93         line = htmlEscape( line );
94         html += line + "<br>";
95         ++it;
96     }
97
98     html += "</td>";
99
100     return html;
101 }
102
103
104 QString
105 YQPkgTechnicalDetailsView::formatRpmGroup( ZyppPkg pkg ) const
106 {
107     QStringList groups = fromUTF8( pkg->group() ).split( '/', QString::KeepEmptyParts );
108
109     // Translate group path components
110
111     QStringList translated;
112
113     for ( QStringList::const_iterator it = groups.begin();
114           it != groups.end();
115           ++it )
116     {
117         translated.append( QString::fromUtf8( dgettext( "rpm-groups", (*it).utf8() ) ) );
118     }
119
120     return translated.join( "/" );
121 }
122
123
124 QString
125 YQPkgTechnicalDetailsView::simpleTable( ZyppSel selectable,
126                                         ZyppPkg         pkg )
127 {
128     QString html;
129
130     html += row( hcell( _( "Version:"           ) ) + cell( pkg->edition().asString()           ) );
131     html += row( hcell( _( "Build Time:"        ) ) + cell( pkg->buildtime()                    ) );
132
133     html +=
134         pkg == selectable->installedObj() ?
135         row( hcell( _( "Install Time:" ) ) + cell( pkg->installtime() ) ) : "";
136
137     html += row( hcell( _( "Package Group:"     ) ) + cell( formatRpmGroup( pkg )               ) );
138     html += row( hcell( _( "License:"           ) ) + cell( pkg->license()                      ) );
139     html += row( hcell( _( "Installed Size:"    ) ) + cell( pkg->size().asString()              ) );
140     html += row( hcell( _( "Download Size:"     ) ) + cell( pkg->downloadSize().asString()      ) );
141     html += row( hcell( _( "Distribution:"      ) ) + cell( pkg->distribution()                 ) );
142     html += row( hcell( _( "Vendor:"            ) ) + cell( pkg->vendor()                       ) );
143     html += row( hcell( _( "Packager:"          ) ) + cell( pkg->packager()                     ) );
144     html += row( hcell( _( "Architecture:"      ) ) + cell( pkg->arch().asString()              ) );
145     html += row( hcell( _( "OS:"                ) ) + cell( pkg->os()                           ) );
146     html += row( hcell( _( "Build Host:"        ) ) + cell( pkg->buildhost()                    ) );
147     html += row( hcell( _( "URL:"               ) ) + cell( pkg->url()                          ) );
148     
149 #ifdef FIXME_missing_in_zypp
150     html += row( hcell( _( "Source RPM:"        ) ) + cell( pkg->sourceloc()                    ) );
151 #endif
152     html += row( hcell( _( "Media No.:"         ) ) + cell( pkg->mediaNr()                      ) );
153     html += row( hcell( _( "Authors:"           ) ) + authorsListCell( pkg                      ) );
154     
155     html = "<br>" + table( html );
156
157     return html;
158 }
159
160
161 QString
162 YQPkgTechnicalDetailsView::complexTable( ZyppSel        selectable,
163                                          ZyppPkg        installed,
164                                          ZyppPkg        candidate )
165 {
166     ZyppPkg p1 = candidate;
167     ZyppPkg p2 = installed;
168
169     QString p1_header = _( "<b>Alternate Version</b>" );
170     QString p2_header = _( "<b>Installed Version</b>" );
171
172     QString html;
173
174     html += row( hcell( QString( "" ) )             + hcell( "<b>" + p1_header + "</b>"         ) + hcell( "<b>" + p2_header + "</b>"   ) );
175
176     html += row( hcell( _( "Version:"           ) ) + cell( p1->edition().asString()            ) + cell( p2->edition().asString()      ) );
177     html += row( hcell( _( "Build Time:"        ) ) + cell( p1->buildtime()                     ) + cell( p2->buildtime()               ) );
178     html += row( hcell( _( "Install Time:"      ) ) + cell( p1->installtime()                   ) + cell( p2->installtime()             ) );
179     html += row( hcell( _( "Package Group:"     ) ) + cell( formatRpmGroup( p1 )                ) + cell( formatRpmGroup( p2 )          ) );
180     html += row( hcell( _( "License:"           ) ) + cell( p1->license()                       ) + cell( p2->license()                 ) );
181     html += row( hcell( _( "Installed Size:"    ) ) + cell( p1->size().asString()               ) + cell( p2->size().asString()         ) );
182     html += row( hcell( _( "Download Size:"     ) ) + cell( p1->downloadSize().asString()       ) + cell( p2->downloadSize().asString() ) );
183     html += row( hcell( _( "Distribution:"      ) ) + cell( p1->distribution()                  ) + cell( p2->distribution()            ) );
184     html += row( hcell( _( "Vendor:"            ) ) + cell( p1->vendor()                        ) + cell( p2->vendor()                  ) );
185     html += row( hcell( _( "Packager:"          ) ) + cell( p1->packager()                      ) + cell( p2->packager()                ) );
186     html += row( hcell( _( "Architecture:"      ) ) + cell( p1->arch().asString()               ) + cell( p2->arch().asString()         ) );
187     html += row( hcell( _( "OS:"                ) ) + cell( p1->os()                            ) + cell( p2->os()                      ) );
188     html += row( hcell( _( "Build Host:"        ) ) + cell( p1->buildhost()                     ) + cell( p2->buildhost()               ) );
189     html += row( hcell( _( "URL:"               ) ) + cell( p1->url()                           ) + cell( p2->url()                     ) );
190 #ifdef FIXME_missing_in_zypp
191     html += row( hcell( _( "Source RPM:"        ) ) + cell( p1->sourceloc()                     ) + cell( p2->sourceloc()               ) );
192 #endif
193     html += row( hcell( _( "Media No.:"         ) ) + cell( p1->mediaNr()                       ) + cell( p2->mediaNr()                 ) );
194     html += row( hcell( _( "Authors:"           ) ) + authorsListCell( p1                       ) + authorsListCell( p2                 ) );
195
196
197     html = "<br>" + table( html );
198     
199     return html;
200 }
201
202
203 #include "YQPkgTechnicalDetailsView.moc"