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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/* This file is part of the KDE project
Copyright (C) 2002 Harald Fernengel <harry@kdevelop.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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 Library General Public License
along with this library; 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 <tqvbox.h>
#include <tqlabel.h>
#include <tqheader.h>
#include <tdelocale.h>
#include <kpushbutton.h>
#include <tdelistbox.h>
#include <tdelistview.h>
#include <kstdguiitem.h>
#include "ksavealldialog.h"
namespace
{
class CheckURL : public TQCheckListItem
{
public:
CheckURL( TQListView * lv, KURL const & url )
: TQCheckListItem( lv, url.path(), TQCheckListItem::CheckBox),
_url( url )
{}
KURL const & url() const { return _url; }
private:
KURL _url;
};
}
KSaveSelectDialog::KSaveSelectDialog( KURL::List const & filelist, KURL::List const & ignorelist, TQWidget * parent ) :
KDialogBase( parent, "SaveAllDialog", true, i18n("Save Modified Files?"),
Ok | User1 | Close )
{
TQVBox *top = makeVBoxMainWidget();
(void)new TQLabel( i18n("The following files have been modified. Save them?"), top );
_listview = new TDEListView( top );
_listview->addColumn( "" );
_listview->header()->hide();
_listview->setResizeMode( TQListView::LastColumn );
setButtonOK( KGuiItem( i18n("Save &Selected"), TQString(), i18n("Saves all selected files") ) );
setButtonText( User1, i18n("Save &None") );
setButtonText( Close, KStdGuiItem::cancel().text() );
setButtonTip( User1, i18n("Lose all modifications") );
setButtonTip( Close, i18n("Cancels the action") );
KURL::List::ConstIterator it = filelist.begin();
while ( it != filelist.end() )
{
if ( !ignorelist.contains( *it ) )
{
TQCheckListItem * x = new CheckURL( _listview, *it );
x->setOn( true );
}
++it;
}
connect( this, TQT_SIGNAL(closeClicked()), this, TQT_SLOT(cancel()) );
connect( this, TQT_SIGNAL(okClicked()), this, TQT_SLOT(save()) );
connect( this, TQT_SIGNAL(user1Clicked()), this, TQT_SLOT(saveNone()) );
}
KSaveSelectDialog::~KSaveSelectDialog() {}
void KSaveSelectDialog::saveNone( )
{
// deselect all
CheckURL * item = static_cast<CheckURL*>( _listview->firstChild() );
while ( item )
{
item->setOn( false );
item = static_cast<CheckURL*>( item->nextSibling() );
}
TQDialog::accept();
}
void KSaveSelectDialog::save( )
{
TQDialog::accept();
}
void KSaveSelectDialog::cancel( )
{
TQDialog::reject();
}
KURL::List KSaveSelectDialog::filesToSave( )
{
KURL::List filelist;
CheckURL const * item = static_cast<CheckURL*>( _listview->firstChild() );
while ( item )
{
if ( item->isOn() )
{
filelist << item->url();
}
item = static_cast<CheckURL*>( item->nextSibling() );
}
return filelist;
}
KURL::List KSaveSelectDialog::filesNotToSave( )
{
KURL::List filelist;
CheckURL const * item = static_cast<CheckURL*>( _listview->firstChild() );
while ( item )
{
if ( ! item->isOn() )
{
filelist << item->url();
}
item = static_cast<CheckURL*>( item->nextSibling() );
}
return filelist;
}
KSaveAllDialog::KSaveAllDialog( const TQStringList& filenames, TQWidget* parent ) :
KDialogBase( parent, "SaveAllDialog", true, i18n("Save Modified Files?"),
Ok | User1 | Close )
{
m_result = Cancel;
TQVBox *top = makeVBoxMainWidget();
(void)new TQLabel( i18n("The following files have been modified. Save them?"), top );
TDEListBox* lb = new TDEListBox( top );
lb->setMinimumHeight( lb->fontMetrics().height() * 5 );
lb->insertStringList( filenames );
setButtonOK( KGuiItem( i18n("Save &All"), TQString(), i18n("Saves all modified files") ) );
setButtonText( User1, i18n("Save &None") );
setButtonText( Close, KStdGuiItem::cancel().text() );
setButtonTip( User1, i18n("Lose all modifications") );
setButtonTip( Close, i18n("Cancels the action") );
connect( this, TQT_SIGNAL(closeClicked()), this, TQT_SLOT(cancel()) );
connect( this, TQT_SIGNAL(okClicked()), this, TQT_SLOT(saveAll()) );
connect( this, TQT_SIGNAL(user1Clicked()), this, TQT_SLOT(revert()) );
}
KSaveAllDialog::~KSaveAllDialog()
{
}
void KSaveAllDialog::revert()
{
m_result = Revert;
TQDialog::accept();
}
void KSaveAllDialog::saveAll()
{
m_result = SaveAll;
TQDialog::accept();
}
void KSaveAllDialog::cancel()
{
m_result = Cancel;
TQDialog::reject();
}
#include "ksavealldialog.moc"
|