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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
/*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include "svn_fileselectdlg_commit.h"
#include "subversion_fileinfo.h"
#include "subversion_part.h"
#include <kurl.h>
#include <tqstring.h>
#include <tqlistview.h>
#include <tqfileinfo.h>
#include <tqcheckbox.h>
#include <kdebug.h>
#include <tdemessagebox.h>
#include "tdevmainwindow.h"
#include <tdelocale.h>
#include <tdevproject.h>
SVNFileSelectDlgCommit::SVNFileSelectDlgCommit( KURL::List &urls, subversionPart *part, TQWidget* parent)
:SvnCommitDlgBase( parent, "svnfileselectcommitdlg", true )
,m_part(part)
{
this->setCaption(i18n("Select Files to Commit"));
listView()->clear();
listView()->setColumnText(0, i18n("select") ); //col 0
listView()->addColumn( i18n("status") ); //col 1
listView()->addColumn( i18n("URL to commit") ); //col 2
listView()->setColumnWidthMode( 2, TQListView::Maximum );
listView()->setSorting( 2, true );
recursiveChk->setChecked(false);
keepLocksChk->setChecked(false);
const VCSFileInfoMap *vcsMap;
VCSFileInfo vcsInfo;
KURL::List tobeCommittedUrls;
for( TQValueListConstIterator<KURL> it = urls.begin(); it != urls.end(); ++it ){
KURL oneUrl(*it);
TQFileInfo fileInfo(oneUrl.path());
//fileInfo.convertToAbs();
if (fileInfo.isFile()){
KURL base_url( part->project()->projectDirectory()+"/" );
TQString dirPath = KURL::relativeURL( base_url, fileInfo.dirPath(TRUE) );
vcsMap = ((SVNFileInfoProvider*)part->fileInfoProvider()) ->
statusExt(dirPath, false/*repository access*/, true/*recurse*/, false/*getall*/, true/*noIgnore*/);
vcsInfo = (*vcsMap)[fileInfo.fileName()];
if( vcsInfo.state == VCSFileInfo::Added || vcsInfo.state == VCSFileInfo::Modified ||
vcsInfo.state == VCSFileInfo::Deleted || vcsInfo.state == VCSFileInfo::Replaced ){
this->insertItem( VCSFileInfo::state2String( vcsInfo.state ), oneUrl );
// tobeCommittedUrls.push_back(oneUrl);
// kdDebug(9036) << "slotCommit() : added AS FILE: " << oneUrl.prettyURL() << endl;
}
else{
kdDebug(9036) << "slotCommit() @ FileCase ignoring " << oneUrl.prettyURL() << endl;
}
}
else if (fileInfo.isDir()){
KURL base_url( part->project()->projectDirectory()+"/" );
TQString dirPath = KURL::relativeURL( base_url, fileInfo.absFilePath() );
vcsMap = ((SVNFileInfoProvider*)part->fileInfoProvider()) ->
statusExt(dirPath, false/*repository access*/, true/*recurse*/, false/*getall*/, true/*noIgnore*/);
for (VCSFileInfoMap::ConstIterator it=vcsMap->begin(); it!=vcsMap->end(); ++it){
vcsInfo = it.data();
// TQString absPathStr( fileInfo.absFilePath() + "/" + it.key() );
TQString absPathStr( fileInfo.filePath() + "/" + it.key() );
KURL urlFromStatus( absPathStr );
if( vcsInfo.state == VCSFileInfo::Added || vcsInfo.state == VCSFileInfo::Modified ||
vcsInfo.state == VCSFileInfo::Deleted || vcsInfo.state == VCSFileInfo::Replaced){
this->insertItem( VCSFileInfo::state2String( vcsInfo.state ), urlFromStatus );
// tobeCommittedUrls.push_back( urlFromStatus );
// kdDebug(9036) << "slotCommit() @ DirCase adding " << urlFromStatus.prettyURL() << endl;
}
else{
kdDebug(9036) << "slotCommit() @ DirCase ignoring " << urlFromStatus.prettyURL() << endl;
}
}
}
else if ( !fileInfo.exists() ){
// maybe deleted files
this->insertItem( VCSFileInfo::state2String( VCSFileInfo::Deleted ), oneUrl );
}
}
}
SVNFileSelectDlgCommit::~SVNFileSelectDlgCommit()
{
}
int SVNFileSelectDlgCommit::exec()
{
if (listView()->childCount() <= 0){
//TODO if tdelauncher fails, this spot is also reached. We should show correct error message to user
KMessageBox::information( (TQWidget*)m_part->project()->mainWindow()->main(), i18n("No added/modified/deleted file(s) to commit") );
return TQDialog::Rejected;
}
else{
return SvnCommitDlgBase::exec();
}
}
void SVNFileSelectDlgCommit::insertItem( TQString status, KURL url )
{
TQCheckListItem *item = new TQCheckListItem( listView(), "", TQCheckListItem::CheckBox );
item->setText( 1, status );
item->setText( 2, url.path() );
item->setOn(true);
}
KURL::List SVNFileSelectDlgCommit::checkedUrls()
{
TQPtrList<TQListViewItem> lst;
TQListViewItemIterator it( listView() );
KURL::List tobeCommittedUrls;
for ( ; it.current() ; ++it ) {
if ( ((TQCheckListItem*)(it.current()))->isOn() ){
KURL tmpurl( it.current()->text(2) );
tobeCommittedUrls.push_back( tmpurl );
}
}
return tobeCommittedUrls;
}
TQListView* SVNFileSelectDlgCommit::listView()
{
return listView1;
}
bool SVNFileSelectDlgCommit::recursive()
{
return recursiveChk->isChecked();
}
bool SVNFileSelectDlgCommit::keepLocks()
{
return keepLocksChk->isChecked();
}
#include "svn_fileselectdlg_commit.moc"
|