kmwinfobase.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "kmwinfobase.h"
00021 
00022 #include <qlabel.h>
00023 #include <qlineedit.h>
00024 #include <qlayout.h>
00025 
00026 KMWInfoBase::KMWInfoBase(int n, QWidget *parent, const char *name)
00027 : KMWizardPage(parent,name)
00028 {
00029     m_labels.setAutoDelete(false);
00030     m_edits.setAutoDelete(false);
00031 
00032     m_nlines = n;
00033     QGridLayout *lay1 = new QGridLayout(this, m_nlines+3, 2, 0, 10);
00034     lay1->addRowSpacing(1,10);
00035     lay1->setRowStretch(m_nlines+2,1);
00036     lay1->setColStretch(1,1);
00037 
00038     m_info = new QLabel(this);
00039     m_info->setTextFormat(Qt::RichText);
00040     lay1->addMultiCellWidget(m_info,0,0,0,1);
00041 
00042     for (int i=0;i<m_nlines;i++)
00043     {
00044         m_labels.append(new QLabel(this));
00045         m_edits.append(new QLineEdit(this));
00046         lay1->addWidget(m_labels.last(),i+2,0);
00047         lay1->addWidget(m_edits.last(),i+2,1);
00048     }
00049 }
00050 
00051 void KMWInfoBase::setInfo(const QString& s)
00052 {
00053     m_info->setText(s);
00054 }
00055 
00056 void KMWInfoBase::setLabel(int i, const QString& s)
00057 {
00058     if (i >= 0 && i < m_nlines)
00059         m_labels.at(i)->setText(s);
00060 }
00061 
00062 void KMWInfoBase::setText(int i, const QString& s)
00063 {
00064     if (i >= 0 && i < m_nlines)
00065         m_edits.at(i)->setText(s);
00066 }
00067 
00068 QString KMWInfoBase::text(int i)
00069 {
00070     if (i >= 0 && i < m_nlines)
00071         return m_edits.at(i)->text();
00072     return QString::null;
00073 }
00074 
00075 void KMWInfoBase::setCurrent(int i)
00076 {
00077     if (i >= 0 && i < m_nlines)
00078     {
00079         m_edits.at(i)->selectAll();
00080         m_edits.at(i)->setFocus();
00081     }
00082 }
00083 
00084 QLineEdit* KMWInfoBase::lineEdit( int i )
00085 {
00086     if ( i >= 0 && i < m_nlines )
00087         return m_edits.at( i );
00088     else
00089         return NULL;
00090 }
KDE Home | KDE Accessibility Home | Description of Access Keys