• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

keduca

keducaeditorstartdialog.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           keducaeditorstartdialog.cpp  -  description
00003                              -------------------
00004     begin                : Fri May 10 2002
00005     copyright            : (C) 2002 by Klas Kalass
00006     email                : klas@kde.org
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 #include <qradiobutton.h>
00018 #include <qbuttongroup.h>
00019 
00020 #include <kdebug.h>
00021 #include <kurlrequester.h>
00022 #include <kmessagebox.h>
00023 #include <klocale.h>
00024 #include <kconfig.h>
00025 #include <kcombobox.h>
00026 
00027 #include "keducaeditorstartdialog.h"
00028 #include "keducabuilder.h"
00029 
00032 KEducaEditorStartDialog::KEducaEditorStartDialog(KEducaBuilder * parent, const char* name, bool modal, WFlags fl)
00033     :KEducaEditorStartDialogBase(parent,  name,  modal, fl),
00034      _choice(NewDoc),
00035      _maxRecentDocumentItems(20)
00036 {
00037     newDocumentRB->setFocus();
00038 
00039     // read recent files
00040     buildRecentFilesList();
00041 
00042 // setup connections
00043     urlRequester->setFilter( "application/x-edu");
00044 
00045     connect( startChoiceBtnGrp,  SIGNAL( clicked(int) ),
00046              this, SLOT( slotChoiceChanged(int) ) );
00047 }
00048 
00051 void KEducaEditorStartDialog::buildRecentFilesList()
00052 {
00053     QString     key;
00054     QString     value;
00055     QString     oldGroup;
00056     KConfig *config = KGlobal::config();
00057 
00058     oldGroup = config->group();
00059 
00060     config->setGroup( "RecentFiles" );
00061 
00062     // read file list
00063     for( unsigned int i = 1 ; i <= _maxRecentDocumentItems ; i++ )
00064     {
00065         key = QString( "File%1" ).arg( i );
00066         value = config->readEntry( key, QString::null );
00067 
00068         if (!value.isNull())
00069             recentDocumentCB->insertURL( KURL(value) );
00070     }
00071 
00072     config->setGroup( oldGroup );
00073 }
00074 
00075 KEducaEditorStartDialog::~KEducaEditorStartDialog() {
00076 
00077 }
00078 
00079 void KEducaEditorStartDialog::slotChoiceChanged(int id) {
00080     _choice = id+1;
00081 }
00082 
00083 KURL KEducaEditorStartDialog::getURL()const{
00084     switch(_choice) {
00085     case OpenDoc:
00086         return KURL(urlRequester->url());
00087         break;
00088     case OpenRecentDoc:
00089         return KURL(recentDocumentCB->currentText());
00090         break;
00091     default:
00092         break;
00093     }
00094 
00095     return KURL();
00096 }
00097 
00098 int KEducaEditorStartDialog::exec() {
00099     int ret = KEducaEditorStartDialogBase::exec();
00100     if ( ret == KEducaEditorStartDialogBase::Rejected )
00101         _choice = KEducaEditorStartDialog::Rejected;
00102 
00103     return _choice;
00104 }
00105 
00106 void KEducaEditorStartDialog::accept() {
00107     if (((_choice == OpenDoc || _choice == OpenRecentDoc)
00108           && getURL().isEmpty())) {
00109         KMessageBox::sorry(this, i18n("You need to specify the file to open!"));
00110     }else
00111         KEducaEditorStartDialogBase::accept();
00112 }
00113 
00114 #include "keducaeditorstartdialog.moc"

keduca

Skip menu "keduca"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal