kpfileselectpage.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 "kpfileselectpage.h"
00021 #include "kfilelist.h"
00022 
00023 #include <qlayout.h>
00024 #include <qstringlist.h>
00025 #include <qregexp.h>
00026 #include <qheader.h>
00027 #include <klocale.h>
00028 #include <kiconloader.h>
00029 
00030 KPFileSelectPage::KPFileSelectPage(QWidget *parent, const char *name)
00031 : KPrintDialogPage(parent, name)
00032 {
00033     setTitle(i18n("&Files"));
00034     m_first = true;
00035 
00036     m_files = new KFileList(this);
00037 
00038     QHBoxLayout *l0 = new QHBoxLayout(this, 0, 10);
00039     l0->addWidget(m_files);
00040 
00041     resize(100, 100);
00042 }
00043 
00044 void KPFileSelectPage::getOptions(QMap<QString,QString>& opts, bool incldef)
00045 {
00046     // (incldef == false) is a hint telling that it should be the last time
00047     // and we want to do it only once
00048     if (!incldef)
00049     {
00050         QStringList l = m_files->fileList();
00051         opts["kde-filelist"] = l.join("@@");
00052     }
00053 }
00054 
00055 void KPFileSelectPage::setOptions(const QMap<QString,QString>& opts)
00056 {
00057     // do it only once as files will only be selected there
00058     if (m_first)
00059     {
00060         QStringList l = QStringList::split("@@", opts["kde-filelist"], false);
00061         m_files->setFileList(l);
00062 
00063         m_first = false;
00064     }
00065 }
KDE Home | KDE Accessibility Home | Description of Access Keys