]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQIconPool.cc
9a49322febcc5d3e34fbea0e4adc114f3360e8c8
[duncan/yast2-qt4.git] / src / YQIconPool.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQIconPool.cc
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19 #define y2log_component "qt-ui"
20 #include <ycp/y2log.h>
21
22 #include "YQIconPool.h"
23
24
25 #include "icons/autodel.xpm"
26 #include "icons/autodel_disabled.xpm"
27 #include "icons/autoinstall.xpm"
28 #include "icons/autoinstall_disabled.xpm"
29 #include "icons/autoupdate.xpm"
30 #include "icons/autoupdate_disabled.xpm"
31 #include "icons/del.xpm"
32 #include "icons/del_disabled.xpm"
33 #include "icons/install.xpm"
34 #include "icons/install_disabled.xpm"
35 #include "icons/keepinstalled.xpm"
36 #include "icons/keepinstalled_disabled.xpm"
37 #include "icons/noinst.xpm"
38 #include "icons/noinst_disabled.xpm"
39 #include "icons/protected.xpm"
40 #include "icons/protected_disabled.xpm"
41 #include "icons/sel_autodel.xpm"
42 #include "icons/sel_autodel_disabled.xpm"
43 #include "icons/sel_autoinstall.xpm"
44 #include "icons/sel_autoinstall_disabled.xpm"
45 #include "icons/sel_autoupdate.xpm"
46 #include "icons/sel_autoupdate_disabled.xpm"
47 #include "icons/taboo.xpm"
48 #include "icons/taboo_disabled.xpm"
49 #include "icons/update.xpm"
50 #include "icons/update_disabled.xpm"
51 #include "icons/tree_plus.xpm"
52 #include "icons/tree_minus.xpm"
53 #include "icons/warning_sign.xpm"
54 #include "icons/satisfied.xpm"
55
56 #include "icons/normal_conflict.xpm"
57 #include "icons/select_conflict.xpm"
58 #include "icons/delete_conflict.xpm"
59 #include "icons/unresolvable_conflict.xpm"
60
61 #include "icons/checklist_off.xpm"
62 #include "icons/checklist_on.xpm"
63
64 #include "icons/step_current.xpm"
65 #include "icons/step_todo.xpm"
66 #include "icons/step_done.xpm"
67
68
69 YQIconPool * YQIconPool::_iconPool = 0;
70
71 QPixmap YQIconPool::pkgTaboo()                  { return iconPool()->cachedIcon( taboo_xpm );                   }
72 QPixmap YQIconPool::pkgDel()                    { return iconPool()->cachedIcon( del_xpm );                     }
73 QPixmap YQIconPool::pkgUpdate()                 { return iconPool()->cachedIcon( update_xpm );                  }
74 QPixmap YQIconPool::pkgInstall()                { return iconPool()->cachedIcon( install_xpm );                 }
75 QPixmap YQIconPool::pkgAutoInstall()            { return iconPool()->cachedIcon( autoinstall_xpm );             }
76 QPixmap YQIconPool::pkgAutoUpdate()             { return iconPool()->cachedIcon( autoupdate_xpm );              }
77 QPixmap YQIconPool::pkgAutoDel()                { return iconPool()->cachedIcon( autodel_xpm );                 }
78 QPixmap YQIconPool::pkgSelAutoInstall()         { return iconPool()->cachedIcon( sel_autoinstall_xpm );         }
79 QPixmap YQIconPool::pkgSelAutoUpdate()          { return iconPool()->cachedIcon( sel_autoupdate_xpm );          }
80 QPixmap YQIconPool::pkgSelAutoDel()             { return iconPool()->cachedIcon( sel_autodel_xpm );             }
81 QPixmap YQIconPool::pkgKeepInstalled()          { return iconPool()->cachedIcon( keepinstalled_xpm );           }
82 QPixmap YQIconPool::pkgNoInst()                 { return iconPool()->cachedIcon( noinst_xpm );                  }
83 QPixmap YQIconPool::pkgProtected()              { return iconPool()->cachedIcon( protected_xpm );               }
84
85 QPixmap YQIconPool::disabledPkgTaboo()          { return iconPool()->cachedIcon( taboo_disabled_xpm );          }
86 QPixmap YQIconPool::disabledPkgDel()            { return iconPool()->cachedIcon( del_disabled_xpm );            }
87 QPixmap YQIconPool::disabledPkgUpdate()         { return iconPool()->cachedIcon( update_disabled_xpm );         }
88 QPixmap YQIconPool::disabledPkgInstall()        { return iconPool()->cachedIcon( install_disabled_xpm );        }
89 QPixmap YQIconPool::disabledPkgAutoInstall()    { return iconPool()->cachedIcon( autoinstall_disabled_xpm );    }
90 QPixmap YQIconPool::disabledPkgAutoUpdate()     { return iconPool()->cachedIcon( autoupdate_disabled_xpm );     }
91 QPixmap YQIconPool::disabledPkgAutoDel()        { return iconPool()->cachedIcon( autodel_disabled_xpm );        }
92 QPixmap YQIconPool::disabledPkgSelAutoInstall() { return iconPool()->cachedIcon( sel_autoinstall_disabled_xpm );}
93 QPixmap YQIconPool::disabledPkgSelAutoUpdate()  { return iconPool()->cachedIcon( sel_autoupdate_disabled_xpm ); }
94 QPixmap YQIconPool::disabledPkgSelAutoDel()     { return iconPool()->cachedIcon( sel_autodel_disabled_xpm );    }
95 QPixmap YQIconPool::disabledPkgKeepInstalled()  { return iconPool()->cachedIcon( keepinstalled_disabled_xpm );  }
96 QPixmap YQIconPool::disabledPkgNoInst()         { return iconPool()->cachedIcon( noinst_disabled_xpm );         }
97 QPixmap YQIconPool::disabledPkgProtected()      { return iconPool()->cachedIcon( protected_disabled_xpm );      }
98
99 QPixmap YQIconPool::checkMarkOn()               { return iconPool()->cachedIcon( checklist_on_xpm );            }
100 QPixmap YQIconPool::checkMarkOff()              { return iconPool()->cachedIcon( checklist_off_xpm );           }
101
102 QPixmap YQIconPool::normalPkgConflict()         { return iconPool()->cachedIcon( normal_conflict_xpm );         }
103 QPixmap YQIconPool::severePkgConflict()         { return iconPool()->cachedIcon( normal_conflict_xpm );         }
104 QPixmap YQIconPool::unresolvablePkgConflict()   { return iconPool()->cachedIcon( unresolvable_conflict_xpm );   }
105 QPixmap YQIconPool::deletePkgConflict()         { return iconPool()->cachedIcon( delete_conflict_xpm );         }
106 QPixmap YQIconPool::tabooPkgConflict()          { return iconPool()->cachedIcon( normal_conflict_xpm );         }
107 QPixmap YQIconPool::selectPkgConflict()         { return iconPool()->cachedIcon( select_conflict_xpm );         }
108
109 QPixmap YQIconPool::treePlus()                  { return iconPool()->cachedIcon( tree_plus_xpm  );              }
110 QPixmap YQIconPool::treeMinus()                 { return iconPool()->cachedIcon( tree_minus_xpm );              }
111
112 QPixmap YQIconPool::warningSign()               { return iconPool()->cachedIcon( warning_sign_xpm );            }
113 QPixmap YQIconPool::pkgSatisfied()              { return iconPool()->cachedIcon( satisfied_xpm );               }
114
115 QPixmap YQIconPool::stepCurrent()               { return iconPool()->cachedIcon( step_current_xpm );            }
116 QPixmap YQIconPool::stepToDo()                  { return iconPool()->cachedIcon( step_todo_xpm );               }
117 QPixmap YQIconPool::stepDone()                  { return iconPool()->cachedIcon( step_done_xpm );               }
118
119
120 YQIconPool * YQIconPool::iconPool()
121 {
122     if ( ! _iconPool )
123         _iconPool = new YQIconPool();
124
125     return _iconPool;
126 }
127
128
129 YQIconPool::YQIconPool()
130 {
131     _iconCache.setAutoDelete( true );
132 }
133
134
135 YQIconPool::~YQIconPool()
136 {
137     // NOP
138 }
139
140
141
142 QPixmap
143 YQIconPool::cachedIcon( const char ** xpm_data )
144 {
145     QPixmap * iconPtr = _iconCache[ xpm_data ];
146
147     if ( ! iconPtr )
148     {
149         iconPtr = new QPixmap( xpm_data );
150         _iconCache.insert( xpm_data, iconPtr );
151     }
152         
153     return *iconPtr;
154 }
155