KNewStuff
downloaddialog.cpp
Go to the documentation of this file.
00001 /* 00002 knewstuff3/ui/downloaddialog.cpp. 00003 Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> 00004 Copyright (C) 2005 - 2007 Josef Spillner <spillner@kde.org> 00005 Copyright (C) 2007 Dirk Mueller <mueller@kde.org> 00006 Copyright (C) 2007-2009 Jeremy Whiting <jpwhiting@kde.org> 00007 Copyright (C) 2009-2010 Frederik Gladhorn <gladhorn@kde.org> 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 00023 #include "downloaddialog.h" 00024 00025 #include <QtCore/QTimer> 00026 #include <QtGui/QSortFilterProxyModel> 00027 #include <QtGui/QScrollBar> 00028 #include <QtGui/QKeyEvent> 00029 00030 #include <kmessagebox.h> 00031 #include <kcomponentdata.h> 00032 #include <kaboutdata.h> 00033 #include <kpushbutton.h> 00034 #include <ktitlewidget.h> 00035 #include <kdebug.h> 00036 00037 #include "downloadwidget.h" 00038 #include "downloadwidget_p.h" 00039 00040 namespace KNS3 { 00041 class DownloadDialogPrivate 00042 { 00043 public: 00044 ~DownloadDialogPrivate() 00045 { 00046 delete downloadWidget; 00047 } 00048 00049 DownloadWidget* downloadWidget; 00050 }; 00051 } 00052 00053 using namespace KNS3; 00054 00055 const char * ConfigGroup = "DownloadDialog Settings"; 00056 00057 00058 DownloadDialog::DownloadDialog(QWidget* parent) 00059 : KDialog(parent) 00060 , d(new DownloadDialogPrivate) 00061 { 00062 KComponentData component = KGlobal::activeComponent(); 00063 QString name = component.componentName(); 00064 init(name + ".knsrc"); 00065 } 00066 00067 DownloadDialog::DownloadDialog(const QString& configFile, QWidget * parent) 00068 : KDialog(parent) 00069 , d(new DownloadDialogPrivate) 00070 { 00071 init(configFile); 00072 } 00073 00074 void DownloadDialog::init(const QString& configFile) 00075 { 00076 // load the last size from config 00077 KConfigGroup group(KGlobal::config(), ConfigGroup); 00078 restoreDialogSize(group); 00079 setMinimumSize(700, 400); 00080 00081 setCaption(i18n("Get Hot New Stuff")); 00082 setButtons(KDialog::None); 00083 00084 d->downloadWidget = new DownloadWidget(configFile ,this); 00085 setMainWidget(d->downloadWidget); 00086 00087 d->downloadWidget->d->ui.m_titleWidget->setText(i18nc("Program name followed by 'Add On Installer'", 00088 "%1 Add-On Installer", 00089 KGlobal::activeComponent().aboutData()->programName())); 00090 d->downloadWidget->d->ui.m_titleWidget->setPixmap(KIcon(KGlobal::activeComponent().aboutData()->programIconName())); 00091 d->downloadWidget->d->ui.m_titleWidget->setVisible(true); 00092 d->downloadWidget->d->ui.closeButton->setVisible(true); 00093 d->downloadWidget->d->ui.closeButton->setGuiItem(KStandardGuiItem::Close); 00094 d->downloadWidget->d->dialogMode = true; 00095 connect(d->downloadWidget->d->ui.closeButton, SIGNAL(clicked()), this, SLOT(accept())); 00096 } 00097 00098 DownloadDialog::~DownloadDialog() 00099 { 00100 KConfigGroup group(KGlobal::config(), ConfigGroup); 00101 saveDialogSize(group, KConfigBase::Persistent); 00102 delete d; 00103 } 00104 00105 Entry::List DownloadDialog::changedEntries() 00106 { 00107 return d->downloadWidget->changedEntries(); 00108 } 00109 00110 Entry::List DownloadDialog::installedEntries() 00111 { 00112 return d->downloadWidget->installedEntries(); 00113 } 00114 00115 00116 #include "downloaddialog.moc"
KDE 4.6 API Reference