ide: Package selection improved

git-svn-id: svn://ultimatepp.org/upp/trunk@15669 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2021-01-14 14:28:16 +00:00
parent f3bc80a62f
commit d4fa4a125c
3 changed files with 32 additions and 25 deletions

View file

@ -195,7 +195,7 @@ SelectPackageDlg::SelectPackageDlg(const char *title, bool selectvars_, bool mai
newu <<= THISBACK(OnNew);
filter <<= THISBACK(OnFilter);
filter <<= main ? MAIN|NEST : 0;
filter <<= main ? MAIN|NEST : NONMAIN;
progress.Hide();
brief <<= THISBACK(SyncBrief);
search.NullText("Search (Ctrl+K)", StdFont().Italic(), SColorDisabled());
@ -231,6 +231,7 @@ void SelectPackageDlg::SyncFilter()
filter.Add(NEST|i, "All packages of " + fn);
}
filter.Add(MAIN, "All main packages");
filter.Add(NONMAIN, "All non-main packages");
filter.Add(0, "All packages");
if(filter.HasKey(v))
filter <<= v;
@ -367,7 +368,8 @@ void SelectPackageDlg::OnOK()
int f = ~filter;
String n = GetCurrentName();
if(n.GetCount() && pkg.Load(PackagePath(n)) &&
(!(f & MAIN) || pkg.config.GetCount())) {
(!(f & MAIN) || pkg.config.GetCount()) &&
(!(f & NONMAIN) || !pkg.config.GetCount())) {
loading = false;
finished = true;
AcceptBreak(IDOK);
@ -390,7 +392,7 @@ void SelectPackageDlg::OnBase()
{
if(!finished && !canceled) {
SyncFilter();
filter.GoBegin();
filter <<= (int)~filter & ~NEST_MASK;
Load();
}
}
@ -571,6 +573,7 @@ void SelectPackageDlg::SyncList(const String& find)
if(!nest.IsUnlinked(i) &&
d.ispackage &&
(!(f & MAIN) || d.main) &&
(!(f & NONMAIN) || !d.main) &&
ToUpper(d.package + d.description + d.nest).Find(s) >= 0 &&
added.Find(d.package) < 0) {
packages.Add() = d;

View file

@ -227,7 +227,7 @@ struct SelectPackageDlg : public WithSelectPackageLayout<TopWindow> {
void MovePackage(bool copy);
enum {
MAIN = 0x1000, NEST = 0x2000, UPPHUB = 0x4000, NEST_MASK = 0xfff
MAIN = 0x1000, NEST = 0x2000, UPPHUB = 0x4000, NONMAIN = 0x8000, NEST_MASK = 0xfff
};
};

View file

@ -27,8 +27,11 @@ struct UppHubDlg : WithUppHubLayout<TopWindow> {
void Install(bool noprompt = false);
void Uninstall(bool noprompt = false);
void Reinstall();
void Install(const Index<int>& ii);
void Install(const Index<String>& ii);
void SyncList();
UppHubNest *Get(const String& name) { return upv.FindPtr(name); }
UppHubNest *Current() { return Get(list.GetKey()); }
UppHubDlg();
};
@ -85,10 +88,11 @@ UppHubDlg::UppHubDlg()
void UppHubDlg::Readme()
{
String link = list.Get("README");
String s = HttpRequest(link).RequestTimeout(3000).Execute();
UppHubNest *n = Current();
if(!n) return;
String s = HttpRequest(n->readme).RequestTimeout(3000).Execute();
if(s.GetCount()) {
if(link.EndsWith(".qtf"))
if(n->readme.EndsWith(".qtf"))
PromptOK(s);
else
PromptOK("\1" + s);
@ -205,21 +209,26 @@ void UppHubDlg::Load()
pi.Close();
}
void UppHubDlg::Install(const Index<int>& ii)
void UppHubDlg::Install(const Index<String>& ii_)
{
Index<String> ii = clone(ii_);
for(int i = 0; i < ii.GetCount(); i++)
if(UppHubNest *n = Get(ii[i]))
for(String s : n->uses)
ii.FindAdd(s);
UrepoConsole console;
if(ii.GetCount()) {
for(int i : ii) {
String n = list.Get(i, 0);
if(n.GetCount()) {
for(String ns : ii) {
UppHubNest *n = Get(ns);
if(n) {
String cmd = "git clone ";
String repo = list.Get(i, "REPO");
String repo2, branch;
if(SplitTo(repo, ' ', repo2, branch))
if(SplitTo(n->repo, ' ', repo2, branch))
cmd << "-b " + branch + " " + repo2;
else
cmd << repo;
cmd << ' ' << GetHubDir() << '/' << n;
cmd << n->repo;
cmd << ' ' << GetHubDir() << '/' << n->name;
console.System(cmd);
}
}
@ -232,9 +241,7 @@ void UppHubDlg::Install(const Index<int>& ii)
void UppHubDlg::Install(bool noprompt)
{
if(list.IsCursor() && (noprompt || PromptYesNo("Install " + ~list.GetKey() + "?"))) {
Index<int> h;
h << list.GetCursor();
Install(h);
Install(Index<String>{ ~list.GetKey() });
SyncList();
}
}
@ -282,14 +289,11 @@ void UppHubAuto(const String& main)
UppHubDlg dlg;
dlg.Load();
Index<int> found;
Index<String> found;
for(const UppHubNest& n : dlg.upv)
for(const String& p : n.packages)
if(missing.Find(p) >= 0) {
int i = dlg.list.Find(n.name);
if(i >= 0)
found.FindAdd(i);
}
if(missing.Find(p) >= 0)
found.FindAdd(n.name);
if(found.GetCount() == missing.GetCount() && missing != pmissing &&
(noprompt || PromptYesNo("Missing packages were found in UppHub. Install?"))) {