summaryrefslogtreecommitdiffstats
path: root/src/projects/k3bdatamultisessioncombobox.cpp
blob: aa038eba80a009d0141db3353de0ef6681fed667 (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
/* 
 *
 * $Id: k3bdatamultisessioncombobox.cpp 619556 2007-01-03 17:38:12Z trueg $
 * Copyright (C) 2005 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 "k3bdatamultisessioncombobox.h"

#include <klocale.h>
#include <tdeconfig.h>

#include <tqwhatsthis.h>
#include <tqtooltip.h>


static const int s_autoIndex = 0;
static const int s_noneIndex = 1;
static const int s_startIndex = 2;
static const int s_continueIndex = 3;
static const int s_finishIndex = 4;


K3bDataMultiSessionCombobox::K3bDataMultiSessionCombobox( TQWidget* parent, const char* name )
  : TQComboBox( parent, name ),
    m_forceNoMultiSession(false)
{
  init( false );

  TQToolTip::add( this, i18n("Select the Multisession Mode for the project.") );
  TQWhatsThis::add( this, i18n("<p><b>Multisession Mode</b>"
			      "<p><b>Auto</b><br>"
			      "Let K3b decide which mode to use. The decision will be based "
			      "on the size of the project (does it fill the whole media) and "
			      "the state of the inserted media (appendable or not)."
			      "<p><b>No Multisession</b><br>"
			      "Create a single-session CD or DVD and close the disk."
			      "<p><b>Start Multisession</b><br>"
			      "Start a multisession CD or DVD, not closing the disk to "
			      "allow further sessions to be apppended."
			      "<p><b>Continue Multisession</b><br>"
			      "Continue an appendable data CD (as for example created in "
			      "<em>Start Multisession</em> mode) and add another session "
			      "without closing the disk to "
			      "allow further sessions to be apppended."
			      "<p><b>Finish Multisession</b><br>"
			      "Continue an appendable data CD (as for example created in "
			      "<em>Start Multisession</em> mode), add another session, "
			      "and close the disk."
			      "<p><em>In the case of DVD+RW and DVD-RW restricted overwrite media "
			      "K3b will not actually create multiple sessions but grow the "
			      "file system to include the new data.</em>") );
}


K3bDataMultiSessionCombobox::~K3bDataMultiSessionCombobox()
{
}


void K3bDataMultiSessionCombobox::init( bool force )
{
  m_forceNoMultiSession = force;

  clear();

  insertItem( i18n("Auto"), s_autoIndex );
  insertItem( i18n("No Multisession"), s_noneIndex );
  if( !m_forceNoMultiSession ) {
    insertItem( i18n("Start Multisession"), s_startIndex );
    insertItem( i18n("Continue Multisession "), s_continueIndex );
    insertItem( i18n("Finish Multisession "), s_finishIndex );
  }
}


K3bDataDoc::MultiSessionMode K3bDataMultiSessionCombobox::multiSessionMode() const
{
  switch( currentItem() ) {
  case s_noneIndex:
    return K3bDataDoc::NONE;
  case s_startIndex:
    return K3bDataDoc::START;
  case s_continueIndex:
    return K3bDataDoc::CONTINUE;
  case s_finishIndex:
    return K3bDataDoc::FINISH;
  default:
    return K3bDataDoc::AUTO;
  }
}


void K3bDataMultiSessionCombobox::saveConfig( TDEConfigBase* c )
{
  TQString s;
  switch( currentItem() ) {
  case s_autoIndex:
    s = "auto";
    break;
  case s_noneIndex:
    s = "none";
    break;
  case s_startIndex:
    s = "start";
    break;
  case s_continueIndex:
    s = "continue";
    break;
  case s_finishIndex:
    s = "finish";
    break;
  }

  c->writeEntry( "multisession mode", s );
}


void K3bDataMultiSessionCombobox::loadConfig( TDEConfigBase* c )
{
  TQString s = c->readEntry( "multisession mode" );
  if( s == "none" )
    setMultiSessionMode( K3bDataDoc::NONE );
  else if( s == "start" )
    setMultiSessionMode( K3bDataDoc::START );
  else if( s == "continue" )
    setMultiSessionMode( K3bDataDoc::CONTINUE );
  else if( s == "finish" )
    setMultiSessionMode( K3bDataDoc::FINISH );
  else
    setMultiSessionMode( K3bDataDoc::AUTO );
}


void K3bDataMultiSessionCombobox::setMultiSessionMode( K3bDataDoc::MultiSessionMode m )
{
  switch( m ) {
  case K3bDataDoc::AUTO:
    setCurrentItem( s_autoIndex );
    break;
  case K3bDataDoc::NONE:
    setCurrentItem( s_noneIndex );
    break;
  case K3bDataDoc::START:
    if( !m_forceNoMultiSession )
      setCurrentItem( s_startIndex );
    break;
  case K3bDataDoc::CONTINUE:
    if( !m_forceNoMultiSession )
      setCurrentItem( s_continueIndex );
    break;
  case K3bDataDoc::FINISH:
    if( !m_forceNoMultiSession )
      setCurrentItem( s_finishIndex );
    break;
  }
}


void K3bDataMultiSessionCombobox::setForceNoMultisession( bool f )
{
  if( f != m_forceNoMultiSession ) {
    K3bDataDoc::MultiSessionMode m = multiSessionMode();
    init( f );
    setMultiSessionMode( m );
  }
}

#include "k3bdatamultisessioncombobox.moc"