• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdenewstuff
 

tdenewstuff

  • tdenewstuff
uploaddialog.cpp
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include <tqcombobox.h>
22#include <tqlabel.h>
23#include <tqlayout.h>
24#include <tqlineedit.h>
25#include <tqspinbox.h>
26#include <tqstring.h>
27#include <ktextedit.h>
28
29#include <tdelistview.h>
30#include <tdelocale.h>
31#include <kdebug.h>
32#include <kurlrequester.h>
33#include <tdemessagebox.h>
34#include <tdeconfig.h>
35#include <tdeapplication.h>
36#include <kuser.h>
37
38#include "engine.h"
39#include "entry.h"
40
41#include "uploaddialog.h"
42#include "uploaddialog.moc"
43
44using namespace KNS;
45
46UploadDialog::UploadDialog( Engine *engine, TQWidget *parent ) :
47 KDialogBase( Plain, i18n("Share Hot New Stuff"), Ok | Cancel, Cancel,
48 parent, 0, false, true ),
49 mEngine( engine )
50{
51 mEntryList.setAutoDelete( true );
52
53 TQFrame *topPage = plainPage();
54
55 TQGridLayout *topLayout = new TQGridLayout( topPage );
56 topLayout->setSpacing( spacingHint() );
57
58 TQLabel *nameLabel = new TQLabel( i18n("Name:"), topPage );
59 topLayout->addWidget( nameLabel, 0, 0 );
60 mNameEdit = new TQLineEdit( topPage );
61 topLayout->addWidget( mNameEdit, 0, 1 );
62
63 TQLabel *authorLabel = new TQLabel( i18n("Author:"), topPage );
64 topLayout->addWidget( authorLabel, 1, 0 );
65 mAuthorEdit = new TQLineEdit( topPage );
66 topLayout->addWidget( mAuthorEdit, 1, 1 );
67
68 TQLabel *emailLabel = new TQLabel( i18n("Email:"), topPage );
69 topLayout->addWidget( emailLabel, 2, 0 );
70 mEmailEdit = new TQLineEdit( topPage );
71 topLayout->addWidget( mEmailEdit, 2, 1 );
72
73 TQLabel *versionLabel = new TQLabel( i18n("Version:"), topPage );
74 topLayout->addWidget( versionLabel, 3, 0 );
75 mVersionEdit = new TQLineEdit( topPage );
76 topLayout->addWidget( mVersionEdit, 3, 1 );
77
78 TQLabel *releaseLabel = new TQLabel( i18n("Release:"), topPage );
79 topLayout->addWidget( releaseLabel, 4, 0 );
80 mReleaseSpin = new TQSpinBox( topPage );
81 mReleaseSpin->setMinValue( 1 );
82 topLayout->addWidget( mReleaseSpin, 4, 1 );
83
84 TQLabel *licenceLabel = new TQLabel( i18n("License:"), topPage );
85 topLayout->addWidget( licenceLabel, 5, 0 );
86 mLicenceCombo = new TQComboBox( topPage );
87 mLicenceCombo->setEditable( true );
88 mLicenceCombo->insertItem( i18n("GPL") );
89 mLicenceCombo->insertItem( i18n("LGPL") );
90 mLicenceCombo->insertItem( i18n("BSD") );
91 topLayout->addWidget( mLicenceCombo, 5, 1 );
92
93 TQLabel *languageLabel = new TQLabel( i18n("Language:"), topPage );
94 topLayout->addWidget( languageLabel, 6, 0 );
95 mLanguageCombo = new TQComboBox( topPage );
96 topLayout->addWidget( mLanguageCombo, 6, 1 );
97 mLanguageCombo->insertStringList( TDEGlobal::locale()->languageList() );
98
99 TQLabel *previewLabel = new TQLabel( i18n("Preview URL:"), topPage );
100 topLayout->addWidget( previewLabel, 7, 0 );
101 mPreviewUrl = new KURLRequester( topPage );
102 topLayout->addWidget( mPreviewUrl, 7, 1 );
103
104 TQLabel *summaryLabel = new TQLabel( i18n("Summary:"), topPage );
105 topLayout->addMultiCellWidget( summaryLabel, 8, 8, 0, 1 );
106 mSummaryEdit = new KTextEdit( topPage );
107 topLayout->addMultiCellWidget( mSummaryEdit, 9, 9, 0, 1 );
108
109 KUser user;
110 mAuthorEdit->setText(user.fullName());
111}
112
113UploadDialog::~UploadDialog()
114{
115 mEntryList.clear();
116}
117
118void UploadDialog::slotOk()
119{
120 if ( mNameEdit->text().isEmpty() ) {
121 KMessageBox::error( this, i18n("Please put in a name.") );
122 return;
123 }
124
125 Entry *entry = new Entry;
126
127 mEntryList.append( entry );
128
129 entry->setName( mNameEdit->text() );
130 entry->setAuthor( mAuthorEdit->text() );
131 entry->setAuthorEmail( mEmailEdit->text() );
132 entry->setVersion( mVersionEdit->text() );
133 entry->setRelease( mReleaseSpin->value() );
134 entry->setLicence( mLicenceCombo->currentText() );
135 entry->setPreview( KURL( mPreviewUrl->url().section("/", -1) ), mLanguageCombo->currentText() );
136 entry->setSummary( mSummaryEdit->text(), mLanguageCombo->currentText() );
137
138 if ( mPayloadUrl.isValid() ) {
139 TDEConfig *conf = tdeApp->config();
140 conf->setGroup( TQString("TDENewStuffUpload:%1").arg(mPayloadUrl.fileName()) );
141 conf->writeEntry("name", mNameEdit->text());
142 conf->writeEntry("author", mAuthorEdit->text());
143 conf->writeEntry("email", mEmailEdit->text());
144 conf->writeEntry("version", mVersionEdit->text());
145 conf->writeEntry("release", mReleaseSpin->value());
146 conf->writeEntry("licence", mLicenceCombo->currentText());
147 conf->writeEntry("preview", mPreviewUrl->url());
148 conf->writeEntry("summary", mSummaryEdit->text());
149 conf->writeEntry("language", mLanguageCombo->currentText());
150 conf->sync();
151 }
152
153 mEngine->upload( entry );
154
155 accept();
156}
157
158void UploadDialog::setPreviewFile( const TQString &previewFile )
159{
160 mPreviewUrl->setURL( previewFile );
161}
162
163void UploadDialog::setPayloadFile( const TQString &payloadFile )
164{
165 mPayloadUrl = payloadFile;
166
167 TDEConfig *conf = tdeApp->config();
168 conf->setGroup( TQString("TDENewStuffUpload:%1").arg(mPayloadUrl.fileName()) );
169 TQString name = conf->readEntry("name");
170 TQString author = conf->readEntry("author");
171 TQString email = conf->readEntry("email");
172 TQString version = conf->readEntry("version");
173 TQString release = conf->readEntry("release");
174 TQString preview = conf->readEntry("preview");
175 TQString summary = conf->readEntry("summary");
176 TQString lang = conf->readEntry("language");
177 TQString licence = conf->readEntry("licence");
178
179 mNameEdit->clear();
180 mAuthorEdit->clear();
181 mEmailEdit->clear();
182 mVersionEdit->clear();
183 mReleaseSpin->setValue(1);
184 mPreviewUrl->clear();
185 mSummaryEdit->clear();
186 mLanguageCombo->setCurrentItem(0);
187 mLicenceCombo->setCurrentItem(0);
188
189 if(!name.isNull())
190 {
191 int prefill = KMessageBox::questionYesNo(this, i18n("Old upload information found, fill out fields?"),TQString::null,i18n("Fill Out"),i18n("Do Not Fill Out"));
192 if(prefill == KMessageBox::Yes)
193 {
194 mNameEdit->setText(name);
195 mAuthorEdit->setText(author);
196 mEmailEdit->setText(email);
197 mVersionEdit->setText(version);
198 mReleaseSpin->setValue(release.toInt());
199 mPreviewUrl->setURL(preview);
200 mSummaryEdit->setText(summary);
201 if(!lang.isEmpty()) mLanguageCombo->setCurrentText(lang);
202 if(!licence.isEmpty()) mLicenceCombo->setCurrentText(licence);
203 }
204 }
205}
206
KNS::Engine
Central class combining all possible TDENewStuff operations.
Definition: engine.h:53
KNS::Engine::upload
void upload(const TQString &fileName=TQString::null, const TQString &previewName=TQString::null)
Initiates the upload process, invoking the provider selection dialog and the file upload dialog.
Definition: engine.cpp:245
KNS::Entry
TDENewStuff data entry container.
Definition: entry.h:46
KNS::Entry::setSummary
void setSummary(const TQString &, const TQString &lang=TQString::null)
Sets a short description on what the object is all about.
Definition: entry.cpp:166
KNS::Entry::setLicence
void setLicence(const TQString &)
Sets the license (abbreviation) applicable to the object.
Definition: entry.cpp:155
KNS::Entry::setName
void setName(const TQString &)
Sets the (unique) name for this data object.
Definition: entry.cpp:122
KNS::Entry::setAuthorEmail
void setAuthorEmail(const TQString &)
Sets the email address of the object's author.
Definition: entry.cpp:65
KNS::Entry::setRelease
void setRelease(int)
Sets the release number, which is increased for feature-equal objects with the same version number,...
Definition: entry.cpp:199
KNS::Entry::setVersion
void setVersion(const TQString &)
Sets the version number.
Definition: entry.cpp:188
KNS::Entry::setPreview
void setPreview(const KURL &, const TQString &lang=TQString::null)
Sets the object's preview file, if available.
Definition: entry.cpp:244
KNS::Entry::setAuthor
void setAuthor(const TQString &)
Sets the full name of the object's author.
Definition: entry.cpp:144
KNS::UploadDialog::~UploadDialog
~UploadDialog()
Destructor.
Definition: uploaddialog.cpp:113
KNS::UploadDialog::setPayloadFile
void setPayloadFile(const TQString &payloadFile)
Sets the payload filename.
Definition: uploaddialog.cpp:163
KNS::UploadDialog::setPreviewFile
void setPreviewFile(const TQString &previewFile)
Sets the preview filename.
Definition: uploaddialog.cpp:158
KNS
Handles security releated issues, like signing, verifying.
Definition: downloaddialog.h:37

tdenewstuff

Skip menu "tdenewstuff"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdenewstuff

Skip menu "tdenewstuff"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdenewstuff by doxygen 1.9.4
This website is maintained by Timothy Pearson.