1 // KDat - a tar-based DAT archiver
2 // Copyright (C) 1998-2000 Sean Vyain, svyain@mail.tds.net
3 // Copyright (C) 2001-2002 Lawrence Widman, kdat@cardiothink.com
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <QVBoxLayout>
27 #include <QHBoxLayout>
29 #include <kpushbutton.h>
30 #include <KStandardGuiItem>
32 #include "BackupProfile.h"
33 #include "BackupProfileInfoWidget.h"
34 #include "BackupProfileWidget.h"
35 #include "KDatMainWindow.h"
39 #include "BackupProfileInfoWidget.moc"
41 BackupProfileInfoWidget::BackupProfileInfoWidget( QWidget
* parent
, const char* name
)
42 : QWidget( parent
, name
),
45 QLabel
* lbl1
= new QLabel( i18n( "Backup profile name:" ), this );
47 int max
= lbl1
->sizeHint().width();
49 lbl1
->setFixedSize( max
, lbl1
->sizeHint().height() );
51 _name
= new QLineEdit( this );
52 _name
->setFixedHeight( _name
->sizeHint().height() );
54 _profile
= new BackupProfileWidget( this );
56 QPushButton
* getSelection
= new QPushButton( i18n( "Files >>" ), this );
57 getSelection
->setFixedSize( 80, getSelection
->sizeHint().height() );
59 QPushButton
* setSelection
= new QPushButton( i18n( "<< Files" ), this );
60 setSelection
->setFixedSize( 80, setSelection
->sizeHint().height() );
62 _apply
= new KPushButton( KStandardGuiItem::apply(), this );
63 _apply
->setFixedSize( 80, _apply
->sizeHint().height() );
64 _apply
->setEnabled( FALSE
);
66 QVBoxLayout
* l1
= new QVBoxLayout( this, 4, 4 );
68 QHBoxLayout
* l1_1
= new QHBoxLayout();
69 l1
->addLayout( l1_1
);
70 l1_1
->addWidget( lbl1
);
71 l1_1
->addWidget( _name
, 1 );
73 l1
->addWidget( _profile
, 1 );
75 QHBoxLayout
* l1_2
= new QHBoxLayout();
76 l1
->addLayout( l1_2
);
77 l1_2
->addWidget( setSelection
);
78 l1_2
->addWidget( getSelection
);
79 l1_2
->addStretch( 1 );
80 l1_2
->addWidget( _apply
);
82 connect( setSelection
, SIGNAL( clicked() ) , this, SLOT( slotSetSelection() ) );
83 connect( getSelection
, SIGNAL( clicked() ) , this, SLOT( slotGetSelection() ) );
84 connect( _name
, SIGNAL( textChanged( const QString
& ) ), this, SLOT( slotTextChanged( const QString
& ) ) );
85 connect( _profile
, SIGNAL( sigSomethingChanged() ) , this, SLOT( slotSomethingChanged() ) );
86 connect( _apply
, SIGNAL( clicked() ) , this, SLOT( slotApply() ) );
89 BackupProfileInfoWidget::~BackupProfileInfoWidget()
93 void BackupProfileInfoWidget::setBackupProfile( BackupProfile
* backupProfile
)
95 _backupProfile
= backupProfile
;
97 if ( !_backupProfile
) {
101 _name
->setText( _backupProfile
->getName() );
103 _profile
->setBackupProfile( _backupProfile
);
106 bool BackupProfileInfoWidget::isModified()
108 if ( _backupProfile
->getName() != _name
->text() ) {
112 if ( _profile
->getArchiveName() != _backupProfile
->getArchiveName() ) {
116 QString one
= _backupProfile
->getWorkingDirectory();
117 QString two
= _profile
->getWorkingDirectory();
118 // 7/31/01: this breaks
119 // if ( _profile->getWorkingDirectory() != _backupProfile->getWorkingDirectory() ) {
124 if ( _profile
->getAbsoluteFiles().count() != _backupProfile
->getAbsoluteFiles().count() ) {
128 QStringList list1
= _profile
->getAbsoluteFiles();
129 QStringList list2
= _backupProfile
->getAbsoluteFiles();
130 QStringList::Iterator i
= list1
.begin();
131 QStringList::Iterator j
= list2
.begin();
132 for ( ; i
!= list1
.end(); ++i
) {
133 for ( ; j
!= list2
.end(); ++j
) {
138 if ( j
== list2
.end() ) {
139 // Could not find i.current() in j => lists are not equal.
144 if ( _profile
->isOneFilesystem() != _backupProfile
->isOneFilesystem() ) {
148 if ( _profile
->isIncremental() != _backupProfile
->isIncremental() ) {
152 if ( _profile
->getSnapshotFile() != _backupProfile
->getSnapshotFile() ) {
156 if ( _profile
->getRemoveSnapshot() != _backupProfile
->getRemoveSnapshot() ) {
163 void BackupProfileInfoWidget::slotTextChanged( const QString
& )
165 if ( !_backupProfile
) {
169 _apply
->setEnabled( isModified() );
172 void BackupProfileInfoWidget::slotSomethingChanged()
174 if ( !_backupProfile
) {
178 _apply
->setEnabled( isModified() );
181 void BackupProfileInfoWidget::slotApply()
183 if ( !_backupProfile
) {
187 _backupProfile
->setName( _name
->text() );
188 _backupProfile
->setArchiveName( _profile
->getArchiveName() );
189 _backupProfile
->setWorkingDirectory( _profile
->getWorkingDirectory() );
190 _backupProfile
->setAbsoluteFiles( _profile
->getAbsoluteFiles() );
191 _backupProfile
->setOneFilesystem( _profile
->isOneFilesystem() );
192 _backupProfile
->setIncremental( _profile
->isIncremental() );
193 _backupProfile
->setSnapshotFile( _profile
->getSnapshotFile() );
194 _backupProfile
->setRemoveSnapshot( _profile
->getRemoveSnapshot() );
196 _backupProfile
->save();
198 _apply
->setEnabled( FALSE
);
201 void BackupProfileInfoWidget::slotSetSelection()
203 KDatMainWindow::getInstance()->setBackupFiles( _profile
->getAbsoluteFiles() );
206 void BackupProfileInfoWidget::slotGetSelection()
209 KDatMainWindow::getInstance()->getBackupFiles( files
);
210 _profile
->setAbsoluteFiles( files
);