• 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
  • history
transferhistorycategorizeddelegate.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2 
3  Copyright (C) 2008 Javier Goday <jgoday@gmail.com>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 */
10 #include "transferhistorycategorizeddelegate.h"
11 
12 #include <kcategorizedsortfilterproxymodel.h>
13 
14 #include <QStandardItem>
15 #include <QVariant>
16 #include <QDate>
17 #include <QUrl>
18 
19 #include <KLocale>
20 
21 TransferHistoryCategorizedDelegate::TransferHistoryCategorizedDelegate()
22 {
23 }
24 
25 TransferHistoryCategorizedDelegate::~TransferHistoryCategorizedDelegate()
26 {
27 }
28 
29 DateCategorizedDelegate::DateCategorizedDelegate() : TransferHistoryCategorizedDelegate()
30 {
31 }
32 
33 DateCategorizedDelegate::~DateCategorizedDelegate()
34 {
35 }
36 
37 void DateCategorizedDelegate::categorizeItem(QStandardItem *item)
38 {
39  int categorySort = 0;
40 
41  QDate date = item->data(TransferHistoryCategorizedDelegate::RoleDate).toDate();
42  QVariant value;
43 
44  if (date == QDate::currentDate()) {
45  value = QVariant(i18n("Today"));
46  }
47  else if (date.daysTo(QDate::currentDate()) <= 7) {
48  categorySort = 1;
49  value = QVariant(i18n("Last week"));
50  }
51  else if (date.daysTo(QDate::currentDate()) <= 30) {
52  categorySort = 2;
53  value = QVariant(i18n("Last Month"));
54  }
55  else {
56  categorySort = 3;
57  value = QVariant(i18n("A long time ago"));
58  }
59 
60  item->setData(value, KCategorizedSortFilterProxyModel::CategoryDisplayRole);
61  item->setData(categorySort, KCategorizedSortFilterProxyModel::CategorySortRole);
62 }
63 
64 SizeCategorizedDelegate::SizeCategorizedDelegate() : TransferHistoryCategorizedDelegate()
65 {}
66 
67 SizeCategorizedDelegate::~SizeCategorizedDelegate()
68 {}
69 
70 void SizeCategorizedDelegate::categorizeItem(QStandardItem *item)
71 {
72  int size = item->data(TransferHistoryCategorizedDelegate::RoleSize).toInt();
73  int categorySort = 0;
74  QVariant value;
75 
76  if (size < 10 * 1024 * 1024) {
77  value = QVariant(i18n("Under 10MiB"));
78  }
79  else if (size >= 10 * 1024 * 1024 && size < 50 * 1024 * 1024) {
80  value = QVariant(i18n("Between 10MiB and 50MiB"));
81  categorySort = 1;
82  }
83  else if (size >= 50 * 1024 * 1024 && size < 100 * 1024 * 1024) {
84  value = QVariant(i18n("Between 50MiB and 100MiB"));
85  categorySort = 2;
86  }
87  else {
88  categorySort = 3;
89  value = QVariant(i18n("More than 100MiB"));
90  }
91 
92  item->setData(value, KCategorizedSortFilterProxyModel::CategoryDisplayRole);
93  item->setData(categorySort, KCategorizedSortFilterProxyModel::CategorySortRole);
94 }
95 
96 HostCategorizedDelegate::HostCategorizedDelegate() : TransferHistoryCategorizedDelegate()
97 {
98 }
99 
100 HostCategorizedDelegate::~HostCategorizedDelegate()
101 {
102 }
103 
104 void HostCategorizedDelegate::categorizeItem(QStandardItem *item)
105 {
106  QUrl host(item->data(TransferHistoryCategorizedDelegate::RoleUrl).toString());
107 
108  item->setData(host.host(), KCategorizedSortFilterProxyModel::CategoryDisplayRole);
109  item->setData(host.host(), KCategorizedSortFilterProxyModel::CategorySortRole);
110 }
SizeCategorizedDelegate::SizeCategorizedDelegate
SizeCategorizedDelegate()
Definition: transferhistorycategorizeddelegate.cpp:64
DateCategorizedDelegate::~DateCategorizedDelegate
~DateCategorizedDelegate()
Definition: transferhistorycategorizeddelegate.cpp:33
DateCategorizedDelegate::DateCategorizedDelegate
DateCategorizedDelegate()
Definition: transferhistorycategorizeddelegate.cpp:29
SizeCategorizedDelegate::categorizeItem
void categorizeItem(QStandardItem *item)
Definition: transferhistorycategorizeddelegate.cpp:70
HostCategorizedDelegate::HostCategorizedDelegate
HostCategorizedDelegate()
Definition: transferhistorycategorizeddelegate.cpp:96
TransferHistoryCategorizedDelegate::RoleDate
Definition: transferhistorycategorizeddelegate.h:24
TransferHistoryCategorizedDelegate
Definition: transferhistorycategorizeddelegate.h:18
SizeCategorizedDelegate::~SizeCategorizedDelegate
~SizeCategorizedDelegate()
Definition: transferhistorycategorizeddelegate.cpp:67
TransferHistoryCategorizedDelegate::TransferHistoryCategorizedDelegate
TransferHistoryCategorizedDelegate()
Definition: transferhistorycategorizeddelegate.cpp:21
TransferHistoryCategorizedDelegate::~TransferHistoryCategorizedDelegate
~TransferHistoryCategorizedDelegate()
Definition: transferhistorycategorizeddelegate.cpp:25
HostCategorizedDelegate::~HostCategorizedDelegate
~HostCategorizedDelegate()
Definition: transferhistorycategorizeddelegate.cpp:100
TransferHistoryCategorizedDelegate::RoleSize
Definition: transferhistorycategorizeddelegate.h:23
TransferHistoryCategorizedDelegate::RoleUrl
Definition: transferhistorycategorizeddelegate.h:25
transferhistorycategorizeddelegate.h
DateCategorizedDelegate::categorizeItem
void categorizeItem(QStandardItem *item)
Definition: transferhistorycategorizeddelegate.cpp:37
HostCategorizedDelegate::categorizeItem
void categorizeItem(QStandardItem *item)
Definition: transferhistorycategorizeddelegate.cpp:104
QStandardItem
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