Diffstat (limited to 'pwmanager/pwmanager/listviewpwm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | pwmanager/pwmanager/listviewpwm.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/pwmanager/pwmanager/listviewpwm.cpp b/pwmanager/pwmanager/listviewpwm.cpp index 0df9431..4253ab1 100644 --- a/pwmanager/pwmanager/listviewpwm.cpp +++ b/pwmanager/pwmanager/listviewpwm.cpp | |||
@@ -2,128 +2,131 @@ | |||
2 | * * | 2 | * * |
3 | * copyright (C) 2004 by Michael Buesch * | 3 | * copyright (C) 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.0.1 of pwmanager | 14 | * This file is originaly based on version 1.0.1 of pwmanager |
15 | * and was modified to run on embedded devices that run microkde | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #include "listviewpwm.h" | 20 | #include "listviewpwm.h" |
21 | #include "pwmexception.h" | 21 | #include "pwmexception.h" |
22 | #include "pwmview.h" | 22 | #include "pwmview.h" |
23 | 23 | ||
24 | #include <qpainter.h> | 24 | #include <qpainter.h> |
25 | #include <qpixmap.h> | 25 | #include <qpixmap.h> |
26 | //Added by qt3to4: | ||
27 | #include <QEvent> | ||
28 | #include <QKeyEvent> | ||
26 | 29 | ||
27 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
28 | 31 | ||
29 | #ifdef PWM_EMBEDDED | 32 | #ifdef PWM_EMBEDDED |
30 | #include <kglobal.h> | 33 | #include <kglobal.h> |
31 | #endif | 34 | #endif |
32 | 35 | ||
33 | ListViewPwM::ListViewPwM(QWidget *parent, const char *name) | 36 | ListViewPwM::ListViewPwM(QWidget *parent, const char *name) |
34 | : KListView(parent, name) | 37 | : KListView(parent, name) |
35 | { | 38 | { |
36 | //setResizeMode(QListView::AllColumns); | 39 | //setResizeMode(QListView::AllColumns); |
37 | setAllColumnsShowFocus (true ); | 40 | setAllColumnsShowFocus (true ); |
38 | } | 41 | } |
39 | 42 | ||
40 | bool ListViewPwM::event(QEvent *e) | 43 | bool ListViewPwM::event(QEvent *e) |
41 | { | 44 | { |
42 | if (e->type() == QEvent::LayoutHint) | 45 | if (e->type() == QEvent::LayoutRequest) |
43 | emit layoutChanged(); | 46 | emit layoutChanged(); |
44 | if (e->type() == QEvent::KeyPress) { | 47 | if (e->type() == QEvent::KeyPress) { |
45 | QKeyEvent* ke = (QKeyEvent*) e; | 48 | QKeyEvent* ke = (QKeyEvent*) e; |
46 | if ( ke->key() == Qt::Key_Space) { | 49 | if ( ke->key() == Qt::Key_Space) { |
47 | emit toggleOverview(); | 50 | emit toggleOverview(); |
48 | return true; | 51 | return true; |
49 | } | 52 | } |
50 | if ( ke->key() == Qt::Key_I || ke->key() == Qt::Key_N || ke->key() == Qt::Key_Insert) { | 53 | if ( ke->key() == Qt::Key_I || ke->key() == Qt::Key_N || ke->key() == Qt::Key_Insert) { |
51 | emit insertPW(); | 54 | emit insertPW(); |
52 | return true; | 55 | return true; |
53 | } | 56 | } |
54 | if ( ke->key() == Qt::Key_Delete || ke->key() == Qt::Key_Backspace) { | 57 | if ( ke->key() == Qt::Key_Delete || ke->key() == Qt::Key_Backspace) { |
55 | emit deletePW(); | 58 | emit deletePW(); |
56 | return true; | 59 | return true; |
57 | } | 60 | } |
58 | 61 | ||
59 | } | 62 | } |
60 | return KListView::event(e); | 63 | return KListView::event(e); |
61 | } | 64 | } |
62 | 65 | ||
63 | 66 | ||
64 | QPixmap * ListViewItemPwM::onPix = 0; | 67 | QPixmap * ListViewItemPwM::onPix = 0; |
65 | QPixmap * ListViewItemPwM::offPix = 0; | 68 | QPixmap * ListViewItemPwM::offPix = 0; |
66 | 69 | ||
67 | ListViewItemPwM::ListViewItemPwM(QListView *parent) | 70 | ListViewItemPwM::ListViewItemPwM(Q3ListView *parent) |
68 | : QCheckListItem(parent, "", QCheckListItem::CheckBox) | 71 | : Q3CheckListItem(parent, "", Q3CheckListItem::CheckBox) |
69 | { | 72 | { |
70 | if (!onPix) { | 73 | if (!onPix) { |
71 | PWM_ASSERT(!offPix); | 74 | PWM_ASSERT(!offPix); |
72 | KIconLoader* picons; | 75 | KIconLoader* picons; |
73 | #ifndef PWM_EMBEDDED | 76 | #ifndef PWM_EMBEDDED |
74 | KIconLoader il; | 77 | KIconLoader il; |
75 | picons = &il; | 78 | picons = &il; |
76 | #else | 79 | #else |
77 | picons = KGlobal::iconLoader(); | 80 | picons = KGlobal::iconLoader(); |
78 | #endif | 81 | #endif |
79 | 82 | ||
80 | KIconLoader il; | 83 | KIconLoader il; |
81 | #ifndef PWM_EMBEDDED | 84 | #ifndef PWM_EMBEDDED |
82 | static QPixmap onP(picons->loadIcon("button_ok", KIcon::Small)); | 85 | static QPixmap onP(picons->loadIcon("button_ok", KIcon::Small)); |
83 | #else | 86 | #else |
84 | static QPixmap onP(picons->loadIcon("decrypted", KIcon::Small)); | 87 | static QPixmap onP(picons->loadIcon("decrypted", KIcon::Small)); |
85 | #endif | 88 | #endif |
86 | onPix = &onP; | 89 | onPix = &onP; |
87 | static QPixmap offP(picons->loadIcon("encrypted", KIcon::Small)); | 90 | static QPixmap offP(picons->loadIcon("encrypted", KIcon::Small)); |
88 | offPix = &offP; | 91 | offPix = &offP; |
89 | } | 92 | } |
90 | } | 93 | } |
91 | 94 | ||
92 | void ListViewItemPwM::paintCell(QPainter *p, const QColorGroup &cg, | 95 | void ListViewItemPwM::paintCell(QPainter *p, const QColorGroup &cg, |
93 | int column, int width, int align) | 96 | int column, int width, int align) |
94 | { | 97 | { |
95 | // qDebug("ListViewItemPwM::paintCell column=%i", column); | 98 | // qDebug("ListViewItemPwM::paintCell column=%i", column); |
96 | if (!p) | 99 | if (!p) |
97 | return; | 100 | return; |
98 | //US BUG: | 101 | //US BUG: |
99 | if (column != COLUMN_DESC) { | 102 | if (column != COLUMN_DESC) { |
100 | QCheckListItem::paintCell(p, cg, column, width, align); | 103 | Q3CheckListItem::paintCell(p, cg, column, width, align); |
101 | return; | 104 | return; |
102 | } | 105 | } |
103 | QPixmap *curPix = isOn() ? onPix : offPix; | 106 | QPixmap *curPix = isOn() ? onPix : offPix; |
104 | int pixSpace = curPix->width(); | 107 | int pixSpace = curPix->width(); |
105 | pixSpace += 4; | 108 | pixSpace += 4; |
106 | #ifndef PWM_EMBEDDED | 109 | #ifndef PWM_EMBEDDED |
107 | QRect window(p->viewport()); | 110 | QRect window(p->viewport()); |
108 | // clear the rectangle (we have to clear it first. see QT doc) | 111 | // clear the rectangle (we have to clear it first. see QT doc) |
109 | p->eraseRect(0, 0, pixSpace, window.height()); | 112 | p->eraseRect(0, 0, pixSpace, window.height()); |
110 | // now draw the pixmap | 113 | // now draw the pixmap |
111 | int y = (height() - curPix->height()) / 2; | 114 | int y = (height() - curPix->height()) / 2; |
112 | p->drawPixmap(1, y, *curPix); | 115 | p->drawPixmap(1, y, *curPix); |
113 | window.moveLeft(pixSpace); | 116 | window.moveLeft(pixSpace); |
114 | p->setViewport(window); | 117 | p->setViewport(window); |
115 | #else | 118 | #else |
116 | p->eraseRect(0, 0, pixSpace, height()); | 119 | p->eraseRect(0, 0, pixSpace, height()); |
117 | // now draw the pixmap | 120 | // now draw the pixmap |
118 | int y = (height() - curPix->height()) / 2; | 121 | int y = (height() - curPix->height()) / 2; |
119 | p->drawPixmap(1, y, *curPix); | 122 | p->drawPixmap(1, y, *curPix); |
120 | p->translate( pixSpace, 0 ); | 123 | p->translate( pixSpace, 0 ); |
121 | 124 | ||
122 | #endif | 125 | #endif |
123 | QListViewItem::paintCell(p, cg, column, width - pixSpace, align); | 126 | Q3ListViewItem::paintCell(p, cg, column, width - pixSpace, align); |
124 | 127 | ||
125 | } | 128 | } |
126 | 129 | ||
127 | #ifndef PWM_EMBEDDED | 130 | #ifndef PWM_EMBEDDED_ |
128 | #include "listviewpwm.moc" | 131 | #include "moc_listviewpwm.cpp" |
129 | #endif | 132 | #endif |