From ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- keduca/keducabuilder/keducaeditorstartdialog.cpp | 114 +++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 keduca/keducabuilder/keducaeditorstartdialog.cpp (limited to 'keduca/keducabuilder/keducaeditorstartdialog.cpp') diff --git a/keduca/keducabuilder/keducaeditorstartdialog.cpp b/keduca/keducabuilder/keducaeditorstartdialog.cpp new file mode 100644 index 00000000..88cf9305 --- /dev/null +++ b/keduca/keducabuilder/keducaeditorstartdialog.cpp @@ -0,0 +1,114 @@ +/*************************************************************************** + keducaeditorstartdialog.cpp - description + ------------------- + begin : Fri May 10 2002 + copyright : (C) 2002 by Klas Kalass + email : klas@kde.org +***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "keducaeditorstartdialog.h" +#include "keducabuilder.h" + +/** + */ +KEducaEditorStartDialog::KEducaEditorStartDialog(KEducaBuilder * parent, const char* name, bool modal, WFlags fl) + :KEducaEditorStartDialogBase(parent, name, modal, fl), + _choice(NewDoc), + _maxRecentDocumentItems(20) +{ + newDocumentRB->setFocus(); + + // read recent files + buildRecentFilesList(); + +// setup connections + urlRequester->setFilter( "application/x-edu"); + + connect( startChoiceBtnGrp, SIGNAL( clicked(int) ), + this, SLOT( slotChoiceChanged(int) ) ); +} + +/** based on code in kaction.cpp + */ +void KEducaEditorStartDialog::buildRecentFilesList() +{ + QString key; + QString value; + QString oldGroup; + KConfig *config = KGlobal::config(); + + oldGroup = config->group(); + + config->setGroup( "RecentFiles" ); + + // read file list + for( unsigned int i = 1 ; i <= _maxRecentDocumentItems ; i++ ) + { + key = QString( "File%1" ).arg( i ); + value = config->readEntry( key, QString::null ); + + if (!value.isNull()) + recentDocumentCB->insertURL( KURL(value) ); + } + + config->setGroup( oldGroup ); +} + +KEducaEditorStartDialog::~KEducaEditorStartDialog() { + +} + +void KEducaEditorStartDialog::slotChoiceChanged(int id) { + _choice = id+1; +} + +KURL KEducaEditorStartDialog::getURL()const{ + switch(_choice) { + case OpenDoc: + return KURL(urlRequester->url()); + break; + case OpenRecentDoc: + return KURL(recentDocumentCB->currentText()); + break; + default: + break; + } + + return KURL(); +} + +int KEducaEditorStartDialog::exec() { + int ret = KEducaEditorStartDialogBase::exec(); + if ( ret == KEducaEditorStartDialogBase::Rejected ) + _choice = KEducaEditorStartDialog::Rejected; + + return _choice; +} + +void KEducaEditorStartDialog::accept() { + if (((_choice == OpenDoc || _choice == OpenRecentDoc) + && getURL().isEmpty())) { + KMessageBox::sorry(this, i18n("You need to specify the file to open!")); + }else + KEducaEditorStartDialogBase::accept(); +} + +#include "keducaeditorstartdialog.moc" -- cgit v1.2.1