-rw-r--r-- | pwmanager/pwmanager/editcategory.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/editcategory.cpp b/pwmanager/pwmanager/editcategory.cpp index 4e55de8..4e2378c 100644 --- a/pwmanager/pwmanager/editcategory.cpp +++ b/pwmanager/pwmanager/editcategory.cpp | |||
@@ -52,137 +52,138 @@ editCategoryWnd::editCategoryWnd( PwMDoc* d, QWidget* parent, const char* name) | |||
52 | findButton( User2 )->setText (i18n("Cancel" )) ; | 52 | findButton( User2 )->setText (i18n("Cancel" )) ; |
53 | connect(this,SIGNAL(user2Clicked()), SLOT(cancel_slot())); | 53 | connect(this,SIGNAL(user2Clicked()), SLOT(cancel_slot())); |
54 | enableButton( KDialogBase::Apply, false ); | 54 | enableButton( KDialogBase::Apply, false ); |
55 | 55 | ||
56 | 56 | ||
57 | QWidget *page = plainPage(); | 57 | QWidget *page = plainPage(); |
58 | QGridLayout *layout = new QGridLayout( page, 3, 1 ); | 58 | QGridLayout *layout = new QGridLayout( page, 3, 1 ); |
59 | layout->setMargin( KDialogBase::marginHint() ); | 59 | layout->setMargin( KDialogBase::marginHint() ); |
60 | layout->setSpacing( KDialogBase::spacingHint() ); | 60 | layout->setSpacing( KDialogBase::spacingHint() ); |
61 | 61 | ||
62 | int i = 0; | 62 | int i = 0; |
63 | categoryComboBox = new KComboBox( page ); | 63 | categoryComboBox = new KComboBox( page ); |
64 | QLabel* label = new QLabel( categoryComboBox, i18n("Category:"), page ); | 64 | QLabel* label = new QLabel( categoryComboBox, i18n("Category:"), page ); |
65 | layout->addWidget( label, i, 0 ); | 65 | layout->addWidget( label, i, 0 ); |
66 | layout->addWidget( categoryComboBox, i, 1 ); | 66 | layout->addWidget( categoryComboBox, i, 1 ); |
67 | i++; | 67 | i++; |
68 | categoryComboBox->setEditable( FALSE ); | 68 | categoryComboBox->setEditable( FALSE ); |
69 | categoryComboBox->setSizeLimit( 100 ); | 69 | categoryComboBox->setSizeLimit( 100 ); |
70 | connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&))); | 70 | connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&))); |
71 | 71 | ||
72 | 72 | ||
73 | descLineEdit = new KLineEdit( page, "descLineEdit" ); | 73 | descLineEdit = new KLineEdit( page, "descLineEdit" ); |
74 | label = new QLabel( descLineEdit, i18n("Text1 (Description):"), page ); | 74 | label = new QLabel( descLineEdit, i18n("Text1 (Description):"), page ); |
75 | layout->addWidget( label, i, 0 ); | 75 | layout->addWidget( label, i, 0 ); |
76 | layout->addWidget( descLineEdit, i, 1 ); | 76 | layout->addWidget( descLineEdit, i, 1 ); |
77 | connect( descLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) ); | 77 | connect( descLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) ); |
78 | i++; | 78 | i++; |
79 | 79 | ||
80 | usernameLineEdit = new KLineEdit( page, "usernameLineEdit" ); | 80 | usernameLineEdit = new KLineEdit( page, "usernameLineEdit" ); |
81 | label = new QLabel( usernameLineEdit, i18n("Text2 (Username):"), page ); | 81 | label = new QLabel( usernameLineEdit, i18n("Text2 (Username):"), page ); |
82 | layout->addWidget( label, i, 0 ); | 82 | layout->addWidget( label, i, 0 ); |
83 | layout->addWidget( usernameLineEdit, i, 1 ); | 83 | layout->addWidget( usernameLineEdit, i, 1 ); |
84 | connect( usernameLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) ); | 84 | connect( usernameLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) ); |
85 | i++; | 85 | i++; |
86 | 86 | ||
87 | pwLineEdit = new KLineEdit( page, "pwLineEdit" ); | 87 | pwLineEdit = new KLineEdit( page, "pwLineEdit" ); |
88 | label = new QLabel( pwLineEdit, i18n("Text3 (Password):"), page ); | 88 | label = new QLabel( pwLineEdit, i18n("Text3 (Password):"), page ); |
89 | layout->addWidget( label, i, 0 ); | 89 | layout->addWidget( label, i, 0 ); |
90 | layout->addWidget( pwLineEdit, i, 1 ); | 90 | layout->addWidget( pwLineEdit, i, 1 ); |
91 | connect( pwLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) ); | 91 | connect( pwLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) ); |
92 | i++; | 92 | i++; |
93 | 93 | ||
94 | unsigned int count = doc->numCategories(); | 94 | unsigned int count = doc->numCategories(); |
95 | 95 | ||
96 | for (unsigned int i = 0; i < count; ++i) { | 96 | for (unsigned int i = 0; i < count; ++i) { |
97 | categoryComboBox->insertItem(doc->getCategory(i)->c_str()); | 97 | categoryComboBox->insertItem(doc->getCategory(i)->c_str()); |
98 | } | 98 | } |
99 | 99 | ||
100 | //PwMCategoryItem* getCategoryEntry(unsigned int index) | 100 | //PwMCategoryItem* getCategoryEntry(unsigned int index) |
101 | // { return &(dti.dta[index]); } | 101 | // { return &(dti.dta[index]); } |
102 | 102 | ||
103 | 103 | ||
104 | 104 | ||
105 | } | 105 | } |
106 | 106 | ||
107 | /* | 107 | /* |
108 | * Destroys the object and frees any allocated resources | 108 | * Destroys the object and frees any allocated resources |
109 | */ | 109 | */ |
110 | editCategoryWnd::~editCategoryWnd() | 110 | editCategoryWnd::~editCategoryWnd() |
111 | { | 111 | { |
112 | // no need to delete child widgets, Qt does it all for us | 112 | // no need to delete child widgets, Qt does it all for us |
113 | } | 113 | } |
114 | 114 | ||
115 | void editCategoryWnd::slotOk() | 115 | void editCategoryWnd::slotOk() |
116 | { | 116 | { |
117 | // qDebug( "addEntryWnd::slotOk(): Not implemented yet" ); | 117 | // qDebug( "addEntryWnd::slotOk(): Not implemented yet" ); |
118 | slotApply(); | 118 | slotApply(); |
119 | accept(); | 119 | accept(); |
120 | } | 120 | } |
121 | 121 | ||
122 | void editCategoryWnd::slotApply() | 122 | void editCategoryWnd::slotApply() |
123 | { | 123 | { |
124 | QString cat = categoryComboBox->currentText(); | 124 | QString cat = categoryComboBox->currentText(); |
125 | 125 | ||
126 | unsigned int idx; | 126 | unsigned int idx; |
127 | bool found = doc->findCategory(cat, &idx); | 127 | bool found = doc->findCategory(cat, &idx); |
128 | 128 | ||
129 | if (found == true) | 129 | if (found == true) |
130 | { | 130 | { |
131 | PwMCategoryItem* catitem = doc->getCategoryEntry(idx); | 131 | PwMCategoryItem* catitem = doc->getCategoryEntry(idx); |
132 | 132 | ||
133 | catitem->desc_text = descLineEdit->text().latin1(); | 133 | catitem->desc_text = descLineEdit->text().latin1(); |
134 | catitem->name_text = usernameLineEdit->text().latin1(); | 134 | catitem->name_text = usernameLineEdit->text().latin1(); |
135 | catitem->pw_text = pwLineEdit->text().latin1(); | 135 | catitem->pw_text = pwLineEdit->text().latin1(); |
136 | enableButton( KDialogBase::Apply, false ); | 136 | enableButton( KDialogBase::Apply, false ); |
137 | return; | 137 | return; |
138 | } | 138 | } |
139 | 139 | ||
140 | BUG(); | 140 | BUG(); |
141 | 141 | ||
142 | } | 142 | } |
143 | 143 | ||
144 | void editCategoryWnd::cancel_slot() | 144 | void editCategoryWnd::cancel_slot() |
145 | { | 145 | { |
146 | QString cat = categoryComboBox->currentText(); | 146 | QString cat = categoryComboBox->currentText(); |
147 | categorySelected ( cat ); | 147 | categorySelected ( cat ); |
148 | reject(); | ||
148 | } | 149 | } |
149 | 150 | ||
150 | void editCategoryWnd::setCurrCategory(const QString &cat) | 151 | void editCategoryWnd::setCurrCategory(const QString &cat) |
151 | { | 152 | { |
152 | int i, count = categoryComboBox->count(); | 153 | int i, count = categoryComboBox->count(); |
153 | 154 | ||
154 | for (i = 0; i < count; ++i) { | 155 | for (i = 0; i < count; ++i) { |
155 | if (categoryComboBox->text(i) == cat) { | 156 | if (categoryComboBox->text(i) == cat) { |
156 | categoryComboBox->setCurrentItem(i); | 157 | categoryComboBox->setCurrentItem(i); |
157 | categorySelected ( cat ); | 158 | categorySelected ( cat ); |
158 | return; | 159 | return; |
159 | } | 160 | } |
160 | } | 161 | } |
161 | BUG(); | 162 | BUG(); |
162 | } | 163 | } |
163 | 164 | ||
164 | void editCategoryWnd::categorySelected ( const QString & string ) | 165 | void editCategoryWnd::categorySelected ( const QString & string ) |
165 | { | 166 | { |
166 | unsigned int idx; | 167 | unsigned int idx; |
167 | bool found = doc->findCategory(string, &idx); | 168 | bool found = doc->findCategory(string, &idx); |
168 | 169 | ||
169 | if (found == true) | 170 | if (found == true) |
170 | { | 171 | { |
171 | PwMCategoryItem* catitem = doc->getCategoryEntry(idx); | 172 | PwMCategoryItem* catitem = doc->getCategoryEntry(idx); |
172 | 173 | ||
173 | descLineEdit->setText(catitem->desc_text.c_str()); | 174 | descLineEdit->setText(catitem->desc_text.c_str()); |
174 | usernameLineEdit->setText(catitem->name_text.c_str()); | 175 | usernameLineEdit->setText(catitem->name_text.c_str()); |
175 | pwLineEdit->setText(catitem->pw_text.c_str()); | 176 | pwLineEdit->setText(catitem->pw_text.c_str()); |
176 | enableButton( KDialogBase::Apply, false ); | 177 | enableButton( KDialogBase::Apply, false ); |
177 | return; | 178 | return; |
178 | } | 179 | } |
179 | 180 | ||
180 | BUG(); | 181 | BUG(); |
181 | 182 | ||
182 | } | 183 | } |
183 | 184 | ||
184 | void editCategoryWnd::widgetModified(const QString &) | 185 | void editCategoryWnd::widgetModified(const QString &) |
185 | { | 186 | { |
186 | enableButton( KDialogBase::Apply, true ); | 187 | enableButton( KDialogBase::Apply, true ); |
187 | } | 188 | } |
188 | 189 | ||