~artmello/gallery-app/gallery-app-fix_crash_adding_files

« back to all changes in this revision

Viewing changes to src/qml/qml-event-overview-model.cpp

  • Committer: Jim Nelson
  • Date: 2012-01-20 22:12:49 UTC
  • Revision ID: jim@yorba.org-20120120221249-81cc1q2jzdkej57k
Event and EventCollection introduced, represented in QML by
QmlEventCollectionModel.  This is work toward completing bug #915655,
the Event Timeline view.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * Jim Nelson <jim@yorba.org>
18
18
 */
19
19
 
20
 
#include "qml/qml-event-collection-model.h"
 
20
#include "qml/qml-event-overview-model.h"
21
21
 
22
22
#include "media/media-source.h"
23
23
#include "qml/qml-event-marker.h"
24
24
 
25
 
QmlEventCollectionModel::QmlEventCollectionModel(QObject* parent)
 
25
QmlEventOverviewModel::QmlEventOverviewModel(QObject* parent)
26
26
  : QmlMediaCollectionModel(parent), markers_("QmlEventMarkers") {
27
27
  // Use internal comparator to ensure EventMarkers are in the right place
28
28
  SetDefaultComparator(Comparator);
31
31
  MonitorNewViewCollection();
32
32
}
33
33
 
34
 
QmlEventCollectionModel::~QmlEventCollectionModel() {
 
34
QmlEventOverviewModel::~QmlEventOverviewModel() {
35
35
  markers_.DestroyAll(false, true);
36
36
}
37
37
 
38
 
void QmlEventCollectionModel::RegisterType() {
39
 
  qmlRegisterType<QmlEventCollectionModel>("Gallery", 1, 0, "EventCollectionModel");
 
38
void QmlEventOverviewModel::RegisterType() {
 
39
  qmlRegisterType<QmlEventOverviewModel>("Gallery", 1, 0, "EventOverviewModel");
40
40
}
41
41
 
42
 
QVariant QmlEventCollectionModel::VariantFor(DataObject* object) const {
 
42
QVariant QmlEventOverviewModel::VariantFor(DataObject* object) const {
43
43
  QmlEventMarker* marker = qobject_cast<QmlEventMarker*>(object);
44
44
  if (marker != NULL)
45
45
    return QVariant::fromValue(marker);
47
47
  return QmlMediaCollectionModel::VariantFor(object);
48
48
}
49
49
 
50
 
void QmlEventCollectionModel::notify_backing_collection_changed() {
 
50
void QmlEventOverviewModel::notify_backing_collection_changed() {
51
51
  MonitorNewViewCollection();
52
52
  
53
53
  QmlViewCollectionModel::notify_backing_collection_changed();
54
54
}
55
55
 
56
 
void QmlEventCollectionModel::MonitorNewViewCollection() {
 
56
void QmlEventOverviewModel::MonitorNewViewCollection() {
57
57
  if (BackingViewCollection() == NULL)
58
58
    return;
59
59
  
76
76
  on_contents_altered(&BackingViewCollection()->GetAsSet(), NULL);
77
77
}
78
78
 
79
 
void QmlEventCollectionModel::on_contents_altered(const QSet<DataObject*>* added,
 
79
void QmlEventOverviewModel::on_contents_altered(const QSet<DataObject*>* added,
80
80
  const QSet<DataObject*>* removed) {
81
81
  SelectableViewCollection* view = BackingViewCollection();
82
82
  
119
119
  }
120
120
}
121
121
 
122
 
void QmlEventCollectionModel::on_selection_altered(const QSet<DataObject*>* selected,
 
122
void QmlEventOverviewModel::on_selection_altered(const QSet<DataObject*>* selected,
123
123
  const QSet<DataObject*>* unselected) {
124
124
  // if an EventMarker is selected, select all photos in that date
125
125
  SelectUnselectEvent(selected, true);
128
128
  SelectUnselectEvent(unselected, false);
129
129
}
130
130
 
131
 
void QmlEventCollectionModel::SelectUnselectEvent(const QSet<DataObject*>* toggled,
 
131
void QmlEventOverviewModel::SelectUnselectEvent(const QSet<DataObject*>* toggled,
132
132
  bool doSelect) {
133
133
  if (toggled == NULL)
134
134
    return;
164
164
  }
165
165
}
166
166
 
167
 
bool QmlEventCollectionModel::Comparator(DataObject* a, DataObject* b) {
 
167
bool QmlEventOverviewModel::Comparator(DataObject* a, DataObject* b) {
168
168
  return ObjectDateTime(a) < ObjectDateTime(b);
169
169
}
170
170
 
171
 
QDateTime QmlEventCollectionModel::ObjectDateTime(DataObject* object) {
 
171
QDateTime QmlEventOverviewModel::ObjectDateTime(DataObject* object) {
172
172
  MediaSource* media = qobject_cast<MediaSource*>(object);
173
173
  if (media != NULL)
174
174
    return media->exposure_date_time();