author | umopapisdn <umopapisdn> | 2002-09-29 19:17:07 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2002-09-29 19:17:07 (UTC) |
commit | d61d575feac628fe4afb3cc9bf4fc8f24fc8616a (patch) (side-by-side diff) | |
tree | 147ded7eb7f3cc2b42bd6b731b93b5c9a108d9ad /noncore/settings/usermanager/userdialog.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/userdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index 719dd1e..b7827a4 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp @@ -146,25 +146,25 @@ void UserDialog::setupTab1() { * Creates the second tab containing additional groups for the user. * */ void UserDialog::setupTab2() { QWidget *tabpage = new QWidget(myTabWidget,"page2"); QVBoxLayout *layout = new QVBoxLayout(tabpage); layout->setMargin(5); // Additional groups groupsListView=new QListView(tabpage,"groups"); groupsListView->addColumn("Additional groups"); groupsListView->setColumnWidthMode(0,QListView::Maximum); - groupsListView->setMultiSelection(true); + groupsListView->setMultiSelection(false); groupsListView->setAllColumnsShowFocus(false); layout->addSpacing(5); // Grouplist layout->addWidget(groupsListView); myTabWidget->addTab(tabpage,"User Groups"); } /** * Static function that creates the userinfo dialog. * The user will be prompted to add a user. @@ -189,37 +189,39 @@ bool UserDialog::addUser(int uid, int gid) { accounts->findGroup(adduserDialog->groupComboBox->currentText()); adduserDialog->groupID=accounts->gr_gid; qWarning(QString::number(accounts->gr_gid)); } if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); return false; } // Add User to additional groups. + QCheckListItem *temp; QListViewItemIterator it( adduserDialog->groupsListView ); for ( ; it.current(); ++it ) { - if ( it.current()->isSelected() ) + temp=(QCheckListItem*)it.current(); + if (temp->isOn() ) accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); } // Copy image to pics/users/ if(!(adduserDialog->userImage.isNull())) { QDir d; if(!(d.exists("/opt/QtPalmtop/pics/users"))) { d.mkdir("/opt/QtPalmtop/pics/users"); } QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; - adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); +// adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); adduserDialog->userImage.save(filename,"PNG"); } return true; } /** * Deletes the user account. * * @param username User to be deleted. * * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. * @@ -259,31 +261,33 @@ bool UserDialog::editUser(const char *username) { // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") { edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); edituserDialog->shellComboBox->setCurrentItem(0); } // Select the primary group for this user. for(int i=0;i<edituserDialog->groupComboBox->count();++i) { if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { edituserDialog->groupComboBox->setCurrentItem(i); } } // Select the groups in the listview, to which the user belongs. + QCheckListItem *temp; QRegExp userRegExp(QString("[:\\s]%1\\s").arg(username)); QStringList tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { // Iterate over all of them. QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. for ( ; lvit.current(); ++lvit ) { if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { - lvit.current()->setSelected(true); // If we find a line with that groupname, select it.; + temp=(QCheckListItem*)lvit.current(); + temp->setOn(true); // If we find a line with that groupname, select it.; } } } if(!(edituserDialog->exec())) return false; // SHOW THE DIALOG! accounts->findUser(username); // Fill user variables in 'acccounts' object. accounts->pw_name=edituserDialog->loginLineEdit->text(); // Has the password been changed ? Make a new "crypt":ed password. if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); // Set all variables in accounts object, that will be used when calling 'updateUser()' @@ -294,36 +298,37 @@ bool UserDialog::editUser(const char *username) { accounts->pw_shell=edituserDialog->shellComboBox->currentText(); // Update userinfo, using the information stored in the user variables stored in the accounts object. accounts->updateUser(username); // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { accounts->delGroupMember((*it).left((*it).find(":")),username); } // Add User to additional groups that he/she is a member of. QListViewItemIterator it( edituserDialog->groupsListView ); for ( ; it.current(); ++it ) { - if ( it.current()->isSelected() ) + temp=(QCheckListItem*)it.current(); + if ( temp->isOn() ) accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); } // Copy image to pics/users/ if(!(edituserDialog->userImage.isNull())) { QDir d; if(!(d.exists("/opt/QtPalmtop/pics/users"))) { d.mkdir("/opt/QtPalmtop/pics/users"); } QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; - edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); +// edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); edituserDialog->userImage.save(filename,"PNG"); } return true; } /** * "OK" has been clicked. Verify some information before closing the dialog. * */ void UserDialog::accept() { // Add checking... valid username? username taken? if(loginLineEdit->text().isEmpty()) { @@ -335,20 +340,20 @@ void UserDialog::accept() { /** * This slot is called when the usericon is clicked, this loads (should) the iconselector. * */ void UserDialog::clickedPicture() { QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics"); if(!(filename.isEmpty())) { userImage.reset(); if(!(userImage.load(filename))) { QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); } else { - userImage=userImage.smoothScale(48,48); +// userImage=userImage.smoothScale(48,48); QPixmap *picture; picture=(QPixmap *)picturePushButton->pixmap(); picture->convertFromImage(userImage,0); picturePushButton->update(); } } } |