summaryrefslogtreecommitdiffstats
path: root/src/projects/k3bdataadvancedimagesettingswidget.cpp
blob: be1cb17eccc913c0f6c802cfd950f05022a446b3 (plain)
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
/* 
 *
 * $Id: k3bdataadvancedimagesettingswidget.cpp 619556 2007-01-03 17:38:12Z trueg $
 * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
 *
 * This file is part of the K3b project.
 * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
 *
 * 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.
 * See the file "COPYING" for the exact licensing terms.
 */

#include "k3bdataadvancedimagesettingswidget.h"

#include "k3bisooptions.h"

#include <tqcheckbox.h>
#include <tqradiobutton.h>
#include <tqbuttongroup.h>
#include <tqheader.h>
#include <tqwhatsthis.h>
#include <tqpoint.h>
#include <tqpainter.h>
#include <tqpalette.h>
#include <tqvalidator.h>
#include <tqregexp.h>

#include <tdelistview.h>
#include <kcombobox.h>
#include <klocale.h>
#include <kdebug.h>


static const char * mkisofsCharacterSets[] = { "cp10081",
					       "cp10079",
					       "cp10029",
					       "cp10007",
					       "cp10006",
					       "cp10000",
					       "koi8-u",
					       "koi8-r",
					       "cp1251",
					       "cp1250",
					       "cp874",
					       "cp869",
					       "cp866",
					       "cp865",
					       "cp864",
					       "cp863",
					       "cp862",
					       "cp861",
					       "cp860",
					       "cp857",
					       "cp855",
					       "cp852",
					       "cp850",
					       "cp775",
					       "cp737",
					       "cp437",
					       "iso8859-15",
					       "iso8859-14",
					       "iso8859-9",
					       "iso8859-8",
					       "iso8859-7",
					       "iso8859-6",
					       "iso8859-5",
					       "iso8859-4",
					       "iso8859-3",
					       "iso8859-2",
					       "iso8859-1",
					       0 };  // terminating zero



class K3bDataAdvancedImageSettingsWidget::PrivateIsoWhatsThis : public TQWhatsThis
{
public:
  PrivateIsoWhatsThis( K3bDataAdvancedImageSettingsWidget* w ) 
    : TQWhatsThis( w->m_viewIsoSettings->viewport() ) {
    this->w = w;
  }

  TQString text( const TQPoint& p ) {
    TQListViewItem* i = w->m_viewIsoSettings->selectedItem(); // dies funktioniert nur bei rechtsklick
    TQListViewItem* i2 = w->m_viewIsoSettings->itemAt( p ); // dies funktioniert nur bei action whatsthis

    if( i2 != 0 )
      kdDebug() << "at p " << i2->text(0) << endl;

    if( i == w->m_checkAllowUntranslatedFilenames )
      return i18n( "Force all options below" );
    else if( i == w->m_radioIsoLevel1 || 
	     i == w->m_radioIsoLevel2 || 
	     i == w->m_radioIsoLevel3 ||
	     i == w->m_isoLevelController )
      return i18n( "<p>Set the ISO-9660 conformance level.\n"
		   "<ul>\n"
		   "<li>Level 1: Files may only consist of one section and filenames are restricted "
		   "to 8.3 characters.</li>\n"
		   "<li>Level 2: Files may only consist of one section.</li>\n"
		   "<li>Level 3: No restrictions.</li>\n"
		   "</ul>\n"
		   "<p>With all ISO-9660 levels, all filenames are restricted to upper case letters, "
		   "numbers and the underscore (_). The maximum filename length is 31 characters, the "
		   "directory nesting level is restricted to 8 and the maximum path length is limited "
		   "to 255 characters. (These restrictions may be violated with the additional ISO-9660 K3b offers)." );
    else
      return i18n("Set special ISO9660 Filesystem preferences.");
  }
  
private:
  K3bDataAdvancedImageSettingsWidget* w;
};



class K3bDataAdvancedImageSettingsWidget::PrivateCheckViewItem : public TQCheckListItem
{
public:
  PrivateCheckViewItem( TQListView* parent, const TQString& text, Type tt = Controller )
    : TQCheckListItem( parent, text, tt ) {
  }

  PrivateCheckViewItem( TQListViewItem* parent, const TQString& text, Type tt = Controller )
    : TQCheckListItem( parent, text, tt ) {
  }

protected:
  void stateChange( bool on ) {
    // enable or disable all children
    TQListViewItem* item = firstChild();
    while( item ) {
      if( PrivateCheckViewItem* pi = dynamic_cast<PrivateCheckViewItem*>(item) )
	pi->setEnabled( !on );
      item = item->nextSibling();
    }
  }
};


K3bDataAdvancedImageSettingsWidget::K3bDataAdvancedImageSettingsWidget( TQWidget* parent, const char* name )
  : base_K3bAdvancedDataImageSettings( parent, name )
{
  m_viewIsoSettings->header()->hide();
  m_viewIsoSettings->setSorting( -1 );

  // create WhatsThis for the isoSettings view
  (void)new PrivateIsoWhatsThis( this );

  // create all the view items
  TQCheckListItem* iso9660Root = new TQCheckListItem( m_viewIsoSettings, 
						    i18n("IS09660 Settings"),
						    TQCheckListItem::Controller );
  TQCheckListItem* rrRoot = new TQCheckListItem( m_viewIsoSettings, 
					       iso9660Root,
					       i18n("Rock Ridge Settings"),
					       TQCheckListItem::Controller );
  TQCheckListItem* jolietRoot = new TQCheckListItem( m_viewIsoSettings, 
						   rrRoot,
						   i18n("Joliet Settings"),
						   TQCheckListItem::Controller );
  TQCheckListItem* miscRoot = new TQCheckListItem( m_viewIsoSettings, 
						 jolietRoot,
						 i18n("Misc Settings"),
						 TQCheckListItem::Controller );

  // ISO9660 settings
  m_checkAllowUntranslatedFilenames = new PrivateCheckViewItem( iso9660Root, 
								i18n( "Allow untranslated ISO9660 filenames" ), 
								TQCheckListItem::CheckBox );
  m_checkAllowMaxLengthFilenames = new PrivateCheckViewItem( m_checkAllowUntranslatedFilenames, 
							     i18n( "Allow max length ISO9660 filenames (37 characters)" ),
							     TQCheckListItem::CheckBox );
  m_checkAllowFullAscii = new PrivateCheckViewItem( m_checkAllowUntranslatedFilenames, 
						    i18n( "Allow full ASCII charset for ISO9660 filenames" ),
						    TQCheckListItem::CheckBox );
  m_checkAllowOther = new PrivateCheckViewItem( m_checkAllowUntranslatedFilenames, 
						i18n( "Allow ~ and # in ISO9660 filenames" ),
						TQCheckListItem::CheckBox );
  m_checkAllowLowercaseCharacters = new PrivateCheckViewItem( m_checkAllowUntranslatedFilenames, 
							      i18n( "Allow lowercase characters in ISO9660 filenames" ),
							      TQCheckListItem::CheckBox );
  m_checkAllowMultiDot = new PrivateCheckViewItem( m_checkAllowUntranslatedFilenames, 
						   i18n( "Allow multiple dots in ISO9660 filenames" ),
						   TQCheckListItem::CheckBox );
  m_checkAllow31CharFilenames = new PrivateCheckViewItem( m_checkAllowUntranslatedFilenames, 
							  i18n( "Allow 31 character ISO9660 filenames" ),
							  TQCheckListItem::CheckBox );
  m_checkAllowBeginningPeriod = new PrivateCheckViewItem( m_checkAllowUntranslatedFilenames, 
							  i18n( "Allow leading period in ISO9660 filenames" ),
							  TQCheckListItem::CheckBox );
  m_checkOmitVersionNumbers = new PrivateCheckViewItem( m_checkAllowUntranslatedFilenames, 
							i18n( "Omit version numbers in ISO9660 filenames" ),
							TQCheckListItem::CheckBox );
  m_checkOmitTrailingPeriod = new PrivateCheckViewItem( m_checkAllowUntranslatedFilenames, 
							i18n( "Omit trailing period in ISO9660 filenames" ),
							TQCheckListItem::CheckBox );

  m_checkAllowUntranslatedFilenames->setOpen(true);
  m_isoLevelController = new TQCheckListItem( iso9660Root, 
					     m_checkAllowUntranslatedFilenames,
					     i18n("ISO Level") );

  m_radioIsoLevel3 = new TQCheckListItem( m_isoLevelController, 
					 i18n("Level %1").arg(3),
					 TQCheckListItem::RadioButton );
  m_radioIsoLevel2 = new TQCheckListItem( m_isoLevelController, 
					 i18n("Level %1").arg(2),
					 TQCheckListItem::RadioButton );
  m_radioIsoLevel1 = new TQCheckListItem( m_isoLevelController, 
					 i18n("Level %1").arg(1),
					 TQCheckListItem::RadioButton );

  m_isoLevelController->setOpen(true);

  // Joliet Settings
  m_checkJolietLong = new TQCheckListItem( jolietRoot,
					  i18n("Allow 103 character Joliet filenames"),
					  TQCheckListItem::CheckBox );

  // Rock Ridge Settings
  m_checkCreateTransTbl = new TQCheckListItem( rrRoot, 
					      i18n( "Create TRANS.TBL files" ),
					      TQCheckListItem::CheckBox );
  m_checkHideTransTbl = new TQCheckListItem( rrRoot, m_checkCreateTransTbl, 
					    i18n( "Hide TRANS.TBL files in Joliet" ),
					    TQCheckListItem::CheckBox );

  // Misc Settings
//   m_checkFollowSymbolicLinks = new TQCheckListItem( m_viewIsoSettings, 
// 						   i18n( "Follow symbolic links" ),
// 						   TQCheckListItem::CheckBox );

  m_checkDoNotCacheInodes = new TQCheckListItem( miscRoot,
						i18n("Do not cache inodes" ),
						TQCheckListItem::CheckBox );

  iso9660Root->setOpen( true );
  jolietRoot->setOpen( true );
  rrRoot->setOpen( true );
  miscRoot->setOpen( true );


  m_comboInputCharset->setValidator( new TQRegExpValidator( TQRegExp("[\\w_-]*"), TQT_TQOBJECT(this) ) );

  // fill charset combo
  for( int i = 0; mkisofsCharacterSets[i]; i++ ) {
    m_comboInputCharset->insertItem( TQString( mkisofsCharacterSets[i] ) );
  }

  connect( m_checkJoliet, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotJolietToggled(bool)) );
}


K3bDataAdvancedImageSettingsWidget::~K3bDataAdvancedImageSettingsWidget()
{
}


void K3bDataAdvancedImageSettingsWidget::load( const K3bIsoOptions& o )
{
  m_checkRockRidge->setChecked( o.createRockRidge() );
  m_checkJoliet->setChecked( o.createJoliet() );
  m_checkUdf->setChecked( o.createUdf() );

  switch( o.ISOLevel() ) {
  case 1:
    m_radioIsoLevel1->setOn(true);
    break;
  case 2:
    m_radioIsoLevel2->setOn(true);
    break;
  case 3:
    m_radioIsoLevel3->setOn(true);
    break;
  }

  m_checkForceInputCharset->setChecked( o.forceInputCharset() );
  m_comboInputCharset->setEditText( o.inputCharset() );
  m_checkPreservePermissions->setChecked( o.preserveFilePermissions() );

  // RR settings
  m_checkCreateTransTbl->setOn( o.createTRANS_TBL() );
  m_checkHideTransTbl->setOn( o.hideTRANS_TBL() );

  // iso9660 settings
  m_checkAllowUntranslatedFilenames->setOn( o.ISOuntranslatedFilenames() );
  m_checkAllow31CharFilenames->setOn( o.ISOallow31charFilenames() );
  m_checkAllowMaxLengthFilenames->setOn( o.ISOmaxFilenameLength() );
  m_checkAllowBeginningPeriod->setOn( o.ISOallowPeriodAtBegin() );
  m_checkAllowFullAscii->setOn( o.ISOrelaxedFilenames() );
  m_checkOmitVersionNumbers->setOn( o.ISOomitVersionNumbers() );
  m_checkOmitTrailingPeriod->setOn( o.ISOomitTrailingPeriod() );
  m_checkAllowOther->setOn( o.ISOnoIsoTranslate() );
  m_checkAllowMultiDot->setOn( o.ISOallowMultiDot() );
  m_checkAllowLowercaseCharacters->setOn( o.ISOallowLowercase() );

  // joliet settings
  m_checkJolietLong->setOn( o.jolietLong() );

  // misc (FIXME: should not be here)
  m_checkDoNotCacheInodes->setOn( o.doNotCacheInodes() );

  slotJolietToggled( m_checkJoliet->isChecked() );
}


void K3bDataAdvancedImageSettingsWidget::save( K3bIsoOptions& o )
{
  o.setCreateRockRidge( m_checkRockRidge->isChecked() );
  o.setCreateJoliet( m_checkJoliet->isChecked() );
  o.setCreateUdf( m_checkUdf->isChecked() );

  // save iso-level
  if( m_radioIsoLevel3->isOn() )
    o.setISOLevel( 3 );
  else if( m_radioIsoLevel2->isOn() )
    o.setISOLevel( 2 );
  else
    o.setISOLevel( 1 );
	
  o.setForceInputCharset( m_checkForceInputCharset->isChecked() );
  o.setInputCharset( m_comboInputCharset->currentText() );
  o.setPreserveFilePermissions( m_checkPreservePermissions->isChecked() );

  o.setCreateTRANS_TBL( m_checkCreateTransTbl->isOn() );
  o.setHideTRANS_TBL( m_checkHideTransTbl->isOn() );
  o.setISOuntranslatedFilenames( m_checkAllowUntranslatedFilenames->isOn() );
  o.setISOallow31charFilenames( m_checkAllow31CharFilenames->isOn() );
  o.setISOmaxFilenameLength( m_checkAllowMaxLengthFilenames->isOn() );
  o.setISOallowPeriodAtBegin( m_checkAllowBeginningPeriod->isOn() );
  o.setISOrelaxedFilenames( m_checkAllowFullAscii->isOn() );
  o.setISOomitVersionNumbers( m_checkOmitVersionNumbers->isOn() );
  o.setISOomitTrailingPeriod( m_checkOmitTrailingPeriod->isOn() );
  o.setISOnoIsoTranslate( m_checkAllowOther->isOn() );
  o.setISOallowMultiDot( m_checkAllowMultiDot->isOn() );
  o.setISOallowLowercase( m_checkAllowLowercaseCharacters->isOn() );
  //  o.setFollowSymbolicLinks( m_checkFollowSymbolicLinks->isOn() );
  o.setJolietLong( m_checkJolietLong->isOn() );
  o.setDoNotCacheInodes( m_checkDoNotCacheInodes->isOn() );
}


void K3bDataAdvancedImageSettingsWidget::slotJolietToggled( bool on )
{
  m_checkJolietLong->setEnabled( on );
}

#include "k3bdataadvancedimagesettingswidget.moc"