summaryrefslogtreecommitdiffstats
path: root/src/k3bprojectinterface.cpp
blob: 094e3865f199705982b1d75423e58c3af700fc1e (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
/* 
 *
 * $Id: k3bprojectinterface.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 "k3bprojectinterface.h"
#include "k3bburnprogressdialog.h"
#include <k3bdoc.h>
#include <k3bview.h>
#include <k3bmsf.h>
#include <k3bcore.h>
#include <k3bdevicemanager.h>
#include <k3bjob.h>

#include <tqtimer.h>


//static
TQCString K3bProjectInterface::newIfaceName()
{
  static int s_docIFNumber = 0;
  TQCString name;
  name.setNum( s_docIFNumber++ ); 
  name.prepend("K3bProject-");
  return name;
}


K3bProjectInterface::K3bProjectInterface( K3bDoc* doc, const char* name )
  : DCOPObject( name ? TQCString(name) : newIfaceName() ),
    m_doc( doc )
{
}


K3bProjectInterface::~K3bProjectInterface()
{
}

void K3bProjectInterface::addUrls( const TQStringList& urls )
{
  m_doc->addUrls( KURL::List(urls) );
}

void K3bProjectInterface::addUrl( const TQString& url )
{
  m_doc->addUrl( KURL(url) );
}

void K3bProjectInterface::burn()
{
  // we want to return this method immediately
  TQTimer::singleShot( 0, m_doc->view(), TQT_SLOT(slotBurn()) );
}


bool K3bProjectInterface::directBurn()
{
  if( m_doc->burner() ) {
    K3bJobProgressDialog* dlg = 0;
    if( m_doc->onlyCreateImages() )
      dlg = new K3bJobProgressDialog( m_doc->view() );
    else
      dlg = new K3bBurnProgressDialog( m_doc->view() );
    
    K3bJob* job = m_doc->newBurnJob( dlg );
    
    dlg->startJob( job );
    
    delete job;
    delete dlg;

    return true;
  }
  else
    return false;
}


void K3bProjectInterface::setBurnDevice( const TQString& name )
{
  if( K3bDevice::Device* dev = k3bcore->deviceManager()->findDevice( name ) )
    m_doc->setBurner( dev );
}


int K3bProjectInterface::length() const
{
  return m_doc->length().lba();
}


TDEIO::filesize_t K3bProjectInterface::size() const
{
  return m_doc->size();
}


const TQString& K3bProjectInterface::imagePath() const
{
  return m_doc->tempDir();
}


TQString K3bProjectInterface::projectType() const
{
  switch( m_doc->type() ) {
  case K3bDoc::AUDIO:
    return "audiocd";
  case K3bDoc::DATA:
    return "datacd";
  case K3bDoc::MIXED:
    return "mixedcd";
  case K3bDoc::VCD:
    return "videocd";
  case K3bDoc::MOVIX:
    return "emovixcd";
  case K3bDoc::MOVIX_DVD:
    return "emovixdvd";
  case K3bDoc::DVD:
    return "datadvd";
  case K3bDoc::VIDEODVD:
    return "videodvd";
  default:
    return "unknown";
  }
}