+2012-12-08 Keith Marshall <keithmarshall@users.sourceforge.net>
+
+ Implement "Discard" handler for GUI "Apply Changes" dialogue.
+
+ * src/pkgbase.h (pkgActionItem::Reset): New public method; declare it.
+ (pkgActionItem::Clear): New public method; declare two overloaded
+ variants, of which implement one inline.
+ (pkgXmlDocument::ClearScheduledActions): New public method; declare
+ and implement it inline.
+
+ * src/pkgtask.h (ACTION_DOWNLOAD_FAILED, ACTION_APPLY_FAILED): New
+ manifest bit-flag constants; define them. They provide a mechanism
+ for blocking the discard event in respect of failed actions.
+
+ * src/guixmld.cpp (pkgActionItem::Reset): Implement it.
+ (pkgActionItem::Clear): Implement second, out-of-line variant.
+ (ACTION_PRESERVE_FAILED): New local manifest bit-flag constant; define
+ it as an aggregate of ACTION_DOWNLOAD_FAILED and ACTION_APPLY_FAILED.
+ (AppWindowMaker::OnCommand) [IDD_REPO_APPLY]: Use them.
+
2012-12-07 Keith Marshall <keithmarshall@users.sourceforge.net>
Implement GUI dialogue for "Apply Changes" action approval.
return pkgData->Schedule()->EnumeratePendingActions( classified );
}
+pkgActionItem *pkgActionItem::Clear( pkgActionItem *schedule, unsigned long mask )
+# define ACTION_PRESERVE_FAILED (ACTION_DOWNLOAD_FAILED | ACTION_APPLY_FAILED)
+{
+ /* Method to remove those action items which have no attribute flags in common
+ * with the specified mask, from the schedule; return the residual schedule of
+ * items, if any, which were not removed. (Note that specifying a mask with a
+ * value of 0UL, which is the default, results in removal of all items).
+ */
+ pkgActionItem *residual = NULL;
+
+ /* Starting at the specified item, or the invoking class object item
+ * if no starting point is specified...
+ */
+ if( (schedule != NULL) || ((schedule = this) != NULL) )
+ {
+ /* ...and provided this starting point is not NULL, walk back to
+ * the first item in the associated task schedule...
+ */
+ while( schedule->prev != NULL ) schedule = schedule->prev;
+ while( schedule != NULL )
+ {
+ /* ...then, processing each scheduled task item in sequence, and
+ * keeping track of the next to be processed...
+ */
+ pkgActionItem *nextptr = schedule->next;
+ if( (schedule->flags & mask) == 0 )
+ /*
+ * ...delete each which doesn't match any masked attribute...
+ */
+ delete schedule;
+
+ else
+ /* ...otherwise add it to the residual schedule.
+ */
+ residual = schedule;
+
+ /* In either event, move on to the next item in sequence, if any.
+ */
+ schedule = nextptr;
+ }
+ }
+ /* Ultimately, return a pointer to the last item added to the residual
+ * schedule, or NULL if all items were deleted.
+ */
+ return residual;
+}
+
+void pkgActionItem::Reset
+( unsigned long set, unsigned long mask, pkgActionItem *schedule )
+{
+ /* A method to manipulate the control, error trapping, and state
+ * flags for all items in the specified schedule of actions.
+ *
+ * Starting at the specified item, or the invoking class object
+ * item if no starting point is specified...
+ */
+ if( (schedule != NULL) || ((schedule = this) != NULL) )
+ {
+ /* ...and provided this starting point is not NULL, walk back
+ * to the first item in the associated task schedule...
+ */
+ while( schedule->prev != NULL ) schedule = schedule->prev;
+ while( schedule != NULL )
+ {
+ /* ...then, processing each scheduled task item in sequence,
+ * update the flags according to the specified mask and new
+ * bits to be set...
+ */
+ schedule->flags = (flags & mask) | set;
+ /*
+ * ...before moving on to the next item in the sequence.
+ */
+ schedule = schedule->next;
+ }
+ }
+}
+
static int pkgActionCount( HWND dlg, int id, const char *fmt, int classified )
{
/* Helper function to itemise the currently scheduled actions
case IDM_REPO_APPLY:
/* Initiated when the user selects the "Apply Changes" option,
- * we present the user with a dialogue requesting confirmation
- * of intent to proceed...
+ * we first reset the error trapping and download request state
+ * for all scheduled actions, then we present the user with a
+ * dialogue requesting confirmation of approval to proceed.
*/
+ pkgData->Schedule()->Reset( ACTION_DOWNLOAD, ~ACTION_PRESERVE_FAILED );
switch( DialogueResponse( IDD_APPLY_APPROVE, pkgApplyApproved ) )
{
- /* ...then, of the three possible return conditions, we simply
- * ignore the "Defer" option, (since it requires no action), but
- * we must explicitly handle the "Apply" and "Discard" options.
+ /* Of the three possible responses, we simply ignore the "Defer"
+ * option, (since it requires no action), but we must explicitly
+ * handle the "Apply" and "Discard" options.
*/
case ID_APPLY:
/* When "Apply" confirmation is forthcoming, we proceed to
* result of processing the "Apply" selection, we clear the
* actions schedule, remove all marker icons, and refresh
* the package list to reflect current status.
- *
- * FIXME: the pkgXmlDocument::ClearScheduledActions() method
- * has yet to be implemented.
*/
pkgListViewMaker pkglist( PackageListView );
-// pkgData->ClearScheduledActions( PRESERVE_FAILED );
pkglist.UpdateListView();
/* Updating the list view clears pending action marks from
* request relating to a failed action; restore marked state
* for such residual actions.
*/
- pkglist.MarkScheduledActions( pkgData->Schedule() );
+ if( pkgData->ClearScheduledActions( ACTION_PRESERVE_FAILED ) != NULL )
+ pkglist.MarkScheduledActions( pkgData->Schedule() );
/* Clearing the schedule of actions may also affect the
* validity of menu options; update accordingly.
*/
void Execute();
+ /* Method to manipulate error trapping, control, and state
+ * flags for the schedule of actions.
+ */
+ void Reset( unsigned long, unsigned long = ~0UL, pkgActionItem * = NULL );
+
+ /* Method to filter actions from an action list: the default is to
+ * clear ALL entries; specify a value of ACTION_MASK for the second
+ * argument, to filter out entries with no assigned action.
+ */
+ pkgActionItem *Clear( pkgActionItem * = NULL, unsigned long = 0UL );
+ pkgActionItem *Clear( unsigned long mask ){ return Clear( this, mask ); }
+
/* Destructor...
*/
~pkgActionItem();
*/
inline void ExecuteActions(){ actions->Execute(); }
+ /* Method to clear the list of scheduled actions.
+ */
+ inline pkgActionItem* ClearScheduledActions( unsigned long mask = 0UL )
+ {
+ return actions = actions->Clear( mask );
+ }
+
/* Methods to retrieve and optionally extract source archives
* for a collection of dependent packages.
*/