summaryrefslogtreecommitdiffstats
path: root/src/projects/k3bmixedview.cpp
blob: 8d1b9398b430ec895165689a4ee40ebd573b950f (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
/* 
 *
 * $Id: k3bmixedview.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 "k3bmixedview.h"

#include "k3bmixeddoc.h"
#include "k3bmixedburndialog.h"
#include "k3bmixeddirtreeview.h"
#include "k3baudiotrackaddingdialog.h"
#include "k3bdataurladdingdialog.h"

#include <k3baudiotrackplayer.h>
#include <k3baudiodoc.h>
#include <k3bdataviewitem.h>
#include <k3bdatafileview.h>
#include <k3bdatadoc.h>
#include <k3baudiotrackview.h>
#include <k3bfillstatusdisplay.h>
#include <k3btoolbox.h>
#include <k3bprojectplugin.h>

#include <tqwidgetstack.h>
#include <tqsplitter.h>
#include <tqlayout.h>
#include <tqvaluelist.h>

#include <kdialog.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kdebug.h>
#include <kmessagebox.h>
#include <kactionclasses.h>


K3bMixedView::K3bMixedView( K3bMixedDoc* doc, TQWidget* parent, const char* name )
  : K3bView( doc, parent, name ), m_doc(doc)
{
  TQSplitter* splitter = new TQSplitter( this );
  m_mixedDirTreeView = new K3bMixedDirTreeView( this, doc, splitter );
  m_widgetStack = new TQWidgetStack( splitter );
  m_dataFileView = new K3bDataFileView( this, m_mixedDirTreeView, doc->dataDoc(), m_widgetStack );
  m_mixedDirTreeView->setFileView( m_dataFileView );
  m_audioListView = new K3bAudioTrackView( doc->audioDoc(), m_widgetStack );

  setMainWidget( splitter );

  connect( m_mixedDirTreeView, TQT_SIGNAL(audioTreeSelected()), 
	   this, TQT_SLOT(slotAudioTreeSelected()) );
  connect( m_mixedDirTreeView, TQT_SIGNAL(dataTreeSelected()), 
	   this, TQT_SLOT(slotDataTreeSelected()) );

  m_widgetStack->raiseWidget( m_dataFileView );

  toolBox()->addButton( m_audioListView->player()->action( K3bAudioTrackPlayer::ACTION_PLAY ) );
  toolBox()->addButton( m_audioListView->player()->action( K3bAudioTrackPlayer::ACTION_PAUSE ) );
  toolBox()->addButton( m_audioListView->player()->action( K3bAudioTrackPlayer::ACTION_STOP ) );
  toolBox()->addSpacing();
  toolBox()->addButton( m_audioListView->player()->action( K3bAudioTrackPlayer::ACTION_PREV ) );
  toolBox()->addButton( m_audioListView->player()->action( K3bAudioTrackPlayer::ACTION_NEXT ) );
  toolBox()->addSpacing();
  toolBox()->addWidgetAction( static_cast<KWidgetAction*>(m_audioListView->player()->action( K3bAudioTrackPlayer::ACTION_SEEK )) );
  toolBox()->addSeparator();

#ifdef HAVE_MUSICBRAINZ
  toolBox()->addButton( m_audioListView->actionCollection()->action( "project_audio_musicbrainz" ) );
  toolBox()->addSeparator();
#endif

  addPluginButtons( K3bProjectPlugin::MIXED_CD );

  toolBox()->addStretch();

  m_mixedDirTreeView->checkForNewItems();
  m_dataFileView->checkForNewItems();
}


K3bMixedView::~K3bMixedView()
{
}


K3bAudioTrackPlayer* K3bMixedView::player() const
{
  return m_audioListView->player();
}


void K3bMixedView::slotAudioTreeSelected()
{
  m_widgetStack->raiseWidget( m_audioListView );
}


void K3bMixedView::slotDataTreeSelected()
{
  m_widgetStack->raiseWidget( m_dataFileView );
}


K3bDirItem* K3bMixedView::currentDir() const
{
  if( m_widgetStack->visibleWidget() == m_dataFileView )
    return m_dataFileView->currentDir();
  else
    return 0;
}


void K3bMixedView::slotBurn()
{
  if( m_doc->audioDoc()->numOfTracks() == 0 || m_doc->dataDoc()->size() == 0 ) {
    KMessageBox::information( this, i18n("Please add files and audio titles to your project first."),
			      i18n("No Data to Burn"), TQString(), false );
  }
  else {
    K3bProjectBurnDialog* dlg = newBurnDialog( this );
    if( dlg ) {
      dlg->execBurnDialog(true);
      delete dlg;
    }
    else {
      kdDebug() << "(K3bDoc) Error: no burndialog available." << endl;
    }
  }
}


K3bProjectBurnDialog* K3bMixedView::newBurnDialog( TQWidget* parent, const char* name )
{
  return new K3bMixedBurnDialog( m_doc, parent, name, true );
}


void K3bMixedView::addUrls( const KURL::List& urls )
{
  if( m_widgetStack->visibleWidget() == m_dataFileView )
    K3bDataUrlAddingDialog::addUrls( urls, currentDir() );
  else
    K3bAudioTrackAddingDialog::addUrls( urls, m_doc->audioDoc(), 0, 0, 0, this );
}

#include "k3bmixedview.moc"