File: PackageDetails.h

package info (click to toggle)
apper 1.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,164 kB
  • sloc: cpp: 14,382; xml: 970; makefile: 13; sh: 4
file content (138 lines) | stat: -rw-r--r-- 4,444 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/***************************************************************************
 *   Copyright (C) 2009-2010 by Daniel Nicoletti                           *
 *   dantti12@gmail.com                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; see the file COPYING. If not, write to       *
 *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  *
 *   Boston, MA 02110-1301, USA.                                           *
 ***************************************************************************/

#ifndef PACKAGE_DETAILS_H
#define PACKAGE_DETAILS_H

#include <Transaction>
#include <Details>

#include <KPixmapSequenceOverlayPainter>
#include <KJob>

#include <QUrl>
#include <QWidget>
#include <QSortFilterProxyModel>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QActionGroup>

namespace Ui {
    class PackageDetails;
}

class PackageModel;
class PackageDetails : public QWidget
{
    Q_OBJECT
public:
    enum FadeWidget {
        FadeNone       = 0x0,
        FadeStacked    = 0x1,
        FadeScreenshot = 0x2
    };
    Q_DECLARE_FLAGS(FadeWidgets, FadeWidget)
    explicit PackageDetails(QWidget *parent = 0);
    ~PackageDetails();

    void init(PackageKit::Transaction::Roles roles);

    void setPackage(const QModelIndex &index);
    void hidePackageVersion(bool hide);
    void hidePackageArch(bool hide);

public Q_SLOTS:
    void hide();

Q_SIGNALS:
    void ensureVisible(const QModelIndex &index);

private Q_SLOTS:
    void on_screenshotL_clicked();
    void actionActivated(QAction *action);
    void description(const PackageKit::Details &details);
    void files(const QString &packageID, const QStringList &files);
    void finished();
    void resultJob(KJob *);

    void display();

private:
    void fadeOut(FadeWidgets widgets);
    void setupDescription();
    QVector<QPair<QString, QString> > locateApplication(const QString &_relPath, const QString &menuId) const;
    QUrl thumbnail(const QString &pkgName) const;
    QUrl screenshot(const QString &pkgName) const;

    Ui::PackageDetails *ui;
    QActionGroup *m_actionGroup;
    QModelIndex   m_index;
    QString m_packageID;
    PackageKit::Details m_details;
    QString m_detailsDescription;

    QAction *descriptionAction;
    QAction *dependsOnAction;
    QAction *requiredByAction;
    QAction *fileListAction;

    QString       m_appName;

    QParallelAnimationGroup       *m_expandPanel;
    KPixmapSequenceOverlayPainter *m_busySeq;

    QPropertyAnimation *m_fadeStacked;
    QPropertyAnimation *m_fadeScreenshot;
    bool m_display;
    bool m_hideVersion;
    bool m_hideArch;

    // We need a copy of prety much every thing
    // we have, so that we update only when we are
    // totaly transparent this way the user
    // does not see the ui flicker
    PackageKit::Transaction *m_transaction;
    bool         m_hasDetails;
    QString      m_currentText;
    QPixmap      m_currentIcon;
    QString      m_appId;

    // file list buffer
    bool         m_hasFileList;
    QStringList  m_currentFileList;

    // GetDepends buffer
    bool m_hasDepends;
    PackageModel *m_dependsModel;
    QSortFilterProxyModel *m_dependsProxy;

    // GetRequires buffer
    bool m_hasRequires;
    PackageModel *m_requiresModel;
    QSortFilterProxyModel *m_requiresProxy;

    // Screen shot buffer
    QUrl      m_currentScreenshot;
    QHash<QUrl, QString> m_screenshotPath;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(PackageDetails::FadeWidgets)

#endif