parley
kvtnewdocumentwizard.cpp
Go to the documentation of this file.00001 /*************************************************************************** 00002 00003 kvtnewdocumentwizard 00004 00005 ----------------------------------------------------------------------- 00006 00007 copyright : (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net> 00008 00009 ----------------------------------------------------------------------- 00010 00011 ***************************************************************************/ 00012 00013 /*************************************************************************** 00014 * * 00015 * This program is free software; you can redistribute it and/or modify * 00016 * it under the terms of the GNU General Public License as published by * 00017 * the Free Software Foundation; either version 2 of the License, or * 00018 * (at your option) any later version. * 00019 * * 00020 ***************************************************************************/ 00021 00022 #include "kvtnewdocumentwizard.h" 00023 00024 #include <QWizard> 00025 #include <QLabel> 00026 #include <QLineEdit> 00027 #include <QVBoxLayout> 00028 00029 #include <KLocale> 00030 #include <KComboBox> 00031 00032 00033 KVTNewDocumentWizard::KVTNewDocumentWizard(KEduVocDocument* doc, QWidget *parent) 00034 : QWizard(parent) 00035 { 00036 m_doc = doc; 00037 00038 resize(800,400); 00039 00040 setPage(Intro, new KVTNewDocumentWizardIntroPage); 00041 00042 setPage(AuthorTitle, new AuthorTitlePage(this)); 00043 00044 setPage(FirstIdentifierLanguage, new FirstIdentifierLanguagePage(this)); 00045 00046 setPage(SecondIdentifierLanguage, new SecondIdentifierLanguagePage(this)); 00047 00048 setStartId(Intro); 00049 00050 setWindowTitle(i18n("Create a New Parley Document")); 00051 } 00052 00053 00054 int KVTNewDocumentWizard::nextId() const 00055 { 00056 switch (currentId()) { 00057 case Intro: 00058 return AuthorTitle; 00059 case AuthorTitle: 00060 return FirstIdentifierLanguage; 00061 case FirstIdentifierLanguage: 00062 return SecondIdentifierLanguage; 00063 case SecondIdentifierLanguage: 00064 default: 00065 return -1; 00066 } 00067 } 00068 00069 00070 void KVTNewDocumentWizard::accept() 00071 { 00072 QString author = field("authorField").toString(); 00073 m_doc->setAuthor(author); 00074 m_doc->setTitle( field("titleField").toString() ); 00075 m_doc->setLicense( field("licenseField").toString() ); 00076 m_doc->setDocumentComment( field("commentField").toString() ); 00077 m_doc->setCategory( field("categoryField").toString() ); 00078 00079 m_doc->appendIdentifier(); 00080 m_doc->appendIdentifier(); 00081 m_doc->identifier(0).setName( field("firstIdentifierName").toString() ); 00082 m_doc->identifier(1).setName( field("secondIdentifierName").toString() ); 00083 00084 // ugly but works for now: iterate over languages to check which code we have 00085 foreach ( QString code, KGlobal::locale()->allLanguagesList() ) { 00086 if ( field("firstLocale").toString() == KGlobal::locale()->languageCodeToName(code) ) { 00087 m_doc->identifier(0).setLocale( code ); 00088 } 00089 if ( field("secondLocale").toString() == KGlobal::locale()->languageCodeToName(code) ) { 00090 m_doc->identifier(1).setLocale( code ); 00091 } 00092 } 00093 00094 QWizard::accept(); 00095 } 00096 00097 00098 #include "kvtnewdocumentwizard.moc"
KDE 4.0 API Reference