2 * Copyright (c) 2002 Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <robertc@hotmail.com>
16 #include "PickCategoryLine.h"
17 #include "package_db.h"
20 #include "package_meta.h"
25 PickCategoryLine::get_text (int col_num
) const
27 if (col_num
== pkgname_col
)
30 s
<< cat_tree
->category().first
;
32 s
<< " (" << pkgcount
<< ")";
33 return string_to_wstring(s
.str());
35 else if (col_num
== new_col
)
37 return LoadStringW(packagemeta::action_caption (cat_tree
->action()));
43 PickCategoryLine::do_action(int col_num
, int action_id
)
45 if (col_num
== pkgname_col
)
47 cat_tree
->collapsed() = ! cat_tree
->collapsed();
50 else if (col_num
== new_col
)
52 theView
.GetParent ()->SetBusy ();
53 int u
= cat_tree
->do_action((packagemeta::_actions
)(action_id
), theView
.deftrust
);
54 theView
.GetParent ()->ClearBusy ();
61 PickCategoryLine::do_default_action(int col_num
)
67 PickCategoryLine::get_actions(int col
) const
69 ActionList
*al
= new ActionList();
70 packagemeta::_actions current_default
= cat_tree
->action();
72 al
->add(IDS_ACTION_DEFAULT
, (int)packagemeta::NoChange_action
, (current_default
== packagemeta::NoChange_action
), TRUE
);
73 al
->add(IDS_ACTION_INSTALL
, (int)packagemeta::Install_action
, (current_default
== packagemeta::Install_action
), TRUE
);
74 al
->add(packagedb::task
== PackageDB_Install
? IDS_ACTION_REINSTALL
: IDS_ACTION_RETRIEVE
,
75 (int)packagemeta::Reinstall_action
, (current_default
== packagemeta::Reinstall_action
), TRUE
);
76 al
->add(IDS_ACTION_UNINSTALL
, (int)packagemeta::Uninstall_action
, (current_default
== packagemeta::Uninstall_action
), TRUE
);
82 PickCategoryLine::get_state() const
84 return cat_tree
->collapsed() ? State::collapsed
: State::expanded
;
88 PickCategoryLine::get_indent() const
94 PickCategoryLine::get_tooltip(int col_num
) const
100 PickCategoryLine::map_key_to_action(WORD vkey
, int *col_num
, int *action_id
) const
105 *col_num
= pkgname_col
;