summaryrefslogtreecommitdiff
path: root/noncore/settings/usermanager/usermanager.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/usermanager/usermanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/usermanager/usermanager.cpp21
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
@@ -50,155 +50,156 @@ UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWind
addToolBar(toolbar,"myToolBar");
// Add a tabwidget and all the tabs.
myTabWidget = new QTabWidget(this,"My Tab Widget");
setupTabAccounts();
setupTabAllUsers();
setupTabAllGroups();
getUsers(); // Fill out the iconview & listview with all users.
getGroups(); // Fill out the group listview with all groups.
setCentralWidget(myTabWidget);
}
UserConfig::~UserConfig() {
accounts->close();
delete accounts;
}
void UserConfig::setupTabAccounts() {
QWidget *tabpage = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(tabpage);
layout->setMargin(5);
- usersIconView=new QIconView(tabpage,"users");
- usersIconView->setItemTextPos(QIconView::Right);
- usersIconView->setArrangement(QIconView::LeftToRight);
+ usersIconView=new QListView(tabpage,"users");
+ usersIconView->addColumn("Icon");
+ usersIconView->addColumn("Username");
+ usersIconView->setAllColumnsShowFocus(true);
layout->addWidget(usersIconView);
myTabWidget->addTab(tabpage,"Users");
}
void UserConfig::setupTabAllUsers() {
QWidget *tabpage = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(tabpage);
layout->setMargin(5);
usersListView=new QListView(tabpage,"allusers");
usersListView->addColumn("UID");
usersListView->addColumn("Login");
usersListView->addColumn("Username");
layout->addWidget(usersListView);
usersListView->setSorting(1,1);
usersListView->setAllColumnsShowFocus(true);
myTabWidget->addTab(tabpage,"All Users");
}
void UserConfig::setupTabAllGroups() {
QWidget *tabpage = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(tabpage);
layout->setMargin(5);
groupsListView=new QListView(tabpage,"groups");
groupsListView->addColumn("GID");
groupsListView->addColumn("Groupname");
layout->addWidget(groupsListView);
groupsListView->setSorting(1,1);
groupsListView->setAllColumnsShowFocus(true);
myTabWidget->addTab(tabpage,"All Groups");
}
void UserConfig::getUsers() {
QString mytext;
QPixmap mypixmap;
-
+ QListViewItem *listviewitem;
+
// Empty the iconview & the listview.
usersIconView->clear();
usersListView->clear();
// availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500.
availableUID=500;
for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) {
accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.)
new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos);
if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) { // Is this user a "normal" user ?
mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon.
-// mypixmap=Resource::loadPixmap(QString("users/"+accounts->pw_name)); // Is there an icon for this user? Resource::loadPixmap is caching, doesn't work.
- if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) {
-// if(mypixmap.isNull()) {
+ 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.
mypixmap=Resource::loadPixmap(QString("usermanager/usericon")); // If this user has no icon, load the default icon.
}
- new QIconViewItem(usersIconView,mytext,mypixmap); // Add the icon+text to the qiconview.
+ listviewitem=new QListViewItem(usersIconView,"",mytext); // Add the icon+text to the qiconview.
+ listviewitem->setPixmap(0,mypixmap);
}
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.
}
usersIconView->sort();
}
void UserConfig::addUser() {
if(UserDialog::addUser(availableUID,availableGID)) { // Add the user to the system, also send next available UID and GID.
getUsers(); // Update users views.
getGroups(); // Update groups view.
}
}
void UserConfig::editUser() {
QString username;
if(myTabWidget->currentPageIndex()==0) { // Users
if(usersIconView->currentItem()) { // Any icon selected?
- username=usersIconView->currentItem()->text(); // Get the text associated with the icon.
+ username=usersIconView->currentItem()->text(1); // Get the text associated with the icon.
username=username.left(username.find(" - (",0,true)); // Strip out the username.
if(UserDialog::editUser(username)) { // Bring up the userinfo dialog.
// If there were any changed also update the views.
getUsers();
getGroups();
}
} else {
QMessageBox::information(this,"No selection.","No user has been selected.");
}
}
if(myTabWidget->currentPageIndex()==1) { // All users
if(usersListView->currentItem()) { // Anything changed!?
username=usersListView->currentItem()->text(1); // Get the username.
if(UserDialog::editUser(username)) { // Bring up the userinfo dialog.
// And again update the views if there were any changes.
getUsers();
getGroups();
}
} else {
QMessageBox::information(this,"No selection.","No user has been selected.");
}
}
}
void UserConfig::delUser() {
QString username;
if(myTabWidget->currentPageIndex()==0) { // Users, Iconview.
if(usersIconView->currentItem()) { // Anything selected?
- username=usersIconView->currentItem()->text(); // Get string associated with icon.
+ username=usersIconView->currentItem()->text(1); // Get string associated with icon.
username=username.left(username.find(" - (",0,true)); // Strip out the username.
if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) {
if(UserDialog::delUser(username)) { // Delete the user if possible.
// Update views.
getUsers();
getGroups();
}
}
} else {
QMessageBox::information(this,"No selection","No user has been selected.");
}
}
if(myTabWidget->currentPageIndex()==1) { // All users
if(usersListView->currentItem()) { // Anything changed!?
username=usersListView->currentItem()->text(1); // Get the username.
if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) {
if(UserDialog::delUser(username)) { // Try to delete the user.
// Update views.
getUsers();
getGroups();
}
}
} else {
QMessageBox::information(this,"No selection","No user has been selected.");