|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include "savedelwidget.h" |
|
18 |
|
19 |
|
20 |
|
21 savedelwidget::savedelwidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent) |
|
22 : basewidget(activityStorage, activityManager, stream, parent) |
|
23 { |
|
24 mStartTestButton->setText("Save"); |
|
25 } |
|
26 |
|
27 savedelwidget::~savedelwidget() |
|
28 { |
|
29 } |
|
30 |
|
31 |
|
32 void savedelwidget::timeout() |
|
33 { |
|
34 if(mAction == "predel") { |
|
35 if(mItemsCounter<mItems) { |
|
36 QString name = mActivities.at(mItemsCounter); |
|
37 bool ok = removeActivity(name); |
|
38 mItemsCounter++; |
|
39 if(!ok) { |
|
40 setError("remove activity"); |
|
41 return; |
|
42 } |
|
43 updateItemLabel(mItemsCounter); |
|
44 } |
|
45 else { |
|
46 mItems=Items(); |
|
47 mTimes=Times(); |
|
48 mItemsCounter = 0; |
|
49 mAction = "save"; |
|
50 updateActionLabel(); |
|
51 //updateItemLabel(mItemsCounter); |
|
52 updateTimeLabel(mTimesCounter); |
|
53 logFirst(); |
|
54 prepareSave(); |
|
55 } |
|
56 } |
|
57 else if(mAction=="save") { |
|
58 if(mTimesCounter==mTimes) { |
|
59 endNormally(); |
|
60 return; |
|
61 } |
|
62 if(mItemsCounter<mItems) { |
|
63 |
|
64 bool ok = saveActivity(mItemsCounter); |
|
65 if(!ok) { |
|
66 setError("save activity"); |
|
67 return; |
|
68 } |
|
69 mItemsCounter++; |
|
70 updateItemLabel(mItemsCounter); |
|
71 } |
|
72 else { |
|
73 if(TestCheckBoxChecked()) { |
|
74 bool ok = activities(); |
|
75 if(!ok) { |
|
76 setError("get activities list"); |
|
77 return; |
|
78 } |
|
79 ok = checkActNum(); |
|
80 if(!ok) { |
|
81 setError("unexpected act number"); |
|
82 return; |
|
83 } |
|
84 mItemsCounter = 0; |
|
85 mAction = "remove"; |
|
86 updateActionLabel(); |
|
87 //updateItemLabel(mItemsCounter); |
|
88 |
|
89 } |
|
90 else { |
|
91 mTimesCounter++; |
|
92 mItemsCounter = 0; |
|
93 //updateItemLabel(mItemsCounter); |
|
94 updateTimeLabel(mTimesCounter); |
|
95 } |
|
96 } |
|
97 } |
|
98 else if(mAction=="remove") { |
|
99 if(mItemsCounter<mItems) { |
|
100 |
|
101 QString name = mActivities.at(mItemsCounter); |
|
102 bool ok = removeActivity(name); |
|
103 mItemsCounter++; |
|
104 if(!ok) { |
|
105 setError("remove activity"); |
|
106 return; |
|
107 } |
|
108 updateItemLabel(mItemsCounter); |
|
109 } |
|
110 else { |
|
111 mTimesCounter++; |
|
112 mItemsCounter = 0; |
|
113 //updateItemLabel(mItemsCounter); |
|
114 updateTimeLabel(mTimesCounter); |
|
115 mAction = "save"; |
|
116 updateActionLabel(); |
|
117 } |
|
118 } |
|
119 else { |
|
120 setError("unexpected state"); |
|
121 } |
|
122 } |
|
123 |
|
124 void savedelwidget::test() |
|
125 { |
|
126 mTimesCounter = 0; |
|
127 mStatusValueLabel->setPlainText("Pending"); |
|
128 enableControls(false); |
|
129 *mStream<<tr("*Save del start*\n"); |
|
130 logSettings(); |
|
131 mStream->flush(); |
|
132 mAction = "predel"; |
|
133 bool ok = activities(); |
|
134 if(!ok) { |
|
135 setError("get activities list"); |
|
136 return; |
|
137 } |
|
138 mItems = mActivities.count(); |
|
139 basewidget::test(); |
|
140 } |