/* * 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 TQString &s) { // fill TQValueVector > r; TQStringList list = TQStringList::split(',', s); TQRegExp range("^([0-9]+)\\-([0-9]+)$"); TQRegExp one("^[0-9]+$"); for (TQStringList::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 TQPair tmp; for (uint i=1; isetInsideSpacing(KDialogBase::spacingHint()); top->addWidget(gbox); _group = new TQButtonGroup; _allButton = new TQRadioButton(i18n("All (%1 pages)").arg(nbPages), gbox); _allButton->setChecked(true); _group->insert(_allButton); TQHBox *hbox = new TQHBox(gbox); _rangeButton = new TQRadioButton(i18n("Range:"), hbox); _group->insert(_rangeButton); _range = new KLineEdit(hbox); _range->setFocus(); connect(_range, TQT_SIGNAL(textChanged(const TQString &)), TQT_SLOT(rangeChanged(const TQString &))); // options _images = new TQCheckBox(i18n("Import images"), plainPage()); _images->setChecked(true); top->addWidget(_images); _smart = new TQCheckBox(i18n("\"Smart\" mode"), plainPage()); _smart->setChecked(true); TQWhatsThis::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 TQVGroupBox(i18n("Passwords"), plainPage()); top->addWidget(gbox); TQGrid *grid = new TQGrid(2, gbox); grid->setSpacing(KDialogBase::spacingHint()); (void)new TQLabel(i18n("Owner:"), grid); _owner = new KLineEdit(grid); _owner->setEchoMode(TQLineEdit::Password); (void)new TQLabel(i18n("User:"), grid); _user = new KLineEdit(grid); _user->setEchoMode(TQLineEdit::Password); grid->setEnabled(isEncrypted); } Dialog::~Dialog() { delete _group; TQApplication::setOverrideCursor(TQt::waitCursor); } void Dialog::rangeChanged(const TQString &) { _rangeButton->setChecked(true); } Options Dialog::options() const { Options o; o.range = SelectionRange( (_allButton->isChecked() ? TQString("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