Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

SessionsDialog.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2002 by Yann Hodique                                    *
00003  *   Yann.Hodique@lifl.fr                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 
00011 #include "SessionsDialog.h"
00012 
00013 #include <qlistbox.h>
00014 #include <qlineedit.h>
00015 #include <qcheckbox.h>
00016 
00017 SessionsDialog::SessionsDialog(QWidget *parent, const char *name)
00018         : SessionsDialogBase(parent, name) {}
00019 
00020 
00021 SessionsDialog::~SessionsDialog() {}
00022 
00023 void SessionsDialog::addSessionItem(SessionItem & it, int index) {
00024     map.insert(it.name,it);
00025     sessions_box->insertItem(it.name, index);
00026 }
00027 
00028 void SessionsDialog::delSessionItem(const QString& name) {
00029     map.remove(name);
00030 }
00031 
00032 void SessionsDialog::slotSubs() {
00033     SessionItem *it = &(*(map.find(sessions_box->currentText())));
00034     if (it->name != name_edit->text())
00035         return;
00036     it->host = host_edit->text();
00037     it->port = port_edit->text();
00038     it->login = login_edit->text();
00039     it->password = pass_edit->text();
00040     it->autoconnect = auto_check->isChecked();
00041 }
00042 
00043 void SessionsDialog::slotAdd() {
00044     if (name_edit->text().length() && host_edit->text().length() && port_edit->text().length()) {
00045         SessionItem it(name_edit->text(),host_edit->text(),port_edit->text(),login_edit->text(),pass_edit->text(),auto_check->isChecked());
00046         addSessionItem(it);
00047     }
00048 }
00049 
00050 void SessionsDialog::slotDel() {
00051     delSessionItem(QString(sessions_box->currentText()));
00052     sessions_box->removeItem(sessions_box->currentItem());
00053 }
00054 
00055 void SessionsDialog::slotDown() {
00056     unsigned int index = sessions_box->currentItem();
00057 
00058     if (index < sessions_box->count()) {
00059         QString text = sessions_box->currentText();
00060         sessions_box->removeItem(index);
00061         sessions_box->insertItem(text,index + 1);
00062     }
00063 }
00064 
00065 void SessionsDialog::slotUp() {
00066     int index = sessions_box->currentItem();
00067     if (index) {
00068         QString text = sessions_box->currentText();
00069         sessions_box->removeItem(index);
00070         sessions_box->insertItem(text,index - 1);
00071     }
00072 }
00073 
00074 void SessionsDialog::slotUpdateInfo(const QString & name) {
00075     SessionItem it = *(map.find(name));
00076     name_edit->setText(it.name);
00077     host_edit->setText(it.host);
00078     port_edit->setText(it.port);
00079     login_edit->setText(it.login);
00080     pass_edit->setText(it.password);
00081     auto_check->setChecked(it.autoconnect);
00082 }

Generated on Sat May 10 15:09:28 2003 for qnet by doxygen1.3