blob: 56543a2681b077dca6a48b7059b8f52fe77e0285 (
plain)
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
|
/*
* Copyright (c) 2011 Vlad Voicu
* Licensed under the Simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#include <QWidget>
#include <QBoxLayout>
#include <QString>
#include <cstring>
#include "QtViewHistoryWindow.h"
#include "QtChatView.h"
#include "QtChatTheme.h"
#include "MessageSnippet.h"
#include "QtSwiftUtil.h"
#include <QDebug>
#include <QStandardItemModel>
#include <boost/bind.hpp>
#include <cstdio>
namespace Swift {
QtViewHistoryWindow::QtViewHistoryWindow() {
ui.setupUi(this);
QtChatTheme *theme = new QtChatTheme(""); // Where should I get the theme path from?
messageLog_ = new QtChatView(theme, this);
ui.chatView_ = messageLog_;
QStandardItemModel *dummyModel = new QStandardItemModel(1, 1);
QStandardItem *item = new QStandardItem(QString("test row, test column"));
dummyModel->setItem(0, 0, item);
QTreeView *userHistory = new QTreeView();
userHistory->setModel(dummyModel);
ui.userHistory_ = userHistory;
connect(ui.periodPickerBefore_, SIGNAL(valueChanged(int)), this, SLOT(handleBeforeSliderValueChanged(int)));
connect(ui.periodPickerAfter_, SIGNAL(valueChanged(int)), this, SLOT(handleAfterSliderValueChanged(int)));
show();
}
void QtViewHistoryWindow::show() {
QWidget::show();
QWidget::activateWindow();
}
void QtViewHistoryWindow::setEnabled(bool enabled) {
QWidget::setEnabled(enabled);
}
std::string QtViewHistoryWindow::getLabel(const int value) {
std::string labelText;
switch (value / 16) {
case 0:
labelText = "1 day";
break;
case 1:
labelText = "3 days";
break;
case 2:
labelText = "1 week";
break;
case 3:
labelText = "2 weeks";
break;
case 4:
labelText = "1 month";
break;
case 5:
labelText = "3 months";
break;
case 6:
labelText = "1 year";
break;
}
return labelText;
}
void QtViewHistoryWindow::handleBeforeSliderValueChanged(const int value) {
QString labelText = P2QSTRING(getLabel(value));
ui.beforePeriodLabel_->setText(labelText);
}
void QtViewHistoryWindow::handleAfterSliderValueChanged(const int value) {
QString labelText = P2QSTRING(getLabel(value));
ui.afterPeriodLabel_->setText(labelText);
}
}
|