]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgUpdateProblemFilterView.cc
restart qt4 porting
[duncan/yast2-qt4.git] / src / pkg / YQPkgUpdateProblemFilterView.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgUpdateProblemFilterView.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 "YQPkgUpdateProblemFilterView.h"
26 #include "YQi18n.h"
27 #include "utf8.h"
28
29 #include <zypp/ZYppFactory.h>
30 #include <zypp/Resolver.h>
31
32 using std::list;
33
34
35 YQPkgUpdateProblemFilterView::YQPkgUpdateProblemFilterView( QWidget * parent )
36     : QTextBrowser( parent )
37 {
38     QString html = _( "\
39 <br>\n\
40 <h2>Update Problem</h2>\n\
41 <p>\n\
42 <font color=blue>\n\
43 The packages in this list cannot be updated automatically.\n\
44 </font>\n\
45 </p>\n\
46 <p>Possible reasons:</p>\n\
47 <ul>\n\
48 <li>They are obsoleted by other packages\n\
49 <li>There is no newer version to update to on any installation media\n\
50 <li>They are third-party packages\n\
51 </ul>\n\
52 </p>\n\
53 <p>\n\
54 Please choose manually what to do with them.\n\
55 The safest course of action is to delete them.\n\
56 </p>\
57 " );
58
59     setTextFormat( Qt::RichText );
60     setText( html );
61 }
62
63
64 YQPkgUpdateProblemFilterView::~YQPkgUpdateProblemFilterView()
65 {
66     // NOP
67 }
68
69 void
70 YQPkgUpdateProblemFilterView::filterIfVisible()
71 {
72     if ( isVisible() )
73         filter();
74 }
75
76
77 void
78 YQPkgUpdateProblemFilterView::filter()
79 {
80     emit filterStart();
81
82     list<zypp::PoolItem_Ref> problemList = zypp::getZYpp()->resolver()->problematicUpdateItems();
83     
84     for ( list<zypp::PoolItem_Ref>::const_iterator it = problemList.begin();
85           it != problemList.end();
86           ++it )
87     {
88         ZyppPkg pkg = tryCastToZyppPkg( (*it).resolvable() );
89
90         if ( pkg )
91         {
92             ZyppSel sel = _selMapper.findZyppSel( pkg );
93
94             if ( sel )
95             {
96                 y2milestone( "Problematic package: %s-%s",
97                              pkg->name().c_str(), pkg->edition().asString().c_str() );
98                 
99                 emit filterMatch( sel, pkg );
100             }
101         }
102         
103     }
104
105     emit filterFinished();
106 }
107
108
109 bool
110 YQPkgUpdateProblemFilterView::haveProblematicPackages()
111 {
112     return ! zypp::getZYpp()->resolver()->problematicUpdateItems().empty();
113 }
114
115
116 #include "YQPkgUpdateProblemFilterView.moc"