/* * Copyright (c) 2002-2003 Nicolas HADACEK (hadacek@kde.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "dialog.h" #include "dialog.moc" #include #include #include #include #include #include #include #include #include #include #include #include #include #include //----------------------------------------------------------------------------- SelectionRange::SelectionRange(const QString &s) { // fill QValueVector > r; QStringList list = QStringList::split(',', s); QRegExp range("^([0-9]+)\\-([0-9]+)$"); QRegExp one("^[0-9]+$"); for (QStringList::iterator it = list.begin(); it!=list.end(); ++it) { if ( one.exactMatch(*it) ) { uint p = (*it).toUInt(); r.push_back( qMakePair(p, p) ); } else if ( range.exactMatch(*it) ) { uint p1 = range.cap(1).toUInt(); uint p2 = range.cap(2).toUInt(); if ( p1>p2 ) continue; r.push_back( qMakePair(p1, p2) ); } } // order QPair tmp; for (uint i=1; isetInsideSpacing(KDialogBase::spacingHint()); top->addWidget(gbox); _group = new QButtonGroup; _allButton = new QRadioButton(i18n("All (%1 pages)").arg(nbPages), gbox); _allButton->setChecked(true); _group->insert(_allButton); QHBox *hbox = new QHBox(gbox); _rangeButton = new QRadioButton(i18n("Range:"), hbox); _group->insert(_rangeButton); _range = new KLineEdit(hbox); _range->setFocus(); connect(_range, SIGNAL(textChanged(const QString &)), SLOT(rangeChanged(const QString &))); // options _images = new QCheckBox(i18n("Import images"), plainPage()); _images->setChecked(true); top->addWidget(_images); _smart = new QCheckBox(i18n("\"Smart\" mode"), plainPage()); _smart->setChecked(true); QWhatsThis::add(_smart, i18n("Removes returns and hyphens at end of line. " "Also tries to compute the paragraph alignment. " "Note that the layout of some pages can " "get messed up.")); top->addWidget(_smart); // passwords gbox = new QVGroupBox(i18n("Passwords"), plainPage()); top->addWidget(gbox); QGrid *grid = new QGrid(2, gbox); grid->setSpacing(KDialogBase::spacingHint()); (void)new QLabel(i18n("Owner:"), grid); _owner = new KLineEdit(grid); _owner->setEchoMode(QLineEdit::Password); (void)new QLabel(i18n("User:"), grid); _user = new KLineEdit(grid); _user->setEchoMode(QLineEdit::Password); grid->setEnabled(isEncrypted); } Dialog::~Dialog() { delete _group; QApplication::setOverrideCursor(Qt::waitCursor); } void Dialog::rangeChanged(const QString &) { _rangeButton->setChecked(true); } Options Dialog::options() const { Options o; o.range = SelectionRange( (_allButton->isChecked() ? QString("1-%1").arg(_nbPages) : _range->text()) ); o.ownerPassword = _owner->text(); o.userPassword = _user->text(); o.importImages = _images->isChecked(); o.smart = _smart->isChecked(); return o; } } // namespace