-fpermissive to allow GCC to compile old C++
[oweals/cde.git] / cde / programs / dtmail / dtmail / SortCmd.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $TOG: SortCmd.C /main/8 1998/10/22 19:57:10 mgreess $ */
24 #include "SortCmd.hh"
25 #include <stdlib.h>
26 #include <unistd.h>
27 #include "RoamApp.h"
28 #include "MailMsg.h"
29 #include "MotifCmds.h"
30 #include "MsgHndArray.hh"
31
32 SortCmd::SortCmd( 
33     char *name, 
34     char *label,
35     int active, 
36     RoamMenuWindow *window,
37     enum sortBy sortstyle 
38     ) : ToggleButtonCmd ( name, label, active, FALSE, XmONE_OF_MANY_ROUND )
39 {
40         // initialize the internal state
41         _sortparent = window;
42         _sortstyle = sortstyle;
43         _sorter = new Sort ();
44 }
45
46 void
47 SortCmd::doit()
48 {
49         MsgScrollingList        *displayList;
50         DtMail::MailBox         *mbox;
51         int                     current_msg;
52
53         theRoamApp.busyAllWindows(GETMSG(DT_catd, 1, 219, "Sorting..."));
54
55         // Get Mailbox
56         mbox = _sortparent->mailbox();
57
58         // Get array of message handles from scrolling list
59         displayList = _sortparent->list();
60
61         MsgHndArray *selected_messages = displayList->selected();
62
63         // Sort array of message handles
64         current_msg = _sorter->sortMessages (displayList, mbox, _sortstyle);
65
66         // The array of message handles is sorted. Now we need to update
67         // the display preserving the state of the selected messages.
68         displayList->updateListItems(current_msg, FALSE, selected_messages);
69
70         delete selected_messages;
71
72
73         _sortparent->last_sorted_by(_sortstyle);
74         _sortparent->message_summary();
75
76         theRoamApp.unbusyAllWindows();
77 }