1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
/*
* Copyright (C) 1999-2002 Bernd Gehrmann
* bernd@mail.berlios.de
*
* 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 "annotatedialog.h"
#include "annotateview.h"
#include <KConfigGroup>
#include <KHelpClient>
#include <KLocalizedString>
#include <kconfig.h>
#include <QDialogButtonBox>
#include <QInputDialog>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
AnnotateDialog::AnnotateDialog(KConfig &cfg, QWidget *parent)
: QDialog(parent)
, partConfig(cfg)
{
auto mainLayout = new QVBoxLayout;
setLayout(mainLayout);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close);
auto user1Button = new QPushButton;
user1Button->setText(i18n("Go to Line..."));
user1Button->setAutoDefault(false);
buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
auto user2Button = new QPushButton;
user2Button->setText(i18n("Find Prev"));
user2Button->setAutoDefault(false);
buttonBox->addButton(user2Button, QDialogButtonBox::ActionRole);
auto user3Button = new QPushButton;
user3Button->setText(i18n("Find Next"));
buttonBox->addButton(user3Button, QDialogButtonBox::ActionRole);
buttonBox->button(QDialogButtonBox::Help)->setAutoDefault(false);
connect(buttonBox, &QDialogButtonBox::rejected, this, &AnnotateDialog::reject);
connect(buttonBox, &QDialogButtonBox::helpRequested, this, &AnnotateDialog::slotHelp);
findEdit = new QLineEdit;
findEdit->setClearButtonEnabled(true);
findEdit->setPlaceholderText(i18n("Search"));
annotate = new AnnotateView(this);
mainLayout->addWidget(findEdit);
mainLayout->addWidget(annotate);
mainLayout->addWidget(buttonBox);
connect(user3Button, SIGNAL(clicked()), this, SLOT(findNext()));
connect(user2Button, SIGNAL(clicked()), this, SLOT(findPrev()));
connect(user1Button, SIGNAL(clicked()), this, SLOT(gotoLine()));
setAttribute(Qt::WA_DeleteOnClose, true);
KConfigGroup cg(&partConfig, "AnnotateDialog");
restoreGeometry(cg.readEntry<QByteArray>("geometry", QByteArray()));
findEdit->setFocus();
}
AnnotateDialog::~AnnotateDialog()
{
KConfigGroup cg(&partConfig, "AnnotateDialog");
cg.writeEntry("geometry", saveGeometry());
}
void AnnotateDialog::slotHelp()
{
KHelpClient::invokeHelp(QLatin1String("annotate"));
}
void AnnotateDialog::addLine(const Cervisia::LogInfo &logInfo, const QString &content, bool odd)
{
annotate->addLine(logInfo, content, odd);
}
void AnnotateDialog::findNext()
{
if (!findEdit->text().isEmpty())
annotate->findText(findEdit->text(), false);
}
void AnnotateDialog::findPrev()
{
if (!findEdit->text().isEmpty())
annotate->findText(findEdit->text(), true);
}
void AnnotateDialog::gotoLine()
{
bool ok = false;
int line = QInputDialog::getInt(this, i18n("Go to Line"), i18n("Go to line number:"), annotate->currentLine(), 1, annotate->lastLine(), 1, &ok);
if (ok)
annotate->gotoLine(line);
}
// Local Variables:
// c-basic-offset: 4
// End:
|