00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "docmanager.h"
00012 #include "filemetainfo.h"
00013 #include "textdocument.h"
00014 #include "outputmethodwidget.h"
00015 #include "outputmethoddlg.h"
00016 #include "microlibrary.h"
00017 #include "microselectwidget.h"
00018 #include "projectmanager.h"
00019
00020 #include <kcombobox.h>
00021 #include <kconfigskeleton.h>
00022 #include <kdebug.h>
00023 #include <ktempfile.h>
00024 #include <kurlrequester.h>
00025
00026 #include <qcheckbox.h>
00027 #include <qfile.h>
00028 #include <qradiobutton.h>
00029
00030
00031
00032 OutputMethodInfo::OutputMethodInfo()
00033 {
00034 m_method = Method::Direct;
00035 m_bAddToProject = false;
00036 }
00037
00038
00039 void OutputMethodInfo::initialize( OutputMethodDlg * dlg )
00040 {
00041 if ( dlg->m_widget->displayDirectCheck->isChecked() )
00042 {
00043 m_method = Method::Direct;
00044 KTempFile f( QString::null, dlg->m_outputExtension );
00045 f.close();
00046 m_outputFile = f.name();
00047 m_bAddToProject = false;
00048 }
00049
00050 else
00051 {
00052 if ( dlg->m_widget->loadFileCheck->isChecked() )
00053 m_method = Method::SaveAndLoad;
00054
00055 else
00056 m_method = Method::SaveAndForget;
00057
00058 m_outputFile = dlg->m_widget->outputFileURL->url();
00059 m_bAddToProject = dlg->m_widget->addToProjectCheck->isChecked();
00060 }
00061
00062 m_picID = dlg->m_widget->m_pMicroSelect->micro();
00063 }
00064
00065
00066
00067
00068
00069 OutputMethodDlg::OutputMethodDlg( const QString &caption, const KURL & inputURL, bool showPICSelect, QWidget *parent, const char *name )
00070 : KDialogBase( parent, name, true, caption, Ok|Cancel )
00071 {
00072 m_inputURL = inputURL;
00073 m_bAccepted = false;
00074 m_widget = new OutputMethodWidget(this);
00075
00076 m_widget->addToProjectCheck->setEnabled( ProjectManager::self()->currentProject() );
00077
00078 if (!showPICSelect)
00079 {
00080 m_widget->m_pMicroSelect->hide();
00081 m_widget->adjustSize();
00082 }
00083
00084 fileMetaInfo()->initializeFromMetaInfo( m_inputURL, this );
00085
00086 setMainWidget(m_widget);
00087 }
00088
00089
00090 OutputMethodDlg::~OutputMethodDlg()
00091 {
00092 }
00093
00094
00095 void OutputMethodDlg::setOutputExtension( const QString & extension )
00096 {
00097 m_outputExtension = extension;
00098 }
00099
00100
00101 void OutputMethodDlg::setFilter( const QString &filter )
00102 {
00103 m_widget->outputFileURL->setFilter(filter);
00104 }
00105
00106
00107 void OutputMethodDlg::setMethod( OutputMethodInfo::Method::Type m )
00108 {
00109 switch (m)
00110 {
00111 case OutputMethodInfo::Method::Direct:
00112 m_widget->displayDirectCheck->setChecked(true);
00113 break;
00114
00115 case OutputMethodInfo::Method::SaveAndForget:
00116 m_widget->saveFileCheck->setChecked(true);
00117 m_widget->loadFileCheck->setChecked(false);
00118 break;
00119
00120 case OutputMethodInfo::Method::SaveAndLoad:
00121 m_widget->saveFileCheck->setChecked(true);
00122 m_widget->loadFileCheck->setChecked(true);
00123 break;
00124 };
00125 }
00126
00127
00128 void OutputMethodDlg::setPicID( const QString & id )
00129 {
00130 m_widget->m_pMicroSelect->setMicro(id);
00131 }
00132
00133
00134 void OutputMethodDlg::setOutputFile( const KURL & out )
00135 {
00136 m_widget->outputFileURL->setURL(out.prettyURL());
00137 }
00138
00139
00140 void OutputMethodDlg::accept()
00141 {
00142 m_bAccepted = true;
00143 m_outputMethodInfo.initialize(this);
00144 fileMetaInfo()->grabMetaInfo( m_inputURL, this );
00145 hide();
00146 }
00147
00148
00149 void OutputMethodDlg::reject()
00150 {
00151 m_bAccepted = false;
00152 }
00153
00154
00155 MicroSelectWidget * OutputMethodDlg::microSelect() const
00156 {
00157 return m_widget->m_pMicroSelect;
00158 }
00159
00160
00161
00162 #include "outputmethoddlg.moc"