24 #include <tdelocale.h> 25 #include <kpushbutton.h> 26 #include <tdelistbox.h> 27 #include <tdelistview.h> 28 #include <kstdguiitem.h> 35 class CheckURL :
public TQCheckListItem
38 CheckURL( TQListView * lv, KURL
const & url )
39 : TQCheckListItem( lv, url.path(), TQCheckListItem::CheckBox),
43 KURL
const & url()
const {
return _url; }
52 KSaveSelectDialog::KSaveSelectDialog( KURL::List
const & filelist, KURL::List
const & ignorelist, TQWidget * parent ) :
53 KDialogBase( parent,
"SaveAllDialog", true, i18n(
"Save Modified Files?"),
56 TQVBox *top = makeVBoxMainWidget();
58 (void)
new TQLabel( i18n(
"The following files have been modified. Save them?"), top );
60 _listview =
new TDEListView( top );
61 _listview->addColumn(
"" );
62 _listview->header()->hide();
63 _listview->setResizeMode( TQListView::LastColumn );
65 setButtonOK( KGuiItem(i18n(
"Save &Selected"), TQString(), i18n(
"Saves all selected files")) );
66 setButtonText( User1, i18n(
"Save &None") );
67 setButtonText( Close, KStdGuiItem::cancel().text() );
68 setButtonTip( User1, i18n(
"Lose all modifications") );
69 setButtonTip( Close, i18n(
"Cancels the action") );
71 KURL::List::ConstIterator it = filelist.begin();
72 while ( it != filelist.end() )
74 if ( !ignorelist.contains( *it ) )
76 TQCheckListItem * x =
new CheckURL( _listview, *it );
82 connect(
this, TQT_SIGNAL(closeClicked()),
this, TQT_SLOT(cancel()) );
83 connect(
this, TQT_SIGNAL(okClicked()),
this, TQT_SLOT(save()) );
84 connect(
this, TQT_SIGNAL(user1Clicked()),
this, TQT_SLOT(saveNone()) );
87 KSaveSelectDialog::~KSaveSelectDialog() {}
89 void KSaveSelectDialog::saveNone( )
92 CheckURL * item =
static_cast<CheckURL*
>( _listview->firstChild() );
96 item =
static_cast<CheckURL*
>( item->nextSibling() );
102 void KSaveSelectDialog::save( )
107 void KSaveSelectDialog::cancel( )
112 KURL::List KSaveSelectDialog::filesToSave( )
115 CheckURL
const * item =
static_cast<CheckURL*
>( _listview->firstChild() );
120 filelist << item->url();
122 item =
static_cast<CheckURL*
>( item->nextSibling() );
127 KURL::List KSaveSelectDialog::filesNotToSave( )
130 CheckURL
const * item =
static_cast<CheckURL*
>( _listview->firstChild() );
133 if ( ! item->isOn() )
135 filelist << item->url();
137 item =
static_cast<CheckURL*
>( item->nextSibling() );
143 KSaveAllDialog::KSaveAllDialog(
const TQStringList& filenames, TQWidget* parent ) :
144 KDialogBase( parent,
"SaveAllDialog", true, i18n(
"Save Modified Files?"),
149 TQVBox *top = makeVBoxMainWidget();
151 (void)
new TQLabel( i18n(
"The following files have been modified. Save them?"), top );
152 TDEListBox* lb =
new TDEListBox( top );
153 lb->setMinimumHeight( lb->fontMetrics().height() * 5 );
154 lb->insertStringList( filenames );
156 setButtonOK( KGuiItem(i18n(
"Save &All"), TQString(), i18n(
"Saves all modified files")) );
157 setButtonText( User1, i18n(
"Save &None") );
158 setButtonText( Close, KStdGuiItem::cancel().text() );
159 setButtonTip( User1, i18n(
"Lose all modifications") );
160 setButtonTip( Close, i18n(
"Cancels the action") );
162 connect(
this, TQT_SIGNAL(closeClicked()),
this, TQT_SLOT(cancel()) );
163 connect(
this, TQT_SIGNAL(okClicked()),
this, TQT_SLOT(saveAll()) );
164 connect(
this, TQT_SIGNAL(user1Clicked()),
this, TQT_SLOT(revert()) );
167 KSaveAllDialog::~KSaveAllDialog()
171 void KSaveAllDialog::revert()
177 void KSaveAllDialog::saveAll()
183 void KSaveAllDialog::cancel()
189 #include "ksavealldialog.moc" Dialogs to save multiple files.