~kubuntu-members/kompare/4.11

« back to all changes in this revision

Viewing changes to komparepart/kompareview.cpp

  • Committer: Otto Bruggeman
  • Date: 2003-08-22 20:54:19 UTC
  • Revision ID: git-v1:d09a8c32a5056998bdb6f604549a5f24c8f6fe75
Die make_it_cool, die kompare! :)

svn path=/trunk/kdesdk/kompare/; revision=244089

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
                                kompareview.cpp  -  description
3
3
                                -------------------
4
4
        begin                   : Sun Mar 4 2001
5
 
        copyright               : (C) 2001 by Otto Bruggeman
 
5
        copyright               : (C) 2001-2003 by Otto Bruggeman
6
6
                                  and John Firebaugh
7
7
        email                   : otto.bruggeman@home.nl
8
8
                                  jfirebaugh@kde.org
28
28
#include "difference.h"
29
29
#include "diffhunk.h"
30
30
#include "diffmodel.h"
31
 
#include "generalsettings.h"
 
31
#include "viewsettings.h"
32
32
#include "kompareconnectwidget.h"
 
33
#include "komparemodellist.h"
33
34
#include "komparelistview.h"
34
35
 
 
36
 
35
37
#include "kompareview.h"
36
38
 
37
 
#define kdDebug() kdDebug(8103)
 
39
using namespace Diff2;
38
40
 
39
 
KompareView::KompareView( GeneralSettings* settings, QWidget *parent, const char *name )
 
41
KompareView::KompareView( ViewSettings* settings, QWidget *parent, const char *name )
40
42
        : QFrame(parent, name),
41
43
        m_selectedModel( 0 ),
42
44
        m_settings( settings )
109
111
        connect( m_hScroll, SIGNAL(valueChanged(int)), m_diff2, SLOT(setXOffset(int)) );
110
112
        connect( m_hScroll, SIGNAL(sliderMoved(int)), m_diff1, SLOT(setXOffset(int)) );
111
113
        connect( m_hScroll, SIGNAL(sliderMoved(int)), m_diff2, SLOT(setXOffset(int)) );
112
 
        connect( m_diff1, SIGNAL(differenceClicked(const Difference*)),
113
 
                 this, SLOT(slotDifferenceClicked(const Difference*)) );
114
 
        connect( m_diff2, SIGNAL(differenceClicked(const Difference*)),
115
 
                 this, SLOT(slotDifferenceClicked(const Difference*)) );
 
114
        connect( m_diff1, SIGNAL(differenceClicked(const Diff2::Difference*)),
 
115
                 this, SLOT(slotDifferenceClicked(const Diff2::Difference*)) );
 
116
        connect( m_diff2, SIGNAL(differenceClicked(const Diff2::Difference*)),
 
117
                 this, SLOT(slotDifferenceClicked(const Diff2::Difference*)) );
116
118
        updateScrollBars();
117
119
}
118
120
 
129
131
 
130
132
void KompareView::slotSetSelection( const DiffModel* model, const Difference* diff )
131
133
{
132
 
        kdDebug() << "KompareView::slotSetSelection( model, diff )" << endl;
 
134
        kdDebug(8104) << "KompareView::slotSetSelection( model, diff )" << endl;
133
135
        if( model )
134
136
        {
135
137
                m_selectedModel = model;
136
 
                m_revlabel1->setText( model->srcFile() );
137
 
                m_revlabel2->setText( model->destFile() );
 
138
                m_revlabel1->setText( model->sourceFile() );
 
139
                m_revlabel2->setText( model->destinationFile() );
138
140
                if( !model->sourceRevision().isEmpty() )
139
 
                        m_revlabel1->setText( model->srcFile() + " (" + model->sourceRevision() + ")" );
 
141
                        m_revlabel1->setText( model->sourceFile() + " (" + model->sourceRevision() + ")" );
140
142
                if( !model->destinationRevision().isEmpty() )
141
 
                        m_revlabel1->setText( model->destFile() + " (" + model->destinationRevision() + ")" );
 
143
                        m_revlabel1->setText( model->destinationFile() + " (" + model->destinationRevision() + ")" );
142
144
        } else {
143
145
                m_revlabel1->setText( QString::null );
144
146
                m_revlabel2->setText( QString::null );
151
153
 
152
154
void KompareView::slotSetSelection( const Difference* diff )
153
155
{
154
 
        kdDebug() << "KompareView::slotSetSelection( diff )" << endl;
 
156
        kdDebug(8104) << "KompareView::slotSetSelection( diff )" << endl;
155
157
        m_diff1->slotSetSelection( diff );
156
158
        m_diff2->slotSetSelection( diff );
157
159
        m_zoom->slotSetSelection( diff );
177
179
                }
178
180
 
179
181
                m_vScroll->blockSignals( true );
180
 
                m_vScroll->setRange( QMIN( m_diff1->minScrollId(), m_diff2->minScrollId() ),
181
 
                                   QMAX( m_diff1->maxScrollId(), m_diff2->maxScrollId() ) );
 
182
                m_vScroll->setRange( 0, QMAX( m_diff1->maxScrollId(), m_diff2->maxScrollId() ) );
182
183
                m_vScroll->setValue( m_diff1->scrollId() );
183
184
                m_vScroll->setSteps( 7, m_diff1->visibleHeight() - 14 );
184
185
                m_vScroll->blockSignals( false );
211
212
void KompareView::wheelEvent( QWheelEvent* e )
212
213
{
213
214
        // scroll lines...
214
 
        int pos = m_vScroll->value();
215
 
        int height = m_diff1->itemRect( 0 ).height();
216
215
        if ( e->delta() < 0 ) // scroll back into file
217
216
        {
218
 
                m_vScroll->setValue( pos + m_settings->m_scrollNoOfLines*height );
 
217
                m_vScroll->addLine();
219
218
        }
220
219
        else // scroll forward into file
221
220
        {
222
 
                m_vScroll->setValue( pos - m_settings->m_scrollNoOfLines*height );
 
221
                m_vScroll->subtractLine();
223
222
        }
224
223
        m_zoom->repaint();
225
224
}