summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2002-09-30 18:11:33 (UTC)
committer umopapisdn <umopapisdn>2002-09-30 18:11:33 (UTC)
commitd49bd63f3b15795a1ee2497960f00eb3fb075e69 (patch) (unidiff)
tree44459a473faadc66288822f43146af817bac124e
parent096eb52cfbb50fefbe6679fb91e926346ff3c9d7 (diff)
downloadopie-d49bd63f3b15795a1ee2497960f00eb3fb075e69.zip
opie-d49bd63f3b15795a1ee2497960f00eb3fb075e69.tar.gz
opie-d49bd63f3b15795a1ee2497960f00eb3fb075e69.tar.bz2
Primary group combobox is sorted.
Deleting a primary group for a user sets the primarygroup combobox to <Undefined group> not an arbitrary group.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/usermanager/userdialog.cpp32
-rw-r--r--noncore/settings/usermanager/userdialog.h3
-rw-r--r--noncore/settings/usermanager/usermanager.cpp8
-rw-r--r--noncore/settings/usermanager/usermanager.h9
4 files changed, 42 insertions, 10 deletions
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp
index b7827a4..90e27d5 100644
--- a/noncore/settings/usermanager/userdialog.cpp
+++ b/noncore/settings/usermanager/userdialog.cpp
@@ -31,20 +31,19 @@ UserDialog::UserDialog(QWidget* parent, const char* name, bool modal, WFlags fl)
31 QVBoxLayout *layout = new QVBoxLayout(this); 31 QVBoxLayout *layout = new QVBoxLayout(this);
32 myTabWidget=new QTabWidget(this,"User Tab Widget"); 32 myTabWidget=new QTabWidget(this,"User Tab Widget");
33 layout->addWidget(myTabWidget); 33 layout->addWidget(myTabWidget);
34 setupTab1(); 34 setupTab1();
35 setupTab2(); 35 setupTab2();
36 36
37 accounts->groupStringList.sort();
37 // And also fill the listview & the combobox with all available groups. 38 // And also fill the listview & the combobox with all available groups.
38 for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) { 39 for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {
39 accounts->splitGroupEntry(*it); 40 accounts->splitGroupEntry(*it);
40 //new QListViewItem(groupsListView,accounts->gr_name);
41 new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); 41 new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox);
42 groupComboBox->insertItem(accounts->gr_name); 42 groupComboBox->insertItem(accounts->gr_name);
43 } 43 }
44
45 showMaximized(); 44 showMaximized();
46} 45}
47 46
48/** 47/**
49 * Empty destructor. 48 * Empty destructor.
50 * 49 *
@@ -102,13 +101,21 @@ void UserDialog::setupTab1() {
102 101
103 // Primary Group 102 // Primary Group
104 QLabel *groupLabel=new QLabel(tabpage,"group"); 103 QLabel *groupLabel=new QLabel(tabpage,"group");
105 groupLabel->setText("Primary group: "); 104 groupLabel->setText("Primary group: ");
106 groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); 105 groupComboBox=new QComboBox(tabpage,"PrimaryGroup");
107 106
108 // Widget layout 107 // Copy /etc/skel
108 QLabel *skelLabel=new QLabel(tabpage,"skel");
109 skelLabel->setText("Copy /etc/skel: ");
110 skelCheckBox=new QCheckBox(tabpage);
111 skelCheckBox->setChecked(true);
112 skelLabel->setDisabled(true);
113 skelCheckBox->setDisabled(true);
114
115 // Widget layout
109 QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); 116 QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout");
110 layout->addWidget(picturePushButton); 117 layout->addWidget(picturePushButton);
111 layout->addSpacing(5); 118 layout->addSpacing(5);
112 layout->addLayout(hlayout); 119 layout->addLayout(hlayout);
113 QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); 120 QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1");
114 QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); 121 QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2");
@@ -121,24 +128,28 @@ void UserDialog::setupTab1() {
121 vlayout1->addSpacing(5); 128 vlayout1->addSpacing(5);
122 vlayout1->addWidget(passwordLabel); 129 vlayout1->addWidget(passwordLabel);
123 vlayout1->addSpacing(5); 130 vlayout1->addSpacing(5);
124 vlayout1->addWidget(shellLabel); 131 vlayout1->addWidget(shellLabel);
125 vlayout1->addSpacing(5); 132 vlayout1->addSpacing(5);
126 vlayout1->addWidget(groupLabel); 133 vlayout1->addWidget(groupLabel);
134 vlayout1->addSpacing(5);
135 vlayout1->addWidget(skelLabel);
127 // Second column, data 136 // Second column, data
128 vlayout2->addWidget(loginLineEdit); 137 vlayout2->addWidget(loginLineEdit);
129 vlayout2->addSpacing(5); 138 vlayout2->addSpacing(5);
130 vlayout2->addWidget(uidLineEdit); 139 vlayout2->addWidget(uidLineEdit);
131 vlayout2->addSpacing(5); 140 vlayout2->addSpacing(5);
132 vlayout2->addWidget(gecosLineEdit); 141 vlayout2->addWidget(gecosLineEdit);
133 vlayout2->addSpacing(5); 142 vlayout2->addSpacing(5);
134 vlayout2->addWidget(passwordLineEdit); 143 vlayout2->addWidget(passwordLineEdit);
135 vlayout2->addSpacing(5); 144 vlayout2->addSpacing(5);
136 vlayout2->addWidget(shellComboBox); 145 vlayout2->addWidget(shellComboBox);
137 vlayout2->addSpacing(5); 146 vlayout2->addSpacing(5);
138 vlayout2->addWidget(groupComboBox); 147 vlayout2->addWidget(groupComboBox);
148 vlayout2->addSpacing(5);
149 vlayout2->addWidget(skelCheckBox);
139 hlayout->addLayout(vlayout1); 150 hlayout->addLayout(vlayout1);
140 hlayout->addLayout(vlayout2); 151 hlayout->addLayout(vlayout2);
141 152
142 myTabWidget->addTab(tabpage,"User Info"); 153 myTabWidget->addTab(tabpage,"User Info");
143} 154}
144 155
@@ -245,16 +256,19 @@ bool UserDialog::delUser(const char *username) {
245 * @param username User to be deleted. 256 * @param username User to be deleted.
246 * 257 *
247 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. 258 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
248 * 259 *
249 */ 260 */
250bool UserDialog::editUser(const char *username) { 261bool UserDialog::editUser(const char *username) {
262 int invalid_group=0;
251 UserDialog *edituserDialog=new UserDialog();// Create Dialog 263 UserDialog *edituserDialog=new UserDialog();// Create Dialog
252 edituserDialog->setCaption(tr("Edit User")); 264 edituserDialog->setCaption(tr("Edit User"));
253 accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. 265 accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object.
254 accounts->findGroup(accounts->pw_gid);// Locate the user's primary group, and fill group variables in 'accounts' object. 266 if(!(accounts->findGroup(accounts->pw_gid))) {// Locate the user's primary group, and fill group variables in 'accounts' object.
267 invalid_group=1;
268 }
255 // Fill widgets with userinfo. 269 // Fill widgets with userinfo.
256 edituserDialog->loginLineEdit->setText(accounts->pw_name); 270 edituserDialog->loginLineEdit->setText(accounts->pw_name);
257 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); 271 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid));
258 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); 272 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos);
259 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. 273 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed.
260 edituserDialog->passwordLineEdit->setText("........"); 274 edituserDialog->passwordLineEdit->setText("........");
@@ -264,14 +278,19 @@ bool UserDialog::editUser(const char *username) {
264 edituserDialog->shellComboBox->setCurrentItem(0); 278 edituserDialog->shellComboBox->setCurrentItem(0);
265 } 279 }
266 // Select the primary group for this user. 280 // Select the primary group for this user.
267 for(int i=0;i<edituserDialog->groupComboBox->count();++i) { 281 for(int i=0;i<edituserDialog->groupComboBox->count();++i) {
268 if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { 282 if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) {
269 edituserDialog->groupComboBox->setCurrentItem(i); 283 edituserDialog->groupComboBox->setCurrentItem(i);
284 break;
270 } 285 }
271 } 286 }
287 if(invalid_group) {
288 edituserDialog->groupComboBox->insertItem("<Undefined group>",0);
289 edituserDialog->groupComboBox->setCurrentItem(0);
290 }
272 // Select the groups in the listview, to which the user belongs. 291 // Select the groups in the listview, to which the user belongs.
273 QCheckListItem *temp; 292 QCheckListItem *temp;
274 QRegExp userRegExp(QString("[:\\s]%1\\s").arg(username)); 293 QRegExp userRegExp(QString("[:\\s]%1\\s").arg(username));
275 QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. 294 QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of.
276 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. 295 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them.
277 QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. 296 QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups.
@@ -289,14 +308,15 @@ bool UserDialog::editUser(const char *username) {
289 accounts->pw_name=edituserDialog->loginLineEdit->text(); 308 accounts->pw_name=edituserDialog->loginLineEdit->text();
290 // Has the password been changed ? Make a new "crypt":ed password. 309 // Has the password been changed ? Make a new "crypt":ed password.
291 if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); 310 if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt());
292 311
293 // Set all variables in accounts object, that will be used when calling 'updateUser()' 312 // Set all variables in accounts object, that will be used when calling 'updateUser()'
294 accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); 313 accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt();
295 accounts->findGroup(edituserDialog->groupComboBox->currentText());// Fill all group variables in 'accounts' object. 314 if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) {// Fill all group variables in 'accounts' object.
296 accounts->pw_gid=accounts->gr_gid; 315 accounts->pw_gid=accounts->gr_gid;// Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group.
316 }
297 accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); 317 accounts->pw_gecos=edituserDialog->gecosLineEdit->text();
298 accounts->pw_shell=edituserDialog->shellComboBox->currentText(); 318 accounts->pw_shell=edituserDialog->shellComboBox->currentText();
299 // Update userinfo, using the information stored in the user variables stored in the accounts object. 319 // Update userinfo, using the information stored in the user variables stored in the accounts object.
300 accounts->updateUser(username); 320 accounts->updateUser(username);
301 321
302 // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) 322 // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.)
diff --git a/noncore/settings/usermanager/userdialog.h b/noncore/settings/usermanager/userdialog.h
index a878588..133b35d 100644
--- a/noncore/settings/usermanager/userdialog.h
+++ b/noncore/settings/usermanager/userdialog.h
@@ -12,12 +12,13 @@
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#include <qcheckbox.h>
18 19
19#include <qpe/resource.h> 20#include <qpe/resource.h>
20 21
21#include <opie/ofiledialog.h> 22#include <opie/ofiledialog.h>
22 23
23class UserDialog : public QDialog 24class UserDialog : public QDialog
@@ -29,12 +30,14 @@ private:
29 QLineEdit *loginLineEdit; 30 QLineEdit *loginLineEdit;
30 QLineEdit *uidLineEdit; 31 QLineEdit *uidLineEdit;
31 QLineEdit *gecosLineEdit; 32 QLineEdit *gecosLineEdit;
32 QLineEdit *passwordLineEdit; 33 QLineEdit *passwordLineEdit;
33 QComboBox *shellComboBox; 34 QComboBox *shellComboBox;
34 QComboBox *groupComboBox; 35 QComboBox *groupComboBox;
36 QLabel *skelLabel;
37 QCheckBox *skelCheckBox;
35 QListView *groupsListView; 38 QListView *groupsListView;
36 39
37 QStringList groupMembers; 40 QStringList groupMembers;
38 QString pictureLocation; 41 QString pictureLocation;
39 QImage userImage; 42 QImage userImage;
40 int groupID; 43 int groupID;
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp
index 2735e6a..57efa71 100644
--- a/noncore/settings/usermanager/usermanager.cpp
+++ b/noncore/settings/usermanager/usermanager.cpp
@@ -51,12 +51,13 @@ UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWind
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 userPopupMenu.insertItem("Copy",0);
57 58
58 getUsers(); // Fill out the iconview & listview with all users. 59 getUsers(); // Fill out the iconview & listview with all users.
59 getGroups(); // Fill out the group listview with all groups. 60 getGroups(); // Fill out the group listview with all groups.
60 61
61 setCentralWidget(myTabWidget); 62 setCentralWidget(myTabWidget);
62} 63}
@@ -74,12 +75,14 @@ void UserConfig::setupTabAccounts() {
74 usersIconView=new QListView(tabpage,"users"); 75 usersIconView=new QListView(tabpage,"users");
75 usersIconView->addColumn("Icon"); 76 usersIconView->addColumn("Icon");
76 usersIconView->addColumn("Username"); 77 usersIconView->addColumn("Username");
77 usersIconView->setAllColumnsShowFocus(true); 78 usersIconView->setAllColumnsShowFocus(true);
78 layout->addWidget(usersIconView); 79 layout->addWidget(usersIconView);
79 80
81 connect(usersIconView,SIGNAL(returnPressed(QListViewItem *)),this,SLOT(showUserMenu(QListViewItem *)));
82
80 myTabWidget->addTab(tabpage,"Users"); 83 myTabWidget->addTab(tabpage,"Users");
81} 84}
82 85
83void UserConfig::setupTabAllUsers() { 86void UserConfig::setupTabAllUsers() {
84 QWidget *tabpage = new QWidget(this); 87 QWidget *tabpage = new QWidget(this);
85 QVBoxLayout *layout = new QVBoxLayout(tabpage); 88 QVBoxLayout *layout = new QVBoxLayout(tabpage);
@@ -241,6 +244,11 @@ void UserConfig::delGroup() {
241 if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted. 244 if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted.
242 } 245 }
243 } else { 246 } else {
244 QMessageBox::information(this,"No selection","No group has been selected."); 247 QMessageBox::information(this,"No selection","No group has been selected.");
245 } 248 }
246} 249}
250
251void UserConfig::showUserMenu(QListViewItem *item) {
252 //userPopupMenu.exec(item->mapToGlobal(QPoint(0,0)));
253 qWarning("Pressed!");
254}
diff --git a/noncore/settings/usermanager/usermanager.h b/noncore/settings/usermanager/usermanager.h
index 9909242..6782923 100644
--- a/noncore/settings/usermanager/usermanager.h
+++ b/noncore/settings/usermanager/usermanager.h
@@ -10,19 +10,17 @@
10#ifndef USERCONFIG_H 10#ifndef USERCONFIG_H
11#define USERCONFIG_H 11#define USERCONFIG_H
12 12
13#include <qmainwindow.h> 13#include <qmainwindow.h>
14#include <qtabwidget.h> 14#include <qtabwidget.h>
15#include <qlistview.h> 15#include <qlistview.h>
16//#include <qiconview.h>
17
18#include <qpe/qpemenubar.h>
19#include <qpopupmenu.h> 16#include <qpopupmenu.h>
20#include <qpe/qpetoolbar.h>
21#include <qtoolbutton.h> 17#include <qtoolbutton.h>
22 18
19#include <qpe/qpetoolbar.h>
20
23#include "userdialog.h" 21#include "userdialog.h"
24#include "groupdialog.h" 22#include "groupdialog.h"
25#include "passwd.h" 23#include "passwd.h"
26 24
27class UserConfig : public QMainWindow 25class UserConfig : public QMainWindow
28{ 26{
@@ -40,12 +38,14 @@ private:
40 QToolButton *editgroupToolButton; 38 QToolButton *editgroupToolButton;
41 QToolButton *deletegroupToolButton; 39 QToolButton *deletegroupToolButton;
42 QTabWidget *myTabWidget; 40 QTabWidget *myTabWidget;
43 QListView *usersIconView; 41 QListView *usersIconView;
44 QListView *usersListView; 42 QListView *usersListView;
45 QListView *groupsListView; 43 QListView *groupsListView;
44 QPopupMenu userPopupMenu;
45 QPopupMenu groupPopupMenu;
46 int availableUID; 46 int availableUID;
47 int availableGID; 47 int availableGID;
48 void setupTabAccounts(); 48 void setupTabAccounts();
49 void setupTabAllUsers(); 49 void setupTabAllUsers();
50 void setupTabAllGroups(); 50 void setupTabAllGroups();
51 void setupTabPrefs(); 51 void setupTabPrefs();
@@ -57,9 +57,10 @@ private slots:
57 void addUser(); 57 void addUser();
58 void editUser(); 58 void editUser();
59 void delUser(); 59 void delUser();
60 void addGroup(); 60 void addGroup();
61 void editGroup(); 61 void editGroup();
62 void delGroup(); 62 void delGroup();
63 void showUserMenu(QListViewItem *item);
63}; 64};
64 65
65#endif // USERCONFIG_H 66#endif // USERCONFIG_H