summaryrefslogtreecommitdiffstats
path: root/src/gui/previewdialog.cpp
blob: 4c0d8e1618cc42e97d6d21b4553fdd66400c1c26 (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
/***************************************************************************
    copyright            : (C) 2006 by Robby Stephenson
    email                : [email protected]
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of version 2 of the GNU General Public License as  *
 *   published by the Free Software Foundation;                            *
 *                                                                         *
 ***************************************************************************/

#include "previewdialog.h"
#include "../entryview.h"
#include "../entry.h"
#include "../imagefactory.h" // for StyleOptions

#include <klocale.h>
#include <ktempdir.h>
#include <khtmlview.h>

using Tellico::GUI::PreviewDialog;

PreviewDialog::PreviewDialog(QWidget* parent_)
        : KDialogBase(parent_, "template preview dialog", false /* modal */,
                      i18n("Template Preview"), KDialogBase::Ok)
        , m_tempDir(new KTempDir()) {
  m_tempDir->setAutoDelete(true);
  connect(this, SIGNAL(finished()), SLOT(delayedDestruct()));

  m_view = new EntryView(this);
  setMainWidget(m_view->view());
  setInitialSize(QSize(600, 500));
}

PreviewDialog::~PreviewDialog() {
  delete m_tempDir;
  m_tempDir = 0;
}

void PreviewDialog::setXSLTFile(const QString& file_) {
  m_view->setXSLTFile(file_);
}

void PreviewDialog::setXSLTOptions(StyleOptions options_) {
  options_.imgDir = m_tempDir->name(); // images always get written to temp dir
  ImageFactory::createStyleImages(options_);
  m_view->setXSLTOptions(options_);
}

void PreviewDialog::showEntry(Data::EntryPtr entry_) {
  m_view->showEntry(entry_);
}

#include "previewdialog.moc"