summaryrefslogtreecommitdiffstats
path: root/vcs/subversion/svn_blamewidget.cpp
blob: b40953894383dcf29c69f9180c7bfd6f3c34809d (plain)
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
124
125
126
127
128
129
130
131
132
133
134
135
/*
 *  Copyright (C) 2007 Dukju Ahn (dukjuahn@gmail.com)
 *
 *  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
 *  Library General Public License for more details.
 */

#include "svn_blamewidget.h"
#include "subversion_widget.h"
#include <tqmap.h>
#include <tqlistview.h>
#include <tqlayout.h>
#include <tqpushbutton.h>
#include <tqstringlist.h>
#include <tqfont.h>

#include <klocale.h>
#include <kmessagebox.h>

SvnBlameWidget::SvnBlameWidget( TQWidget *parent, const char* name, bool modal, WFlags f )
	:TQWidget( parent )
{
    m_layout = new TQVBoxLayout( this, 1, 1 );
    m_layout->setMargin(1);
    
    m_listView = new TQListView( this );
    outView()->setAllColumnsShowFocus( TRUE );
    outView()->addColumn( i18n("Line") );
    outView()->addColumn( i18n("Rev") );
    outView()->addColumn( i18n("Date") );
    outView()->addColumn( i18n("Author") );
    outView()->addColumn( i18n("Content") );
    
    m_layout->addWidget( m_listView );
}
SvnBlameWidget::~SvnBlameWidget()
{}

void SvnBlameWidget::copyBlameData( TQValueList<SvnBlameHolder> *blamelist )
{
	m_blamelist = *blamelist;
}
	
void SvnBlameWidget::show()
{
	outView()->clear();
	outView()->setSortColumn(0);
	
	TQFont f = outView()->font();
	f.setFixedPitch( true );
	outView()->setFont( f );

	TQValueList<SvnBlameHolder>::Iterator it;
	
	for( it = m_blamelist.begin(); it != m_blamelist.end(); ++it ){
		
		SvnBlameHolder holder = *it;
		SvnIntSortListItem *item = new SvnIntSortListItem(outView());
		
		TQString prettyDate = holder.date.left(16).replace(10, 1, ' ');
		
		item->setText(0, TQString::number( holder.line+1 ) ); 
		item->setText(1, TQString::number(holder.rev) );
		item->setText(2, prettyDate );
		item->setText(3, holder.author );
		item->setText(4, holder.content );
		
	}
	outView()->sort();
	TQWidget::show();
}

TQListView* SvnBlameWidget::outView()
{
    return m_listView;
}

/////////////////////////////////////////////////////////////

SvnBlameFileSelectDlg::SvnBlameFileSelectDlg( TQWidget *parent )
    : TQDialog( parent )
{
    m_selected = "";
    setCaption( i18n("Select one file to view annotation") );
    
    m_layout = new TQGridLayout( this, 2, 2 );
    m_view = new TQListView( this );
    m_view->addColumn( i18n("files") );
    m_okBtn = new TQPushButton( i18n("OK"), this );
    m_cancelBtn = new TQPushButton( i18n("Cancel"), this );
    m_layout->addMultiCellWidget( m_view, 0, 0, 0, 1 );
    m_layout->addWidget( m_okBtn, 1, 0 );
    m_layout->addWidget( m_cancelBtn, 1, 1 );
    
    connect( m_okBtn, TQT_SIGNAL(clicked()), this, TQT_SLOT(accept()) );
    connect( m_cancelBtn, TQT_SIGNAL(clicked()), this, TQT_SLOT(reject()) );
}
SvnBlameFileSelectDlg::~SvnBlameFileSelectDlg()
{}

void SvnBlameFileSelectDlg::setCandidate( TQStringList *list )
{
    for( TQValueList<TQString>::iterator it = list->begin(); it != list->end(); ++it ){
        TQListViewItem *item = new TQListViewItem( m_view, *it );
    }
}

TQString SvnBlameFileSelectDlg::selected()
{
    return m_selected;
}

void SvnBlameFileSelectDlg::accept()
{
    while( true ){
        TQListViewItem *item = m_view->currentItem();
        if( item ){
            m_selected = item->text(0);
            break;
        }
        else{
            KMessageBox::error( this, i18n("Select file from list to view annotation") );
        }
    }
    TQDialog::accept();
}

#include "svn_blamewidget.moc"