• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdevelop API Reference
  • KDE Home
  • Contact Us
 

kdevplatform/vcs

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • vcs
  • widgets
vcsdiffwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * This file is part of KDevelop *
3  * Copyright 2007 Andreas Pakulat <[email protected]> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU Library General Public License as *
7  * published by the Free Software Foundation; either version 2 of the *
8  * License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Library General Public *
16  * License along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #include "vcsdiffwidget.h"
22 
23 #include <KLocalizedString>
24 
25 #include <interfaces/icore.h>
26 #include <interfaces/iruncontroller.h>
27 
28 #include "../vcsjob.h"
29 #include "../vcsrevision.h"
30 #include "../vcsdiff.h"
31 #include "debug.h"
32 
33 #include "ui_vcsdiffwidget.h"
34 #include "vcsdiffpatchsources.h"
35 
36 namespace KDevelop
37 {
38 
39 class VcsDiffWidgetPrivate
40 {
41 public:
42  Ui::VcsDiffWidget* m_ui;
43  VcsJob* m_job;
44  VcsDiffWidget* q;
45 
46  explicit VcsDiffWidgetPrivate(VcsDiffWidget* _q) : q(_q) {
47  }
48 
49  void diffReady( KDevelop::VcsJob* job )
50  {
51  if( job != m_job )
52  return;
53  KDevelop::VcsDiff diff = m_job->fetchResults().value<KDevelop::VcsDiff>();
54 
55  // Try using the patch-review plugin if possible
56  auto* patch = new VCSDiffPatchSource(diff);
57 
58  if(showVcsDiff(patch))
59  {
60  q->deleteLater();
61  return;
62  }else{
63  delete patch;
64  }
65 
66  qCDebug(VCS) << "diff:" << diff.diff();
67  m_ui->diffDisplay->setPlainText( diff.diff() );
68  m_ui->diffDisplay->setReadOnly( true );
69 
70  }
71 
72 };
73 
74 VcsDiffWidget::VcsDiffWidget( KDevelop::VcsJob* job, QWidget* parent )
75  : QWidget(parent)
76  , d_ptr(new VcsDiffWidgetPrivate(this))
77 {
78  Q_D(VcsDiffWidget);
79 
80  d->m_job = job;
81  d->m_ui = new Ui::VcsDiffWidget();
82  d->m_ui->setupUi( this );
83  connect( d->m_job, &VcsJob::resultsReady,
84  this, [this] (VcsJob* job) { Q_D(VcsDiffWidget); d->diffReady(job); } );
85  ICore::self()->runController()->registerJob( d->m_job );
86 }
87 
88 VcsDiffWidget::~VcsDiffWidget()
89 {
90  Q_D(VcsDiffWidget);
91 
92  delete d->m_ui;
93 }
94 
95 void VcsDiffWidget::setRevisions( const KDevelop::VcsRevision& first,
96  const KDevelop::VcsRevision& second )
97 {
98  Q_D(VcsDiffWidget);
99 
100  d->m_ui->revLabel->setText( i18nc("@label", "Difference between revision %1 and %2:",
101  first.prettyValue(),
102  second.prettyValue() ) );
103 }
104 
105 }
106 
107 #include "moc_vcsdiffwidget.cpp"
QWidget
VCSDiffPatchSource
Definition: vcsdiffpatchsources.h:66
KDevelop::VcsDiff
Definition: vcsdiff.h:37
showVcsDiff
bool showVcsDiff(IPatchSource *vcsDiff)
Sends the diff to the patch-review plugin.
Definition: vcsdiffpatchsources.cpp:291
KDevelop::VcsRevision
Encapsulates a vcs revision number, date or range of revisions.
Definition: vcsrevision.h:66
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
vcsdiffpatchsources.h
KDevelop::VcsDiffWidget::VcsDiffWidget
VcsDiffWidget(KDevelop::VcsJob *, QWidget *parent=nullptr)
Definition: vcsdiffwidget.cpp:91
KDevelop::VcsDiff::diff
QString diff() const
Definition: vcsdiff.cpp:71
KDevelop::VcsJob
This class provides an extension of KJob to get various VCS-specific information about the job.
Definition: vcsjob.h:43
KDevelop::VcsRevision::prettyValue
QString prettyValue() const
This returns the value of the revision, suitable for displaying to the user.
Definition: vcsrevision.cpp:144
KDevelop
Definition: dvcsevent.h:33
KDevelop::VcsDiffWidget
Definition: vcsdiffwidget.h:49
vcsdiffwidget.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 23 2021 09:41:52 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/vcs

Skip menu "kdevplatform/vcs"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal