• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Widgets Library
 

KDevelop Widgets Library

  • lib
  • widgets
ksavealldialog.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002 Harald Fernengel <harry@kdevelop.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include <tqvbox.h>
21#include <tqlabel.h>
22#include <tqheader.h>
23
24#include <tdelocale.h>
25#include <kpushbutton.h>
26#include <tdelistbox.h>
27#include <tdelistview.h>
28#include <kstdguiitem.h>
29
30#include "ksavealldialog.h"
31
32namespace
33{
34
35class CheckURL : public TQCheckListItem
36{
37public:
38 CheckURL( TQListView * lv, KURL const & url )
39 : TQCheckListItem( lv, url.path(), TQCheckListItem::CheckBox),
40 _url( url )
41 {}
42
43 KURL const & url() const { return _url; }
44
45private:
46 KURL _url;
47};
48
49}
50
51
52KSaveSelectDialog::KSaveSelectDialog( KURL::List const & filelist, KURL::List const & ignorelist, TQWidget * parent ) :
53 KDialogBase( parent, "SaveAllDialog", true, i18n("Save Modified Files?"),
54 Ok | User1 | Close )
55{
56 TQVBox *top = makeVBoxMainWidget();
57
58 (void)new TQLabel( i18n("The following files have been modified. Save them?"), top );
59
60 _listview = new TDEListView( top );
61 _listview->addColumn( "" );
62 _listview->header()->hide();
63 _listview->setResizeMode( TQListView::LastColumn );
64
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") );
70
71 KURL::List::ConstIterator it = filelist.begin();
72 while ( it != filelist.end() )
73 {
74 if ( !ignorelist.contains( *it ) )
75 {
76 TQCheckListItem * x = new CheckURL( _listview, *it );
77 x->setOn( true );
78 }
79 ++it;
80 }
81
82 connect( this, TQ_SIGNAL(closeClicked()), this, TQ_SLOT(cancel()) );
83 connect( this, TQ_SIGNAL(okClicked()), this, TQ_SLOT(save()) );
84 connect( this, TQ_SIGNAL(user1Clicked()), this, TQ_SLOT(saveNone()) );
85}
86
87KSaveSelectDialog::~KSaveSelectDialog() {}
88
89void KSaveSelectDialog::saveNone( )
90{
91 // deselect all
92 CheckURL * item = static_cast<CheckURL*>( _listview->firstChild() );
93 while ( item )
94 {
95 item->setOn( false );
96 item = static_cast<CheckURL*>( item->nextSibling() );
97 }
98
99 TQDialog::accept();
100}
101
102void KSaveSelectDialog::save( )
103{
104 TQDialog::accept();
105}
106
107void KSaveSelectDialog::cancel( )
108{
109 TQDialog::reject();
110}
111
112KURL::List KSaveSelectDialog::filesToSave( )
113{
114 KURL::List filelist;
115 CheckURL const * item = static_cast<CheckURL*>( _listview->firstChild() );
116 while ( item )
117 {
118 if ( item->isOn() )
119 {
120 filelist << item->url();
121 }
122 item = static_cast<CheckURL*>( item->nextSibling() );
123 }
124 return filelist;
125}
126
127KURL::List KSaveSelectDialog::filesNotToSave( )
128{
129 KURL::List filelist;
130 CheckURL const * item = static_cast<CheckURL*>( _listview->firstChild() );
131 while ( item )
132 {
133 if ( ! item->isOn() )
134 {
135 filelist << item->url();
136 }
137 item = static_cast<CheckURL*>( item->nextSibling() );
138 }
139 return filelist;
140}
141
142
143KSaveAllDialog::KSaveAllDialog( const TQStringList& filenames, TQWidget* parent ) :
144 KDialogBase( parent, "SaveAllDialog", true, i18n("Save Modified Files?"),
145 Ok | User1 | Close )
146{
147 m_result = Cancel;
148
149 TQVBox *top = makeVBoxMainWidget();
150
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 );
155
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") );
161
162 connect( this, TQ_SIGNAL(closeClicked()), this, TQ_SLOT(cancel()) );
163 connect( this, TQ_SIGNAL(okClicked()), this, TQ_SLOT(saveAll()) );
164 connect( this, TQ_SIGNAL(user1Clicked()), this, TQ_SLOT(revert()) );
165}
166
167KSaveAllDialog::~KSaveAllDialog()
168{
169}
170
171void KSaveAllDialog::revert()
172{
173 m_result = Revert;
174 TQDialog::accept();
175}
176
177void KSaveAllDialog::saveAll()
178{
179 m_result = SaveAll;
180 TQDialog::accept();
181}
182
183void KSaveAllDialog::cancel()
184{
185 m_result = Cancel;
186 TQDialog::reject();
187}
188
189#include "ksavealldialog.moc"
ksavealldialog.h
Dialogs to save multiple files.

KDevelop Widgets Library

Skip menu "KDevelop Widgets Library"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

KDevelop Widgets Library

Skip menu "KDevelop Widgets Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Widgets Library by doxygen 1.15.0
This website is maintained by Timothy Pearson.