summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2002-09-28 22:28:39 (UTC)
committer umopapisdn <umopapisdn>2002-09-28 22:28:39 (UTC)
commitaa347496d408431d85ff2d7a2cf60479407620af (patch) (unidiff)
tree64e7fed8efd41d2c4b3bdf26c863a5486ee0ede3
parent7980189a2cb34e2864c339ef68bfbe7fb4910750 (diff)
downloadopie-aa347496d408431d85ff2d7a2cf60479407620af.zip
opie-aa347496d408431d85ff2d7a2cf60479407620af.tar.gz
opie-aa347496d408431d85ff2d7a2cf60479407620af.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/usermanager/userdialog.cpp37
-rw-r--r--noncore/settings/usermanager/userdialog.h1
-rw-r--r--noncore/settings/usermanager/usermanager.cpp7
3 files changed, 39 insertions, 6 deletions
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp
index 6940a3b..c6b8a57 100644
--- a/noncore/settings/usermanager/userdialog.cpp
+++ b/noncore/settings/usermanager/userdialog.cpp
@@ -78,248 +78,277 @@ void UserDialog::setupTab1() {
78 QLabel *uidLabel=new QLabel(tabpage,"uid: "); 78 QLabel *uidLabel=new QLabel(tabpage,"uid: ");
79 uidLabel->setText("UserID: "); 79 uidLabel->setText("UserID: ");
80 uidLineEdit=new QLineEdit(tabpage,"uid: "); 80 uidLineEdit=new QLineEdit(tabpage,"uid: ");
81 uidLineEdit->setEnabled(false); 81 uidLineEdit->setEnabled(false);
82 82
83 // Username (gecos) 83 // Username (gecos)
84 QLabel *gecosLabel=new QLabel(tabpage,"gecos"); 84 QLabel *gecosLabel=new QLabel(tabpage,"gecos");
85 gecosLabel->setText("Username: "); 85 gecosLabel->setText("Username: ");
86 gecosLineEdit=new QLineEdit(tabpage,"gecos"); 86 gecosLineEdit=new QLineEdit(tabpage,"gecos");
87 87
88 // Password 88 // Password
89 QLabel *passwordLabel=new QLabel(tabpage,"password"); 89 QLabel *passwordLabel=new QLabel(tabpage,"password");
90 passwordLabel->setText("Password: "); 90 passwordLabel->setText("Password: ");
91 passwordLineEdit=new QLineEdit(tabpage,"password"); 91 passwordLineEdit=new QLineEdit(tabpage,"password");
92 passwordLineEdit->setEchoMode(QLineEdit::Password); 92 passwordLineEdit->setEchoMode(QLineEdit::Password);
93 93
94 // Shell 94 // Shell
95 QLabel *shellLabel=new QLabel(tabpage,"shell"); 95 QLabel *shellLabel=new QLabel(tabpage,"shell");
96 shellLabel->setText("Shell: "); 96 shellLabel->setText("Shell: ");
97 shellComboBox=new QComboBox(tabpage,"shell"); 97 shellComboBox=new QComboBox(tabpage,"shell");
98 shellComboBox->setEditable(true); 98 shellComboBox->setEditable(true);
99 shellComboBox->insertItem("/bin/sh"); 99 shellComboBox->insertItem("/bin/sh");
100 shellComboBox->insertItem("/bin/ash"); 100 shellComboBox->insertItem("/bin/ash");
101 shellComboBox->insertItem("/bin/false"); 101 shellComboBox->insertItem("/bin/false");
102 102
103 // Primary Group 103 // Primary Group
104 QLabel *groupLabel=new QLabel(tabpage,"group"); 104 QLabel *groupLabel=new QLabel(tabpage,"group");
105 groupLabel->setText("Primary group: "); 105 groupLabel->setText("Primary group: ");
106 groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); 106 groupComboBox=new QComboBox(tabpage,"PrimaryGroup");
107 107
108 // Widget layout 108 // Widget layout
109 QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); 109 QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout");
110 layout->addWidget(picturePushButton); 110 layout->addWidget(picturePushButton);
111 layout->addSpacing(5); 111 layout->addSpacing(5);
112 layout->addLayout(hlayout); 112 layout->addLayout(hlayout);
113 QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); 113 QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1");
114 QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); 114 QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2");
115 // First column, labels 115 // First column, labels
116 vlayout1->addWidget(loginLabel); 116 vlayout1->addWidget(loginLabel);
117 vlayout1->addSpacing(5); 117 vlayout1->addSpacing(5);
118 vlayout1->addWidget(uidLabel); 118 vlayout1->addWidget(uidLabel);
119 vlayout1->addSpacing(5); 119 vlayout1->addSpacing(5);
120 vlayout1->addWidget(gecosLabel); 120 vlayout1->addWidget(gecosLabel);
121 vlayout1->addSpacing(5); 121 vlayout1->addSpacing(5);
122 vlayout1->addWidget(passwordLabel); 122 vlayout1->addWidget(passwordLabel);
123 vlayout1->addSpacing(5); 123 vlayout1->addSpacing(5);
124 vlayout1->addWidget(shellLabel); 124 vlayout1->addWidget(shellLabel);
125 vlayout1->addSpacing(5); 125 vlayout1->addSpacing(5);
126 vlayout1->addWidget(groupLabel); 126 vlayout1->addWidget(groupLabel);
127 // Second column, data 127 // Second column, data
128 vlayout2->addWidget(loginLineEdit); 128 vlayout2->addWidget(loginLineEdit);
129 vlayout2->addSpacing(5); 129 vlayout2->addSpacing(5);
130 vlayout2->addWidget(uidLineEdit); 130 vlayout2->addWidget(uidLineEdit);
131 vlayout2->addSpacing(5); 131 vlayout2->addSpacing(5);
132 vlayout2->addWidget(gecosLineEdit); 132 vlayout2->addWidget(gecosLineEdit);
133 vlayout2->addSpacing(5); 133 vlayout2->addSpacing(5);
134 vlayout2->addWidget(passwordLineEdit); 134 vlayout2->addWidget(passwordLineEdit);
135 vlayout2->addSpacing(5); 135 vlayout2->addSpacing(5);
136 vlayout2->addWidget(shellComboBox); 136 vlayout2->addWidget(shellComboBox);
137 vlayout2->addSpacing(5); 137 vlayout2->addSpacing(5);
138 vlayout2->addWidget(groupComboBox); 138 vlayout2->addWidget(groupComboBox);
139 hlayout->addLayout(vlayout1); 139 hlayout->addLayout(vlayout1);
140 hlayout->addLayout(vlayout2); 140 hlayout->addLayout(vlayout2);
141 141
142 myTabWidget->addTab(tabpage,"User Info"); 142 myTabWidget->addTab(tabpage,"User Info");
143} 143}
144 144
145/** 145/**
146 * Creates the second tab containing additional groups for the user. 146 * Creates the second tab containing additional groups for the user.
147 * 147 *
148 */ 148 */
149void UserDialog::setupTab2() { 149void UserDialog::setupTab2() {
150 QWidget *tabpage = new QWidget(myTabWidget,"page2"); 150 QWidget *tabpage = new QWidget(myTabWidget,"page2");
151 QVBoxLayout *layout = new QVBoxLayout(tabpage); 151 QVBoxLayout *layout = new QVBoxLayout(tabpage);
152 layout->setMargin(5); 152 layout->setMargin(5);
153 153
154 // Additional groups 154 // Additional groups
155 groupsListView=new QListView(tabpage,"groups"); 155 groupsListView=new QListView(tabpage,"groups");
156 groupsListView->addColumn("Additional groups"); 156 groupsListView->addColumn("Additional groups");
157 groupsListView->setColumnWidthMode(0,QListView::Maximum); 157 groupsListView->setColumnWidthMode(0,QListView::Maximum);
158 groupsListView->setMultiSelection(true); 158 groupsListView->setMultiSelection(true);
159 groupsListView->setAllColumnsShowFocus(false); 159 groupsListView->setAllColumnsShowFocus(false);
160 160
161 layout->addSpacing(5); 161 layout->addSpacing(5);
162 // Grouplist 162 // Grouplist
163 layout->addWidget(groupsListView); 163 layout->addWidget(groupsListView);
164 164
165 myTabWidget->addTab(tabpage,"User Groups"); 165 myTabWidget->addTab(tabpage,"User Groups");
166} 166}
167 167
168/** 168/**
169 * Static function that creates the userinfo dialog. 169 * Static function that creates the userinfo dialog.
170 * The user will be prompted to add a user. 170 * The user will be prompted to add a user.
171 * 171 *
172 * @param uid This is a suggested available UID. 172 * @param uid This is a suggested available UID.
173 * @param gid This is a suggested available GID. 173 * @param gid This is a suggested available GID.
174 * 174 *
175 * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. 175 * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>.
176 * 176 *
177 */ 177 */
178bool UserDialog::addUser(int uid, int gid) { 178bool UserDialog::addUser(int uid, int gid) {
179 UserDialog *adduserDialog=new UserDialog(); 179 UserDialog *adduserDialog=new UserDialog();
180 adduserDialog->setCaption(tr("Add User")); 180 adduserDialog->setCaption(tr("Add User"));
181 adduserDialog->userID=uid;// Set next available UID as default uid. 181 adduserDialog->userID=uid;// Set next available UID as default uid.
182 adduserDialog->groupID=gid;// Set next available GID as default gid. 182 adduserDialog->groupID=gid;// Set next available GID as default gid.
183 // Insert default group into groupComboBox 183 // Insert default group into groupComboBox
184 adduserDialog->groupComboBox->insertItem("<create new group>",0); 184 adduserDialog->groupComboBox->insertItem("<create new group>",0);
185 adduserDialog->uidLineEdit->setText(QString::number(uid)); 185 adduserDialog->uidLineEdit->setText(QString::number(uid));
186 // Show the dialog! 186 // Show the dialog!
187 if(!(adduserDialog->exec())) return false; 187 if(!(adduserDialog->exec())) return false;
188 if((adduserDialog->groupComboBox->currentItem()!=0)) { 188 if((adduserDialog->groupComboBox->currentItem()!=0)) {
189 accounts->findGroup(adduserDialog->groupComboBox->currentText()); 189 accounts->findGroup(adduserDialog->groupComboBox->currentText());
190 adduserDialog->groupID=accounts->gr_gid; 190 adduserDialog->groupID=accounts->gr_gid;
191 qWarning(QString::number(accounts->gr_gid)); 191 qWarning(QString::number(accounts->gr_gid));
192 } 192 }
193 if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), 193 if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(),
194 adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), 194 adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(),
195 QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { 195 QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) {
196 QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); 196 QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user.");
197 return false; 197 return false;
198 } 198 }
199 199
200 // Add User to additional groups. 200 // Add User to additional groups.
201 QListViewItemIterator it( adduserDialog->groupsListView ); 201 QListViewItemIterator it( adduserDialog->groupsListView );
202 for ( ; it.current(); ++it ) { 202 for ( ; it.current(); ++it ) {
203 if ( it.current()->isSelected() ) 203 if ( it.current()->isSelected() )
204 accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); 204 accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text());
205 } 205 }
206 // Copy image to pics/users/
207 if(!(adduserDialog->userImage.isNull())) {
208 QDir d;
209 if(!(d.exists("/opt/QtPalmtop/pics/users"))) {
210 d.mkdir("/opt/QtPalmtop/pics/users");
211 }
212 QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png";
213 adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48);
214 adduserDialog->userImage.save(filename,"PNG");
215 }
206 return true; 216 return true;
207} 217}
208 218
209/** 219/**
210 * Deletes the user account. 220 * Deletes the user account.
211 * 221 *
212 * @param username User to be deleted. 222 * @param username User to be deleted.
213 * 223 *
214 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. 224 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
215 * 225 *
216 */ 226 */
217bool UserDialog::delUser(const char *username) { 227bool UserDialog::delUser(const char *username) {
218 if((accounts->findUser(username))) {// Does that user exist? 228 if((accounts->findUser(username))) {// Does that user exist?
219 if(!(accounts->delUser(username))) {// Delete the user. 229 if(!(accounts->delUser(username))) {// Delete the user.
220 QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); 230 QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+".");
221 } 231 }
222 } else { 232 } else {
223 QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); 233 QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist.");
224 return false; 234 return false;
225 } 235 }
226 return true; 236 return true;
227} 237}
228 238
229/** 239/**
230 * This displays a confirmation dialog wether a user should be deleted or not. 240 * This displays a confirmation dialog wether a user should be deleted or not.
231 * (And also deletes the account) 241 * (And also deletes the account)
232 * 242 *
233 * @param username User to be deleted. 243 * @param username User to be deleted.
234 * 244 *
235 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. 245 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
236 * 246 *
237 */ 247 */
238bool UserDialog::editUser(const char *username) { 248bool UserDialog::editUser(const char *username) {
239 UserDialog *edituserDialog=new UserDialog();// Create Dialog 249 UserDialog *edituserDialog=new UserDialog();// Create Dialog
240 edituserDialog->setCaption(tr("Edit User")); 250 edituserDialog->setCaption(tr("Edit User"));
241 accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. 251 accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object.
242 accounts->findGroup(accounts->pw_gid);// Locate the user's primary group, and fill group variables in 'accounts' object. 252 accounts->findGroup(accounts->pw_gid);// Locate the user's primary group, and fill group variables in 'accounts' object.
243 // Fill widgets with userinfo. 253 // Fill widgets with userinfo.
244 edituserDialog->loginLineEdit->setText(accounts->pw_name); 254 edituserDialog->loginLineEdit->setText(accounts->pw_name);
245 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); 255 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid));
246 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); 256 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos);
247 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. 257 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed.
248 edituserDialog->passwordLineEdit->setText("........"); 258 edituserDialog->passwordLineEdit->setText("........");
249 // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. 259 // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox.
250 if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") { 260 if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") {
251 edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); 261 edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0);
252 edituserDialog->shellComboBox->setCurrentItem(0); 262 edituserDialog->shellComboBox->setCurrentItem(0);
253 } 263 }
254 // Select the primary group for this user. 264 // Select the primary group for this user.
255 for(int i=0;i<edituserDialog->groupComboBox->count();++i) { 265 for(int i=0;i<edituserDialog->groupComboBox->count();++i) {
256 if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { 266 if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) {
257 edituserDialog->groupComboBox->setCurrentItem(i); 267 edituserDialog->groupComboBox->setCurrentItem(i);
258 } 268 }
259 } 269 }
260 // Select the groups in the listview, to which the user belongs. 270 // Select the groups in the listview, to which the user belongs.
261 QRegExp userRegExp(QString("[:\\s]%1\\s").arg(username)); 271 QRegExp userRegExp(QString("[:\\s]%1\\s").arg(username));
262 QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. 272 QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of.
263 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. 273 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them.
264 QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. 274 QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups.
265 for ( ; lvit.current(); ++lvit ) { 275 for ( ; lvit.current(); ++lvit ) {
266 if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { 276 if(lvit.current()->text(0)==(*it).left((*it).find(":"))) {
267 lvit.current()->setSelected(true);// If we find a line with that groupname, select it.; 277 lvit.current()->setSelected(true);// If we find a line with that groupname, select it.;
268 } 278 }
269 } 279 }
270 } 280 }
271 281
272 if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! 282 if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG!
273 283
274 accounts->findUser(username);// Fill user variables in 'acccounts' object. 284 accounts->findUser(username);// Fill user variables in 'acccounts' object.
275 accounts->pw_name=edituserDialog->loginLineEdit->text(); 285 accounts->pw_name=edituserDialog->loginLineEdit->text();
276 // Has the password been changed ? Make a new "crypt":ed password. 286 // Has the password been changed ? Make a new "crypt":ed password.
277 if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); 287 if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt());
278 288
279 // Set all variables in accounts object, that will be used when calling 'updateUser()' 289 // Set all variables in accounts object, that will be used when calling 'updateUser()'
280 accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); 290 accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt();
281 accounts->findGroup(edituserDialog->groupComboBox->currentText());// Fill all group variables in 'accounts' object. 291 accounts->findGroup(edituserDialog->groupComboBox->currentText());// Fill all group variables in 'accounts' object.
282 accounts->pw_gid=accounts->gr_gid; 292 accounts->pw_gid=accounts->gr_gid;
283 accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); 293 accounts->pw_gecos=edituserDialog->gecosLineEdit->text();
284 accounts->pw_shell=edituserDialog->shellComboBox->currentText(); 294 accounts->pw_shell=edituserDialog->shellComboBox->currentText();
285 // Update userinfo, using the information stored in the user variables stored in the accounts object. 295 // Update userinfo, using the information stored in the user variables stored in the accounts object.
286 accounts->updateUser(username); 296 accounts->updateUser(username);
287 297
288 // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) 298 // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.)
289 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { 299 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {
290 accounts->delGroupMember((*it).left((*it).find(":")),username); 300 accounts->delGroupMember((*it).left((*it).find(":")),username);
291 } 301 }
292 302
293 // Add User to additional groups that he/she is a member of. 303 // Add User to additional groups that he/she is a member of.
294 QListViewItemIterator it( edituserDialog->groupsListView ); 304 QListViewItemIterator it( edituserDialog->groupsListView );
295 for ( ; it.current(); ++it ) { 305 for ( ; it.current(); ++it ) {
296 if ( it.current()->isSelected() ) 306 if ( it.current()->isSelected() )
297 accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); 307 accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text());
298 } 308 }
309
310 // Copy image to pics/users/
311 if(!(edituserDialog->userImage.isNull())) {
312 QDir d;
313 if(!(d.exists("/opt/QtPalmtop/pics/users"))) {
314 d.mkdir("/opt/QtPalmtop/pics/users");
315 }
316 QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png";
317 edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48);
318 edituserDialog->userImage.save(filename,"PNG");
319 }
299 return true; 320 return true;
300} 321}
301 322
302/** 323/**
303 * "OK" has been clicked. Verify some information before closing the dialog. 324 * "OK" has been clicked. Verify some information before closing the dialog.
304 * 325 *
305 */ 326 */
306void UserDialog::accept() { 327void UserDialog::accept() {
307 // Add checking... valid username? username taken? 328 // Add checking... valid username? username taken?
308 if(loginLineEdit->text().isEmpty()) { 329 if(loginLineEdit->text().isEmpty()) {
309 QMessageBox::information(0,"Empty Login","Please enter a login."); 330 QMessageBox::information(0,"Empty Login","Please enter a login.");
310 return; 331 return;
311 } 332 }
312 QDialog::accept(); 333 QDialog::accept();
313} 334}
314 335
315/** 336/**
316 * This slot is called when the usericon is clicked, this loads (should) the iconselector. 337 * This slot is called when the usericon is clicked, this loads (should) the iconselector.
317 * 338 *
318 */ 339 */
319void UserDialog::clickedPicture() { 340void UserDialog::clickedPicture() {
320 QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics"); 341 QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics");
321 // OFileDialog *fd=new OFileDialog("Select Icon",this, OFileSelector::OPEN, OFileSelector::EXTENDED,"/"); 342 if(!(filename.isEmpty())) {
322 //fd->showMaximized(); 343 userImage.reset();
323 //fd->exec(); 344 if(!(userImage.load(filename))) {
324 QMessageBox::information(0,"Sorry!","Icon selection not yet implemented.\nComming real soon now! (tm)\n"+filename); 345 QMessageBox::information(0,"Sorry!","Icon selection not yet implemented.\nComming real soon now! (tm)\n"+filename);
346 } else {
347 userImage=userImage.smoothScale(48,48);
348 QPixmap *picture;
349 picture=(QPixmap *)picturePushButton->pixmap();
350 picture->convertFromImage(userImage,0);
351 picturePushButton->update();
352 }
353 }
325} 354}
diff --git a/noncore/settings/usermanager/userdialog.h b/noncore/settings/usermanager/userdialog.h
index df54269..a878588 100644
--- a/noncore/settings/usermanager/userdialog.h
+++ b/noncore/settings/usermanager/userdialog.h
@@ -1,57 +1,58 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9#ifndef USERDIALOG_H 9#ifndef USERDIALOG_H
10#define USERDIALOG_H 10#define USERDIALOG_H
11 11
12#include <qdialog.h> 12#include <qdialog.h>
13#include <qlineedit.h> 13#include <qlineedit.h>
14#include <qcombobox.h> 14#include <qcombobox.h>
15#include <qlistview.h> 15#include <qlistview.h>
16#include <qtabwidget.h> 16#include <qtabwidget.h>
17#include <qpushbutton.h> 17#include <qpushbutton.h>
18 18
19#include <qpe/resource.h> 19#include <qpe/resource.h>
20 20
21#include <opie/ofiledialog.h> 21#include <opie/ofiledialog.h>
22 22
23class UserDialog : public QDialog 23class UserDialog : public QDialog
24{ 24{
25 Q_OBJECT 25 Q_OBJECT
26private: 26private:
27 QTabWidget *myTabWidget; 27 QTabWidget *myTabWidget;
28 QPushButton *picturePushButton; 28 QPushButton *picturePushButton;
29 QLineEdit *loginLineEdit; 29 QLineEdit *loginLineEdit;
30 QLineEdit *uidLineEdit; 30 QLineEdit *uidLineEdit;
31 QLineEdit *gecosLineEdit; 31 QLineEdit *gecosLineEdit;
32 QLineEdit *passwordLineEdit; 32 QLineEdit *passwordLineEdit;
33 QComboBox *shellComboBox; 33 QComboBox *shellComboBox;
34 QComboBox *groupComboBox; 34 QComboBox *groupComboBox;
35 QListView *groupsListView; 35 QListView *groupsListView;
36 36
37 QStringList groupMembers; 37 QStringList groupMembers;
38 QString pictureLocation; 38 QString pictureLocation;
39 QImage userImage;
39 int groupID; 40 int groupID;
40 int userID; 41 int userID;
41 42
42 void setupTab1(void); 43 void setupTab1(void);
43 void setupTab2(void); 44 void setupTab2(void);
44 void accept(void); 45 void accept(void);
45 46
46private slots: 47private slots:
47 void clickedPicture(void); 48 void clickedPicture(void);
48 49
49public: 50public:
50 UserDialog( QWidget* parent = 0, const char* name = 0, bool modal=true, WFlags fl = 0 ); 51 UserDialog( QWidget* parent = 0, const char* name = 0, bool modal=true, WFlags fl = 0 );
51 ~UserDialog(); 52 ~UserDialog();
52 static bool addUser(int uid, int gid); 53 static bool addUser(int uid, int gid);
53 static bool editUser(const char *username); 54 static bool editUser(const char *username);
54 static bool delUser(const char *username); 55 static bool delUser(const char *username);
55}; 56};
56 57
57#endif 58#endif
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp
index 87dd7f1..ed18b7f 100644
--- a/noncore/settings/usermanager/usermanager.cpp
+++ b/noncore/settings/usermanager/usermanager.cpp
@@ -1,242 +1,245 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10#include "usermanager.h" 10#include "usermanager.h"
11 11
12#include <qlayout.h> 12#include <qlayout.h>
13#include <stdio.h> 13#include <stdio.h>
14 14
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16#include <qfile.h> 16#include <qfile.h>
17#include <qpe/resource.h> 17#include <qpe/resource.h>
18 18
19#include <qregexp.h> 19#include <qregexp.h>
20 20
21/** 21/**
22 * The mainwindow constructor. 22 * The mainwindow constructor.
23 * 23 *
24 * @param QWidget *parent 24 * @param QWidget *parent
25 * @param const char *name 25 * @param const char *name
26 * @ param WFlags fl 26 * @ param WFlags fl
27 * 27 *
28 */ 28 */
29UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { 29UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) {
30 setCaption(tr("OPIE User Manager")); 30 setCaption(tr("OPIE User Manager"));
31 31
32 // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. 32 // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them.
33 accounts=new Passwd(); 33 accounts=new Passwd();
34 accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. 34 accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory.
35 35
36 // Create the toolbar. 36 // Create the toolbar.
37 QPEToolBar *toolbar = new QPEToolBar(this,"Toolbar"); 37 QPEToolBar *toolbar = new QPEToolBar(this,"Toolbar");
38 toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? 38 toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!?
39 adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User"); 39 adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User");
40 edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); 40 edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User");
41 deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); 41 deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User");
42 QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); 42 QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User");
43 userstext->setUsesTextLabel(true); 43 userstext->setUsesTextLabel(true);
44 toolbar->addSeparator(); 44 toolbar->addSeparator();
45 addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); 45 addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group");
46 editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); 46 editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group");
47 deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); 47 deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group");
48 QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); 48 QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group");
49 groupstext->setUsesTextLabel(true); 49 groupstext->setUsesTextLabel(true);
50 addToolBar(toolbar,"myToolBar"); 50 addToolBar(toolbar,"myToolBar");
51 51
52 // Add a tabwidget and all the tabs. 52 // Add a tabwidget and all the tabs.
53 myTabWidget = new QTabWidget(this,"My Tab Widget"); 53 myTabWidget = new QTabWidget(this,"My Tab Widget");
54 setupTabAccounts(); 54 setupTabAccounts();
55 setupTabAllUsers(); 55 setupTabAllUsers();
56 setupTabAllGroups(); 56 setupTabAllGroups();
57 57
58 getUsers(); // Fill out the iconview & listview with all users. 58 getUsers(); // Fill out the iconview & listview with all users.
59 getGroups(); // Fill out the group listview with all groups. 59 getGroups(); // Fill out the group listview with all groups.
60 60
61 setCentralWidget(myTabWidget); 61 setCentralWidget(myTabWidget);
62} 62}
63 63
64UserConfig::~UserConfig() { 64UserConfig::~UserConfig() {
65 accounts->close(); 65 accounts->close();
66 delete accounts; 66 delete accounts;
67} 67}
68 68
69void UserConfig::setupTabAccounts() { 69void UserConfig::setupTabAccounts() {
70 QWidget *tabpage = new QWidget(this); 70 QWidget *tabpage = new QWidget(this);
71 QVBoxLayout *layout = new QVBoxLayout(tabpage); 71 QVBoxLayout *layout = new QVBoxLayout(tabpage);
72 layout->setMargin(5); 72 layout->setMargin(5);
73 73
74 usersIconView=new QIconView(tabpage,"users"); 74 usersIconView=new QIconView(tabpage,"users");
75 usersIconView->setItemTextPos(QIconView::Right); 75 usersIconView->setItemTextPos(QIconView::Right);
76 usersIconView->setArrangement(QIconView::LeftToRight);
76 layout->addWidget(usersIconView); 77 layout->addWidget(usersIconView);
77 78
78 myTabWidget->addTab(tabpage,"Users"); 79 myTabWidget->addTab(tabpage,"Users");
79} 80}
80 81
81void UserConfig::setupTabAllUsers() { 82void UserConfig::setupTabAllUsers() {
82 QWidget *tabpage = new QWidget(this); 83 QWidget *tabpage = new QWidget(this);
83 QVBoxLayout *layout = new QVBoxLayout(tabpage); 84 QVBoxLayout *layout = new QVBoxLayout(tabpage);
84 layout->setMargin(5); 85 layout->setMargin(5);
85 86
86 usersListView=new QListView(tabpage,"allusers"); 87 usersListView=new QListView(tabpage,"allusers");
87 usersListView->addColumn("UID"); 88 usersListView->addColumn("UID");
88 usersListView->addColumn("Login"); 89 usersListView->addColumn("Login");
89 usersListView->addColumn("Username"); 90 usersListView->addColumn("Username");
90 layout->addWidget(usersListView); 91 layout->addWidget(usersListView);
91 usersListView->setSorting(1,1); 92 usersListView->setSorting(1,1);
92 usersListView->setAllColumnsShowFocus(true); 93 usersListView->setAllColumnsShowFocus(true);
93 94
94 myTabWidget->addTab(tabpage,"All Users"); 95 myTabWidget->addTab(tabpage,"All Users");
95} 96}
96 97
97void UserConfig::setupTabAllGroups() { 98void UserConfig::setupTabAllGroups() {
98 QWidget *tabpage = new QWidget(this); 99 QWidget *tabpage = new QWidget(this);
99 QVBoxLayout *layout = new QVBoxLayout(tabpage); 100 QVBoxLayout *layout = new QVBoxLayout(tabpage);
100 layout->setMargin(5); 101 layout->setMargin(5);
101 102
102 groupsListView=new QListView(tabpage,"groups"); 103 groupsListView=new QListView(tabpage,"groups");
103 groupsListView->addColumn("GID"); 104 groupsListView->addColumn("GID");
104 groupsListView->addColumn("Groupname"); 105 groupsListView->addColumn("Groupname");
105 layout->addWidget(groupsListView); 106 layout->addWidget(groupsListView);
106 groupsListView->setSorting(1,1); 107 groupsListView->setSorting(1,1);
107 groupsListView->setAllColumnsShowFocus(true); 108 groupsListView->setAllColumnsShowFocus(true);
108 109
109 myTabWidget->addTab(tabpage,"All Groups"); 110 myTabWidget->addTab(tabpage,"All Groups");
110} 111}
111void UserConfig::getUsers() { 112void UserConfig::getUsers() {
112 QString mytext; 113 QString mytext;
113 QPixmap mypixmap; 114 QPixmap mypixmap;
114 115
115 // Empty the iconview & the listview. 116 // Empty the iconview & the listview.
116 usersIconView->clear(); 117 usersIconView->clear();
117 usersListView->clear(); 118 usersListView->clear();
118 119
119 // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. 120 // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500.
120 availableUID=500; 121 availableUID=500;
121 for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { 122 for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) {
122 accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) 123 accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.)
123 new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); 124 new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos);
124 if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? 125 if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ?
125 mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. 126 mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon.
126 mypixmap=Resource::loadPixmap(QString("users/"+accounts->pw_name));// Is there an icon for this user? 127 // mypixmap=Resource::loadPixmap(QString("users/"+accounts->pw_name));// Is there an icon for this user? Resource::loadPixmap is caching, doesn't work.
127 if(mypixmap.isNull()) { 128 if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) {
129 // if(mypixmap.isNull()) {
128 mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon. 130 mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon.
129 } 131 }
130 new QIconViewItem(usersIconView,mytext,mypixmap);// Add the icon+text to the qiconview. 132 new QIconViewItem(usersIconView,mytext,mypixmap);// Add the icon+text to the qiconview.
131 } 133 }
132 if((accounts->pw_uid>=availableUID) && (accounts->pw_uid<65000)) availableUID=accounts->pw_uid+1; // Increase 1 to the latest know UID to get a free uid. 134 if((accounts->pw_uid>=availableUID) && (accounts->pw_uid<65000)) availableUID=accounts->pw_uid+1; // Increase 1 to the latest know UID to get a free uid.
133 } 135 }
136 usersIconView->sort();
134} 137}
135 138
136void UserConfig::addUser() { 139void UserConfig::addUser() {
137 if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. 140 if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID.
138 getUsers(); // Update users views. 141 getUsers(); // Update users views.
139 getGroups(); // Update groups view. 142 getGroups(); // Update groups view.
140 } 143 }
141} 144}
142 145
143void UserConfig::editUser() { 146void UserConfig::editUser() {
144 QString username; 147 QString username;
145 if(myTabWidget->currentPageIndex()==0) {// Users 148 if(myTabWidget->currentPageIndex()==0) {// Users
146 if(usersIconView->currentItem()) {// Any icon selected? 149 if(usersIconView->currentItem()) {// Any icon selected?
147 username=usersIconView->currentItem()->text();// Get the text associated with the icon. 150 username=usersIconView->currentItem()->text();// Get the text associated with the icon.
148 username=username.left(username.find(" - (",0,true));// Strip out the username. 151 username=username.left(username.find(" - (",0,true));// Strip out the username.
149 if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. 152 if(UserDialog::editUser(username)) {// Bring up the userinfo dialog.
150 // If there were any changed also update the views. 153 // If there were any changed also update the views.
151 getUsers(); 154 getUsers();
152 getGroups(); 155 getGroups();
153 } 156 }
154 } else { 157 } else {
155 QMessageBox::information(this,"No selection.","No user has been selected."); 158 QMessageBox::information(this,"No selection.","No user has been selected.");
156 } 159 }
157 } 160 }
158 if(myTabWidget->currentPageIndex()==1) {// All users 161 if(myTabWidget->currentPageIndex()==1) {// All users
159 if(usersListView->currentItem()) {// Anything changed!? 162 if(usersListView->currentItem()) {// Anything changed!?
160 username=usersListView->currentItem()->text(1);// Get the username. 163 username=usersListView->currentItem()->text(1);// Get the username.
161 if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. 164 if(UserDialog::editUser(username)) {// Bring up the userinfo dialog.
162 // And again update the views if there were any changes. 165 // And again update the views if there were any changes.
163 getUsers(); 166 getUsers();
164 getGroups(); 167 getGroups();
165 } 168 }
166 } else { 169 } else {
167 QMessageBox::information(this,"No selection.","No user has been selected."); 170 QMessageBox::information(this,"No selection.","No user has been selected.");
168 } 171 }
169 } 172 }
170} 173}
171 174
172void UserConfig::delUser() { 175void UserConfig::delUser() {
173 QString username; 176 QString username;
174 177
175 if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. 178 if(myTabWidget->currentPageIndex()==0) {// Users, Iconview.
176 if(usersIconView->currentItem()) {// Anything selected? 179 if(usersIconView->currentItem()) {// Anything selected?
177 username=usersIconView->currentItem()->text();// Get string associated with icon. 180 username=usersIconView->currentItem()->text();// Get string associated with icon.
178 username=username.left(username.find(" - (",0,true));// Strip out the username. 181 username=username.left(username.find(" - (",0,true));// Strip out the username.
179 if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { 182 if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) {
180 if(UserDialog::delUser(username)) {// Delete the user if possible. 183 if(UserDialog::delUser(username)) {// Delete the user if possible.
181 // Update views. 184 // Update views.
182 getUsers(); 185 getUsers();
183 getGroups(); 186 getGroups();
184 } 187 }
185 } 188 }
186 } else { 189 } else {
187 QMessageBox::information(this,"No selection","No user has been selected."); 190 QMessageBox::information(this,"No selection","No user has been selected.");
188 } 191 }
189 } 192 }
190 if(myTabWidget->currentPageIndex()==1) {// All users 193 if(myTabWidget->currentPageIndex()==1) {// All users
191 if(usersListView->currentItem()) {// Anything changed!? 194 if(usersListView->currentItem()) {// Anything changed!?
192 username=usersListView->currentItem()->text(1);// Get the username. 195 username=usersListView->currentItem()->text(1);// Get the username.
193 if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { 196 if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) {
194 if(UserDialog::delUser(username)) {// Try to delete the user. 197 if(UserDialog::delUser(username)) {// Try to delete the user.
195 // Update views. 198 // Update views.
196 getUsers(); 199 getUsers();
197 getGroups(); 200 getGroups();
198 } 201 }
199 } 202 }
200 } else { 203 } else {
201 QMessageBox::information(this,"No selection","No user has been selected."); 204 QMessageBox::information(this,"No selection","No user has been selected.");
202 } 205 }
203 } 206 }
204 207
205} 208}
206 209
207void UserConfig::getGroups() { 210void UserConfig::getGroups() {
208 groupsListView->clear();// Empty the listview. 211 groupsListView->clear();// Empty the listview.
209 availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000. 212 availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000.
210 for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines. 213 for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines.
211 accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem). 214 accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem).
212 new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name); 215 new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name);
213 if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1;// Maybe a new free GID. 216 if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1;// Maybe a new free GID.
214 } 217 }
215} 218}
216 219
217void UserConfig::addGroup() { 220void UserConfig::addGroup() {
218 if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog. 221 if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog.
219} 222}
220 223
221void UserConfig::editGroup() { 224void UserConfig::editGroup() {
222 int gid; 225 int gid;
223 if(groupsListView->currentItem()) {// Any group selected? 226 if(groupsListView->currentItem()) {// Any group selected?
224 gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview. 227 gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview.
225 if(GroupDialog::editGroup(gid)) getGroups();// Bring up the edit group dialog. 228 if(GroupDialog::editGroup(gid)) getGroups();// Bring up the edit group dialog.
226 } else { 229 } else {
227 QMessageBox::information(this,"No selection","No group has been selected."); 230 QMessageBox::information(this,"No selection","No group has been selected.");
228 } 231 }
229} 232}
230 233
231void UserConfig::delGroup() { 234void UserConfig::delGroup() {
232 const char *groupname; 235 const char *groupname;
233 if(groupsListView->currentItem()) {// Any group selected? 236 if(groupsListView->currentItem()) {// Any group selected?
234 groupname=groupsListView->currentItem()->text(1);// Get the groupname from the listview. 237 groupname=groupsListView->currentItem()->text(1);// Get the groupname from the listview.
235 if(QMessageBox::warning(this,"Delete group","Are you sure you want to\ndelete the group \""+QString(groupname)+"\" ?","&No","&Yes",0,0,1)) { 238 if(QMessageBox::warning(this,"Delete group","Are you sure you want to\ndelete the group \""+QString(groupname)+"\" ?","&No","&Yes",0,0,1)) {
236 // If confirmed, try to delete the group. 239 // If confirmed, try to delete the group.
237 if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted. 240 if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted.
238 } 241 }
239 } else { 242 } else {
240 QMessageBox::information(this,"No selection","No group has been selected."); 243 QMessageBox::information(this,"No selection","No group has been selected.");
241 } 244 }
242} 245}