~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to core/digikam/database/dbstatdlg.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer, Rohan Garg, Philip Muškovac, Felix Geyer
  • Date: 2011-09-23 18:18:55 UTC
  • mfrom: (1.2.36 upstream)
  • Revision ID: package-import@ubuntu.com-20110923181855-ifs67wxkugshev9k
Tags: 2:2.1.1-0ubuntu1
[ Rohan Garg ]
* New upstream release (LP: #834190)
  - debian/control
    + Build with libqtwebkit-dev
 - debian/kipi-plugins-common
    + Install libkvkontakte required by kipi-plugins
 - debian/digikam
    + Install panoramagui

[ Philip Muškovac ]
* New upstream release
  - debian/control:
    + Add libcv-dev, libcvaux-dev, libhighgui-dev, libboost-graph1.46-dev,
      libksane-dev, libxml2-dev, libxslt-dev, libqt4-opengl-dev, libqjson-dev,
      libgpod-dev and libqca2-dev to build-deps
    + Add packages for kipi-plugins, libmediawiki, libkface, libkgeomap and
      libkvkontakte
  - debian/rules:
    + Don't build with gphoto2 since it doesn't build with it.
  - Add kubuntu_fix_test_linking.diff to fix linking of the dngconverter test
  - update install files
  - update kubuntu_01_mysqld_executable_name.diff for new cmake layout
    and rename to kubuntu_mysqld_executable_name.diff
* Fix typo in digikam-data description (LP: #804894)
* Fix Vcs links

[ Felix Geyer ]
* Move library data files to the new packages libkface-data, libkgeomap-data
  and libkvkontakte-data.
* Override version of the embedded library packages to 1.0~digikam<version>.
* Exclude the library packages from digikam-dbg to prevent file conflicts in
  the future.
* Call dh_install with --list-missing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2009-05-28
 
7
 * Description : database statistics dialog
 
8
 *
 
9
 * Copyright (C) 2009-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 *
 
11
 * This program is free software; you can redistribute it
 
12
 * and/or modify it under the terms of the GNU General
 
13
 * Public License as published by the Free Software Foundation;
 
14
 * either version 2, or (at your option)
 
15
 * any later version.
 
16
 *
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
 * GNU General Public License for more details.
 
21
 *
 
22
 * ============================================================ */
 
23
 
 
24
#include "dbstatdlg.h"
 
25
 
 
26
// Qt includes
 
27
 
 
28
#include <QStringList>
 
29
#include <QString>
 
30
#include <QFont>
 
31
#include <QTreeWidget>
 
32
#include <QHeaderView>
 
33
 
 
34
// KDE includes
 
35
 
 
36
#include <klocale.h>
 
37
#include <kiconloader.h>
 
38
#include <kapplication.h>
 
39
#include <kstandarddirs.h>
 
40
#include <kaboutdata.h>
 
41
 
 
42
// Local includes
 
43
 
 
44
#include "daboutdata.h"
 
45
#include "albumdb.h"
 
46
#include "albumsettings.h"
 
47
#include "databaseaccess.h"
 
48
#include "config-digikam.h"
 
49
 
 
50
namespace Digikam
 
51
{
 
52
 
 
53
DBStatDlg::DBStatDlg(QWidget* parent)
 
54
    : InfoDlg(parent)
 
55
{
 
56
    kapp->setOverrideCursor(Qt::WaitCursor);
 
57
 
 
58
    setCaption(i18n("Database Statistics"));
 
59
    listView()->setHeaderLabels(QStringList() << i18n("Format") << i18n("Count"));
 
60
 
 
61
    // get image format statistics
 
62
    int totalImages = generateItemsList(DatabaseItem::Image, i18n("Images"));
 
63
    int totalVideos = generateItemsList(DatabaseItem::Video, i18n("Videos"));
 
64
    int totalAudio  = generateItemsList(DatabaseItem::Audio, i18n("Audio"));
 
65
    int total       = totalImages + totalVideos + totalAudio;
 
66
 
 
67
    // --------------------------------------------------------
 
68
 
 
69
    // To see total count of items at end of list.
 
70
    new QTreeWidgetItem(listView(), QStringList() << i18n("Total Items") << QString::number(total));
 
71
 
 
72
    // get album statistics
 
73
    int albums = DatabaseAccess().db()->scanAlbums().count();
 
74
    new QTreeWidgetItem(listView(), QStringList() << i18n("Albums") << QString::number(albums));
 
75
 
 
76
    // get tags statistics
 
77
    int tags = DatabaseAccess().db()->scanTags().count();
 
78
    new QTreeWidgetItem(listView(), QStringList() << i18n("Tags") << QString::number(tags));
 
79
 
 
80
    // Database Backend information
 
81
    QString dbBe = AlbumSettings::instance()->getDatabaseType();
 
82
    new QTreeWidgetItem(listView(), QStringList() << i18n("Database backend") << dbBe);
 
83
 
 
84
    if (dbBe != QString("QSQLITE"))
 
85
    {
 
86
        QString internal = AlbumSettings::instance()->getInternalDatabaseServer() ? i18n("Yes") : i18n("No");
 
87
        new QTreeWidgetItem(listView(), QStringList() << i18n("Database internal server") << internal);
 
88
    }
 
89
 
 
90
    kapp->restoreOverrideCursor();
 
91
}
 
92
 
 
93
DBStatDlg::~DBStatDlg()
 
94
{
 
95
}
 
96
 
 
97
int DBStatDlg::generateItemsList(DatabaseItem::Category category, const QString& title)
 
98
{
 
99
    // get image format statistics
 
100
    QMap<QString, int> stat = DatabaseAccess().db()->getFormatStatistics(category);
 
101
 
 
102
    // do not add items if the map is empty
 
103
    if (stat.isEmpty())
 
104
    {
 
105
        return 0;
 
106
    }
 
107
 
 
108
    int total = 0;
 
109
    QMap<QString, QString> map;
 
110
    for (QMap<QString, int>::const_iterator it = stat.constBegin(); it != stat.constEnd(); ++it)
 
111
    {
 
112
        total += it.value();
 
113
        map.insert(it.key(), QString::number(it.value()));
 
114
    }
 
115
 
 
116
    // --------------------------------------------------------
 
117
 
 
118
    QTreeWidgetItem* ti = new QTreeWidgetItem(listView(), QStringList() << title << QString());
 
119
    QFont ft = ti->font(0);
 
120
    ft.setBold(true);
 
121
    ti->setFont(0, ft);
 
122
    ti->setFont(1, ft);
 
123
 
 
124
    setInfoMap(map);
 
125
 
 
126
    ti = new QTreeWidgetItem(listView(), QStringList() << i18n("total") << QString::number(total));
 
127
    ti->setFont(0, ft);
 
128
    ti->setFont(1, ft);
 
129
 
 
130
    // Add space.
 
131
    new QTreeWidgetItem(listView(), QStringList());
 
132
    new QTreeWidgetItem(listView(), QStringList());
 
133
 
 
134
    return total;
 
135
}
 
136
 
 
137
}  // namespace Digikam