1
/***************************************************************************
2
* Copyright (C) 2009-2011 by Daniel Nicoletti *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program 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 *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; see the file COPYING. If not, write to *
17
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18
* Boston, MA 02110-1301, USA. *
19
***************************************************************************/
21
#include "PkInstallMimeTypes.h"
22
#include "IntroDialog.h"
23
#include "FilesModel.h"
25
#include <PkStrings.h>
31
PkInstallMimeTypes::PkInstallMimeTypes(uint xid,
32
const QStringList &mime_types,
33
const QString &interaction,
34
const QDBusMessage &message,
36
: SessionTask(xid, interaction, message, parent),
37
m_mimeTypes(mime_types)
39
setWindowTitle(i18n("Install Support for File Types"));
41
IntroDialog *introDialog = new IntroDialog(this);
42
m_model = new FilesModel(QStringList(), mime_types, this);
43
introDialog->setModel(m_model);
44
connect(introDialog, SIGNAL(continueChanged(bool)),
45
this, SLOT(enableButtonOk(bool)));
46
setMainWidget(introDialog);
49
if (m_model->rowCount()) {
50
description = i18np("Do you want to search for a program that can open this file type?",
51
"Do you want to search for a program that can open these file types?",
55
description = i18n("No valid file types were provided");
57
introDialog->setDescription(description);
60
// this will come from DBus interface
61
if (parentTitle.isNull()) {
62
title = i18np("A program is requiring support to open this kind of files",
63
"A program is requiring support to open these kinds of files",
66
title = i18np("The application %2 is requiring support to open this kind of files",
67
"The application %2 is requiring support to open these kinds of files",
74
PkInstallMimeTypes::~PkInstallMimeTypes()
78
void PkInstallMimeTypes::search()
80
QStringList mimeTypes = m_model->files();
81
PkTransaction *transaction = new PkTransaction(this);
82
setTransaction(Transaction::RoleWhatProvides, transaction);
83
connect(transaction, SIGNAL(finished(PkTransaction::ExitStatus)),
84
this, SLOT(searchFinished(PkTransaction::ExitStatus)), Qt::UniqueConnection);
85
connect(transaction, SIGNAL(package(PackageKit::Transaction::Info,QString,QString)),
86
this, SLOT(addPackage(PackageKit::Transaction::Info,QString,QString)));
87
transaction->whatProvides(Transaction::ProvidesMimetype,
89
Transaction::FilterNotInstalled | Transaction::FilterArch | Transaction::FilterNewest);
90
if (transaction->error()) {
92
setError(i18n("Failed to search for provides"),
93
PkStrings::daemonError(transaction->error()));
95
sendErrorFinished(Failed, "Failed to search for provides");
99
void PkInstallMimeTypes::notFound()
101
QString msg = i18n("Could not find software");
103
setInfo(msg, i18n("No new applications can be found "
104
"to handle this type of file"));
106
sendErrorFinished(NoPackagesFound, "nothing was found to handle mime type");
109
//setTitle(i18np("Application that can open this type of file",
110
// "Applications that can open this type of file",
111
// m_foundPackages.size()));
113
#include "PkInstallMimeTypes.moc"