• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kget

  • sources
  • kde-4.12
  • kdenetwork
  • kget
  • ui
  • metalinkcreator
dragdlg.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 * Copyright (C) 2009 Matthias Fuchs <mat69@gmx.net> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18 ***************************************************************************/
19 
20 #include "dragdlg.h"
21 #include "metalinker.h"
22 #include "urlwidget.h"
23 
24 #include "core/verifier.h"
25 
26 #include <QtGui/QCheckBox>
27 #include <QtGui/QSortFilterProxyModel>
28 
29 DragDlg::DragDlg(KGetMetalink::Resources *resources, KGetMetalink::CommonData *commonData, QSortFilterProxyModel *countrySort, QSortFilterProxyModel *languageSort, QWidget *parent)
30  : KGetSaveSizeDialog("DragDlg", parent),
31  m_resources(resources),
32  m_commonData(commonData)
33 {
34  QWidget *widget = new QWidget(this);
35  ui.setupUi(widget);
36  setMainWidget(widget);
37 
38  m_urlWidget = new UrlWidget(this);
39  m_urlWidget->init(m_resources, countrySort);
40  ui.urlLayout->addWidget(m_urlWidget->widget());
41 
42  QWidget *data = new QWidget(this);
43  uiData.setupUi(data);
44  ui.dataLayout->addWidget(data);
45 
46  QVBoxLayout *layout = new QVBoxLayout;
47  QStringList verifierTypes = Verifier::supportedVerficationTypes();
48  verifierTypes.sort();
49 
50  //NOTE only supports the types that are supported by the Metalink 4.0 specification -- "Hash Function Textual Names"
51  foreach (const QString &type, verifierTypes) {
52  if (type.contains("sha", Qt::CaseInsensitive) || type.contains("md5", Qt::CaseInsensitive)) {
53  QCheckBox *checkBox = new QCheckBox(type, this);
54  layout->addWidget(checkBox);
55  m_checkBoxes.append(checkBox);
56  }
57  }
58 
59  ui.groupBox->setLayout(layout);
60 
61  //create the language selection
62  uiData.language->setModel(languageSort);
63  uiData.language->setCurrentIndex(-1);
64 
65  connect(this, SIGNAL(accepted()), this, SLOT(slotFinished()));
66 
67  setCaption(i18n("Import dropped files"));
68 }
69 
70 void DragDlg::slotFinished()
71 {
72  m_urlWidget->save();
73 
74  QStringList used;
75  foreach (QCheckBox *checkbox, m_checkBoxes)
76  {
77  if (checkbox->isChecked())
78  {
79  used.append(checkbox->text().remove('&'));
80  }
81  }
82 
83  m_commonData->identity = uiData.identity->text();
84  m_commonData->version = uiData.version->text();
85  m_commonData->description = uiData.description->text();
86  m_commonData->logo = KUrl(uiData.logo->text());
87  if (uiData.os->text().isEmpty()) {
88  m_commonData->oses.clear();
89  } else {
90  m_commonData->oses = uiData.os->text().split(i18nc("comma, to seperate members of a list", ","));
91  }
92  m_commonData->copyright = uiData.copyright->text();
93  m_commonData->publisher.name = uiData.pub_name->text();
94  m_commonData->publisher.url = KUrl(uiData.pub_url->text());
95  m_commonData->languages << uiData.language->itemData(uiData.language->currentIndex()).toString();
96 
97  emit usedTypes(used, ui.partialChecksums->isChecked());
98 }
99 
100 #include "dragdlg.moc"
KGetMetalink::CommonData::publisher
UrlText publisher
Definition: metalinker.h:116
DragDlg::usedTypes
void usedTypes(const QStringList &types, bool createPartial)
The types the user want to be checked and if partial checksums should be created. ...
KGetMetalink::CommonData::languages
QStringList languages
Definition: metalinker.h:115
KGetMetalink::CommonData::logo
KUrl logo
Definition: metalinker.h:114
UrlWidget
Definition: urlwidget.h:36
UrlWidget::widget
QWidget * widget()
Definition: urlwidget.cpp:61
QWidget
Verifier::supportedVerficationTypes
static QStringList supportedVerficationTypes()
Returns the supported verification types.
Definition: verifier.cpp:216
KGetMetalink::CommonData::identity
QString identity
Definition: metalinker.h:110
KGetMetalink::UrlText::url
KUrl url
Definition: metalinker.h:86
metalinker.h
verifier.h
KGetMetalink::CommonData
Files, File and Metadata contain this Metadata not as member and only for compatibility.
Definition: metalinker.h:93
KGetSaveSizeDialog
Subclass to make sure that the size of the dialog is automatically stored and restored.
Definition: basedialog.h:32
QSortFilterProxyModel
urlwidget.h
UrlWidget::save
void save()
Definition: urlwidget.cpp:111
KGetMetalink::CommonData::copyright
QString copyright
Definition: metalinker.h:117
KGetMetalink::CommonData::oses
QStringList oses
Definition: metalinker.h:113
KGetMetalink::CommonData::version
QString version
Definition: metalinker.h:111
UrlWidget::init
void init(KGetMetalink::Resources *resources, QSortFilterProxyModel *countrySort)
Definition: urlwidget.cpp:66
DragDlg::DragDlg
DragDlg(KGetMetalink::Resources *resources, KGetMetalink::CommonData *commonData, QSortFilterProxyModel *countrySort, QSortFilterProxyModel *languageSort, QWidget *parent=0)
Definition: dragdlg.cpp:29
KGetMetalink::Resources
Definition: metalinker.h:190
KGetMetalink::CommonData::description
QString description
Definition: metalinker.h:112
KGetMetalink::UrlText::name
QString name
Definition: metalinker.h:85
dragdlg.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal