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 00060 QLabel *authorLabel = new QLabel( i18n("Author:"), topPage ); 00061 topLayout->addWidget( authorLabel, 1, 0 ); 00062 mAuthorEdit = new QLineEdit( topPage ); 00063 topLayout->addWidget( mAuthorEdit, 1, 1 ); 00064 00065 QLabel *versionLabel = new QLabel( i18n("Version:"), topPage ); 00066 topLayout->addWidget( versionLabel, 2, 0 ); 00067 mVersionEdit = new QLineEdit( topPage ); 00068 topLayout->addWidget( mVersionEdit, 2, 1 ); 00069 00070 QLabel *releaseLabel = new QLabel( i18n("Release:"), topPage ); 00071 topLayout->addWidget( releaseLabel, 3, 0 ); 00072 mReleaseSpin = new QSpinBox( topPage ); 00073 mReleaseSpin->setMinValue( 1 ); 00074 topLayout->addWidget( mReleaseSpin, 3, 1 ); 00075 00076 QLabel *licenceLabel = new QLabel( i18n("License:"), topPage ); 00077 topLayout->addWidget( licenceLabel, 4, 0 ); 00078 mLicenceCombo = new QComboBox( topPage ); 00079 mLicenceCombo->setEditable( true ); 00080 mLicenceCombo->insertItem( i18n("GPL") ); 00081 mLicenceCombo->insertItem( i18n("LGPL") ); 00082 mLicenceCombo->insertItem( i18n("BSD") ); 00083 topLayout->addWidget( mLicenceCombo, 4, 1 ); 00084 00085 QLabel *languageLabel = new QLabel( i18n("Language:"), topPage ); 00086 topLayout->addWidget( languageLabel, 5, 0 ); 00087 mLanguageCombo = new QComboBox( topPage ); 00088 topLayout->addWidget( mLanguageCombo, 5, 1 ); 00089 mLanguageCombo->insertStringList( KGlobal::locale()->languagesTwoAlpha() ); 00090 00091 QLabel *previewLabel = new QLabel( i18n("Preview URL:"), topPage ); 00092 topLayout->addWidget( previewLabel, 6, 0 ); 00093 mPreviewUrl = new KURLRequester( topPage ); 00094 topLayout->addWidget( mPreviewUrl, 6, 1 ); 00095 00096 QLabel *summaryLabel = new QLabel( i18n("Summary:"), topPage ); 00097 topLayout->addMultiCellWidget( summaryLabel, 7, 7, 0, 1 ); 00098 mSummaryEdit = new KTextEdit( topPage ); 00099 topLayout->addMultiCellWidget( mSummaryEdit, 8, 8, 0, 1 ); 00100 } 00101 00102 UploadDialog::~UploadDialog() 00103 { 00104 mEntryList.clear(); 00105 } 00106 00107 void UploadDialog::slotOk() 00108 { 00109 if ( mNameEdit->text().isEmpty() ) { 00110 KMessageBox::error( this, i18n("Please put in a name.") ); 00111 return; 00112 } 00113 00114 Entry *entry = new Entry; 00115 00116 mEntryList.append( entry ); 00117 00118 entry->setName( mNameEdit->text() ); 00119 entry->setAuthor( mAuthorEdit->text() ); 00120 entry->setVersion( mVersionEdit->text() ); 00121 entry->setRelease( mReleaseSpin->value() ); 00122 entry->setLicence( mLicenceCombo->currentText() ); 00123 entry->setPreview( KURL( mPreviewUrl->url() ), mLanguageCombo->currentText() ); 00124 entry->setSummary( mSummaryEdit->text(), mLanguageCombo->currentText() ); 00125 00126 mEngine->upload( entry ); 00127 00128 accept(); 00129 } 00130 00131 void UploadDialog::setPreviewFile( const QString &previewFile ) 00132 { 00133 mPreviewUrl->setURL( previewFile ); 00134 } 00135
KDE Logo
This file is part of the documentation for korganizer Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:14 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003