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
|
/***************************************************************************
* Copyright (C) 2003-2004 by David Saxton *
* [email protected] *
* *
* 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. *
***************************************************************************/
#include "docmanager.h"
#include "filemetainfo.h"
#include "textdocument.h"
#include "outputmethodwidget.h"
#include "outputmethoddlg.h"
#include "microlibrary.h"
#include "microselectwidget.h"
#include "projectmanager.h"
#include <kcombobox.h>
#include <kconfigskeleton.h>
#include <kdebug.h>
#include <ktempfile.h>
#include <kurlrequester.h>
#include <qcheckbox.h>
#include <qfile.h>
#include <qradiobutton.h>
//BEGIN class OutputMethodInfo
OutputMethodInfo::OutputMethodInfo()
{
m_method = Method::Direct;
m_bAddToProject = false;
}
void OutputMethodInfo::initialize( OutputMethodDlg * dlg )
{
if ( dlg->m_widget->displayDirectCheck->isChecked() )
{
m_method = Method::Direct;
KTempFile f( QString::null, dlg->m_outputExtension );
f.close();
m_outputFile = f.name();
m_bAddToProject = false;
}
else
{
if ( dlg->m_widget->loadFileCheck->isChecked() )
m_method = Method::SaveAndLoad;
else
m_method = Method::SaveAndForget;
m_outputFile = dlg->m_widget->outputFileURL->url();
m_bAddToProject = dlg->m_widget->addToProjectCheck->isChecked();
}
m_picID = dlg->m_widget->m_pMicroSelect->micro();
}
//END class OutputMethodInfo
//BEGIN class OutputMethodDlg
OutputMethodDlg::OutputMethodDlg( const QString &caption, const KURL & inputURL, bool showPICSelect, QWidget *parent, const char *name )
: KDialogBase( parent, name, true, caption, Ok|Cancel )
{
m_inputURL = inputURL;
m_bAccepted = false;
m_widget = new OutputMethodWidget(this);
m_widget->addToProjectCheck->setEnabled( ProjectManager::self()->currentProject() );
if (!showPICSelect)
{
m_widget->m_pMicroSelect->hide();
m_widget->adjustSize();
}
fileMetaInfo()->initializeFromMetaInfo( m_inputURL, this );
setMainWidget(m_widget);
}
OutputMethodDlg::~OutputMethodDlg()
{
}
void OutputMethodDlg::setOutputExtension( const QString & extension )
{
m_outputExtension = extension;
}
void OutputMethodDlg::setFilter( const QString &filter )
{
m_widget->outputFileURL->setFilter(filter);
}
void OutputMethodDlg::setMethod( OutputMethodInfo::Method::Type m )
{
switch (m)
{
case OutputMethodInfo::Method::Direct:
m_widget->displayDirectCheck->setChecked(true);
break;
case OutputMethodInfo::Method::SaveAndForget:
m_widget->saveFileCheck->setChecked(true);
m_widget->loadFileCheck->setChecked(false);
break;
case OutputMethodInfo::Method::SaveAndLoad:
m_widget->saveFileCheck->setChecked(true);
m_widget->loadFileCheck->setChecked(true);
break;
};
}
void OutputMethodDlg::setPicID( const QString & id )
{
m_widget->m_pMicroSelect->setMicro(id);
}
void OutputMethodDlg::setOutputFile( const KURL & out )
{
m_widget->outputFileURL->setURL(out.prettyURL());
}
void OutputMethodDlg::accept()
{
m_bAccepted = true;
m_outputMethodInfo.initialize(this);
fileMetaInfo()->grabMetaInfo( m_inputURL, this );
hide();
}
void OutputMethodDlg::reject()
{
m_bAccepted = false;
}
MicroSelectWidget * OutputMethodDlg::microSelect() const
{
return m_widget->m_pMicroSelect;
}
//END class OutputMethodDlg
#include "outputmethoddlg.moc"
|