pans
2016-12-15 87e3ee273b2f84081ac45926be9d8e5be3166eaa
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
 
#include <QMessageBox>
#include "cdlgremoterecordschedule.h"
#include "publicfuc.h"
 
 
CDlgRemoteRecordSchedule::CDlgRemoteRecordSchedule(QWidget *parent)
    : QDialog(parent)
{
    ui.setupUi(this);
 
    //¼ÏóÀàÐÍ£º0-¶¨Ê±Â¼Ïñ£¬1-ÒÆ¶¯Õì²â¼Ïñ£¬2-±¨¾¯Â¼Ïñ£¬3-ÒÆ¶¯Õì²â»ò±¨¾¯Â¼Ïñ£¬4-ÒÆ¶¯Õì²âºÍ±¨¾¯Â¼Ïñ£¬5-ÃüÁî´¥·¢Â¼Ïñ£¬6-ÖÇÄܱ¨¾¯Â¼Ïñ
    QStringList strings;
    strings<<"Schedule"<<"Motion detect"<<"Alarm"<<"Motion or alarm"<<"Motion and alarm"<<"Command trigger"<<"VCA alarm";
    int i;
    for(i=0; i < 8; i++)
    {
        ui.vLayStartHour->addWidget(&(m_editStartHour[i]));
        ui.vLayStartMin->addWidget(&(m_editStartMin[i]));
        ui.vLayEndHour->addWidget(&(m_editEndHour[i]));
        ui.vLayEndMin->addWidget(&(m_editEndMin[i]));
        ui.vLayRecordType->addWidget(&(m_comboRecordType[i]));
        m_comboRecordType[i].addItems(strings);
    }
    ui.comboDayRecordType->addItems(strings);
    strings.clear();
    strings<<"Monday"<<"Tuesday"<<"Wednesday"<<"Thursday"<<"Friday"<<"Saturday"<<"Sunday";
    ui.comboWeekDay->addItems(strings);
    strings<<"Whole week";
    ui.comboCopyRecordDay->addItems(strings);
 
    m_pstruRecord = NULL;
 
    connect(ui.comboWeekDay, SIGNAL(activated(int)), this, SLOT(comboWeekDayChanged (int)));
    connect(ui.checkRecordAllDay, SIGNAL(clicked()), this, SLOT(clickRecordAllDay()));
}
 
CDlgRemoteRecordSchedule::~CDlgRemoteRecordSchedule()
{
 
}
 
void CDlgRemoteRecordSchedule::on_btnCopyDay_clicked()
{
    if(m_pstruRecord == NULL)
    {
        QMessageBox::information(this, tr("Please check!"), tr("the m_pstruRecord is null!"));
        return;
    }
    int iCopyDay;;
    int i;
    iCopyDay = ui.comboCopyRecordDay->currentIndex();
 
    if(iCopyDay < 7)//Ö»¸´ÖÆÄ³Ò»Ìì
    {
        copyDaySetting(iCopyDay);
    }
    else //¸´ÖƵ½ËùÓÐÌì
    {
        for(i = 0; i < MAX_DAYS; i++)
        {
            copyDaySetting(i);
        }
    }
}
 
//±£´æ°´Å¥±»µã»÷
void CDlgRemoteRecordSchedule::on_btnSave_clicked()
{
    if(m_pstruRecord != NULL)
    {
        int iWeekDay;
        int i;
        int iTime;
        iWeekDay = ui.comboWeekDay->currentIndex();
        if(ui.checkRecordAllDay->isChecked())//È«Ìì¼Ïñ
        {
            m_pstruRecord->struRecAllDay[iWeekDay].wAllDayRecord = 1;
            m_pstruRecord->struRecAllDay[iWeekDay].byRecordType = ( BYTE)(ui.comboDayRecordType->currentIndex());
        }
        else//ʱ¼ä¶Î¼Ïñ
        {
            for(i = 0; i < MAX_TIMESEGMENT; i++)
            {
                //ÀàÐÍ
                m_pstruRecord->struRecordSched[iWeekDay][i].byRecordType = m_comboRecordType[i].currentIndex();
                //¿ªÊ¼Ð¡Ê±
                KIT_editToInt(&(m_editStartHour[i]), &iTime);
                m_pstruRecord->struRecordSched[iWeekDay][i].struRecordTime.byStartHour = iTime;
                //¿ªÊ¼·ÖÖÓ
                KIT_editToInt(&(m_editStartMin[i]), &iTime);
                m_pstruRecord->struRecordSched[iWeekDay][i].struRecordTime.byStartMin = iTime;
                //½áÊøÐ¡Ê±
                KIT_editToInt(&(m_editEndHour[i]), &iTime);
                m_pstruRecord->struRecordSched[iWeekDay][i].struRecordTime.byStopHour = iTime;
                //½áÊø·ÖÖÓ
                KIT_editToInt(&(m_editEndMin[i]), &iTime);
                m_pstruRecord->struRecordSched[iWeekDay][i].struRecordTime.byStopMin = iTime;
            }
        }
    }
    else
    {
        QMessageBox::information(this, tr("Please check!"), tr("the m_pstruRecord is null!"));
    }
}
 
int CDlgRemoteRecordSchedule::comboWeekDayChanged(int iWeekDay)
{
    setEachWidget(iWeekDay);
    return HPR_OK;
}
 
int CDlgRemoteRecordSchedule::clickRecordAllDay()
{
    int i;
    if(ui.checkRecordAllDay->isChecked())
    {
        ui.comboDayRecordType->setEnabled(TRUE);
        for(i = 0; i <MAX_TIMESEGMENT_V30; i++)
        {
            m_comboRecordType[i].setEnabled(FALSE);
            m_editStartHour[i].setEnabled(FALSE);
            m_editStartMin[i].setEnabled(FALSE);
            m_editEndHour[i].setEnabled(FALSE);
            m_editEndMin[i].setEnabled(FALSE);
        }
    }
    else
    {
        ui.comboDayRecordType->setEnabled(FALSE);
        for(i = 0; i <MAX_TIMESEGMENT_V30; i++)
        {
            m_comboRecordType[i].setEnabled(TRUE);
            m_editStartHour[i].setEnabled(TRUE);
            m_editStartMin[i].setEnabled(TRUE);
            m_editEndHour[i].setEnabled(TRUE);
            m_editEndMin[i].setEnabled(TRUE);
        }
    }
 
    return HPR_OK;
}
 
 
//¿½±´µ±Ç°ÉèÖõ½Ä³Ò»Ì죬ÄÚ²¿½Ó¿ÚĬÈÏm_pstruRecord²»Îª¿Õ
int CDlgRemoteRecordSchedule::copyDaySetting(int iWeekNo)
{
    int i;
    int iTime;
 
    if(ui.checkRecordAllDay->isChecked())
    {
        m_pstruRecord->struRecAllDay[iWeekNo].wAllDayRecord = 1;
        m_pstruRecord->struRecAllDay[iWeekNo].byRecordType = ( BYTE)(ui.comboDayRecordType->currentIndex());
    }
    else
    {
        for (i = 0; i < MAX_TIMESEGMENT_V30; i++)
        {
            //ÀàÐÍ
            m_pstruRecord->struRecordSched[iWeekNo][i].byRecordType = m_comboRecordType[i].currentIndex();
            //¿ªÊ¼Ð¡Ê±
            KIT_editToInt(&(m_editStartHour[i]), &iTime);
            m_pstruRecord->struRecordSched[iWeekNo][i].struRecordTime.byStartHour = iTime;
            //¿ªÊ¼·ÖÖÓ
            KIT_editToInt(&(m_editStartMin[i]), &iTime);
            m_pstruRecord->struRecordSched[iWeekNo][i].struRecordTime.byStartMin
                    = iTime;
            //½áÊøÐ¡Ê±
            KIT_editToInt(&(m_editEndHour[i]), &iTime);
            m_pstruRecord->struRecordSched[iWeekNo][i].struRecordTime.byStopHour
                    = iTime;
            //½áÊø·ÖÖÓ
            KIT_editToInt(&(m_editEndMin[i]), &iTime);
            m_pstruRecord->struRecordSched[iWeekNo][i].struRecordTime.byStopMin = iTime;
        }
    }
 
     return HPR_ERROR;
}
 
int CDlgRemoteRecordSchedule::SetStruRecord(NET_DVR_RECORD_V30 *pstruRecord)
{
    m_pstruRecord = pstruRecord;
    return HPR_ERROR;
}
 
//event
void CDlgRemoteRecordSchedule::showEvent ( QShowEvent * event )
{
    if(event ==NULL)
    {
    }
    setEachWidget(0);
}
 
int  CDlgRemoteRecordSchedule::setEachWidget(int iWeekDay)
{
    if(m_pstruRecord == NULL)
    {
        QMessageBox::information(this, tr("Please check!"), tr("the m_pstruRecord is null!"));
        return HPR_ERROR;
    }
    int iTemp;
    iTemp = m_pstruRecord->struRecAllDay[iWeekDay].byRecordType;
    ui.comboDayRecordType->setCurrentIndex(int(iTemp));
    iTemp = m_pstruRecord->struRecAllDay[iWeekDay].wAllDayRecord;
    if(iTemp == 0)//ÊÇ·ñÈ«Ìì¼Ïñ
    {
        ui.checkRecordAllDay->setCheckState(Qt::Unchecked);
    }
    else
    {
           ui.checkRecordAllDay->setCheckState(Qt::Checked);
     }
     int i;
     for(i = 0; i < MAX_TIMESEGMENT_V30; i++)
     {
           //ÀàÐÍ
           iTemp = m_pstruRecord->struRecordSched[iWeekDay][i].byRecordType;
           m_comboRecordType[i].setCurrentIndex(iTemp);
           //ʱ¼ä
        iTemp = m_pstruRecord->struRecordSched[iWeekDay][i].struRecordTime.byStartHour;
        KIT_intToEdit(&(m_editStartHour[i]), iTemp);
        iTemp = m_pstruRecord->struRecordSched[iWeekDay][i].struRecordTime.byStartMin;
           KIT_intToEdit(&(m_editStartMin[i]), iTemp);
           iTemp = m_pstruRecord->struRecordSched[iWeekDay][i].struRecordTime.byStopHour;
        KIT_intToEdit(&(m_editEndHour[i]), iTemp);
        iTemp = m_pstruRecord->struRecordSched[iWeekDay][i].struRecordTime.byStopMin;
        KIT_intToEdit(&(m_editEndMin[i]), iTemp);
     }
 
    return HPR_OK;
}