• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão5ecea0f05a0d8ebf3bf2980729af879620f7302c (tree)
Hora2013-12-27 20:56:35
Autoralucky4416 <alucky4416@user...>
Commiteralucky4416

Mensagem de Log

CHG: implement RegistHoliday Dialog, and add INI file.

Mudança Sumário

Diff

--- a/QtSchChime.pro
+++ b/QtSchChime.pro
@@ -1,30 +1,30 @@
1-#-------------------------------------------------
2-#
3-# Project created by QtCreator 2013-12-20T08:02:13
4-#
5-#-------------------------------------------------
6-
7-QT += core gui
8-
9-TARGET = QtSchChime
10-TEMPLATE = app
11-
12-
13-SOURCES += main.cpp\
14- mainwindow.cpp \
15- PlayMusicThread.cpp \
16- thschmanager.cpp \
17- registholiday_dialog.cpp
18-
19-HEADERS += mainwindow.h \
20- PlayMusicThread.h \
21- thschmanager.h \
22- registholiday_dialog.h
23-
24-FORMS += mainwindow.ui \
25- registholiday_dialog.ui
26-
27-INCLUDEPATH += $$PWD/libbass/
28-
29-win32:LIBS += $$PWD/libbass/libbass.dll.a
30-unix:LIBS += -lbass
1+#-------------------------------------------------
2+#
3+# Project created by QtCreator 2013-12-20T08:02:13
4+#
5+#-------------------------------------------------
6+
7+QT += core gui
8+
9+TARGET = QtSchChime
10+TEMPLATE = app
11+
12+
13+SOURCES += main.cpp\
14+ mainwindow.cpp \
15+ PlayMusicThread.cpp \
16+ thschmanager.cpp \
17+ registholiday_dialog.cpp
18+
19+HEADERS += mainwindow.h \
20+ PlayMusicThread.h \
21+ thschmanager.h \
22+ registholiday_dialog.h
23+
24+FORMS += mainwindow.ui \
25+ registholiday_dialog.ui
26+
27+INCLUDEPATH += $$PWD/libbass/
28+
29+win32:LIBS += $$PWD/libbass/libbass.dll.a
30+unix:LIBS += -lbass
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -49,6 +49,7 @@ MainWindow::MainWindow(QWidget *parent) :
4949 ui->lineEdit_FilePath->setText(DefaultChimeFilePath);
5050 }
5151 }
52+
5253 #if 0
5354 // Set SchTimeList
5455 QStringList list;
@@ -124,7 +125,8 @@ void MainWindow::LoadSaveSetting(QString filepath, bool store = false)
124125 settings.setValue("SETTING/SCHTIME_LIST", list);
125126
126127 // HolidaysList
127- ;
128+ settings.setValue("SETTING/HOLIDAYS_LIST", Holidays);
129+
128130 } else { // Load
129131 // Exclude SS flag
130132 ui->checkBox_Exclude_SS->setChecked(settings.value("SETTING/EXCLUDE_SS", true).toBool());
@@ -141,6 +143,16 @@ void MainWindow::LoadSaveSetting(QString filepath, bool store = false)
141143 }
142144 // Set ListWidget, and spinBox hh:mm
143145 ui->listWidget_SchTimeList->addItems(list);
146+
147+ QStringList list1(settings.value("SETTING/HOLIDAYS_LIST", QStringList()).toStringList());
148+ if (list1.count() == 0) {
149+ Holidays.clear();
150+ Holidays << "01/01" << "01/15" << "02/11" << "03/21" << "04/29" << "05/01" << "05/03" << "05/04" << "05/05" << "07/21" << "09/15" << "09/23" << "10/10" << "11/03" << "11/23" << "12/23";
151+ } else {
152+ Holidays.clear();
153+ Holidays.append(list1);
154+ }
155+ qDebug() << Holidays;
144156 }
145157 }
146158
@@ -235,6 +247,7 @@ void MainWindow::on_pushButton_clicked()
235247 ThSchMngr->setExcludeSS(ui->checkBox_Exclude_SS->isChecked());
236248 ThSchMngr->setExcludeHolidays(ui->checkBox_Exclude_Holiday->isChecked());
237249 ThSchMngr->setChimeFilepath(ui->lineEdit_FilePath->text());
250+ ThSchMngr->setHolidaysList(Holidays);
238251
239252 // Update SchTimeList
240253 QStringList list;
@@ -242,6 +255,7 @@ void MainWindow::on_pushButton_clicked()
242255 list << ui->listWidget_SchTimeList->item(i)->text();
243256 }
244257 ThSchMngr->setSchTimeList(list);
258+
245259 // Start SchChime
246260 ThSchMngr->sendEvent_Start();
247261 statusbar_label_status->setText("start");
@@ -289,6 +303,7 @@ void MainWindow::on_pushButton_Change_clicked()
289303 int hour = ui->spinBox_Hour->value();
290304 int min = ui->spinBox_Min->value();
291305 QString timestr = QString("%1:%2").arg(hour,2,10,QChar('0')).arg(min, 2, 10, QChar('0'));
306+
292307 QList<QListWidgetItem*> findresult = ui->listWidget_SchTimeList->findItems(timestr, Qt::MatchExactly);
293308 if (findresult.isEmpty()) {
294309 // change item when not exist of SchTimeList
@@ -328,15 +343,19 @@ void MainWindow::on_pushButton_Del_clicked()
328343
329344 void MainWindow::on_pushButton_RegistHoliday_clicked()
330345 {
331- RegistHoliday_Dialog *dlg = new RegistHoliday_Dialog(this);
346+ RegistHoliday_Dialog *dlg = new RegistHoliday_Dialog(Holidays, this);
332347
333348 int i = dlg->exec();
334349 if (i == QDialog::Accepted) {
335- // qDebug() << "Ok";
350+ qDebug() << "Ok";
351+ Holidays.clear();
352+ qDebug() << Holidays;
353+ Holidays.append(dlg->HolidaysList());
354+ qDebug() << Holidays;
336355 } else if (i == QDialog::Rejected) {
337- // qDebug() << "Cancel";
356+ qDebug() << "Cancel";
338357 } else {
339- // qDebug() << "Unkown";
358+ qDebug() << "Unkown";
340359 }
341360
342361 delete dlg;
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -61,6 +61,7 @@ private:
6161 ThSchManager *ThSchMngr;
6262 PlayMusicThread *ThPlayMusic;
6363
64+ QStringList Holidays;
6465 };
6566
6667 #endif // MAINWINDOW_H
--- a/registholiday_dialog.cpp
+++ b/registholiday_dialog.cpp
@@ -1,14 +1,85 @@
1-#include "registholiday_dialog.h"
2-#include "ui_registholiday_dialog.h"
3-
4-RegistHoliday_Dialog::RegistHoliday_Dialog(QWidget *parent) :
5- QDialog(parent),
6- ui(new Ui::RegistHoliday_Dialog)
7-{
8- ui->setupUi(this);
9-}
10-
11-RegistHoliday_Dialog::~RegistHoliday_Dialog()
12-{
13- delete ui;
14-}
1+#include "registholiday_dialog.h"
2+#include "ui_registholiday_dialog.h"
3+
4+#include <QDebug>
5+
6+RegistHoliday_Dialog::RegistHoliday_Dialog(QStringList &list, QWidget *parent) :
7+ QDialog(parent),
8+ ui(new Ui::RegistHoliday_Dialog)
9+{
10+ ui->setupUi(this);
11+
12+ ui->listWidget_HolidaysList->clear();
13+ ui->listWidget_HolidaysList->addItems(list);
14+
15+ // Set ListWidget, and spinBox hh:mm
16+ ui->listWidget_HolidaysList->setCurrentRow(0);
17+ QStringList current_data = ui->listWidget_HolidaysList->currentItem()->text().split("/");
18+ ui->spinBox_Month->setValue(current_data.at(0).toInt());
19+ ui->spinBox_Day->setValue(current_data.at(1).toInt());
20+}
21+
22+RegistHoliday_Dialog::~RegistHoliday_Dialog()
23+{
24+ delete ui;
25+}
26+
27+QStringList RegistHoliday_Dialog::HolidaysList()
28+{
29+ QStringList list;
30+ for (int i = 0; i < ui->listWidget_HolidaysList->count(); i++) {
31+ list << ui->listWidget_HolidaysList->item(i)->text();
32+ }
33+ return list;
34+}
35+
36+void RegistHoliday_Dialog::on_listWidget_HolidaysList_currentRowChanged(int currentRow)
37+{
38+ QStringList current_data = ui->listWidget_HolidaysList->currentItem()->text().split("/");
39+ ui->spinBox_Month->setValue(current_data.at(0).toInt());
40+ ui->spinBox_Day->setValue(current_data.at(1).toInt());
41+}
42+
43+void RegistHoliday_Dialog::on_pushButton_Change_clicked()
44+{
45+ int mon = ui->spinBox_Month->value();
46+ int day = ui->spinBox_Day->value();
47+ QString datestr = QString("%1/%2").arg(mon,2,10,QChar('0')).arg(day,2,10,QChar('0'));
48+
49+ QList<QListWidgetItem*> findresult = ui->listWidget_HolidaysList->findItems(datestr, Qt::MatchExactly);
50+ if (findresult.isEmpty()) {
51+ // change item when not exist of SchTimeList
52+ QListWidgetItem *item = ui->listWidget_HolidaysList->currentItem();
53+ item->setText(datestr);
54+ ui->listWidget_HolidaysList->setCurrentItem(item);
55+ } else {
56+ ;
57+ }
58+}
59+
60+void RegistHoliday_Dialog::on_pushButton_Add_clicked()
61+{
62+ int mon = ui->spinBox_Month->value();
63+ int day = ui->spinBox_Day->value();
64+ QString datestr = QString("%1/%2").arg(mon,2,10,QChar('0')).arg(day,2,10,QChar('0'));
65+
66+ QList<QListWidgetItem*> findresult = ui->listWidget_HolidaysList->findItems(datestr, Qt::MatchExactly);
67+ if (findresult.isEmpty()) {
68+ // change item when not exist of SchTimeList
69+ QListWidgetItem *item = new QListWidgetItem();
70+ item->setText(datestr);
71+ ui->listWidget_HolidaysList->insertItem(ui->listWidget_HolidaysList->currentRow(), item);
72+ } else {
73+ ;
74+ }
75+}
76+
77+void RegistHoliday_Dialog::on_pushButton_Del_clicked()
78+{
79+ // one of the last?
80+ if (1 >= ui->listWidget_HolidaysList->count()) return;
81+
82+ // delete currentRow item
83+ ui->listWidget_HolidaysList->takeItem(ui->listWidget_HolidaysList->currentRow());
84+
85+}
--- a/registholiday_dialog.h
+++ b/registholiday_dialog.h
@@ -1,22 +1,36 @@
1-#ifndef REGISTHOLIDAY_DIALOG_H
2-#define REGISTHOLIDAY_DIALOG_H
3-
4-#include <QDialog>
5-
6-namespace Ui {
7-class RegistHoliday_Dialog;
8-}
9-
10-class RegistHoliday_Dialog : public QDialog
11-{
12- Q_OBJECT
13-
14-public:
15- explicit RegistHoliday_Dialog(QWidget *parent = 0);
16- ~RegistHoliday_Dialog();
17-
18-private:
19- Ui::RegistHoliday_Dialog *ui;
20-};
21-
22-#endif // REGISTHOLIDAY_DIALOG_H
1+#ifndef REGISTHOLIDAY_DIALOG_H
2+#define REGISTHOLIDAY_DIALOG_H
3+
4+#include <QDialog>
5+#include <QStringList>
6+
7+namespace Ui {
8+class RegistHoliday_Dialog;
9+}
10+
11+class RegistHoliday_Dialog : public QDialog
12+{
13+ Q_OBJECT
14+
15+public:
16+ explicit RegistHoliday_Dialog( QStringList&, QWidget *parent = 0);
17+ ~RegistHoliday_Dialog();
18+
19+ QStringList HolidaysList();
20+
21+private slots:
22+ void on_listWidget_HolidaysList_currentRowChanged(int currentRow);
23+
24+ void on_pushButton_Change_clicked();
25+
26+ void on_pushButton_Add_clicked();
27+
28+ void on_pushButton_Del_clicked();
29+
30+private:
31+ Ui::RegistHoliday_Dialog *ui;
32+
33+ QStringList *Holidays;
34+};
35+
36+#endif // REGISTHOLIDAY_DIALOG_H
--- a/registholiday_dialog.ui
+++ b/registholiday_dialog.ui
@@ -1,68 +1,197 @@
1-<?xml version="1.0" encoding="UTF-8"?>
2-<ui version="4.0">
3- <class>RegistHoliday_Dialog</class>
4- <widget class="QDialog" name="RegistHoliday_Dialog">
5- <property name="geometry">
6- <rect>
7- <x>0</x>
8- <y>0</y>
9- <width>400</width>
10- <height>300</height>
11- </rect>
12- </property>
13- <property name="windowTitle">
14- <string>Regist Holiday Dialog</string>
15- </property>
16- <widget class="QDialogButtonBox" name="buttonBox">
17- <property name="geometry">
18- <rect>
19- <x>30</x>
20- <y>240</y>
21- <width>341</width>
22- <height>32</height>
23- </rect>
24- </property>
25- <property name="orientation">
26- <enum>Qt::Horizontal</enum>
27- </property>
28- <property name="standardButtons">
29- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
30- </property>
31- </widget>
32- </widget>
33- <resources/>
34- <connections>
35- <connection>
36- <sender>buttonBox</sender>
37- <signal>accepted()</signal>
38- <receiver>RegistHoliday_Dialog</receiver>
39- <slot>accept()</slot>
40- <hints>
41- <hint type="sourcelabel">
42- <x>248</x>
43- <y>254</y>
44- </hint>
45- <hint type="destinationlabel">
46- <x>157</x>
47- <y>274</y>
48- </hint>
49- </hints>
50- </connection>
51- <connection>
52- <sender>buttonBox</sender>
53- <signal>rejected()</signal>
54- <receiver>RegistHoliday_Dialog</receiver>
55- <slot>reject()</slot>
56- <hints>
57- <hint type="sourcelabel">
58- <x>316</x>
59- <y>260</y>
60- </hint>
61- <hint type="destinationlabel">
62- <x>286</x>
63- <y>274</y>
64- </hint>
65- </hints>
66- </connection>
67- </connections>
68-</ui>
1+<?xml version="1.0" encoding="UTF-8"?>
2+<ui version="4.0">
3+ <class>RegistHoliday_Dialog</class>
4+ <widget class="QDialog" name="RegistHoliday_Dialog">
5+ <property name="geometry">
6+ <rect>
7+ <x>0</x>
8+ <y>0</y>
9+ <width>316</width>
10+ <height>379</height>
11+ </rect>
12+ </property>
13+ <property name="windowTitle">
14+ <string>Regist Holiday Dialog</string>
15+ </property>
16+ <widget class="QDialogButtonBox" name="buttonBox">
17+ <property name="geometry">
18+ <rect>
19+ <x>-40</x>
20+ <y>320</y>
21+ <width>341</width>
22+ <height>32</height>
23+ </rect>
24+ </property>
25+ <property name="orientation">
26+ <enum>Qt::Horizontal</enum>
27+ </property>
28+ <property name="standardButtons">
29+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
30+ </property>
31+ </widget>
32+ <widget class="QLabel" name="label">
33+ <property name="geometry">
34+ <rect>
35+ <x>30</x>
36+ <y>20</y>
37+ <width>121</width>
38+ <height>16</height>
39+ </rect>
40+ </property>
41+ <property name="font">
42+ <font>
43+ <pointsize>12</pointsize>
44+ <weight>75</weight>
45+ <bold>true</bold>
46+ </font>
47+ </property>
48+ <property name="text">
49+ <string>Holidays</string>
50+ </property>
51+ </widget>
52+ <widget class="QListWidget" name="listWidget_HolidaysList">
53+ <property name="geometry">
54+ <rect>
55+ <x>30</x>
56+ <y>80</y>
57+ <width>111</width>
58+ <height>221</height>
59+ </rect>
60+ </property>
61+ <property name="sortingEnabled">
62+ <bool>true</bool>
63+ </property>
64+ <item>
65+ <property name="text">
66+ <string>1/1</string>
67+ </property>
68+ </item>
69+ </widget>
70+ <widget class="QPushButton" name="pushButton_Add">
71+ <property name="geometry">
72+ <rect>
73+ <x>170</x>
74+ <y>80</y>
75+ <width>61</width>
76+ <height>21</height>
77+ </rect>
78+ </property>
79+ <property name="text">
80+ <string>Add</string>
81+ </property>
82+ </widget>
83+ <widget class="QPushButton" name="pushButton_Del">
84+ <property name="geometry">
85+ <rect>
86+ <x>170</x>
87+ <y>110</y>
88+ <width>61</width>
89+ <height>21</height>
90+ </rect>
91+ </property>
92+ <property name="text">
93+ <string>Del</string>
94+ </property>
95+ </widget>
96+ <widget class="QPushButton" name="pushButton_Change">
97+ <property name="geometry">
98+ <rect>
99+ <x>170</x>
100+ <y>50</y>
101+ <width>71</width>
102+ <height>21</height>
103+ </rect>
104+ </property>
105+ <property name="text">
106+ <string>Change</string>
107+ </property>
108+ </widget>
109+ <widget class="QWidget" name="layoutWidget">
110+ <property name="geometry">
111+ <rect>
112+ <x>30</x>
113+ <y>50</y>
114+ <width>133</width>
115+ <height>30</height>
116+ </rect>
117+ </property>
118+ <layout class="QHBoxLayout" name="horizontalLayout">
119+ <item>
120+ <widget class="QSpinBox" name="spinBox_Month">
121+ <property name="minimum">
122+ <number>1</number>
123+ </property>
124+ <property name="maximum">
125+ <number>12</number>
126+ </property>
127+ <property name="value">
128+ <number>1</number>
129+ </property>
130+ </widget>
131+ </item>
132+ <item>
133+ <widget class="QLabel" name="label_2">
134+ <property name="font">
135+ <font>
136+ <pointsize>12</pointsize>
137+ <weight>75</weight>
138+ <bold>true</bold>
139+ </font>
140+ </property>
141+ <property name="text">
142+ <string>/</string>
143+ </property>
144+ </widget>
145+ </item>
146+ <item>
147+ <widget class="QSpinBox" name="spinBox_Day">
148+ <property name="minimum">
149+ <number>1</number>
150+ </property>
151+ <property name="maximum">
152+ <number>31</number>
153+ </property>
154+ <property name="value">
155+ <number>1</number>
156+ </property>
157+ </widget>
158+ </item>
159+ </layout>
160+ </widget>
161+ </widget>
162+ <resources/>
163+ <connections>
164+ <connection>
165+ <sender>buttonBox</sender>
166+ <signal>accepted()</signal>
167+ <receiver>RegistHoliday_Dialog</receiver>
168+ <slot>accept()</slot>
169+ <hints>
170+ <hint type="sourcelabel">
171+ <x>248</x>
172+ <y>254</y>
173+ </hint>
174+ <hint type="destinationlabel">
175+ <x>157</x>
176+ <y>274</y>
177+ </hint>
178+ </hints>
179+ </connection>
180+ <connection>
181+ <sender>buttonBox</sender>
182+ <signal>rejected()</signal>
183+ <receiver>RegistHoliday_Dialog</receiver>
184+ <slot>reject()</slot>
185+ <hints>
186+ <hint type="sourcelabel">
187+ <x>316</x>
188+ <y>260</y>
189+ </hint>
190+ <hint type="destinationlabel">
191+ <x>286</x>
192+ <y>274</y>
193+ </hint>
194+ </hints>
195+ </connection>
196+ </connections>
197+</ui>
--- a/thschmanager.cpp
+++ b/thschmanager.cpp
@@ -125,6 +125,16 @@ void ThSchManager::setSchTimeList(QStringList list)
125125 SchTimeList = list;
126126 qDebug() << "ThSchManager::SchTimeList:" << SchTimeList;
127127 }
128+
129+void ThSchManager::setHolidaysList(QStringList list)
130+{
131+ if (list.isEmpty()) return;
132+
133+ HolidaysList.clear();
134+ HolidaysList = list;
135+ qDebug() << "ThSchManager::HolidaysList:" << HolidaysList;
136+}
137+
128138 void ThSchManager::setExcludeSS(bool flag)
129139 {
130140 ExcludeSS = flag;
@@ -178,14 +188,11 @@ bool ThSchManager::isHolidays()
178188 {
179189 bool ret = false;
180190
181- QStringList holidays; // for Debug
182- holidays << "1/15" << "2/11" << "3/21" << "4/29" << "5/3" << "5/4" << "5/5" << "7/21" << "9/15" << "9/23" << "10/10" << "11/23" << "12/23";
183-
184191 int mon, day;
185192 QDate today;
186193 today = QDate::currentDate();
187- for (int i = 0; i < holidays.count(); i++) {
188- QStringList mandd = holidays.at(i).split("/");
194+ for (int i = 0; i < HolidaysList.count(); i++) {
195+ QStringList mandd = HolidaysList.at(i).split("/");
189196 mon = mandd.at(0).toInt();
190197 day = mandd.at(1).toInt();
191198 if ((today.month() == mon) && (today.day() == day)) {
--- a/thschmanager.h
+++ b/thschmanager.h
@@ -25,6 +25,7 @@ public:
2525 void setThreadPtrPlayMusic(PlayMusicThread *th);
2626 void setChimeFilepath(QString filepath);
2727 void setSchTimeList(QStringList list);
28+ void setHolidaysList(QStringList list);
2829 void setExcludeSS(bool flag);
2930 void setExcludeHolidays(bool flag);
3031
@@ -51,6 +52,7 @@ private:
5152 QString ChimeFilepath;
5253
5354 QStringList SchTimeList; // { "9:00", "12:00", 13:00", "17:30" }
55+ QStringList HolidaysList; // { "01/01", "02/11", "04/29", ... }
5456
5557 bool ExcludeSS; // Disable Chime when Saturday, Sunday
5658 bool ExcludeHolidays; // Disable Chime when Holiday