Warning, file /sdk/cervisia/resolvedialog_p.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *  Copyright (c) 2004 Christian Loose <christian.loose@kdemail.net>
0003  *
0004  * This program is free software; you can redistribute it and/or modify
0005  * it under the terms of the GNU General Public License as published by
0006  * the Free Software Foundation; either version 2 of the License, or
0007  * (at your option) any later version.
0008  *
0009  * This program is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  * GNU General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU General Public License
0015  * along with this program; if not, write to the Free Software
0016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0017  */
0018 
0019 #include "resolvedialog_p.h"
0020 #include "cervisiasettings.h"
0021 
0022 #include <KConfigGroup>
0023 #include <QDialogButtonBox>
0024 #include <QPlainTextEdit>
0025 #include <QPushButton>
0026 #include <QVBoxLayout>
0027 #include <kconfig.h>
0028 #include <kconfiggroup.h>
0029 
0030 using namespace Cervisia;
0031 
0032 ResolveEditorDialog::ResolveEditorDialog(KConfig &cfg, QWidget *parent)
0033     : QDialog(parent)
0034     , m_partConfig(cfg)
0035 {
0036     setModal(true);
0037 
0038     auto mainLayout = new QVBoxLayout;
0039     setLayout(mainLayout);
0040 
0041     auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
0042     QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
0043     okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
0044     connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
0045     connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
0046 
0047     m_edit = new QPlainTextEdit(this);
0048     m_edit->setFont(CervisiaSettings::diffFont());
0049     m_edit->setFocus();
0050 
0051     mainLayout->addWidget(m_edit);
0052     mainLayout->addWidget(buttonBox);
0053 
0054     QFontMetrics const fm(fontMetrics());
0055     resize(fm.width('0') * 120, fm.lineSpacing() * 40);
0056 
0057     KConfigGroup cg(&m_partConfig, "ResolveEditorDialog");
0058     restoreGeometry(cg.readEntry<QByteArray>("geometry", QByteArray()));
0059 }
0060 
0061 ResolveEditorDialog::~ResolveEditorDialog()
0062 {
0063     KConfigGroup cg(&m_partConfig, "ResolveEditorDialog");
0064     cg.writeEntry("geometry", saveGeometry());
0065 }
0066 
0067 void ResolveEditorDialog::setContent(const QString &text)
0068 {
0069     m_edit->setPlainText(text);
0070 }
0071 
0072 QString ResolveEditorDialog::content() const
0073 {
0074     return m_edit->toPlainText();
0075 }