source: terepaima/terepaima-0.4.16/sources/bookmarkdialog.cpp

desarrollostretch
Last change on this file was 1f4adec, checked in by aosorio <aosorio@…>, 8 years ago

Agregado proyecto base, esto luego del dh_make -f

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2
3Copyright 2014 Adam Reichold
4
5This file is part of qpdfview.
6
7qpdfview is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 2 of the License, or
10(at your option) any later version.
11
12qpdfview is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along 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
33namespace qpdfview
34{
35
36BookmarkDialog::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
73void 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
83void BookmarkDialog::showEvent(QShowEvent*)
84{
85    m_labelEdit->setFocus();
86}
87
88} // qpdfview
Note: See TracBrowser for help on using the repository browser.