libyui-qt-pkg  2.45.6
 All Classes Functions Variables Enumerations
YQPkgTechnicalDetailsView.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: YQPkgTechnicalDetailsView.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 "YQPkgTechnicalDetailsView.h"
46 #include "YQi18n.h"
47 #include "utf8.h"
48 //Added by qt3to4:
49 #include <QList>
50 
51 using std::list;
52 using std::string;
53 
54 
56  : YQPkgGenericDetailsView( parent )
57 {
58 }
59 
60 
62 {
63  // NOP
64 }
65 
66 
67 void
69 {
70  _selectable = selectable;
71 
72  if ( ! selectable )
73  {
74  clear();
75  return;
76  }
77 
78 
79 
80  QString html_text = htmlStart();
81 
82  html_text += htmlHeading( selectable );
83 
84  ZyppPkg candidate = tryCastToZyppPkg( selectable->candidateObj() );
85  ZyppPkg installed = tryCastToZyppPkg( selectable->installedObj() );
86 
87  if ( candidate && installed && candidate != installed )
88  {
89  html_text += complexTable( selectable, installed, candidate );
90  }
91  else
92  {
93  if ( candidate )
94  html_text += simpleTable( selectable, candidate );
95 
96  if ( installed )
97  html_text += simpleTable( selectable, installed );
98  }
99 
100  html_text += htmlEnd();
101 
102  setHtml( html_text );
103 }
104 
105 
106 QString
108 {
109  QString html = "<td align='top'>";
110  QString line;
111  list<string> authors = pkg->authors();
112  list<string>::const_iterator it = authors.begin();
113 
114  while ( it != authors.end() )
115  {
116  line = fromUTF8( *it );
117  line = htmlEscape( line );
118  html += line + "<br>";
119  ++it;
120  }
121 
122  html += "</td>";
123 
124  return html;
125 }
126 
127 
128 QString
130 {
131  QStringList groups = fromUTF8( pkg->group() ).split( '/', QString::KeepEmptyParts );
132 
133  // Translate group path components
134 
135  QStringList translated;
136 
137  for ( QStringList::const_iterator it = groups.begin();
138  it != groups.end();
139  ++it )
140  {
141  translated.append( QString::fromUtf8( dgettext( "rpm-groups", (*it).toUtf8() ) ) );
142  }
143 
144  return translated.join( "/" );
145 }
146 
147 
148 QString
150  ZyppPkg pkg )
151 {
152  QString html;
153 
154  html += row( hcell( _( "Version:" ) ) + cell( pkg->edition().asString() ) );
155  html += row( hcell( _( "Build Time:" ) ) + cell( pkg->buildtime() ) );
156 
157  html +=
158  *pkg == selectable->installedObj() ?
159  row( hcell( _( "Install Time:" ) ) + cell( pkg->installtime() ) ) : "";
160 
161  html += row( hcell( _( "Package Group:" ) ) + cell( formatRpmGroup( pkg ) ) );
162  html += row( hcell( _( "License:" ) ) + cell( pkg->license() ) );
163  html += row( hcell( _( "Installed Size:" ) ) + cell( pkg->installSize().asString() ) );
164  html += row( hcell( _( "Download Size:" ) ) + cell( pkg->downloadSize().asString() ) );
165  html += row( hcell( _( "Distribution:" ) ) + cell( pkg->distribution() ) );
166  html += row( hcell( _( "Vendor:" ) ) + cell( pkg->vendor() ) );
167  html += row( hcell( _( "Packager:" ) ) + cell( pkg->packager() ) );
168  html += row( hcell( _( "Architecture:" ) ) + cell( pkg->arch().asString() ) );
169  html += row( hcell( _( "Build Host:" ) ) + cell( pkg->buildhost() ) );
170  html += row( hcell( _( "URL:" ) ) + cell( pkg->url() ) );
171  html += row( hcell( _( "Source Package:" ) ) + cell( pkg->sourcePkgName() + "-" + pkg->sourcePkgEdition().asString() ) );
172  html += row( hcell( _( "Media No.:" ) ) + cell( pkg->mediaNr() ) );
173  html += row( hcell( _( "Authors:" ) ) + authorsListCell( pkg ) );
174 
175  html = "<br>" + table( html );
176 
177  return html;
178 }
179 
180 
181 QString
183  ZyppPkg installed,
184  ZyppPkg candidate )
185 {
186  ZyppPkg p1 = candidate;
187  ZyppPkg p2 = installed;
188 
189  QString p1_header = _( "<b>Alternate Version</b>" );
190  QString p2_header = _( "<b>Installed Version</b>" );
191 
192  QString html;
193 
194  html += row( hcell( QString( "" ) ) + hcell( "<b>" + p1_header + "</b>" ) + hcell( "<b>" + p2_header + "</b>" ) );
195 
196  html += row( hcell( _( "Version:" ) ) + cell( p1->edition().asString() ) + cell( p2->edition().asString() ) );
197  html += row( hcell( _( "Build Time:" ) ) + cell( p1->buildtime() ) + cell( p2->buildtime() ) );
198  html += row( hcell( _( "Install Time:" ) ) + cell( p1->installtime() ) + cell( p2->installtime() ) );
199  html += row( hcell( _( "Package Group:" ) ) + cell( formatRpmGroup( p1 ) ) + cell( formatRpmGroup( p2 ) ) );
200  html += row( hcell( _( "License:" ) ) + cell( p1->license() ) + cell( p2->license() ) );
201  html += row( hcell( _( "Installed Size:" ) ) + cell( p1->installSize().asString() ) + cell( p2->installSize().asString() ) );
202  html += row( hcell( _( "Download Size:" ) ) + cell( p1->downloadSize().asString() ) + cell( p2->downloadSize().asString() ) );
203  html += row( hcell( _( "Distribution:" ) ) + cell( p1->distribution() ) + cell( p2->distribution() ) );
204  html += row( hcell( _( "Vendor:" ) ) + cell( p1->vendor() ) + cell( p2->vendor() ) );
205  html += row( hcell( _( "Packager:" ) ) + cell( p1->packager() ) + cell( p2->packager() ) );
206  html += row( hcell( _( "Architecture:" ) ) + cell( p1->arch().asString() ) + cell( p2->arch().asString() ) );
207  html += row( hcell( _( "Build Host:" ) ) + cell( p1->buildhost() ) + cell( p2->buildhost() ) );
208  html += row( hcell( _( "URL:" ) ) + cell( p1->url() ) + cell( p2->url() ) );
209  html += row( hcell( _( "Source Package:" ) ) + cell( p1->sourcePkgName() + "-" + p1->sourcePkgEdition().asString() )
210  + cell( p2->sourcePkgName() + "-" + p2->sourcePkgEdition().asString() ) );
211  html += row( hcell( _( "Media No.:" ) ) + cell( p1->mediaNr() ) + cell( p2->mediaNr() ) );
212  html += row( hcell( _( "Authors:" ) ) + authorsListCell( p1 ) + authorsListCell( p2 ) );
213 
214 
215  html = "<br>" + table( html );
216 
217  return html;
218 }
219 
220 
221 #include "YQPkgTechnicalDetailsView.moc"
static QString hcell(QString contents)
Returns a string containing a HTML table cell with 'contents' for table headers.
virtual ~YQPkgTechnicalDetailsView()
Destructor.
virtual void showDetails(ZyppSel selectable)
Show details for the specified zypp::ResObject: In this case technical data, very much like "rpm -qi"...
static QString htmlHeading(ZyppSel selectable, bool showVersion=false)
Returns a uniform heading in HTML format for the specified selectable: name and summary or name...
Abstract base class for details views.
static QString cell(QString contents)
Returns a string containing a HTML table cell with 'contents'.
static QString htmlEscape(const QString &plainText)
Escapes characters special to HTML in a ( plain text ) string, such as: '<' -> '<' '>' -> '>...
QString complexTable(ZyppSel selectable, ZyppPkg installedPkg, ZyppPkg candidatePkg)
Returns a string containing a HTML table for technical details for two package instances: The install...
QString authorsListCell(ZyppPkg pkg) const
Returns a string containing HTML code for a package's authors list.
QString formatRpmGroup(ZyppPkg pkg) const
Format an RPM group.
YQPkgTechnicalDetailsView(QWidget *parent)
Constructor.
QString simpleTable(ZyppSel selectable, ZyppPkg pkg)
Returns a string containing a HTML table for technical details for one package.
static QString table(const QString &contents)
Returns a string containing a HTML table with 'contents'.
static QString row(const QString &contents)
Returns a string containing a HTML table row with 'contents'.
static QString htmlStart()
starts the html tag and set the style