The MinGW.org Installation Manager Tool
リビジョン | eac14c5e252cbb3bf27a85c625258016e28a191a (tree) |
---|---|
日時 | 2012-12-06 21:41:38 |
作者 | Keith Marshall <keithmarshall@user...> |
コミッター | Keith Marshall |
Implement enhanced action item enumeration capability.
@@ -1,3 +1,18 @@ | ||
1 | +2012-12-06 Keith Marshall <keithmarshall@users.sourceforge.net> | |
2 | + | |
3 | + Implement enhanced action item enumeration capability. | |
4 | + | |
5 | + * src/pkgbase.h (pkgActionItem::EnumeratePendingActions): New public | |
6 | + method; declare it. It provides the capability to enumerate scheduled | |
7 | + actions, filtered by action classification; when invoked such that it | |
8 | + selects all actions, it may be used as a replacement for... | |
9 | + (pkgActionItem::Unapplied): ...this; delete declaration. | |
10 | + | |
11 | + * src/pkgdata.cpp (pkgActionItem::EnumeratePendingActions): Implement | |
12 | + it; it is derived, with enhancement, from original implementation... | |
13 | + (pkgActionItem::Unapplied): ...of this; delete it, and... | |
14 | + (AppWindowMaker::OnClose): ...update calling reference accordingly. | |
15 | + | |
1 | 16 | 2012-12-05 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 17 | |
3 | 18 | Implement PTY display emulation for GUI mode DMH. |
@@ -302,9 +302,10 @@ class pkgActionItem | ||
302 | 302 | inline unsigned long CancelScheduledAction( void ); |
303 | 303 | inline void SetPrimary( pkgActionItem* ); |
304 | 304 | |
305 | - /* Method to check for residual unapplied changes. | |
305 | + /* Method to enumerate and identify pending changes, | |
306 | + * and/or check for residual unapplied changes. | |
306 | 307 | */ |
307 | - inline unsigned long Unapplied( void ); | |
308 | + unsigned long EnumeratePendingActions( int = 0 ); | |
308 | 309 | |
309 | 310 | /* Methods for defining the selection criteria for |
310 | 311 | * packages to be processed. |
@@ -1165,7 +1165,7 @@ long AppWindowMaker::OnNotify( WPARAM client_id, LPARAM data ) | ||
1165 | 1165 | return EXIT_SUCCESS; |
1166 | 1166 | } |
1167 | 1167 | |
1168 | -inline unsigned long pkgActionItem::Unapplied( void ) | |
1168 | +unsigned long pkgActionItem::EnumeratePendingActions( int classified ) | |
1169 | 1169 | { |
1170 | 1170 | /* Helper method to count the pending actions in a |
1171 | 1171 | * scheduled action list. |
@@ -1173,33 +1173,64 @@ inline unsigned long pkgActionItem::Unapplied( void ) | ||
1173 | 1173 | unsigned long count = 0; |
1174 | 1174 | if( this != NULL ) |
1175 | 1175 | { |
1176 | - /* Assuming that the initial 'this' pointer is closer | |
1177 | - * to the end of the list, than to the beginning... | |
1176 | + /* Regardless of the position of the 'this' pointer, | |
1177 | + * within the list of scheduled actions... | |
1178 | 1178 | */ |
1179 | 1179 | pkgActionItem *item = this; |
1180 | - while( item->next != NULL ) | |
1180 | + while( item->prev != NULL ) | |
1181 | 1181 | /* |
1182 | - * ...advance, to ensure we have located the very | |
1183 | - * last item in the schedule. | |
1182 | + * ...we want to get a reference to the first | |
1183 | + * item in the list. | |
1184 | 1184 | */ |
1185 | - item = item->next; | |
1185 | + item = item->prev; | |
1186 | 1186 | |
1187 | - /* Now, working back from end to beginning... | |
1187 | + /* Now, working through the list... | |
1188 | 1188 | */ |
1189 | 1189 | while( item != NULL ) |
1190 | 1190 | { |
1191 | 1191 | /* ...note items with any scheduled action... |
1192 | 1192 | */ |
1193 | - if( item->flags & ACTION_MASK ) | |
1194 | - /* | |
1195 | - * ...and count them... | |
1193 | + int action; | |
1194 | + if( (action = item->flags & ACTION_MASK) != 0 ) | |
1195 | + { | |
1196 | + /* ...and, when one is found... | |
1196 | 1197 | */ |
1197 | - ++count; | |
1198 | - | |
1199 | - /* ...then move on, to consider the preceding | |
1200 | - * entry, if any. | |
1198 | + if( action == classified ) | |
1199 | + { | |
1200 | + /* ...and it matches the classification in which | |
1201 | + * we are interested, then we retrieve the tarname | |
1202 | + * for the related package... | |
1203 | + */ | |
1204 | + pkgXmlNode *selected = (classified & ACTION_REMOVE) | |
1205 | + ? item->Selection( to_remove ) | |
1206 | + : item->Selection(); | |
1207 | + const char *notification = (selected != NULL) | |
1208 | + ? selected->GetPropVal( tarname_key, NULL ) | |
1209 | + : NULL; | |
1210 | + if( notification != NULL ) | |
1211 | + { | |
1212 | + /* ...and, provided it is valid, we append it to | |
1213 | + * the DMH driven dialogue in which the enumeration | |
1214 | + * is being reported... | |
1215 | + */ | |
1216 | + dmh_printf( "%s\n", notification ); | |
1217 | + /* | |
1218 | + * ...and include it in the accumulated count... | |
1219 | + */ | |
1220 | + ++count; | |
1221 | + } | |
1222 | + } | |
1223 | + else if( classified == 0 ) | |
1224 | + /* | |
1225 | + * ...otherwise, when we aren't interested in any | |
1226 | + * particular class of action, just count all those | |
1227 | + * which are found, regardless of classification. | |
1228 | + */ | |
1229 | + ++count; | |
1230 | + } | |
1231 | + /* ...then move on, to consider the next entry, if any. | |
1201 | 1232 | */ |
1202 | - item = item->prev; | |
1233 | + item = item->next; | |
1203 | 1234 | } |
1204 | 1235 | } |
1205 | 1236 | /* Ultimately, return the count of pending actions, |
@@ -1215,7 +1246,7 @@ long AppWindowMaker::OnClose() | ||
1215 | 1246 | * option for the termination request, so that the user |
1216 | 1247 | * has an opportunity to complete such actions. |
1217 | 1248 | */ |
1218 | - if( (pkgData->Schedule()->Unapplied() > 0) | |
1249 | + if( (pkgData->Schedule()->EnumeratePendingActions() > 0) | |
1219 | 1250 | && (MessageBox( AppWindow, |
1220 | 1251 | "You have marked changes which have not been applied;\n" |
1221 | 1252 | "these will be lost, if you quit without applying them.\n\n" |