author | umopapisdn <umopapisdn> | 2002-09-29 19:17:07 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2002-09-29 19:17:07 (UTC) |
commit | d61d575feac628fe4afb3cc9bf4fc8f24fc8616a (patch) (unidiff) | |
tree | 147ded7eb7f3cc2b42bd6b731b93b5c9a108d9ad /noncore/settings/usermanager/usermanager.cpp | |
parent | 84a7530b51f537552ea03776c9d8ade88254dc51 (diff) | |
download | opie-d61d575feac628fe4afb3cc9bf4fc8f24fc8616a.zip opie-d61d575feac628fe4afb3cc9bf4fc8f24fc8616a.tar.gz opie-d61d575feac628fe4afb3cc9bf4fc8f24fc8616a.tar.bz2 |
Icon selection now works. User listing lists 1 user per row now. (moved from qiconlist to qlistview)
Diffstat (limited to 'noncore/settings/usermanager/usermanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/usermanager/usermanager.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp index ed18b7f..2735e6a 100644 --- a/noncore/settings/usermanager/usermanager.cpp +++ b/noncore/settings/usermanager/usermanager.cpp | |||
@@ -62,27 +62,28 @@ UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWind | |||
62 | } | 62 | } |
63 | 63 | ||
64 | UserConfig::~UserConfig() { | 64 | UserConfig::~UserConfig() { |
65 | accounts->close(); | 65 | accounts->close(); |
66 | delete accounts; | 66 | delete accounts; |
67 | } | 67 | } |
68 | 68 | ||
69 | void UserConfig::setupTabAccounts() { | 69 | void 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 QListView(tabpage,"users"); |
75 | usersIconView->setItemTextPos(QIconView::Right); | 75 | usersIconView->addColumn("Icon"); |
76 | usersIconView->setArrangement(QIconView::LeftToRight); | 76 | usersIconView->addColumn("Username"); |
77 | usersIconView->setAllColumnsShowFocus(true); | ||
77 | layout->addWidget(usersIconView); | 78 | layout->addWidget(usersIconView); |
78 | 79 | ||
79 | myTabWidget->addTab(tabpage,"Users"); | 80 | myTabWidget->addTab(tabpage,"Users"); |
80 | } | 81 | } |
81 | 82 | ||
82 | void UserConfig::setupTabAllUsers() { | 83 | void UserConfig::setupTabAllUsers() { |
83 | QWidget *tabpage = new QWidget(this); | 84 | QWidget *tabpage = new QWidget(this); |
84 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 85 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
85 | layout->setMargin(5); | 86 | layout->setMargin(5); |
86 | 87 | ||
87 | usersListView=new QListView(tabpage,"allusers"); | 88 | usersListView=new QListView(tabpage,"allusers"); |
88 | usersListView->addColumn("UID"); | 89 | usersListView->addColumn("UID"); |
@@ -103,60 +104,60 @@ void UserConfig::setupTabAllGroups() { | |||
103 | groupsListView=new QListView(tabpage,"groups"); | 104 | groupsListView=new QListView(tabpage,"groups"); |
104 | groupsListView->addColumn("GID"); | 105 | groupsListView->addColumn("GID"); |
105 | groupsListView->addColumn("Groupname"); | 106 | groupsListView->addColumn("Groupname"); |
106 | layout->addWidget(groupsListView); | 107 | layout->addWidget(groupsListView); |
107 | groupsListView->setSorting(1,1); | 108 | groupsListView->setSorting(1,1); |
108 | groupsListView->setAllColumnsShowFocus(true); | 109 | groupsListView->setAllColumnsShowFocus(true); |
109 | 110 | ||
110 | myTabWidget->addTab(tabpage,"All Groups"); | 111 | myTabWidget->addTab(tabpage,"All Groups"); |
111 | } | 112 | } |
112 | void UserConfig::getUsers() { | 113 | void UserConfig::getUsers() { |
113 | QString mytext; | 114 | QString mytext; |
114 | QPixmap mypixmap; | 115 | QPixmap mypixmap; |
115 | 116 | QListViewItem *listviewitem; | |
117 | |||
116 | // Empty the iconview & the listview. | 118 | // Empty the iconview & the listview. |
117 | usersIconView->clear(); | 119 | usersIconView->clear(); |
118 | usersListView->clear(); | 120 | usersListView->clear(); |
119 | 121 | ||
120 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. | 122 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. |
121 | availableUID=500; | 123 | availableUID=500; |
122 | for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { | 124 | for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { |
123 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) | 125 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) |
124 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); | 126 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); |
125 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? | 127 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? |
126 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. | 128 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. |
127 | // mypixmap=Resource::loadPixmap(QString("users/"+accounts->pw_name));// Is there an icon for this user? Resource::loadPixmap is caching, doesn't work. | 129 | if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { // Is there an icon for this user? Resource::loadPixmap is caching, doesn't work. |
128 | if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { | ||
129 | // if(mypixmap.isNull()) { | ||
130 | 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. |
131 | } | 131 | } |
132 | new QIconViewItem(usersIconView,mytext,mypixmap);// Add the icon+text to the qiconview. | 132 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. |
133 | listviewitem->setPixmap(0,mypixmap); | ||
133 | } | 134 | } |
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. | 135 | 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. |
135 | } | 136 | } |
136 | usersIconView->sort(); | 137 | usersIconView->sort(); |
137 | } | 138 | } |
138 | 139 | ||
139 | void UserConfig::addUser() { | 140 | void UserConfig::addUser() { |
140 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. | 141 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. |
141 | getUsers(); // Update users views. | 142 | getUsers(); // Update users views. |
142 | getGroups(); // Update groups view. | 143 | getGroups(); // Update groups view. |
143 | } | 144 | } |
144 | } | 145 | } |
145 | 146 | ||
146 | void UserConfig::editUser() { | 147 | void UserConfig::editUser() { |
147 | QString username; | 148 | QString username; |
148 | if(myTabWidget->currentPageIndex()==0) {// Users | 149 | if(myTabWidget->currentPageIndex()==0) {// Users |
149 | if(usersIconView->currentItem()) {// Any icon selected? | 150 | if(usersIconView->currentItem()) {// Any icon selected? |
150 | username=usersIconView->currentItem()->text();// Get the text associated with the icon. | 151 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. |
151 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 152 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
152 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 153 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
153 | // If there were any changed also update the views. | 154 | // If there were any changed also update the views. |
154 | getUsers(); | 155 | getUsers(); |
155 | getGroups(); | 156 | getGroups(); |
156 | } | 157 | } |
157 | } else { | 158 | } else { |
158 | QMessageBox::information(this,"No selection.","No user has been selected."); | 159 | QMessageBox::information(this,"No selection.","No user has been selected."); |
159 | } | 160 | } |
160 | } | 161 | } |
161 | if(myTabWidget->currentPageIndex()==1) {// All users | 162 | if(myTabWidget->currentPageIndex()==1) {// All users |
162 | if(usersListView->currentItem()) {// Anything changed!? | 163 | if(usersListView->currentItem()) {// Anything changed!? |
@@ -168,25 +169,25 @@ void UserConfig::editUser() { | |||
168 | } | 169 | } |
169 | } else { | 170 | } else { |
170 | QMessageBox::information(this,"No selection.","No user has been selected."); | 171 | QMessageBox::information(this,"No selection.","No user has been selected."); |
171 | } | 172 | } |
172 | } | 173 | } |
173 | } | 174 | } |
174 | 175 | ||
175 | void UserConfig::delUser() { | 176 | void UserConfig::delUser() { |
176 | QString username; | 177 | QString username; |
177 | 178 | ||
178 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. | 179 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. |
179 | if(usersIconView->currentItem()) {// Anything selected? | 180 | if(usersIconView->currentItem()) {// Anything selected? |
180 | username=usersIconView->currentItem()->text();// Get string associated with icon. | 181 | username=usersIconView->currentItem()->text(1);// Get string associated with icon. |
181 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 182 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
182 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { | 183 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { |
183 | if(UserDialog::delUser(username)) {// Delete the user if possible. | 184 | if(UserDialog::delUser(username)) {// Delete the user if possible. |
184 | // Update views. | 185 | // Update views. |
185 | getUsers(); | 186 | getUsers(); |
186 | getGroups(); | 187 | getGroups(); |
187 | } | 188 | } |
188 | } | 189 | } |
189 | } else { | 190 | } else { |
190 | QMessageBox::information(this,"No selection","No user has been selected."); | 191 | QMessageBox::information(this,"No selection","No user has been selected."); |
191 | } | 192 | } |
192 | } | 193 | } |