summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorCatalin Badea <catalin.badea392@gmail.com>2012-08-02 17:08:05 (GMT)
committerCătălin Badea <catalin.badea392@gmail.com>2012-08-11 15:59:13 (GMT)
commit716f6262dd8dce6aae8822355a863433d09dcc97 (patch)
tree013eaebb2ede1f4e8bb12fec0dce2200ffd2402c /Swift
parent2316553cb5a191e0e8b098bb5b39fba0d9e37b13 (diff)
downloadswift-contrib-716f6262dd8dce6aae8822355a863433d09dcc97.zip
swift-contrib-716f6262dd8dce6aae8822355a863433d09dcc97.tar.bz2
Enable calendar widget.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/HistoryViewController.cpp43
-rw-r--r--Swift/Controllers/HistoryViewController.h1
-rw-r--r--Swift/Controllers/UIInterfaces/HistoryWindow.h1
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp6
4 files changed, 51 insertions, 0 deletions
diff --git a/Swift/Controllers/HistoryViewController.cpp b/Swift/Controllers/HistoryViewController.cpp
index 819ba4e..43575d5 100644
--- a/Swift/Controllers/HistoryViewController.cpp
+++ b/Swift/Controllers/HistoryViewController.cpp
@@ -47,6 +47,7 @@ HistoryViewController::~HistoryViewController() {
historyWindow_->onScrollReachedBottom.disconnect(boost::bind(&HistoryViewController::handleScrollReachedBottom, this, _1));
historyWindow_->onPreviousButtonClicked.disconnect(boost::bind(&HistoryViewController::handlePreviousButtonClicked, this));
historyWindow_->onNextButtonClicked.disconnect(boost::bind(&HistoryViewController::handleNextButtonClicked, this));
+ historyWindow_->onCalendarClicked.disconnect(boost::bind(&HistoryViewController::handleCalendarClicked, this, _1));
historyController_->onNewMessage.disconnect(boost::bind(&HistoryViewController::handleNewMessage, this, _1));
delete historyWindow_;
}
@@ -64,6 +65,7 @@ void HistoryViewController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) {
historyWindow_->onScrollReachedBottom.connect(boost::bind(&HistoryViewController::handleScrollReachedBottom, this, _1));
historyWindow_->onPreviousButtonClicked.connect(boost::bind(&HistoryViewController::handlePreviousButtonClicked, this));
historyWindow_->onNextButtonClicked.connect(boost::bind(&HistoryViewController::handleNextButtonClicked, this));
+ historyWindow_->onCalendarClicked.connect(boost::bind(&HistoryViewController::handleCalendarClicked, this, _1));
historyController_->onNewMessage.connect(boost::bind(&HistoryViewController::handleNewMessage, this, _1));
historyWindow_->setRosterModel(roster_);
@@ -236,4 +238,45 @@ void HistoryViewController::reset() {
historyWindow_->resetConversationView();
}
+void HistoryViewController::handleCalendarClicked(const boost::gregorian::date& date) {
+ if (!selectedItem_) {
+ return;
+ }
+
+ boost::gregorian::date newDate;
+ if (contacts_[selectedItemType_][selectedItem_->getJID()].count(date)) {
+ newDate = date;
+ }
+ else if (date < currentResultDate_) {
+ foreach(const boost::gregorian::date& current, contacts_[selectedItemType_][selectedItem_->getJID()]) {
+ if (current > date) {
+ newDate = current;
+ break;
+ }
+ }
+ }
+ else {
+ reverse_foreach(const boost::gregorian::date& current, contacts_[selectedItemType_][selectedItem_->getJID()]) {
+ if (current < date) {
+ newDate = current;
+ break;
+ }
+ }
+ }
+
+ historyWindow_->setDate(newDate);
+ if (newDate == currentResultDate_) {
+ return;
+ }
+ currentResultDate_ = newDate;
+ historyWindow_->resetConversationView();
+
+ std::vector<HistoryMessage> messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_);
+ historyWindow_->setDate(currentResultDate_);
+
+ foreach (const HistoryMessage& message, messages) {
+ addNewMessage(message, false);
+ }
+}
+
}
diff --git a/Swift/Controllers/HistoryViewController.h b/Swift/Controllers/HistoryViewController.h
index e78b5be..2302355 100644
--- a/Swift/Controllers/HistoryViewController.h
+++ b/Swift/Controllers/HistoryViewController.h
@@ -40,6 +40,7 @@ namespace Swift {
void handleScrollReachedBottom(const boost::gregorian::date& date);
void handlePreviousButtonClicked();
void handleNextButtonClicked();
+ void handleCalendarClicked(const boost::gregorian::date& date);
void addNewMessage(const HistoryMessage& message, bool addAtTheTop);
void reset();
diff --git a/Swift/Controllers/UIInterfaces/HistoryWindow.h b/Swift/Controllers/UIInterfaces/HistoryWindow.h
index 7b21184..ffb0ad5 100644
--- a/Swift/Controllers/UIInterfaces/HistoryWindow.h
+++ b/Swift/Controllers/UIInterfaces/HistoryWindow.h
@@ -29,5 +29,6 @@ namespace Swift {
boost::signal<void (const boost::gregorian::date&)> onScrollReachedBottom;
boost::signal<void ()> onPreviousButtonClicked;
boost::signal<void ()> onNextButtonClicked;
+ boost::signal<void (const boost::gregorian::date&)> onCalendarClicked;
};
}
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp
index d926db7..b9f2e91 100644
--- a/Swift/QtUI/QtHistoryWindow.cpp
+++ b/Swift/QtUI/QtHistoryWindow.cpp
@@ -63,6 +63,7 @@ QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* even
connect(conversation_, SIGNAL(fontResized(int)), this, SLOT(handleFontResized(int)));
connect(ui_.searchBox_->lineEdit(), SIGNAL(returnPressed()), this, SLOT(handleReturnPressed()));
connect(ui_.calendarWidget_, SIGNAL(clicked(const QDate&)), this, SLOT(handleCalendarClicked(const QDate&)));
+ connect(ui_.calendarWidget_, SIGNAL(activated(const QDate&)), this, SLOT(handleCalendarClicked(const QDate&)));
connect(ui_.previousButton_, SIGNAL(clicked(bool)), this, SLOT(handlePreviousButtonClicked()));
connect(ui_.nextButton_, SIGNAL(clicked(bool)), this, SLOT(handleNextButtonClicked()));
}
@@ -74,6 +75,7 @@ QtHistoryWindow::~QtHistoryWindow() {
disconnect(conversation_, SIGNAL(fontResized(int)), this, SLOT(handleFontResized(int)));
disconnect(ui_.searchBox_->lineEdit(), SIGNAL(returnPressed()), this, SLOT(handleReturnPressed()));
disconnect(ui_.calendarWidget_, SIGNAL(clicked(const QDate&)), this, SLOT(handleCalendarClicked(const QDate&)));
+ disconnect(ui_.calendarWidget_, SIGNAL(activated(const QDate&)), this, SLOT(handleCalendarClicked(const QDate&)));
disconnect(ui_.previousButton_, SIGNAL(clicked(bool)), this, SLOT(handlePreviousButtonClicked()));
disconnect(ui_.nextButton_, SIGNAL(clicked(bool)), this, SLOT(handleNextButtonClicked()));
@@ -186,6 +188,10 @@ void QtHistoryWindow::handleReturnPressed() {
}
void QtHistoryWindow::handleCalendarClicked(const QDate& date) {
+ int year, month, day;
+ QDate tempDate = date; // getDate discards const qualifier
+ tempDate.getDate(&year, &month, &day);
+ onCalendarClicked(boost::gregorian::date(year, month, day));
}
void QtHistoryWindow::setDate(const boost::gregorian::date& date) {