ide: License overview tool

git-svn-id: svn://ultimatepp.org/upp/trunk@9108 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-10-29 17:35:04 +00:00
parent 85195558c4
commit 8fa50ffc45
3 changed files with 36 additions and 0 deletions

View file

@ -760,6 +760,7 @@ public:
void SwapPackagesFiles();
void Times();
void Statistics();
void Licenses();
void Exit();
String GetOpposite();
void GoOpposite();

View file

@ -101,6 +101,7 @@ void Ide::File(Bar& menu)
menu.Add(AK_STATISTICS, THISBACK(Statistics))
.Help("Display various statistics");
menu.Add("Project licences..", THISBACK(Licenses));
menu.Add("Elapsed times..", THISBACK(Times));
menu.Add(AK_EXIT, THISBACK(Exit));

View file

@ -182,6 +182,40 @@ void sPut(String& qtf, ArrayMap<String, FileStat>& pfs, ArrayMap<String, FileSta
qtf << "}}&&";
}
void Ide::Licenses()
{
Progress pi;
const Workspace& wspc = IdeWorkspace();
pi.SetTotal(wspc.GetCount());
VectorMap<String, String> license_package;
for(int i = 0; i < wspc.GetCount(); i++) {
const Package& pk = wspc.GetPackage(i);
String n = wspc[i];
pi.SetText(n);
if(pi.StepCanceled()) return;
String l = LoadFile(SourcePath(n, "Copying"));
if(l.GetCount())
MergeWith(license_package.GetAdd(l), ", ", n);
}
if(license_package.GetCount() == 0) {
Exclamation("No license files ('Copying') have been found.");
return;
}
String qtf;
for(int i = 0; i < license_package.GetCount(); i++) {
bool m = license_package[i].Find(',') >= 0;
qtf << (m ? "Packages [* \1" : "Package [* \1")
<< license_package[i]
<< (m ? "\1] have" : "\1] has")
<< " following licence notice:&"
<< "{{@Y [C1 " << DeQtf(license_package.GetKey(i)) << "]}}&&";
}
WithStatLayout<TopWindow> dlg;
CtrlLayoutOK(dlg, "Licenses");
dlg.stat = qtf;
dlg.Sizeable().Zoomable();
dlg.Run();
}
void Ide::Statistics()
{