korganizer Library API Documentation

uploaddialog.cpp

00001 /*
00002     This file is part of KOrganizer.
00003     Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #include <qcombobox.h>
00022 #include <qlabel.h>
00023 #include <qlayout.h>
00024 #include <qlineedit.h>
00025 #include <qspinbox.h>
00026 #include <qstring.h>
00027 #include <ktextedit.h>
00028 
00029 #include <klistview.h>
00030 #include <klocale.h>
00031 #include <kdebug.h>
00032 #include <kurlrequester.h>
00033 #include <kmessagebox.h>
00034 
00035 #include "engine.h"
00036 #include "entry.h"
00037 
00038 #include "uploaddialog.h"
00039 #include "uploaddialog.moc"
00040 
00041 using namespace KNS;
00042 
00043 UploadDialog::UploadDialog( Engine *engine, QWidget *parent ) :
00044   KDialogBase( Plain, i18n("Share Hot New Stuff"), Ok | Cancel, Cancel,
00045                parent, 0, false, true ),
00046   mEngine( engine )
00047 {
00048   mEntryList.setAutoDelete( true );
00049 
00050   QFrame *topPage = plainPage();
00051 
00052   QGridLayout *topLayout = new QGridLayout( topPage );
00053   topLayout->setSpacing( spacingHint() );
00054 
00055   QLabel *nameLabel = new QLabel( i18n("Name:"), topPage );
00056   topLayout->addWidget( nameLabel, 0, 0 );
00057   mNameEdit = new QLineEdit( topPage );
00058   topLayout->addWidget( mNameEdit, 0, 1 );
00059   connect( mNameEdit, SIGNAL(textChanged ( const QString & ) ),SLOT( nameChanged( const QString & ) ) );
00060 
00061   QLabel *authorLabel = new QLabel( i18n("Author:"), topPage );
00062   topLayout->addWidget( authorLabel, 1, 0 );
00063   mAuthorEdit = new QLineEdit( topPage );
00064   topLayout->addWidget( mAuthorEdit, 1, 1 );
00065 
00066   QLabel *versionLabel = new QLabel( i18n("Version:"), topPage );
00067   topLayout->addWidget( versionLabel, 2, 0 );
00068   mVersionEdit = new QLineEdit( topPage );
00069   topLayout->addWidget( mVersionEdit, 2, 1 );
00070 
00071   QLabel *releaseLabel = new QLabel( i18n("Release:"), topPage );
00072   topLayout->addWidget( releaseLabel, 3, 0 );
00073   mReleaseSpin = new QSpinBox( topPage );
00074   mReleaseSpin->setMinValue( 1 );
00075   topLayout->addWidget( mReleaseSpin, 3, 1 );
00076 
00077   QLabel *licenceLabel = new QLabel( i18n("License:"), topPage );
00078   topLayout->addWidget( licenceLabel, 4, 0 );
00079   mLicenceCombo = new QComboBox( topPage );
00080   mLicenceCombo->setEditable( true );
00081   mLicenceCombo->insertItem( i18n("GPL") );
00082   mLicenceCombo->insertItem( i18n("LGPL") );
00083   mLicenceCombo->insertItem( i18n("BSD") );
00084   topLayout->addWidget( mLicenceCombo, 4, 1 );
00085 
00086   QLabel *languageLabel = new QLabel( i18n("Language:"), topPage );
00087   topLayout->addWidget( languageLabel, 5, 0 );
00088   mLanguageCombo = new QComboBox( topPage );
00089   topLayout->addWidget( mLanguageCombo, 5, 1 );
00090   mLanguageCombo->insertStringList( KGlobal::locale()->languagesTwoAlpha() );
00091 
00092   QLabel *previewLabel = new QLabel( i18n("Preview URL:"), topPage );
00093   topLayout->addWidget( previewLabel, 6, 0 );
00094   mPreviewUrl = new KURLRequester( topPage );
00095   topLayout->addWidget( mPreviewUrl, 6, 1 );
00096 
00097   QLabel *summaryLabel = new QLabel( i18n("Summary:"), topPage );
00098   topLayout->addMultiCellWidget( summaryLabel, 7, 7, 0, 1 );
00099   mSummaryEdit = new KTextEdit( topPage );
00100   topLayout->addMultiCellWidget( mSummaryEdit, 8, 8, 0, 1 );
00101 
00102   nameChanged( mNameEdit->text() );
00103 }
00104 
00105 UploadDialog::~UploadDialog()
00106 {
00107   mEntryList.clear();
00108 }
00109 
00110 void UploadDialog::nameChanged( const QString &_text )
00111 {
00112   enableButtonOK( !_text.isEmpty() );
00113 }
00114 
00115 void UploadDialog::slotOk()
00116 {
00117   if ( mNameEdit->text().isEmpty() ) {
00118     KMessageBox::error( this, i18n("Please put in a name.") );
00119     return;
00120   }
00121 
00122   Entry *entry = new Entry;
00123 
00124   mEntryList.append( entry );
00125 
00126   entry->setName( mNameEdit->text() );
00127   entry->setAuthor( mAuthorEdit->text() );
00128   entry->setVersion( mVersionEdit->text() );
00129   entry->setRelease( mReleaseSpin->value() );
00130   entry->setLicence( mLicenceCombo->currentText() );
00131   entry->setPreview( KURL( mPreviewUrl->url().section("/", -1) ), mLanguageCombo->currentText() );
00132   entry->setSummary( mSummaryEdit->text(), mLanguageCombo->currentText() );
00133 
00134   mEngine->upload( entry );
00135 
00136   accept();
00137 }
00138 
00139 void UploadDialog::setPreviewFile( const QString &previewFile )
00140 {
00141   mPreviewUrl->setURL( previewFile );
00142 }
00143 
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 17 09:56:26 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003