outputmethoddlg.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2003-2004 by David Saxton                               *
00003  *   david@bluehaze.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
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 //BEGIN class OutputMethodInfo
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 //END class OutputMethodInfo
00065 
00066 
00067 
00068 //BEGIN class OutputMethodDlg
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 //END class OutputMethodDlg
00160 
00161 
00162 #include "outputmethoddlg.moc"

Generated on Tue May 8 17:05:31 2007 for KTechLab by  doxygen 1.5.1