00001 #include "importwizarddialog.h" 00002 #include <qwidget.h> 00003 #include <qhbox.h> 00004 #include <qvbox.h> 00005 #include <qlabel.h> 00006 #include <qlineedit.h> 00007 #include <qpushbutton.h> 00008 #include <qvalidator.h> 00009 #include <qapplication.h> 00010 #include <qradiobutton.h> 00011 #include <qtextedit.h> 00012 #include <qtable.h> 00013 #include "importjstor.h" 00014 #include "importbibtex.h" 00015 #include "importz3950.h" 00016 #include "importfront.h" 00017 00018 ImportWizardDialog::ImportWizardDialog( QWidget *parent, const char *name ) 00019 : QWizard( parent, name, true ) 00020 { 00021 addFrontPage(); 00022 addFinalPage(); 00023 } 00024 00025 void ImportWizardDialog::addFrontPage() 00026 { 00027 frontdlg=new ImportFront(this); 00028 addPage(frontdlg, "Choose Format" ); 00029 00030 setNextEnabled(frontdlg, true); 00031 setHelpEnabled(frontdlg, false); 00032 setFinishEnabled(frontdlg, false); 00033 setBackEnabled(frontdlg, false); 00034 } 00035 00036 void ImportWizardDialog::addCustomPage() 00037 { 00038 customdlg=import->customDlg(); 00039 insertPage(customdlg, "Setup Import", pageCount()-1); 00040 00041 setNextEnabled(customdlg, true); 00042 setHelpEnabled(customdlg, false); 00043 setFinishEnabled(customdlg, false); 00044 setBackEnabled(customdlg, false); 00045 } 00046 00047 00048 void ImportWizardDialog::addPageSet(bool back) 00049 { 00050 ImportPubl *p=new ImportPubl(this); 00051 insertPage(p, "Edit Author and Publication Data", pageCount()-1); 00052 setNextEnabled(p, true); 00053 setHelpEnabled(p, false); 00054 setFinishEnabled(p, false); 00055 setBackEnabled(p, back); 00056 } 00057 00058 void ImportWizardDialog::addFinalPage() 00059 { 00060 finaldlg=new QWidget(this); 00061 addPage(finaldlg, "Import Finished" ); 00062 00063 setNextEnabled(finaldlg, false); 00064 setHelpEnabled(finaldlg, false); 00065 setFinishEnabled(finaldlg, true); 00066 setBackEnabled(finaldlg, true); 00067 } 00068 00069 void ImportWizardDialog::showPage( QWidget* page ) 00070 { 00071 ImportPubl *p=dynamic_cast<ImportPubl*>(page); 00072 int pos=indexOf(page)-2; 00073 if (page == frontdlg) { 00074 } else if (p) { 00075 setTitle(page, title(page)+" - publication "+QString().setNum(pos+1)+" of "+QString().setNum(import->count())); 00076 ASSERT(import); 00077 p->title->setText(import->property("title", pos)); 00078 p->subtitle->setText(import->property("subtitle", pos)); 00079 p->year->setText(import->property("year", pos)); 00080 p->editor->setText(import->property("editor", pos)); 00081 p->type->setText(import->property("type", pos)); 00082 p->howpublished->setText(import->property("howpublished", pos)); 00083 p->series->setText(import->property("series", pos)); 00084 p->volume->setText(import->property("volume", pos)); 00085 p->number->setText(import->property("number", pos)); 00086 p->month->setText(import->property("month", pos)); 00087 p->edition->setText(import->property("edition", pos)); 00088 p->organization->setText(import->property("organization", pos)); 00089 p->school->setText(import->property("school", pos)); 00090 p->translator->setText(import->property("translator", pos)); 00091 p->orgyear->setText(import->property("orgyear", pos)); 00092 p->orgtitle->setText(import->property("orgtitle", pos)); 00093 p->isbnissn->setText(import->property("isbnissn", pos)); 00094 p->hidingplace->setText(import->property("hidingplace", pos)); 00095 p->pages->setText(import->property("pages", pos)); 00096 p->memo->setText(import->property("memo", pos)); 00097 00098 int i=0; 00099 do { 00100 QString lastname=import->property("lastname"+QString().setNum(i), pos); 00101 if(lastname.isEmpty()) break; 00102 QString firstname=import->property("firstname"+QString().setNum(i), pos); 00103 00104 p->authors->setNumRows(i+1); 00105 p->authors->setText(i, 0, firstname); 00106 p->authors->setText(i, 1, lastname); 00107 i++; 00108 } while(1); 00109 00110 00111 } else if (page == finaldlg) { 00112 } 00113 QWizard::showPage(page); 00114 } 00115 00116 00117 void ImportWizardDialog::setupImport() { 00118 if(frontdlg->bibtex->isChecked()) { 00119 import=new ImportBibTex(this); 00120 } else if(frontdlg->jstor->isChecked()) { 00121 import=new ImportJStor(this); 00122 } else if(frontdlg->z3950->isChecked()) { 00123 import=new ImportZ3950(this); 00124 } 00125 ASSERT(import); 00126 } 00127 00128 void ImportWizardDialog::save() { 00129 } 00130 00131 void ImportWizardDialog::next() { 00132 if(currentPage()==frontdlg) { 00133 setupImport(); 00134 addCustomPage(); 00135 } 00136 00137 if(currentPage()==customdlg) { 00138 import->process(); 00139 int i; 00140 for(i=0; i<import->count(); i++) 00141 addPageSet((i!=0)); 00142 } 00143 00144 ImportPubl *p=dynamic_cast<ImportPubl*>(currentPage()); 00145 if(p) { 00146 save(); 00147 } 00148 QWizard::next(); 00149 }