-rw-r--r-- | pwmanager/pwmanager/addentrywnd_emb.cpp | 7 | ||||
-rw-r--r-- | pwmanager/pwmanager/commentbox.cpp | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmview.cpp | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle.cpp | 11 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle.h | 11 |
6 files changed, 30 insertions, 3 deletions
diff --git a/pwmanager/pwmanager/addentrywnd_emb.cpp b/pwmanager/pwmanager/addentrywnd_emb.cpp index f065058..c2590f0 100644 --- a/pwmanager/pwmanager/addentrywnd_emb.cpp +++ b/pwmanager/pwmanager/addentrywnd_emb.cpp | |||
@@ -76,151 +76,158 @@ addEntryWnd::addEntryWnd( PwMDoc* d, QWidget* parent, const char* name) | |||
76 | layout->addWidget( label, i, 0 ); | 76 | layout->addWidget( label, i, 0 ); |
77 | layout->addWidget( categoryComboBox, i, 1 ); | 77 | layout->addWidget( categoryComboBox, i, 1 ); |
78 | i++; | 78 | i++; |
79 | categoryComboBox->setEditable( TRUE ); | 79 | categoryComboBox->setEditable( TRUE ); |
80 | categoryComboBox->setSizeLimit( 100 ); | 80 | categoryComboBox->setSizeLimit( 100 ); |
81 | categoryComboBox->setAutoCompletion( TRUE ); | 81 | categoryComboBox->setAutoCompletion( TRUE ); |
82 | categoryComboBox->setDuplicatesEnabled( FALSE ); | 82 | categoryComboBox->setDuplicatesEnabled( FALSE ); |
83 | connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&))); | 83 | connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&))); |
84 | 84 | ||
85 | 85 | ||
86 | usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" ); | 86 | usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" ); |
87 | usernameLineLabel = new QLabel( usernameLineEdit, i18n("Username:"), tab1 ); | 87 | usernameLineLabel = new QLabel( usernameLineEdit, i18n("Username:"), tab1 ); |
88 | layout->addWidget( usernameLineLabel, i, 0 ); | 88 | layout->addWidget( usernameLineLabel, i, 0 ); |
89 | layout->addWidget( usernameLineEdit, i, 1 ); | 89 | layout->addWidget( usernameLineEdit, i, 1 ); |
90 | i++; | 90 | i++; |
91 | 91 | ||
92 | pwLineEdit = new KLineEdit( tab1, "pwLineEdit" ); | 92 | pwLineEdit = new KLineEdit( tab1, "pwLineEdit" ); |
93 | pwLineEdit->setEchoMode( QLineEdit::Password ); | 93 | pwLineEdit->setEchoMode( QLineEdit::Password ); |
94 | pwLineLabel = new QLabel( pwLineEdit, i18n("Password:"), tab1 ); | 94 | pwLineLabel = new QLabel( pwLineEdit, i18n("Password:"), tab1 ); |
95 | layout->addWidget( pwLineLabel, i, 0 ); | 95 | layout->addWidget( pwLineLabel, i, 0 ); |
96 | layout->addWidget( pwLineEdit, i, 1 ); | 96 | layout->addWidget( pwLineEdit, i, 1 ); |
97 | i++; | 97 | i++; |
98 | 98 | ||
99 | revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" ); | 99 | revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" ); |
100 | revealButton->setToggleButton( TRUE ); | 100 | revealButton->setToggleButton( TRUE ); |
101 | layout->addWidget( revealButton, i, 0 ); | 101 | layout->addWidget( revealButton, i, 0 ); |
102 | 102 | ||
103 | generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" ); | 103 | generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" ); |
104 | layout->addWidget( generateButton, i, 1 ); | 104 | layout->addWidget( generateButton, i, 1 ); |
105 | i++; | 105 | i++; |
106 | 106 | ||
107 | urlLineEdit = new KLineEdit( tab1, "urlLineEdit" ); | 107 | urlLineEdit = new KLineEdit( tab1, "urlLineEdit" ); |
108 | label = new QLabel( urlLineEdit, i18n("URL:"), tab1 ); | 108 | label = new QLabel( urlLineEdit, i18n("URL:"), tab1 ); |
109 | layout->addWidget( label, i, 0 ); | 109 | layout->addWidget( label, i, 0 ); |
110 | layout->addWidget( urlLineEdit, i, 1 ); | 110 | layout->addWidget( urlLineEdit, i, 1 ); |
111 | i++; | 111 | i++; |
112 | 112 | ||
113 | mTabWidget->addTab( tab1, i18n( "&Password" ) ); | 113 | mTabWidget->addTab( tab1, i18n( "&Password" ) ); |
114 | 114 | ||
115 | 115 | ||
116 | //////////////////////////////////////////////////////////////////// | 116 | //////////////////////////////////////////////////////////////////// |
117 | // This is the Comment tab | 117 | // This is the Comment tab |
118 | QWidget *tab2 = new QWidget( mTabWidget ); | 118 | QWidget *tab2 = new QWidget( mTabWidget ); |
119 | 119 | ||
120 | layout = new QGridLayout( tab2, 3, 1 ); | 120 | layout = new QGridLayout( tab2, 3, 1 ); |
121 | layout->setMargin( KDialogBase::marginHintSmall() ); | 121 | layout->setMargin( KDialogBase::marginHintSmall() ); |
122 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 122 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
123 | i = 0; | 123 | i = 0; |
124 | 124 | ||
125 | commentTextEdit = new QMultiLineEdit(tab2); | 125 | commentTextEdit = new QMultiLineEdit(tab2); |
126 | layout->addMultiCellWidget( commentTextEdit, i, i, 0, 0 ); | 126 | layout->addMultiCellWidget( commentTextEdit, i, i, 0, 0 ); |
127 | i++; | 127 | i++; |
128 | 128 | ||
129 | 129 | ||
130 | mTabWidget->addTab( tab2, i18n( "&Comments" ) ); | 130 | mTabWidget->addTab( tab2, i18n( "&Comments" ) ); |
131 | 131 | ||
132 | 132 | ||
133 | //////////////////////////////////////////////////////////////////// | 133 | //////////////////////////////////////////////////////////////////// |
134 | // This is the Launcher tab | 134 | // This is the Launcher tab |
135 | QWidget *tab3 = new QWidget( mTabWidget ); | 135 | QWidget *tab3 = new QWidget( mTabWidget ); |
136 | 136 | ||
137 | layout = new QGridLayout( tab3, 3, 1 ); | 137 | layout = new QGridLayout( tab3, 3, 1 ); |
138 | layout->setMargin( KDialogBase::marginHintSmall() ); | 138 | layout->setMargin( KDialogBase::marginHintSmall() ); |
139 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 139 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
140 | i = 0; | 140 | i = 0; |
141 | 141 | ||
142 | launcherLineEdit = new KLineEdit( tab3, "launcherLineEdit" ); | 142 | launcherLineEdit = new KLineEdit( tab3, "launcherLineEdit" ); |
143 | label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); | 143 | label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); |
144 | 144 | ||
145 | QLabel* label1 = new QLabel( launcherLineEdit, i18n("$d = Description"), tab3 ); | 145 | QLabel* label1 = new QLabel( launcherLineEdit, i18n("$d = Description"), tab3 ); |
146 | QLabel* label2 = new QLabel( launcherLineEdit, i18n("$n = Username"), tab3 ); | 146 | QLabel* label2 = new QLabel( launcherLineEdit, i18n("$n = Username"), tab3 ); |
147 | QLabel* label3 = new QLabel( launcherLineEdit, i18n("$c = Comment"), tab3 ); | 147 | QLabel* label3 = new QLabel( launcherLineEdit, i18n("$c = Comment"), tab3 ); |
148 | QLabel* label4 = new QLabel( launcherLineEdit, i18n("$u = URL"), tab3 ); | 148 | QLabel* label4 = new QLabel( launcherLineEdit, i18n("$u = URL"), tab3 ); |
149 | QLabel* label5 = new QLabel( launcherLineEdit, i18n("$p = Password"), tab3 ); | 149 | QLabel* label5 = new QLabel( launcherLineEdit, i18n("$p = Password"), tab3 ); |
150 | 150 | ||
151 | label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); | 151 | label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); |
152 | 152 | ||
153 | layout->addWidget( label1, i, 0 ); | 153 | layout->addWidget( label1, i, 0 ); |
154 | layout->addWidget( label2, i, 1 ); | 154 | layout->addWidget( label2, i, 1 ); |
155 | i++; | 155 | i++; |
156 | layout->addWidget( label3, i, 0 ); | 156 | layout->addWidget( label3, i, 0 ); |
157 | layout->addWidget( label4, i, 1 ); | 157 | layout->addWidget( label4, i, 1 ); |
158 | i++; | 158 | i++; |
159 | layout->addWidget( label5, i, 0 ); | 159 | layout->addWidget( label5, i, 0 ); |
160 | i++; | 160 | i++; |
161 | 161 | ||
162 | layout->addWidget( label, i, 0 ); | 162 | layout->addWidget( label, i, 0 ); |
163 | layout->addWidget( launcherLineEdit, i, 1 ); | 163 | layout->addWidget( launcherLineEdit, i, 1 ); |
164 | i++; | 164 | i++; |
165 | 165 | ||
166 | 166 | ||
167 | mTabWidget->addTab( tab3, i18n( "&Launcher" ) ); | 167 | mTabWidget->addTab( tab3, i18n( "&Launcher" ) ); |
168 | 168 | ||
169 | // signals and slots connections | 169 | // signals and slots connections |
170 | connect( generateButton, SIGNAL( clicked() ), this, SLOT( generateButton_slot() ) ); | 170 | connect( generateButton, SIGNAL( clicked() ), this, SLOT( generateButton_slot() ) ); |
171 | connect( revealButton, SIGNAL( toggled(bool) ), this, SLOT( revealButton_slot() ) ); | 171 | connect( revealButton, SIGNAL( toggled(bool) ), this, SLOT( revealButton_slot() ) ); |
172 | |||
173 | #if 0 | ||
174 | if ( QApplication::desktop()->width() <= 640 && QApplication::desktop()->width() >= 480 ) { | ||
175 | resize ( 440, 400 ); | ||
176 | } | ||
177 | #endif | ||
178 | |||
172 | } | 179 | } |
173 | 180 | ||
174 | /* | 181 | /* |
175 | * Destroys the object and frees any allocated resources | 182 | * Destroys the object and frees any allocated resources |
176 | */ | 183 | */ |
177 | addEntryWnd::~addEntryWnd() | 184 | addEntryWnd::~addEntryWnd() |
178 | { | 185 | { |
179 | // no need to delete child widgets, Qt does it all for us | 186 | // no need to delete child widgets, Qt does it all for us |
180 | } | 187 | } |
181 | 188 | ||
182 | void addEntryWnd::slotOk() | 189 | void addEntryWnd::slotOk() |
183 | { | 190 | { |
184 | qWarning( "addEntryWnd::slotOk(): Not implemented yet" ); | 191 | qWarning( "addEntryWnd::slotOk(): Not implemented yet" ); |
185 | } | 192 | } |
186 | 193 | ||
187 | void addEntryWnd::revealButton_slot() | 194 | void addEntryWnd::revealButton_slot() |
188 | { | 195 | { |
189 | qWarning( "addEntryWnd::revealButton_slot(): Not implemented yet" ); | 196 | qWarning( "addEntryWnd::revealButton_slot(): Not implemented yet" ); |
190 | } | 197 | } |
191 | 198 | ||
192 | void addEntryWnd::generateButton_slot() | 199 | void addEntryWnd::generateButton_slot() |
193 | { | 200 | { |
194 | qWarning( "addEntryWnd::generateButton_slot(): Not implemented yet" ); | 201 | qWarning( "addEntryWnd::generateButton_slot(): Not implemented yet" ); |
195 | } | 202 | } |
196 | 203 | ||
197 | void addEntryWnd::advancedCommentButton_slot(bool) | 204 | void addEntryWnd::advancedCommentButton_slot(bool) |
198 | { | 205 | { |
199 | qWarning( "addEntryWnd::advancedCommentButton_slot(bool): Not implemented yet" ); | 206 | qWarning( "addEntryWnd::advancedCommentButton_slot(bool): Not implemented yet" ); |
200 | } | 207 | } |
201 | 208 | ||
202 | void addEntryWnd::categorySelected ( const QString & string ) | 209 | void addEntryWnd::categorySelected ( const QString & string ) |
203 | { | 210 | { |
204 | unsigned int idx; | 211 | unsigned int idx; |
205 | bool found = doc->findCategory(string, &idx); | 212 | bool found = doc->findCategory(string, &idx); |
206 | 213 | ||
207 | if (found == true) | 214 | if (found == true) |
208 | { | 215 | { |
209 | qDebug("addEntryWnd::categorySelected found"); | 216 | qDebug("addEntryWnd::categorySelected found"); |
210 | PwMCategoryItem* catitem = doc->getCategoryEntry(idx); | 217 | PwMCategoryItem* catitem = doc->getCategoryEntry(idx); |
211 | 218 | ||
212 | descLineLabel->setText(catitem->desc_text.c_str()); | 219 | descLineLabel->setText(catitem->desc_text.c_str()); |
213 | usernameLineLabel->setText(catitem->name_text.c_str()); | 220 | usernameLineLabel->setText(catitem->name_text.c_str()); |
214 | pwLineLabel->setText(catitem->pw_text.c_str()); | 221 | pwLineLabel->setText(catitem->pw_text.c_str()); |
215 | return; | 222 | return; |
216 | } | 223 | } |
217 | else | 224 | else |
218 | { | 225 | { |
219 | qDebug("addEntryWnd::categorySelected NOT found"); | 226 | qDebug("addEntryWnd::categorySelected NOT found"); |
220 | BUG(); | 227 | BUG(); |
221 | } | 228 | } |
222 | 229 | ||
223 | 230 | ||
224 | } | 231 | } |
225 | 232 | ||
226 | 233 | ||
diff --git a/pwmanager/pwmanager/commentbox.cpp b/pwmanager/pwmanager/commentbox.cpp index e2d2d2b..0f32561 100644 --- a/pwmanager/pwmanager/commentbox.cpp +++ b/pwmanager/pwmanager/commentbox.cpp | |||
@@ -139,143 +139,144 @@ void CommentBox::switchTo(commentBoxMode newMode) | |||
139 | textDta = new QTextEdit(parentWidget); | 139 | textDta = new QTextEdit(parentWidget); |
140 | textDta->setTextFormat(Qt::PlainText); | 140 | textDta->setTextFormat(Qt::PlainText); |
141 | textDta->setReadOnly(true); | 141 | textDta->setReadOnly(true); |
142 | textDta->show(); | 142 | textDta->show(); |
143 | break; | 143 | break; |
144 | case mode_html: | 144 | case mode_html: |
145 | htmlDta = new KHTMLPart(parentWidget, 0, | 145 | htmlDta = new KHTMLPart(parentWidget, 0, |
146 | parentWidget); | 146 | parentWidget); |
147 | htmlDta->show(); | 147 | htmlDta->show(); |
148 | break; | 148 | break; |
149 | default: | 149 | default: |
150 | BUG(); | 150 | BUG(); |
151 | break; | 151 | break; |
152 | } | 152 | } |
153 | 153 | ||
154 | mode = newMode; | 154 | mode = newMode; |
155 | } | 155 | } |
156 | 156 | ||
157 | void CommentBox::show() | 157 | void CommentBox::show() |
158 | { | 158 | { |
159 | switch (mode) { | 159 | switch (mode) { |
160 | case mode_text: | 160 | case mode_text: |
161 | PWM_ASSERT(textDta); | 161 | PWM_ASSERT(textDta); |
162 | textDta->show(); | 162 | textDta->show(); |
163 | break; | 163 | break; |
164 | case mode_html: | 164 | case mode_html: |
165 | PWM_ASSERT(htmlDta); | 165 | PWM_ASSERT(htmlDta); |
166 | htmlDta->show(); | 166 | htmlDta->show(); |
167 | break; | 167 | break; |
168 | default: | 168 | default: |
169 | break; | 169 | break; |
170 | } | 170 | } |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | void CommentBox::hide() | 174 | void CommentBox::hide() |
175 | { | 175 | { |
176 | switch (mode) { | 176 | switch (mode) { |
177 | case mode_text: | 177 | case mode_text: |
178 | PWM_ASSERT(textDta); | 178 | PWM_ASSERT(textDta); |
179 | textDta->hide(); | 179 | textDta->hide(); |
180 | break; | 180 | break; |
181 | case mode_html: | 181 | case mode_html: |
182 | PWM_ASSERT(htmlDta); | 182 | PWM_ASSERT(htmlDta); |
183 | htmlDta->hide(); | 183 | htmlDta->hide(); |
184 | break; | 184 | break; |
185 | default: | 185 | default: |
186 | break; | 186 | break; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | void CommentBox::resize(const QSize &size) | 190 | void CommentBox::resize(const QSize &size) |
191 | { | 191 | { |
192 | switch (mode) { | 192 | switch (mode) { |
193 | case mode_text: | 193 | case mode_text: |
194 | PWM_ASSERT(textDta); | 194 | PWM_ASSERT(textDta); |
195 | textDta->resize(size); | 195 | textDta->resize(size); |
196 | break; | 196 | break; |
197 | case mode_html: | 197 | case mode_html: |
198 | PWM_ASSERT(htmlDta); | 198 | PWM_ASSERT(htmlDta); |
199 | htmlDta->view()->resize(size); | 199 | htmlDta->view()->resize(size); |
200 | break; | 200 | break; |
201 | default: | 201 | default: |
202 | break; | 202 | break; |
203 | } | 203 | } |
204 | 204 | ||
205 | } | 205 | } |
206 | 206 | ||
207 | QSize CommentBox::size() | 207 | QSize CommentBox::size() |
208 | { | 208 | { |
209 | switch (mode) { | 209 | switch (mode) { |
210 | case mode_text: | 210 | case mode_text: |
211 | PWM_ASSERT(textDta); | 211 | PWM_ASSERT(textDta); |
212 | return textDta->size(); | 212 | return textDta->size(); |
213 | break; | 213 | break; |
214 | case mode_html: | 214 | case mode_html: |
215 | PWM_ASSERT(htmlDta); | 215 | PWM_ASSERT(htmlDta); |
216 | return htmlDta->view()->size(); | 216 | return htmlDta->view()->size(); |
217 | break; | 217 | break; |
218 | default: | 218 | default: |
219 | break; | 219 | break; |
220 | } | 220 | } |
221 | 221 | ||
222 | return QSize(); | 222 | return QSize(); |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | //////////////////////////////////////////////////////////////////////// | 226 | //////////////////////////////////////////////////////////////////////// |
227 | 227 | ||
228 | #else | 228 | #else |
229 | 229 | ||
230 | CommentBox::CommentBox(QWidget *_parentWidget) | 230 | CommentBox::CommentBox(QWidget *_parentWidget) |
231 | : QMultiLineEdit(_parentWidget) | 231 | : QMultiLineEdit(_parentWidget) |
232 | 232 | ||
233 | { | 233 | { |
234 | this->setReadOnly(true); | 234 | this->setReadOnly(true); |
235 | setFocusPolicy( QWidget::ClickFocus ); | ||
235 | } | 236 | } |
236 | 237 | ||
237 | CommentBox::~CommentBox() | 238 | CommentBox::~CommentBox() |
238 | { | 239 | { |
239 | } | 240 | } |
240 | 241 | ||
241 | void CommentBox::clear() | 242 | void CommentBox::clear() |
242 | { | 243 | { |
243 | this->hide(); | 244 | this->hide(); |
244 | } | 245 | } |
245 | 246 | ||
246 | 247 | ||
247 | void CommentBox::setText(const QString &text) | 248 | void CommentBox::setText(const QString &text) |
248 | { | 249 | { |
249 | QMultiLineEdit::setText( text); | 250 | QMultiLineEdit::setText( text); |
250 | if (!this->isVisible()) | 251 | if (!this->isVisible()) |
251 | this->show(); | 252 | this->show(); |
252 | } | 253 | } |
253 | 254 | ||
254 | bool CommentBox::getText(QString *text) | 255 | bool CommentBox::getText(QString *text) |
255 | { | 256 | { |
256 | *text = this->text(); | 257 | *text = this->text(); |
257 | return true; | 258 | return true; |
258 | } | 259 | } |
259 | 260 | ||
260 | void CommentBox::setContent(const QString &dta) | 261 | void CommentBox::setContent(const QString &dta) |
261 | { | 262 | { |
262 | // if there's no data, hide the comment-box | 263 | // if there's no data, hide the comment-box |
263 | if (dta.isEmpty()) { | 264 | if (dta.isEmpty()) { |
264 | clear(); | 265 | clear(); |
265 | return; | 266 | return; |
266 | } | 267 | } |
267 | 268 | ||
268 | // we assume it's plain text | 269 | // we assume it's plain text |
269 | setText(dta); | 270 | setText(dta); |
270 | } | 271 | } |
271 | 272 | ||
272 | #endif | 273 | #endif |
273 | 274 | ||
274 | 275 | ||
275 | 276 | ||
276 | 277 | ||
277 | 278 | ||
278 | 279 | ||
279 | 280 | ||
280 | 281 | ||
281 | 282 | ||
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp index fc6837f..aed8ec0 100644 --- a/pwmanager/pwmanager/pwm.cpp +++ b/pwmanager/pwmanager/pwm.cpp | |||
@@ -566,292 +566,294 @@ PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) | |||
566 | PwM *newInstance = init->createMainWnd(); | 566 | PwM *newInstance = init->createMainWnd(); |
567 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); | 567 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); |
568 | if (!newDoc) { | 568 | if (!newDoc) { |
569 | newInstance->setForceQuit(true); | 569 | newInstance->setForceQuit(true); |
570 | delete_and_null(newInstance); | 570 | delete_and_null(newInstance); |
571 | } | 571 | } |
572 | return newDoc; | 572 | return newDoc; |
573 | } | 573 | } |
574 | 574 | ||
575 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) | 575 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) |
576 | return 0; | 576 | return 0; |
577 | showStatMsg(i18n("Successfully opened file.")); | 577 | showStatMsg(i18n("Successfully opened file.")); |
578 | updateCaption(); | 578 | updateCaption(); |
579 | setVirgin(false); | 579 | setVirgin(false); |
580 | return curDoc(); | 580 | return curDoc(); |
581 | } | 581 | } |
582 | 582 | ||
583 | PwMView * PwM::makeNewListView(PwMDoc *doc) | 583 | PwMView * PwM::makeNewListView(PwMDoc *doc) |
584 | { | 584 | { |
585 | PwMView *ret = new PwMView(this, this, doc); | 585 | PwMView *ret = new PwMView(this, this, doc); |
586 | ret->setFont(conf()->confGlobEntryFont()); | 586 | ret->setFont(conf()->confGlobEntryFont()); |
587 | ret->show(); | 587 | ret->show(); |
588 | return ret; | 588 | return ret; |
589 | } | 589 | } |
590 | 590 | ||
591 | void PwM::close_slot() | 591 | void PwM::close_slot() |
592 | { | 592 | { |
593 | close(); | 593 | close(); |
594 | } | 594 | } |
595 | 595 | ||
596 | void PwM::quitButton_slot() | 596 | void PwM::quitButton_slot() |
597 | { | 597 | { |
598 | init->shutdownApp(0); | 598 | init->shutdownApp(0); |
599 | } | 599 | } |
600 | 600 | ||
601 | void PwM::save_slot() | 601 | void PwM::save_slot() |
602 | { | 602 | { |
603 | save(); | 603 | save(); |
604 | } | 604 | } |
605 | 605 | ||
606 | bool PwM::save() | 606 | bool PwM::save() |
607 | { | 607 | { |
608 | if (!curDoc()->saveDocUi(curDoc())) | 608 | if (!curDoc()->saveDocUi(curDoc())) |
609 | return false; | 609 | return false; |
610 | showStatMsg(i18n("Successfully saved data.")); | 610 | showStatMsg(i18n("Successfully saved data.")); |
611 | updateCaption(); | 611 | updateCaption(); |
612 | return true; | 612 | return true; |
613 | } | 613 | } |
614 | 614 | ||
615 | void PwM::saveAs_slot() | 615 | void PwM::saveAs_slot() |
616 | { | 616 | { |
617 | saveAs(); | 617 | saveAs(); |
618 | } | 618 | } |
619 | 619 | ||
620 | bool PwM::saveAs() | 620 | bool PwM::saveAs() |
621 | { | 621 | { |
622 | if (!curDoc()->saveAsDocUi(curDoc())) | 622 | if (!curDoc()->saveAsDocUi(curDoc())) |
623 | return false; | 623 | return false; |
624 | showStatMsg(i18n("Successfully saved data.")); | 624 | showStatMsg(i18n("Successfully saved data.")); |
625 | updateCaption(); | 625 | updateCaption(); |
626 | return true; | 626 | return true; |
627 | } | 627 | } |
628 | 628 | ||
629 | //US ENH : changed code to run with older MOC | 629 | //US ENH : changed code to run with older MOC |
630 | void PwM::addPwd_slot() | 630 | void PwM::addPwd_slot() |
631 | { | 631 | { |
632 | addPwd_slot1(0, 0); | 632 | addPwd_slot1(0, 0); |
633 | } | 633 | } |
634 | 634 | ||
635 | void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) | 635 | void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) |
636 | { | 636 | { |
637 | PwMDoc *doc; | 637 | PwMDoc *doc; |
638 | if (_doc) { | 638 | if (_doc) { |
639 | doc = _doc; | 639 | doc = _doc; |
640 | } else { | 640 | } else { |
641 | doc = curDoc(); | 641 | doc = curDoc(); |
642 | } | 642 | } |
643 | PWM_ASSERT(doc); | 643 | PWM_ASSERT(doc); |
644 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 644 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
645 | #ifndef PWM_EMBEDDED | 645 | #ifndef PWM_EMBEDDED |
646 | AddEntryWndImpl w; | 646 | AddEntryWndImpl w; |
647 | #else | 647 | #else |
648 | AddEntryWndImpl w(doc, this, "addentrywndimpl"); | 648 | AddEntryWndImpl w(doc, this, "addentrywndimpl"); |
649 | #endif | 649 | #endif |
650 | w.setCaption( i18n ("Add new password") ); | 650 | w.setCaption( i18n ("Add new password") ); |
651 | vector<string> catList; | 651 | vector<string> catList; |
652 | doc->getCategoryList(&catList); | 652 | doc->getCategoryList(&catList); |
653 | unsigned i, size = catList.size(); | 653 | unsigned i, size = catList.size(); |
654 | for (i = 0; i < size; ++i) { | 654 | for (i = 0; i < size; ++i) { |
655 | w.addCategory(catList[i].c_str()); | 655 | w.addCategory(catList[i].c_str()); |
656 | } | 656 | } |
657 | w.setCurrCategory(view->getCurrentCategory()); | 657 | w.setCurrCategory(view->getCurrentCategory()); |
658 | if (pw) | 658 | if (pw) |
659 | w.pwLineEdit->setText(*pw); | 659 | w.pwLineEdit->setText(*pw); |
660 | 660 | ||
661 | tryAgain: | 661 | tryAgain: |
662 | w.descLineEdit->setFocus(); | ||
662 | if (w.exec() == 1) | 663 | if (w.exec() == 1) |
663 | { | 664 | { |
664 | PwMDataItem d; | 665 | PwMDataItem d; |
665 | 666 | ||
666 | //US BUG: to initialize all values of curEntr with meaningfulldata, | 667 | //US BUG: to initialize all values of curEntr with meaningfulldata, |
667 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. | 668 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. |
668 | // another option would be to create a constructor for PwMDataItem | 669 | // another option would be to create a constructor for PwMDataItem |
669 | d.clear(true); | 670 | d.clear(true); |
670 | 671 | ||
671 | d.desc = w.getDescription().latin1(); | 672 | d.desc = w.getDescription().latin1(); |
672 | d.name = w.getUsername().latin1(); | 673 | d.name = w.getUsername().latin1(); |
673 | d.pw = w.getPassword().latin1(); | 674 | d.pw = w.getPassword().latin1(); |
674 | d.comment = w.getComment().latin1(); | 675 | d.comment = w.getComment().latin1(); |
675 | d.url = w.getUrl().latin1(); | 676 | d.url = w.getUrl().latin1(); |
676 | d.launcher = w.getLauncher().latin1(); | 677 | d.launcher = w.getLauncher().latin1(); |
677 | PwMerror ret = doc->addEntry(w.getCategory(), &d); | 678 | PwMerror ret = doc->addEntry(w.getCategory(), &d); |
678 | if (ret == e_entryExists) { | 679 | if (ret == e_entryExists) { |
679 | KMessageBox::error(this, | 680 | KMessageBox::error(this, |
680 | i18n | 681 | i18n |
681 | ("An entry with this \"Description\",\n" | 682 | ("An entry with this \"Description\",\n" |
682 | "does already exist.\n" | 683 | "does already exist.\n" |
683 | "Please select another description."), | 684 | "Please select another description."), |
684 | i18n("entry already exists.")); | 685 | i18n("entry already exists.")); |
685 | goto tryAgain; | 686 | goto tryAgain; |
686 | } else if (ret == e_maxAllowedEntr) { | 687 | } else if (ret == e_maxAllowedEntr) { |
687 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" | 688 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" |
688 | "has been reached.\nYou can't add more entries."), | 689 | "has been reached.\nYou can't add more entries."), |
689 | i18n("maximum number of entries")); | 690 | i18n("maximum number of entries")); |
690 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 691 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
691 | return; | 692 | return; |
692 | } | 693 | } |
693 | } | 694 | } |
694 | setVirgin(false); | 695 | setVirgin(false); |
695 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 696 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
696 | } | 697 | } |
697 | 698 | ||
698 | //US ENH : changed code to run with older MOC | 699 | //US ENH : changed code to run with older MOC |
699 | void PwM::editPwd_slot() | 700 | void PwM::editPwd_slot() |
700 | { | 701 | { |
701 | editPwd_slot3(0,0,0); | 702 | editPwd_slot3(0,0,0); |
702 | } | 703 | } |
703 | 704 | ||
704 | void PwM::editPwd_slot1(const QString *category) | 705 | void PwM::editPwd_slot1(const QString *category) |
705 | { | 706 | { |
706 | editPwd_slot3(category, 0, 0); | 707 | editPwd_slot3(category, 0, 0); |
707 | } | 708 | } |
708 | 709 | ||
709 | void PwM::editPwd_slot3(const QString *category, const int *index, | 710 | void PwM::editPwd_slot3(const QString *category, const int *index, |
710 | PwMDoc *_doc) | 711 | PwMDoc *_doc) |
711 | { | 712 | { |
712 | PwMDoc *doc; | 713 | PwMDoc *doc; |
713 | if (_doc) { | 714 | if (_doc) { |
714 | doc = _doc; | 715 | doc = _doc; |
715 | } else { | 716 | } else { |
716 | doc = curDoc(); | 717 | doc = curDoc(); |
717 | } | 718 | } |
718 | PWM_ASSERT(doc); | 719 | PWM_ASSERT(doc); |
719 | if (doc->isDocEmpty()) | 720 | if (doc->isDocEmpty()) |
720 | return; | 721 | return; |
721 | if (doc->isDeepLocked()) | 722 | if (doc->isDeepLocked()) |
722 | return; | 723 | return; |
723 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 724 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
724 | unsigned int curEntryIndex; | 725 | unsigned int curEntryIndex; |
725 | if (index) { | 726 | if (index) { |
726 | curEntryIndex = *index; | 727 | curEntryIndex = *index; |
727 | } else { | 728 | } else { |
728 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 729 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
729 | printDebug("couldn't get index. Maybe we have a binary entry here."); | 730 | printDebug("couldn't get index. Maybe we have a binary entry here."); |
730 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 731 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
731 | return; | 732 | return; |
732 | } | 733 | } |
733 | } | 734 | } |
734 | QString curCategory; | 735 | QString curCategory; |
735 | if (category) { | 736 | if (category) { |
736 | curCategory = *category; | 737 | curCategory = *category; |
737 | } else { | 738 | } else { |
738 | curCategory = view->getCurrentCategory(); | 739 | curCategory = view->getCurrentCategory(); |
739 | } | 740 | } |
740 | PwMDataItem currItem; | 741 | PwMDataItem currItem; |
741 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { | 742 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { |
742 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 743 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
743 | return; | 744 | return; |
744 | } | 745 | } |
745 | BUG_ON(currItem.binary); | 746 | BUG_ON(currItem.binary); |
746 | 747 | ||
747 | AddEntryWndImpl w(doc); | 748 | AddEntryWndImpl w(doc); |
748 | w.setCaption( i18n ("Edit password") ); | 749 | w.setCaption( i18n ("Edit password") ); |
749 | vector<string> catList; | 750 | vector<string> catList; |
750 | doc->getCategoryList(&catList); | 751 | doc->getCategoryList(&catList); |
751 | unsigned i, size = catList.size(); | 752 | unsigned i, size = catList.size(); |
752 | for (i = 0; i < size; ++i) { | 753 | for (i = 0; i < size; ++i) { |
753 | w.addCategory(catList[i].c_str()); | 754 | w.addCategory(catList[i].c_str()); |
754 | } | 755 | } |
755 | w.setCurrCategory(curCategory); | 756 | w.setCurrCategory(curCategory); |
756 | w.setDescription(currItem.desc.c_str()); | 757 | w.setDescription(currItem.desc.c_str()); |
757 | w.setUsername(currItem.name.c_str()); | 758 | w.setUsername(currItem.name.c_str()); |
758 | w.setPassword(currItem.pw.c_str()); | 759 | w.setPassword(currItem.pw.c_str()); |
759 | w.setUrl(currItem.url.c_str()); | 760 | w.setUrl(currItem.url.c_str()); |
760 | w.setLauncher(currItem.launcher.c_str()); | 761 | w.setLauncher(currItem.launcher.c_str()); |
761 | w.setComment(currItem.comment.c_str()); | 762 | w.setComment(currItem.comment.c_str()); |
763 | w.descLineEdit->setFocus(); | ||
762 | if (w.exec() == 1) { | 764 | if (w.exec() == 1) { |
763 | currItem.desc = w.getDescription().latin1(); | 765 | currItem.desc = w.getDescription().latin1(); |
764 | currItem.name = w.getUsername().latin1(); | 766 | currItem.name = w.getUsername().latin1(); |
765 | currItem.pw = w.getPassword().latin1(); | 767 | currItem.pw = w.getPassword().latin1(); |
766 | currItem.comment = w.getComment().latin1(); | 768 | currItem.comment = w.getComment().latin1(); |
767 | currItem.url = w.getUrl().latin1(); | 769 | currItem.url = w.getUrl().latin1(); |
768 | currItem.launcher = w.getLauncher().latin1(); | 770 | currItem.launcher = w.getLauncher().latin1(); |
769 | if (!doc->editEntry(curCategory, w.getCategory(), | 771 | if (!doc->editEntry(curCategory, w.getCategory(), |
770 | curEntryIndex, &currItem)) { | 772 | curEntryIndex, &currItem)) { |
771 | KMessageBox::error(this, | 773 | KMessageBox::error(this, |
772 | i18n("Couldn't edit the entry.\n" | 774 | i18n("Couldn't edit the entry.\n" |
773 | "Maybe you changed the category and\n" | 775 | "Maybe you changed the category and\n" |
774 | "this entry is already present\nin the new " | 776 | "this entry is already present\nin the new " |
775 | "category?"), | 777 | "category?"), |
776 | i18n("couldn't edit entry.")); | 778 | i18n("couldn't edit entry.")); |
777 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 779 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
778 | return; | 780 | return; |
779 | } | 781 | } |
780 | } | 782 | } |
781 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 783 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
782 | } | 784 | } |
783 | 785 | ||
784 | void PwM::deletePwd_slot() | 786 | void PwM::deletePwd_slot() |
785 | { | 787 | { |
786 | PWM_ASSERT(curDoc()); | 788 | PWM_ASSERT(curDoc()); |
787 | if (curDoc()->isDocEmpty()) | 789 | if (curDoc()->isDocEmpty()) |
788 | return; | 790 | return; |
789 | if (curDoc()->isDeepLocked()) | 791 | if (curDoc()->isDeepLocked()) |
790 | return; | 792 | return; |
791 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 793 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
792 | unsigned int curEntryIndex = 0; | 794 | unsigned int curEntryIndex = 0; |
793 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 795 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
794 | printDebug("couldn't get index"); | 796 | printDebug("couldn't get index"); |
795 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 797 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
796 | return; | 798 | return; |
797 | } | 799 | } |
798 | 800 | ||
799 | PwMDataItem currItem; | 801 | PwMDataItem currItem; |
800 | QString curCategory = view->getCurrentCategory(); | 802 | QString curCategory = view->getCurrentCategory(); |
801 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { | 803 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { |
802 | printDebug("couldn't get entry"); | 804 | printDebug("couldn't get entry"); |
803 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 805 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
804 | return; | 806 | return; |
805 | } | 807 | } |
806 | if (KMessageBox:: | 808 | if (KMessageBox:: |
807 | questionYesNo(this, | 809 | questionYesNo(this, |
808 | i18n | 810 | i18n |
809 | ("Do you really want to delete\nthe selected entry") + | 811 | ("Do you really want to delete\nthe selected entry") + |
810 | " \n\"" + QString(currItem.desc.c_str()) | 812 | " \n\"" + QString(currItem.desc.c_str()) |
811 | + "\" ?", i18n("delete?")) | 813 | + "\" ?", i18n("delete?")) |
812 | == KMessageBox::Yes) { | 814 | == KMessageBox::Yes) { |
813 | 815 | ||
814 | curDoc()->delEntry(curCategory, curEntryIndex); | 816 | curDoc()->delEntry(curCategory, curEntryIndex); |
815 | } | 817 | } |
816 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 818 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
817 | } | 819 | } |
818 | 820 | ||
819 | void PwM::changeMasterPwd_slot() | 821 | void PwM::changeMasterPwd_slot() |
820 | { | 822 | { |
821 | PWM_ASSERT(curDoc()); | 823 | PWM_ASSERT(curDoc()); |
822 | curDoc()->changeCurrentPw(); | 824 | curDoc()->changeCurrentPw(); |
823 | } | 825 | } |
824 | 826 | ||
825 | void PwM::lockWnd_slot() | 827 | void PwM::lockWnd_slot() |
826 | { | 828 | { |
827 | PWM_ASSERT(curDoc()); | 829 | PWM_ASSERT(curDoc()); |
828 | curDoc()->lockAll(true); | 830 | curDoc()->lockAll(true); |
829 | } | 831 | } |
830 | 832 | ||
831 | void PwM::deepLockWnd_slot() | 833 | void PwM::deepLockWnd_slot() |
832 | { | 834 | { |
833 | PWM_ASSERT(curDoc()); | 835 | PWM_ASSERT(curDoc()); |
834 | curDoc()->deepLock(); | 836 | curDoc()->deepLock(); |
835 | } | 837 | } |
836 | 838 | ||
837 | void PwM::unlockWnd_slot() | 839 | void PwM::unlockWnd_slot() |
838 | { | 840 | { |
839 | PWM_ASSERT(curDoc()); | 841 | PWM_ASSERT(curDoc()); |
840 | curDoc()->lockAll(false); | 842 | curDoc()->lockAll(false); |
841 | } | 843 | } |
842 | 844 | ||
843 | void PwM::config_slot() | 845 | void PwM::config_slot() |
844 | { | 846 | { |
845 | int oldStyle = conf()->confWndMainViewStyle(); | 847 | int oldStyle = conf()->confWndMainViewStyle(); |
846 | #ifdef PWM_EMBEDDED | 848 | #ifdef PWM_EMBEDDED |
847 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); | 849 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); |
848 | 850 | ||
849 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); | 851 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); |
850 | ConfigureDialog->addModule(pwmcfg ); | 852 | ConfigureDialog->addModule(pwmcfg ); |
851 | 853 | ||
852 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 854 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
853 | ConfigureDialog->addModule(kdelibcfg ); | 855 | ConfigureDialog->addModule(kdelibcfg ); |
854 | 856 | ||
855 | #ifndef DESKTOP_VERSION | 857 | #ifndef DESKTOP_VERSION |
856 | ConfigureDialog->showMaximized(); | 858 | ConfigureDialog->showMaximized(); |
857 | #endif | 859 | #endif |
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp index 8c4d9cc..7f7dd6f 100644 --- a/pwmanager/pwmanager/pwmview.cpp +++ b/pwmanager/pwmanager/pwmview.cpp | |||
@@ -1,163 +1,164 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003, 2004 by Michael Buesch * | 3 | * copyright (C) 2003, 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 "pwmview.h" | 20 | #include "pwmview.h" |
21 | #include "pwmexception.h" | 21 | #include "pwmexception.h" |
22 | #include "globalstuff.h" | 22 | #include "globalstuff.h" |
23 | #include "pwm.h" | 23 | #include "pwm.h" |
24 | #include "rencatwnd.h" | 24 | #include "rencatwnd.h" |
25 | #ifndef PWM_EMBEDDED | 25 | #ifndef PWM_EMBEDDED |
26 | #include "configuration.h" | 26 | #include "configuration.h" |
27 | #else | 27 | #else |
28 | #include "pwmprefs.h" | 28 | #include "pwmprefs.h" |
29 | #endif | 29 | #endif |
30 | #include "commentbox.h" | 30 | #include "commentbox.h" |
31 | 31 | ||
32 | #include <kmessagebox.h> | 32 | #include <kmessagebox.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qpoint.h> | 36 | #include <qpoint.h> |
37 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | 39 | ||
40 | //US ENH: wouldn't it be a good idea if we could use this consts everywhere else. | 40 | //US ENH: wouldn't it be a good idea if we could use this consts everywhere else. |
41 | //US ENH: for examle in listviewpwm.cpp | 41 | //US ENH: for examle in listviewpwm.cpp |
42 | //US ENH: Because of that I transfer them into the headerfile. | 42 | //US ENH: Because of that I transfer them into the headerfile. |
43 | /* | 43 | /* |
44 | #define COLUMN_DESC 0 | 44 | #define COLUMN_DESC 0 |
45 | #define COLUMN_NAME 1 | 45 | #define COLUMN_NAME 1 |
46 | #define COLUMN_PW 2 | 46 | #define COLUMN_PW 2 |
47 | #define COLUMN_URL 3 | 47 | #define COLUMN_URL 3 |
48 | #define COLUMN_LAUNCHER 4 | 48 | #define COLUMN_LAUNCHER 4 |
49 | */ | 49 | */ |
50 | 50 | ||
51 | PwMView::PwMView(PwM *_mainClass, | 51 | PwMView::PwMView(PwM *_mainClass, |
52 | QWidget *parent, PwMDoc *_doc, | 52 | QWidget *parent, PwMDoc *_doc, |
53 | const char *name) | 53 | const char *name) |
54 | : PwMViewStyle(parent, name) | 54 | : PwMViewStyle(parent, name) |
55 | { | 55 | { |
56 | PWM_ASSERT(_mainClass); | 56 | PWM_ASSERT(_mainClass); |
57 | PWM_ASSERT(parent); | 57 | PWM_ASSERT(parent); |
58 | PWM_ASSERT(_doc); | 58 | PWM_ASSERT(_doc); |
59 | setView(this); | 59 | setView(this); |
60 | doc = _doc; | 60 | doc = _doc; |
61 | doc->setListViewPointer(this); | 61 | doc->setListViewPointer(this); |
62 | mainClass = _mainClass; | 62 | mainClass = _mainClass; |
63 | resize(_mainClass->size()); | 63 | resize(_mainClass->size()); |
64 | initStyle(conf()->confWndMainViewStyle()); | 64 | initStyle(conf()->confWndMainViewStyle()); |
65 | initCtxMenu(); | 65 | initCtxMenu(); |
66 | doc->setCurrentView(this); | 66 | doc->setCurrentView(this); |
67 | connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); | 67 | connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); |
68 | connect(this, SIGNAL(editPW()), mainClass, SLOT(editPwd_slot())); | ||
68 | } | 69 | } |
69 | 70 | ||
70 | PwMView::~PwMView() | 71 | PwMView::~PwMView() |
71 | { | 72 | { |
72 | } | 73 | } |
73 | 74 | ||
74 | void PwMView::initCtxMenu() | 75 | void PwMView::initCtxMenu() |
75 | { | 76 | { |
76 | ctxMenu = new QPopupMenu(this); | 77 | ctxMenu = new QPopupMenu(this); |
77 | ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); | 78 | ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); |
78 | ctxMenu->insertSeparator(); | 79 | ctxMenu->insertSeparator(); |
79 | ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); | 80 | ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); |
80 | ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); | 81 | ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); |
81 | ctxMenu->insertSeparator(); | 82 | ctxMenu->insertSeparator(); |
82 | ctxMenu->insertItem(i18n("copy password to clipboard"), | 83 | ctxMenu->insertItem(i18n("copy password to clipboard"), |
83 | this, SLOT(copyPwToClip())); | 84 | this, SLOT(copyPwToClip())); |
84 | ctxMenu->insertItem(i18n("copy username to clipboard"), | 85 | ctxMenu->insertItem(i18n("copy username to clipboard"), |
85 | this, SLOT(copyNameToClip())); | 86 | this, SLOT(copyNameToClip())); |
86 | ctxMenu->insertItem(i18n("copy description to clipboard"), | 87 | ctxMenu->insertItem(i18n("copy description to clipboard"), |
87 | this, SLOT(copyDescToClip())); | 88 | this, SLOT(copyDescToClip())); |
88 | ctxMenu->insertItem(i18n("copy url to clipboard"), | 89 | ctxMenu->insertItem(i18n("copy url to clipboard"), |
89 | this, SLOT(copyUrlToClip())); | 90 | this, SLOT(copyUrlToClip())); |
90 | ctxMenu->insertItem(i18n("copy launcher to clipboard"), | 91 | ctxMenu->insertItem(i18n("copy launcher to clipboard"), |
91 | this, SLOT(copyLauncherToClip())); | 92 | this, SLOT(copyLauncherToClip())); |
92 | ctxMenu->insertItem(i18n("copy comment to clipboard"), | 93 | ctxMenu->insertItem(i18n("copy comment to clipboard"), |
93 | this, SLOT(copyCommentToClip())); | 94 | this, SLOT(copyCommentToClip())); |
94 | ctxMenu->insertSeparator(); | 95 | ctxMenu->insertSeparator(); |
95 | ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, | 96 | ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, |
96 | SLOT(execLauncher_slot())); | 97 | SLOT(execLauncher_slot())); |
97 | ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, | 98 | ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, |
98 | SLOT(goToURL_slot())); | 99 | SLOT(goToURL_slot())); |
99 | } | 100 | } |
100 | 101 | ||
101 | void PwMView::resizeEvent(QResizeEvent *) | 102 | void PwMView::resizeEvent(QResizeEvent *) |
102 | { | 103 | { |
103 | resizeView(size()); | 104 | resizeView(size()); |
104 | } | 105 | } |
105 | 106 | ||
106 | void PwMView::refreshCommentTextEdit(QListViewItem *curItem) | 107 | void PwMView::refreshCommentTextEdit(QListViewItem *curItem) |
107 | { | 108 | { |
108 | PWM_ASSERT(commentBox); | 109 | PWM_ASSERT(commentBox); |
109 | if (!curItem) | 110 | if (!curItem) |
110 | return; | 111 | return; |
111 | string comment; | 112 | string comment; |
112 | PwMerror ret; | 113 | PwMerror ret; |
113 | ret = document()->getCommentByLvp(getCurrentCategory(), | 114 | ret = document()->getCommentByLvp(getCurrentCategory(), |
114 | lv->childCount() - lv->itemIndex(curItem) - 1, | 115 | lv->childCount() - lv->itemIndex(curItem) - 1, |
115 | &comment); | 116 | &comment); |
116 | if (ret == e_binEntry) { | 117 | if (ret == e_binEntry) { |
117 | commentBox->setContent(i18n("This is a binary entry.\n" | 118 | commentBox->setContent(i18n("This is a binary entry.\n" |
118 | "It is not a normal password-entry, as it contains " | 119 | "It is not a normal password-entry, as it contains " |
119 | "binary data, which PwManager can't display here.")); | 120 | "binary data, which PwManager can't display here.")); |
120 | } else if (ret == e_normalEntry) { | 121 | } else if (ret == e_normalEntry) { |
121 | commentBox->setContent(comment.c_str()); | 122 | commentBox->setContent(comment.c_str()); |
122 | } else { | 123 | } else { |
123 | BUG(); | 124 | BUG(); |
124 | return; | 125 | return; |
125 | } | 126 | } |
126 | lv->ensureItemVisible(curItem); | 127 | lv->ensureItemVisible(curItem); |
127 | } | 128 | } |
128 | 129 | ||
129 | void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) | 130 | void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) |
130 | { | 131 | { |
131 | refreshCommentTextEdit(lv->currentItem()); | 132 | refreshCommentTextEdit(lv->currentItem()); |
132 | } | 133 | } |
133 | 134 | ||
134 | bool PwMView::getCurEntryIndex(unsigned int *index) | 135 | bool PwMView::getCurEntryIndex(unsigned int *index) |
135 | { | 136 | { |
136 | QListViewItem *current = lv->currentItem(); | 137 | QListViewItem *current = lv->currentItem(); |
137 | if (!current) | 138 | if (!current) |
138 | return false; | 139 | return false; |
139 | return getDocEntryIndex(index, current); | 140 | return getDocEntryIndex(index, current); |
140 | } | 141 | } |
141 | 142 | ||
142 | bool PwMView::getDocEntryIndex(unsigned int *index, | 143 | bool PwMView::getDocEntryIndex(unsigned int *index, |
143 | const QListViewItem *item) | 144 | const QListViewItem *item) |
144 | { | 145 | { |
145 | vector<unsigned int> foundPositions; | 146 | vector<unsigned int> foundPositions; |
146 | PwMDataItem curItem; | 147 | PwMDataItem curItem; |
147 | curItem.desc = item->text(COLUMN_DESC).latin1(); | 148 | curItem.desc = item->text(COLUMN_DESC).latin1(); |
148 | curItem.name = item->text(COLUMN_NAME).latin1(); | 149 | curItem.name = item->text(COLUMN_NAME).latin1(); |
149 | document()->getCommentByLvp(getCurrentCategory(), | 150 | document()->getCommentByLvp(getCurrentCategory(), |
150 | lv->childCount() - lv->itemIndex(item) - 1, | 151 | lv->childCount() - lv->itemIndex(item) - 1, |
151 | &curItem.comment); | 152 | &curItem.comment); |
152 | curItem.url = item->text(COLUMN_URL).latin1(); | 153 | curItem.url = item->text(COLUMN_URL).latin1(); |
153 | curItem.launcher = item->text(COLUMN_LAUNCHER).latin1(); | 154 | curItem.launcher = item->text(COLUMN_LAUNCHER).latin1(); |
154 | document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC | | 155 | document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC | |
155 | SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL | | 156 | SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL | |
156 | SEARCH_IN_LAUNCHER, | 157 | SEARCH_IN_LAUNCHER, |
157 | &foundPositions, true); | 158 | &foundPositions, true); |
158 | if (foundPositions.size()) { | 159 | if (foundPositions.size()) { |
159 | *index = foundPositions[0]; | 160 | *index = foundPositions[0]; |
160 | return true; | 161 | return true; |
161 | } | 162 | } |
162 | 163 | ||
163 | return false; | 164 | return false; |
diff --git a/pwmanager/pwmanager/pwmviewstyle.cpp b/pwmanager/pwmanager/pwmviewstyle.cpp index 0af1473..5f25880 100644 --- a/pwmanager/pwmanager/pwmviewstyle.cpp +++ b/pwmanager/pwmanager/pwmviewstyle.cpp | |||
@@ -1,191 +1,202 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
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 | /*************************************************************************** | 13 | /*************************************************************************** |
14 | * copyright (C) 2004 by Ulf Schenk | 14 | * copyright (C) 2004 by Ulf Schenk |
15 | * This file is originaly based on version 1.0.1 of pwmanager | 15 | * This file is originaly based on version 1.0.1 of pwmanager |
16 | * and was modified to run on embedded devices that run microkde | 16 | * and was modified to run on embedded devices that run microkde |
17 | * | 17 | * |
18 | * $Id$ | 18 | * $Id$ |
19 | **************************************************************************/ | 19 | **************************************************************************/ |
20 | 20 | ||
21 | #include "pwmviewstyle.h" | 21 | #include "pwmviewstyle.h" |
22 | #include "pwmexception.h" | 22 | #include "pwmexception.h" |
23 | #include "pwmviewstyle_0.h" | 23 | #include "pwmviewstyle_0.h" |
24 | #include "pwmviewstyle_1.h" | 24 | #include "pwmviewstyle_1.h" |
25 | #include "listviewpwm.h" | 25 | #include "listviewpwm.h" |
26 | #include "pwmview.h" | 26 | #include "pwmview.h" |
27 | #include "commentbox.h" | 27 | #include "commentbox.h" |
28 | #ifndef PWM_EMBEDDED | 28 | #ifndef PWM_EMBEDDED |
29 | #include "configuration.h" | 29 | #include "configuration.h" |
30 | #else | 30 | #else |
31 | #include "pwmprefs.h" | 31 | #include "pwmprefs.h" |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name) | 34 | PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name) |
35 | : QWidget(parent, name) | 35 | : QWidget(parent, name) |
36 | { | 36 | { |
37 | curStyle = style_notset; | 37 | curStyle = style_notset; |
38 | s0 = 0; | 38 | s0 = 0; |
39 | s1 = 0; | 39 | s1 = 0; |
40 | } | 40 | } |
41 | 41 | ||
42 | PwMViewStyle::~PwMViewStyle() | 42 | PwMViewStyle::~PwMViewStyle() |
43 | { | 43 | { |
44 | //US ENH : store the size of the listviewcolumns | 44 | //US ENH : store the size of the listviewcolumns |
45 | switch (curStyle) | 45 | switch (curStyle) |
46 | { | 46 | { |
47 | case style_0: | 47 | case style_0: |
48 | s0->saveSettings(PWMPrefs::instance()); | 48 | s0->saveSettings(PWMPrefs::instance()); |
49 | break; | 49 | break; |
50 | case style_1: | 50 | case style_1: |
51 | s1->saveSettings(PWMPrefs::instance()); | 51 | s1->saveSettings(PWMPrefs::instance()); |
52 | break; | 52 | break; |
53 | default: | 53 | default: |
54 | BUG(); | 54 | BUG(); |
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
58 | PWMPrefs::instance()->writeConfig(); | 58 | PWMPrefs::instance()->writeConfig(); |
59 | 59 | ||
60 | delete_ifnot_null(s0); | 60 | delete_ifnot_null(s0); |
61 | delete_ifnot_null(s1); | 61 | delete_ifnot_null(s1); |
62 | } | 62 | } |
63 | 63 | ||
64 | void PwMViewStyle::editPassWord( QListViewItem * i ) | ||
65 | { | ||
66 | if ( !i ) | ||
67 | return; | ||
68 | emit editPW(); | ||
69 | } | ||
64 | void PwMViewStyle::initStyle(style_t style) | 70 | void PwMViewStyle::initStyle(style_t style) |
65 | { | 71 | { |
66 | printDebug(string("initializing style ") + tostr(style)); | 72 | printDebug(string("initializing style ") + tostr(style)); |
67 | bool wasMaximized = v->isMaximized(); | 73 | bool wasMaximized = v->isMaximized(); |
68 | if (v->isVisible()) | 74 | if (v->isVisible()) |
69 | v->hide(); | 75 | v->hide(); |
70 | switch (style) { | 76 | switch (style) { |
71 | case style_0: | 77 | case style_0: |
72 | delete_ifnot_null(s0); | 78 | delete_ifnot_null(s0); |
73 | delete_ifnot_null(s1); | 79 | delete_ifnot_null(s1); |
74 | s0 = new PwMViewStyle_0(v); | 80 | s0 = new PwMViewStyle_0(v); |
75 | lv = s0->getLv(); | 81 | lv = s0->getLv(); |
76 | commentBox = s0->getCommentBox(); | 82 | commentBox = s0->getCommentBox(); |
77 | break; | 83 | break; |
78 | case style_1: | 84 | case style_1: |
79 | delete_ifnot_null(s0); | 85 | delete_ifnot_null(s0); |
80 | delete_ifnot_null(s1); | 86 | delete_ifnot_null(s1); |
81 | s1 = new PwMViewStyle_1(v); | 87 | s1 = new PwMViewStyle_1(v); |
82 | lv = s1->getLv(); | 88 | lv = s1->getLv(); |
83 | commentBox = s1->getCommentBox(); | 89 | commentBox = s1->getCommentBox(); |
84 | break; | 90 | break; |
85 | default: | 91 | default: |
86 | BUG(); | 92 | BUG(); |
87 | return; | 93 | return; |
88 | } | 94 | } |
89 | curStyle = style; | 95 | curStyle = style; |
90 | connect(lv, SIGNAL(pressed(QListViewItem *)), | 96 | connect(lv, SIGNAL(pressed(QListViewItem *)), |
91 | v, SLOT(handleToggle(QListViewItem *))); | 97 | v, SLOT(handleToggle(QListViewItem *))); |
92 | connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)), | 98 | connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)), |
93 | v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int))); | 99 | v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int))); |
94 | connect(lv, SIGNAL(clicked(QListViewItem *)), | 100 | connect(lv, SIGNAL(clicked(QListViewItem *)), |
95 | v, SLOT(refreshCommentTextEdit(QListViewItem *))); | 101 | v, SLOT(refreshCommentTextEdit(QListViewItem *))); |
102 | connect(lv, SIGNAL(returnPressed(QListViewItem *)), | ||
103 | this, SLOT(editPassWord(QListViewItem *))); | ||
104 | connect(lv, SIGNAL(doubleClicked(QListViewItem *)), | ||
105 | this, SLOT(editPassWord(QListViewItem *))); | ||
106 | |||
96 | lv->addColumn(i18n("Description"), 180); | 107 | lv->addColumn(i18n("Description"), 180); |
97 | lv->addColumn(i18n("Username"), 150); | 108 | lv->addColumn(i18n("Username"), 150); |
98 | lv->addColumn(i18n("Password"), 150); | 109 | lv->addColumn(i18n("Password"), 150); |
99 | lv->addColumn(i18n("URL"), 180); | 110 | lv->addColumn(i18n("URL"), 180); |
100 | lv->addColumn(i18n("Launcher"), 120); | 111 | lv->addColumn(i18n("Launcher"), 120); |
101 | v->tmpReEnableSort(); | 112 | v->tmpReEnableSort(); |
102 | 113 | ||
103 | //US ENH : load the size of the listviewcolumns | 114 | //US ENH : load the size of the listviewcolumns |
104 | switch (curStyle) | 115 | switch (curStyle) |
105 | { | 116 | { |
106 | case style_0: | 117 | case style_0: |
107 | s0->restoreSettings(PWMPrefs::instance()); | 118 | s0->restoreSettings(PWMPrefs::instance()); |
108 | break; | 119 | break; |
109 | case style_1: | 120 | case style_1: |
110 | s1->restoreSettings(PWMPrefs::instance()); | 121 | s1->restoreSettings(PWMPrefs::instance()); |
111 | break; | 122 | break; |
112 | default: | 123 | default: |
113 | BUG(); | 124 | BUG(); |
114 | } | 125 | } |
115 | 126 | ||
116 | resizeView(v->size()); | 127 | resizeView(v->size()); |
117 | v->updateView(); | 128 | v->updateView(); |
118 | if (wasMaximized) { | 129 | if (wasMaximized) { |
119 | v->showMaximized(); | 130 | v->showMaximized(); |
120 | } else { | 131 | } else { |
121 | v->show(); | 132 | v->show(); |
122 | } | 133 | } |
123 | connect(lv, SIGNAL(layoutChanged()), | 134 | connect(lv, SIGNAL(layoutChanged()), |
124 | v, SLOT(reorgLp())); | 135 | v, SLOT(reorgLp())); |
125 | } | 136 | } |
126 | 137 | ||
127 | void PwMViewStyle::resizeView(const QSize &size) | 138 | void PwMViewStyle::resizeView(const QSize &size) |
128 | { | 139 | { |
129 | switch (curStyle) { | 140 | switch (curStyle) { |
130 | case style_0: | 141 | case style_0: |
131 | PWM_ASSERT(s0); | 142 | PWM_ASSERT(s0); |
132 | s0->resize(size); | 143 | s0->resize(size); |
133 | return; | 144 | return; |
134 | case style_1: | 145 | case style_1: |
135 | PWM_ASSERT(s1); | 146 | PWM_ASSERT(s1); |
136 | s1->resize(size); | 147 | s1->resize(size); |
137 | return; | 148 | return; |
138 | default: | 149 | default: |
139 | BUG(); | 150 | BUG(); |
140 | } | 151 | } |
141 | } | 152 | } |
142 | 153 | ||
143 | QString PwMViewStyle::getCurrentCategory() | 154 | QString PwMViewStyle::getCurrentCategory() |
144 | { | 155 | { |
145 | switch (curStyle) { | 156 | switch (curStyle) { |
146 | case style_0: | 157 | case style_0: |
147 | PWM_ASSERT(s0); | 158 | PWM_ASSERT(s0); |
148 | return s0->getCurrentCategory(); | 159 | return s0->getCurrentCategory(); |
149 | case style_1: | 160 | case style_1: |
150 | PWM_ASSERT(s1); | 161 | PWM_ASSERT(s1); |
151 | return s1->getCurrentCategory(); | 162 | return s1->getCurrentCategory(); |
152 | default: | 163 | default: |
153 | BUG(); | 164 | BUG(); |
154 | } | 165 | } |
155 | return ""; | 166 | return ""; |
156 | } | 167 | } |
157 | 168 | ||
158 | void PwMViewStyle::addCategory(const QString &cat) | 169 | void PwMViewStyle::addCategory(const QString &cat) |
159 | { | 170 | { |
160 | switch (curStyle) { | 171 | switch (curStyle) { |
161 | case style_0: | 172 | case style_0: |
162 | PWM_ASSERT(s0); | 173 | PWM_ASSERT(s0); |
163 | s0->addCategory(cat); | 174 | s0->addCategory(cat); |
164 | return; | 175 | return; |
165 | case style_1: | 176 | case style_1: |
166 | PWM_ASSERT(s1); | 177 | PWM_ASSERT(s1); |
167 | s1->addCategory(cat); | 178 | s1->addCategory(cat); |
168 | return; | 179 | return; |
169 | default: | 180 | default: |
170 | BUG(); | 181 | BUG(); |
171 | } | 182 | } |
172 | } | 183 | } |
173 | 184 | ||
174 | void PwMViewStyle::delCategory(const QString &cat) | 185 | void PwMViewStyle::delCategory(const QString &cat) |
175 | { | 186 | { |
176 | switch (curStyle) { | 187 | switch (curStyle) { |
177 | case style_0: | 188 | case style_0: |
178 | PWM_ASSERT(s0); | 189 | PWM_ASSERT(s0); |
179 | s0->delCategory(cat); | 190 | s0->delCategory(cat); |
180 | return; | 191 | return; |
181 | case style_1: | 192 | case style_1: |
182 | PWM_ASSERT(s1); | 193 | PWM_ASSERT(s1); |
183 | s1->delCategory(cat); | 194 | s1->delCategory(cat); |
184 | return; | 195 | return; |
185 | default: | 196 | default: |
186 | BUG(); | 197 | BUG(); |
187 | } | 198 | } |
188 | } | 199 | } |
189 | 200 | ||
190 | void PwMViewStyle::delAllCategories() | 201 | void PwMViewStyle::delAllCategories() |
191 | { | 202 | { |
diff --git a/pwmanager/pwmanager/pwmviewstyle.h b/pwmanager/pwmanager/pwmviewstyle.h index bf5ce91..5656cbc 100644 --- a/pwmanager/pwmanager/pwmviewstyle.h +++ b/pwmanager/pwmanager/pwmviewstyle.h | |||
@@ -1,108 +1,113 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
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 | /*************************************************************************** | 13 | /*************************************************************************** |
14 | * copyright (C) 2004 by Ulf Schenk | 14 | * copyright (C) 2004 by Ulf Schenk |
15 | * This file is originaly based on version 1.0.1 of pwmanager | 15 | * This file is originaly based on version 1.0.1 of pwmanager |
16 | * and was modified to run on embedded devices that run microkde | 16 | * and was modified to run on embedded devices that run microkde |
17 | * | 17 | * |
18 | * $Id$ | 18 | * $Id$ |
19 | **************************************************************************/ | 19 | **************************************************************************/ |
20 | 20 | ||
21 | #ifndef PWMVIEWSTYLE_H | 21 | #ifndef PWMVIEWSTYLE_H |
22 | #define PWMVIEWSTYLE_H | 22 | #define PWMVIEWSTYLE_H |
23 | 23 | ||
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qsplitter.h> | 25 | #include <qsplitter.h> |
26 | #include <qhbox.h> | 26 | #include <qhbox.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qpopupmenu.h> | 29 | #include <qpopupmenu.h> |
30 | #ifndef PWM_EMBEDDED | 30 | #ifndef PWM_EMBEDDED |
31 | #include <qtextedit.h> | 31 | #include <qtextedit.h> |
32 | #else | 32 | #else |
33 | #include <qmultilineedit.h> | 33 | #include <qmultilineedit.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qlistbox.h> | 37 | #include <qlistbox.h> |
38 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
39 | #include <qsize.h> | 39 | #include <qsize.h> |
40 | 40 | ||
41 | class ListViewPwM; | 41 | class ListViewPwM; |
42 | class PwMViewStyle_0; | 42 | class PwMViewStyle_0; |
43 | class PwMViewStyle_1; | 43 | class PwMViewStyle_1; |
44 | class PwMView; | 44 | class PwMView; |
45 | class QListViewItem; | ||
45 | class CommentBox; | 46 | class CommentBox; |
46 | 47 | ||
47 | class PwMViewStyle : public QWidget | 48 | class PwMViewStyle : public QWidget |
48 | { | 49 | { |
49 | Q_OBJECT | 50 | Q_OBJECT |
50 | 51 | ||
51 | public: | 52 | public: |
52 | enum style_t | 53 | enum style_t |
53 | { | 54 | { |
54 | style_notset= -1, | 55 | style_notset= -1, |
55 | style_0 = 0, | 56 | style_0 = 0, |
56 | style_1 = 1 | 57 | style_1 = 1 |
57 | }; | 58 | }; |
58 | 59 | ||
59 | public: | 60 | public: |
60 | PwMViewStyle(QWidget *parent = 0, const char *name = 0); | 61 | PwMViewStyle(QWidget *parent = 0, const char *name = 0); |
61 | ~PwMViewStyle(); | 62 | ~PwMViewStyle(); |
62 | 63 | ||
63 | /** initialize a new style */ | 64 | /** initialize a new style */ |
64 | void initStyle(style_t style); | 65 | void initStyle(style_t style); |
65 | void initStyle(int style) | 66 | void initStyle(int style) |
66 | { initStyle(static_cast<style_t>(style)); } | 67 | { initStyle(static_cast<style_t>(style)); } |
67 | /** returns the currently used style */ | 68 | /** returns the currently used style */ |
68 | style_t getCurStyle() | 69 | style_t getCurStyle() |
69 | { return curStyle; } | 70 | { return curStyle; } |
70 | void setView(PwMView *view) | 71 | void setView(PwMView *view) |
71 | { v = view; } | 72 | { v = view; } |
72 | 73 | ||
73 | /** returns the currently selected category */ | 74 | /** returns the currently selected category */ |
74 | QString getCurrentCategory(); | 75 | QString getCurrentCategory(); |
75 | 76 | ||
76 | protected: | 77 | protected: |
77 | /** add Category to the view */ | 78 | /** add Category to the view */ |
78 | void addCategory(const QString &cat); | 79 | void addCategory(const QString &cat); |
79 | /** delete Category from view */ | 80 | /** delete Category from view */ |
80 | void delCategory(const QString &cat); | 81 | void delCategory(const QString &cat); |
81 | /** delete all categories from view */ | 82 | /** delete all categories from view */ |
82 | void delAllCategories(); | 83 | void delAllCategories(); |
83 | /** select the specified category */ | 84 | /** select the specified category */ |
84 | void selectCategory(const QString &cat); | 85 | void selectCategory(const QString &cat); |
85 | /** returns the number of categories in this view. | 86 | /** returns the number of categories in this view. |
86 | * This value dosn't say anything about the number of | 87 | * This value dosn't say anything about the number of |
87 | * categories in the document. | 88 | * categories in the document. |
88 | */ | 89 | */ |
89 | int numCategories(); | 90 | int numCategories(); |
90 | /** resize the view */ | 91 | /** resize the view */ |
91 | void resizeView(const QSize &size); | 92 | void resizeView(const QSize &size); |
93 | ListViewPwM *lv; | ||
94 | CommentBox *commentBox; | ||
95 | |||
96 | protected slots: | ||
97 | void editPassWord( QListViewItem * ); | ||
92 | 98 | ||
93 | private: | 99 | private: |
94 | /** which style has the view? | 100 | /** which style has the view? |
95 | * KListBox on the left, | 101 | * KListBox on the left, |
96 | * or QComboBox on the top? | 102 | * or QComboBox on the top? |
97 | */ | 103 | */ |
98 | style_t curStyle; | 104 | style_t curStyle; |
99 | 105 | ||
100 | PwMViewStyle_0 *s0; | 106 | PwMViewStyle_0 *s0; |
101 | PwMViewStyle_1 *s1; | 107 | PwMViewStyle_1 *s1; |
102 | PwMView *v; | 108 | PwMView *v; |
109 | signals: | ||
110 | void editPW(); | ||
103 | 111 | ||
104 | protected: | ||
105 | ListViewPwM *lv; | ||
106 | CommentBox *commentBox; | ||
107 | }; | 112 | }; |
108 | #endif | 113 | #endif |