[1f4adec] | 1 | /* |
---|
| 2 | |
---|
| 3 | Copyright 2014 Adam Reichold |
---|
| 4 | |
---|
| 5 | This file is part of qpdfview. |
---|
| 6 | |
---|
| 7 | qpdfview is free software: you can redistribute it and/or modify |
---|
| 8 | it under the terms of the GNU General Public License as published by |
---|
| 9 | the Free Software Foundation, either version 2 of the License, or |
---|
| 10 | (at your option) any later version. |
---|
| 11 | |
---|
| 12 | qpdfview is distributed in the hope that it will be useful, |
---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | GNU General Public License for more details. |
---|
| 16 | |
---|
| 17 | You should have received a copy of the GNU General Public License |
---|
| 18 | along with qpdfview. If not, see <http://www.gnu.org/licenses/>. |
---|
| 19 | |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #include "bookmarkdialog.h" |
---|
| 23 | |
---|
| 24 | #include <QDateTime> |
---|
| 25 | #include <QDialogButtonBox> |
---|
| 26 | #include <QFormLayout> |
---|
| 27 | #include <QLineEdit> |
---|
| 28 | #include <QTextEdit> |
---|
| 29 | |
---|
| 30 | #include "global.h" |
---|
| 31 | #include "bookmarkmodel.h" |
---|
| 32 | |
---|
| 33 | namespace qpdfview |
---|
| 34 | { |
---|
| 35 | |
---|
| 36 | BookmarkDialog::BookmarkDialog(BookmarkItem& bookmark, QWidget* parent) : QDialog(parent), |
---|
| 37 | m_bookmark(bookmark) |
---|
| 38 | { |
---|
| 39 | setWindowTitle(tr("Bookmark")); |
---|
| 40 | |
---|
| 41 | QFormLayout* formLayout = new QFormLayout(this); |
---|
| 42 | setLayout(formLayout); |
---|
| 43 | |
---|
| 44 | m_pageEdit = new QLineEdit(this); |
---|
| 45 | m_pageEdit->setReadOnly(true); |
---|
| 46 | m_pageEdit->setText(QString::number(m_bookmark.page)); |
---|
| 47 | |
---|
| 48 | formLayout->addRow(tr("Page:"), m_pageEdit); |
---|
| 49 | |
---|
| 50 | m_labelEdit = new QLineEdit(this); |
---|
| 51 | m_labelEdit->setText(m_bookmark.label); |
---|
| 52 | |
---|
| 53 | formLayout->addRow(tr("Label:"), m_labelEdit); |
---|
| 54 | |
---|
| 55 | m_commentEdit = new QTextEdit(this); |
---|
| 56 | m_commentEdit->setPlainText(m_bookmark.comment); |
---|
| 57 | |
---|
| 58 | formLayout->addRow(tr("Comment:"), m_commentEdit); |
---|
| 59 | |
---|
| 60 | m_modifiedEdit = new QLineEdit(this); |
---|
| 61 | m_modifiedEdit->setReadOnly(true); |
---|
| 62 | m_modifiedEdit->setText(m_bookmark.modified.toString(Qt::SystemLocaleLongDate)); |
---|
| 63 | |
---|
| 64 | formLayout->addRow(tr("Modified:"), m_modifiedEdit); |
---|
| 65 | |
---|
| 66 | m_dialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); |
---|
| 67 | connect(m_dialogButtonBox, SIGNAL(accepted()), SLOT(accept())); |
---|
| 68 | connect(m_dialogButtonBox, SIGNAL(rejected()), SLOT(reject())); |
---|
| 69 | |
---|
| 70 | formLayout->addWidget(m_dialogButtonBox); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | void BookmarkDialog::accept() |
---|
| 74 | { |
---|
| 75 | QDialog::accept(); |
---|
| 76 | |
---|
| 77 | m_bookmark.label = m_labelEdit->text(); |
---|
| 78 | m_bookmark.comment = m_commentEdit->toPlainText(); |
---|
| 79 | |
---|
| 80 | m_bookmark.modified = QDateTime::currentDateTime(); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | void BookmarkDialog::showEvent(QShowEvent*) |
---|
| 84 | { |
---|
| 85 | m_labelEdit->setFocus(); |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | } // qpdfview |
---|