diff --git a/bazaar/Functions4U/Functions4U.cpp b/bazaar/Functions4U/Functions4U.cpp index 613d44f5d..1f4217338 100644 --- a/bazaar/Functions4U/Functions4U.cpp +++ b/bazaar/Functions4U/Functions4U.cpp @@ -358,7 +358,7 @@ bool SetReadOnly(const char *path, bool readOnly) { return SetReadOnly(path, readOnly, readOnly, readOnly); } -bool SetReadOnly(const char *path, bool usr, bool , bool ) { +bool SetReadOnly(const char *path, bool usr, bool grp, bool oth) { #if defined(PLATFORM_WIN32) || defined (PLATFORM_WIN64) DWORD attr = GetFileAttributesW(ToSystemCharsetW(path)); @@ -2597,7 +2597,7 @@ Dl::Dl() { Dl::~Dl() { if (hinstLib) if (dlclose(hinstLib) == 0) - throw Exc(t_("Dl cannot be released")); + ; // Dl cannot be released } bool Dl::Load(const String &fileDll) { diff --git a/bazaar/Functions4U/Functions4U.h b/bazaar/Functions4U/Functions4U.h index 6ae9fe68f..e799fa160 100644 --- a/bazaar/Functions4U/Functions4U.h +++ b/bazaar/Functions4U/Functions4U.h @@ -118,7 +118,7 @@ struct FileData : Moveable { String ToString() const { return Format("%s %0n", fileName, length); } FileData(bool _isFolder, String _fileName, String _relFilename, int64 _length, - struct Upp::Time _t, uint64 _id) : isFolder(_isFolder), fileName(_fileName), + struct Upp::Time _t, int64 _id) : isFolder(_isFolder), fileName(_fileName), relFilename(_relFilename), length(_length), t(_t), id(_id) {} FileData() {} }; @@ -671,7 +671,20 @@ void Shuffle(C &data, int randomSeed = Null) { } template -bool Equal(const T& a, const T& b, const T& ratio) { +inline T TruncDecimals(T num, int decimals) { + long double val = num*10*decimals; + long int ival = static_cast(val); + val = ival; + return static_cast(val/(10*decimals)); +} + +template +inline String RoundDecimals(T num, int decimals) { + return FormatDouble(num, decimals); +} + +template +bool EqualRatio(const T& a, const T& b, const T& ratio) { if (a == 0) return b <= ratio; if (b == 0) @@ -693,14 +706,13 @@ int FindAdd(Range& r, const V& value, int from = 0) { template void FindAddRatio(Range& r, const V& value, const V& ratio, int from = 0) { for(int i = from; i < r.GetCount(); i++) - if(Equal(r[i], value, ratio)) + if(EqualRatio(r[i], value, ratio)) return; r.Add(value); } template -int FindIndexDelta(const Range& r, const V& value, const V& delta, int from = 0) -{ +int FindIndexDelta(const Range& r, const V& value, const V& delta, int from = 0) { for(int i = from; i < r.GetCount(); i++) if(abs(r[i] - value) <= delta) return i; @@ -708,10 +720,45 @@ int FindIndexDelta(const Range& r, const V& value, const V& delta, int from = 0) } template -int FindIndexRatio(const Range& r, const V& value, const V& ratio, int from = 0) -{ +int FindIndexRoundDecimals(const Range& r, const V& value, int numDecimals, int from = 0) { + String svalue = RoundDecimals(value, numDecimals); for(int i = from; i < r.GetCount(); i++) { - if (Equal(r[i], value, ratio)) + String s = RoundDecimals(r[i], numDecimals); + if(s == svalue) + return i; + } + return -1; +} + +template +int FindIndexTruncDecimals(const Range& r, const V& value, int numDecimals, int from = 0) { + V svalue = TruncDecimals(value, numDecimals); + for(int i = from; i < r.GetCount(); i++) { + V s = TruncDecimals(r[i], numDecimals); + if(s == svalue) + return i; + } + return -1; +} + +template +int FindIndexCloser(const Range& r, const V& value, int from = 0) { + int minId = -1; + V minDiff = FLT_MAX; + for(int i = from; i < r.GetCount(); i++) { + V diff = abs(value - r[i]); + if (diff < minDiff) { + minDiff = diff; + minId = i; + } + } + return minId; +} + +template +int FindIndexRatio(const Range& r, const V& value, const V& ratio, int from = 0) { + for(int i = from; i < r.GetCount(); i++) { + if (EqualRatio(r[i], value, ratio)) return i; } return -1; diff --git a/bazaar/Functions4U/Functions4U.t b/bazaar/Functions4U/Functions4U.t index 8f27d51fe..afc16f147 100644 --- a/bazaar/Functions4U/Functions4U.t +++ b/bazaar/Functions4U/Functions4U.t @@ -150,6 +150,42 @@ esES("Imprimiendo documento") euES("") frFR("") +T_("Select all") +caES("Seleccionar tot") +esES("Seleccionar todo") +euES("") +frFR("") + +T_("Select all rows") +caES("") +esES("") +euES("") +frFR("") + +T_("No row selected") +caES("") +esES("") +euES("") +frFR("") + +T_("Selected %d rows") +caES("") +esES("") +euES("") +frFR("") + +T_("Copy") +caES("Copiar") +esES("Copiar") +euES("") +frFR("") + +T_("Copy selected rows to clipboard") +caES("") +esES("") +euES("") +frFR("") + // GatherTpp.cpp diff --git a/bazaar/Functions4U/Functions4U_Gui.cpp b/bazaar/Functions4U/Functions4U_Gui.cpp index b1dde9e55..846b9f2ee 100644 --- a/bazaar/Functions4U/Functions4U_Gui.cpp +++ b/bazaar/Functions4U/Functions4U_Gui.cpp @@ -207,7 +207,7 @@ void ArrayCtrlWhenBar(Bar &menu, ArrayCtrl &array) { } } -void ArrayCtrlRowCopy(ArrayCtrl &array, bool header) { +void ArrayCtrlRowCopy(const ArrayCtrl &array, bool header) { array.SetClipboard(true, header); } @@ -215,4 +215,13 @@ void ArrayCtrlRowSelect(ArrayCtrl &array) { array.Select(0, array.GetCount(), true); } +Vector ArrayCtrlGetSelected(const ArrayCtrl &array) { + Vector selected; + for (int r = 0; r < array.GetCount(); ++r) { + if (array.IsSel(r)) + selected << r; + } + return selected; +} + #endif \ No newline at end of file diff --git a/bazaar/Functions4U/Functions4U_Gui.h b/bazaar/Functions4U/Functions4U_Gui.h index 2a1c4f698..5fe16057b 100644 --- a/bazaar/Functions4U/Functions4U_Gui.h +++ b/bazaar/Functions4U/Functions4U_Gui.h @@ -107,7 +107,8 @@ private: }; void ArrayCtrlWhenBar(Bar &menu, ArrayCtrl &array); -void ArrayCtrlRowCopy(ArrayCtrl &array, bool header); +void ArrayCtrlRowCopy(const ArrayCtrl &array, bool header); void ArrayCtrlRowSelect(ArrayCtrl &array); - +Vector ArrayCtrlGetSelected(const ArrayCtrl &array); + #endif diff --git a/bazaar/Functions4U/GatherTpp.cpp b/bazaar/Functions4U/GatherTpp.cpp index 654f9f6db..23da2081a 100644 --- a/bazaar/Functions4U/GatherTpp.cpp +++ b/bazaar/Functions4U/GatherTpp.cpp @@ -60,8 +60,8 @@ struct ScanTopicIterator : RichText::Iterator { String link; StaticCriticalSection reflink_lock; - ScanTopicIterator(VectorMap *reflink) : reflink(reflink) {}; - virtual bool operator()(int pos, const RichPara& para) + ScanTopicIterator(VectorMap *_reflink) : reflink(_reflink) {}; + virtual bool operator()(int , const RichPara& para) { if(!IsNull(para.format.label)) reflink->Add(para.format.label, link); @@ -102,8 +102,8 @@ struct GatherLinkIterator : RichText::Iterator { VectorMap *reflink; Index link; - GatherLinkIterator(VectorMap *reflink) : reflink(reflink) {}; - virtual bool operator()(int pos, const RichPara& para) + GatherLinkIterator(VectorMap *_reflink) : reflink(_reflink) {}; + virtual bool operator()(int , const RichPara& para) { for(int i = 0; i < para.GetCount(); i++) { String l = para[i].format.link; @@ -175,11 +175,11 @@ bool EndsWith(const String &source, const String &pattern) } String GatherTpp::QtfAsHtml(const char *qtf, Index& css, - const VectorMap& links, - const VectorMap& labels, + const VectorMap& _links, + const VectorMap& _labels, const String& outdir, const String& fn) { - return EncodeHtml(ParseQTF(qtf), css, links, labels, outdir, fn, Zoom(8, 40), escape, 40); + return EncodeHtml(ParseQTF(qtf), css, _links, _labels, outdir, fn, Zoom(8, 40), escape, 40); } String GetText(const char *s) @@ -187,7 +187,7 @@ String GetText(const char *s) return GetTopic(s).text; } -void GatherTpp::ExportPage(int i, String htmlFolder, String keywords) +void GatherTpp::ExportPage(int i, String htmlFolder, String _keywords) { Index css; String path = links.GetKey(i); @@ -244,7 +244,7 @@ void GatherTpp::ExportPage(int i, String htmlFolder, String keywords) "a.l2:hover { color:#BC0624; }\n" "a.l2:active { color:#BC0024; }\n", "" + "CONTENT=\"" + _keywords + "\">" "" ) .BgColor(bg) @@ -291,7 +291,7 @@ String GetTopicLanguage(const String &topic) { return topic.Mid(pos+1, 5); } -String GatherTpp::GatherTopics(const char *topic, String& title) +String GatherTpp::GatherTopics(const char *topic, String& _title) { static StaticCriticalSection mapl; int q; @@ -299,15 +299,15 @@ String GatherTpp::GatherTopics(const char *topic, String& title) q = tt.Find(topic); if(q < 0) { Topic p = ReadTopic(LoadFile(TopicFileName(topic))); - title = p.title; + _title = p.title; String t = p; if(IsNull(t)) { String topicEng = ChangeTopicLanguage(topic, LNG_('E','N','U','S')); p = ReadTopic(LoadFile(TopicFileName(topicEng))); - String tt = p; - if(IsNull(tt)) + String _tt = p; + if(IsNull(_tt)) return "index.html"; - title = p.title; + _title = p.title; p.title += " (translated)"; String help = "topic://uppweb/www/contribweb$" + GetTopicLanguage(topic); p.text = String("{{1f1t0/50b0/50@(240.240.240) [= '0' && c <= '9'); } diff --git a/bazaar/Functions4U/StaticPlugin.cpp b/bazaar/Functions4U/StaticPlugin.cpp index 13c36c116..de3b1ea1d 100644 --- a/bazaar/Functions4U/StaticPlugin.cpp +++ b/bazaar/Functions4U/StaticPlugin.cpp @@ -2,7 +2,6 @@ #include "StaticPlugin.h" -//NAMESPACE_UPP using namespace Upp; Array& StaticPlugin::Plugins() { diff --git a/bazaar/Functions4U/SvgColors.cpp b/bazaar/Functions4U/SvgColors.cpp index bfd1f15d0..0727bfd7a 100644 --- a/bazaar/Functions4U/SvgColors.cpp +++ b/bazaar/Functions4U/SvgColors.cpp @@ -151,7 +151,7 @@ Color GetSvgColor(const char *color) { {"whitesmoke", 245, 245, 245}, {"yellow", 255, 255, 0}, {"yellowgreen", 154, 205, 50}, - {""}}; + {"", 0, 0, 0}}; for (int i = 0; colors[i].name[0] != '\0'; ++i) // Naive algorithm to get the color if (strcmp(color, colors[i].name) == 0)