1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPkgDependenciesView.cc
15 Author: Stefan Hundhammer <sh@suse.de>
17 Textdomain "packages-qt"
21 #define y2log_component "qt-pkg"
22 #include <ycp/y2log.h>
24 #include <qdatetime.h>
25 #include "YQPkgDependenciesView.h"
30 YQPkgDependenciesView::YQPkgDependenciesView( QWidget * parent )
31 : YQPkgGenericDetailsView( parent )
36 YQPkgDependenciesView::~YQPkgDependenciesView()
43 YQPkgDependenciesView::showDetails( ZyppSel selectable )
45 _selectable = selectable;
53 QString html_text = htmlHeading( selectable );
55 ZyppObj candidate = selectable->candidateObj();
56 ZyppObj installed = selectable->installedObj();
58 if ( candidate && installed && candidate != installed )
60 html_text += complexTable( installed, candidate );
65 html_text += simpleTable( candidate );
68 html_text += simpleTable( installed );
76 YQPkgDependenciesView::simpleTable( ZyppObj pkg )
78 QString html = "<br>" +
80 row( hcell( _( "Version:" ) ) + cell( pkg->edition().asString() ) ) +
82 // Intentionally NOT translating the RPM depencency tags:
83 // They make only sense to users who have some basic knowledge what they are anyway.
85 row( "Provides:", pkg->dep( zypp::Dep::PROVIDES ) ) +
86 row( "Prerequires:", pkg->dep( zypp::Dep::PREREQUIRES ) ) +
87 row( "Requires:", pkg->dep( zypp::Dep::REQUIRES ) ) +
88 row( "Conflicts:", pkg->dep( zypp::Dep::CONFLICTS ) ) +
89 row( "Obsoletes:", pkg->dep( zypp::Dep::OBSOLETES ) ) +
90 row( "Recommends:", pkg->dep( zypp::Dep::RECOMMENDS ) ) +
91 row( "Suggests:", pkg->dep( zypp::Dep::SUGGESTS ) ) +
92 row( "Freshens:", pkg->dep( zypp::Dep::FRESHENS ) ) +
93 row( "Enances:", pkg->dep( zypp::Dep::ENHANCES ) ) +
94 row( "Supplements:", pkg->dep( zypp::Dep::SUPPLEMENTS ) )
102 YQPkgDependenciesView::complexTable( ZyppObj installed, ZyppObj candidate )
104 ZyppObj p1 = candidate;
105 ZyppObj p2 = installed;
107 QString p1_header = _( "<b>Alternate Version</b>" );
108 QString p2_header = _( "<b>Installed Version</b>" );
110 QString html = "<br>" +
112 row( hcell( QString( "" ) ) + hcell( "<b>" + p1_header + "</b>" ) + hcell( "<b>" + p2_header + "</b>" ) ) +
114 row( hcell( _( "Version:" ) ) + cell( p1->edition().asString() ) + cell( p2->edition().asString() ) ) +
116 row( "Provides:", p1->dep( zypp::Dep::PROVIDES ), p2->dep( zypp::Dep::PROVIDES ) ) +
117 row( "Prerequires:", p1->dep( zypp::Dep::PREREQUIRES ), p2->dep( zypp::Dep::PREREQUIRES ) ) +
118 row( "Requires:", p1->dep( zypp::Dep::REQUIRES ), p2->dep( zypp::Dep::REQUIRES ) ) +
119 row( "Conflicts:", p1->dep( zypp::Dep::CONFLICTS ), p2->dep( zypp::Dep::CONFLICTS ) ) +
120 row( "Obsoletes:", p1->dep( zypp::Dep::OBSOLETES ), p2->dep( zypp::Dep::OBSOLETES ) ) +
121 row( "Recommends:", p1->dep( zypp::Dep::RECOMMENDS ), p2->dep( zypp::Dep::RECOMMENDS ) ) +
122 row( "Suggests:", p1->dep( zypp::Dep::SUGGESTS ), p2->dep( zypp::Dep::SUGGESTS ) ) +
123 row( "Freshens:", p1->dep( zypp::Dep::FRESHENS ), p2->dep( zypp::Dep::FRESHENS ) ) +
124 row( "Enances:", p1->dep( zypp::Dep::ENHANCES ), p2->dep( zypp::Dep::ENHANCES ) ) +
125 row( "Supplements:", p1->dep( zypp::Dep::SUPPLEMENTS ), p2->dep( zypp::Dep::SUPPLEMENTS ) )
133 YQPkgDependenciesView::row( const QString & heading,
134 const zypp::CapSet & capSet )
136 QString content = htmlLines( capSet );
138 if ( content.isEmpty() )
141 return QString( "<tr>" ) +
143 "<td>" + content + "</td>"
149 YQPkgDependenciesView::row( const QString & heading,
150 const zypp::CapSet & capSet1,
151 const zypp::CapSet & capSet2 )
153 QString content1 = htmlLines( capSet1 );
154 QString content2 = htmlLines( capSet2 );
156 if ( content1.isEmpty() && content2.isEmpty() )
159 return QString( "<tr>" ) +
161 "<td>" + content1 + "</td>" +
162 "<td>" + content2 + "</td>" +
168 YQPkgDependenciesView::htmlLines( const zypp::CapSet & capSet )
172 for ( zypp::CapSet::const_iterator it = capSet.begin();
176 if ( ! html.isEmpty() )
179 html += htmlEscape( ( *it).asString().c_str() );
186 #include "YQPkgDependenciesView.moc"