base-39b61c737a6f38aaf4bb59e8eb6f8c438e48c06e-actor.patch 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881
  1. From 39b61c737a6f38aaf4bb59e8eb6f8c438e48c06e Mon Sep 17 00:00:00 2001
  2. From: matheuter <[email protected]>
  3. Date: Thu, 20 Apr 2023 16:39:20 +0800
  4. Subject: [PATCH 1/4] add actor to plugin_v2
  5. ---
  6. src/actor.h | 129 +++++
  7. src/actorprocessor.cpp | 67 +++
  8. src/actorprocessor.h | 67 +++
  9. src/cceditor/ccnotepad.cpp | 73 ++-
  10. src/cceditor/ccnotepad.h | 9 +-
  11. src/functiontraits.h | 81 +++
  12. src/plugin.h | 2 +
  13. src/plugin/CMakeLists.txt | 16 +-
  14. src/plugin/filetreeview/CMakeLists.txt | 74 +++
  15. src/plugin/filetreeview/abstractfile.cpp | 6 +
  16. src/plugin/filetreeview/abstractfile.h | 11 +
  17. src/plugin/filetreeview/actor.h | 120 ++++
  18. src/plugin/filetreeview/actorprocessor.cpp | 67 +++
  19. src/plugin/filetreeview/actorprocessor.h | 66 +++
  20. src/plugin/filetreeview/filesystemmodel.cpp | 526 ++++++++++++++++++
  21. src/plugin/filetreeview/filesystemmodel.h | 193 +++++++
  22. src/plugin/filetreeview/filetreeview.cpp | 195 +++++++
  23. src/plugin/filetreeview/filetreeview.h | 73 +++
  24. .../filetreeview/filetreeviewexport.cpp | 77 +++
  25. .../filetreeview/filetreeviewplugin.cpp | 121 ++++
  26. src/plugin/filetreeview/filetreeviewplugin.h | 40 ++
  27. 21 files changed, 2001 insertions(+), 12 deletions(-)
  28. create mode 100644 src/actor.h
  29. create mode 100644 src/actorprocessor.cpp
  30. create mode 100644 src/actorprocessor.h
  31. create mode 100644 src/functiontraits.h
  32. create mode 100644 src/plugin/filetreeview/CMakeLists.txt
  33. create mode 100644 src/plugin/filetreeview/abstractfile.cpp
  34. create mode 100644 src/plugin/filetreeview/abstractfile.h
  35. create mode 100644 src/plugin/filetreeview/actor.h
  36. create mode 100644 src/plugin/filetreeview/actorprocessor.cpp
  37. create mode 100644 src/plugin/filetreeview/actorprocessor.h
  38. create mode 100644 src/plugin/filetreeview/filesystemmodel.cpp
  39. create mode 100644 src/plugin/filetreeview/filesystemmodel.h
  40. create mode 100644 src/plugin/filetreeview/filetreeview.cpp
  41. create mode 100644 src/plugin/filetreeview/filetreeview.h
  42. create mode 100644 src/plugin/filetreeview/filetreeviewexport.cpp
  43. create mode 100644 src/plugin/filetreeview/filetreeviewplugin.cpp
  44. create mode 100644 src/plugin/filetreeview/filetreeviewplugin.h
  45. diff --git a/src/actor.h b/src/actor.h
  46. new file mode 100644
  47. index 0000000..86378d0
  48. --- /dev/null
  49. +++ b/src/actor.h
  50. @@ -0,0 +1,129 @@
  51. +#pragma once
  52. +#include <cstdint>
  53. +#include <string>
  54. +#include <memory>
  55. +#include <tuple>
  56. +#include <functional>
  57. +
  58. +#include "functiontraits.h"
  59. +
  60. +/**
  61. + * @brief Actor class, which encapsulates the event model
  62. + * @note enable_shared_from_this allows us to get safe Pointers internally
  63. + */
  64. +class Actor : public std::enable_shared_from_this<Actor>
  65. +{
  66. +public:
  67. + using Ptr = std::shared_ptr<Actor>;
  68. + using FunctionWapper = std::function<void(void*, void*)>;
  69. +
  70. +public:
  71. + Actor(){}
  72. + ~Actor(){}
  73. +
  74. + /**
  75. + * @brief Register the callback function and construct the anonymous function with std::bind
  76. + */
  77. + template<typename Function>
  78. + void operator+=(Function&& function_any) noexcept
  79. + {
  80. + m_invokeFunctionWapper = { std::bind(&invoker<Function>::apply, function_any, std::placeholders::_1, std::placeholders::_2) };
  81. + }
  82. +
  83. + /**
  84. + * @brief Register the callback function and construct the anonymous function with std::bind
  85. + */
  86. + template<typename Function>
  87. + void registerFunction(Function&& function_any) noexcept
  88. + {
  89. + m_invokeFunctionWapper = { std::bind(&invoker<Function>::apply, function_any, std::placeholders::_1, std::placeholders::_2) };
  90. + }
  91. +
  92. + /**
  93. + * @brief Register the callback function and construct the anonymous function with std::bind
  94. + */
  95. + template<typename ... Args>
  96. + void invoke(Args&& ... args) const noexcept
  97. + {
  98. + auto args_tuple = std::make_tuple(std::forward<Args>(args)...);
  99. + m_invokeFunctionWapper(&args_tuple, nullptr);
  100. + }
  101. +
  102. + /**
  103. + * @brief Register the callback function and construct the anonymous function with std::bind
  104. + */
  105. + template<typename R, typename ... Args>
  106. + R invoke(Args&& ...args) const
  107. + {
  108. + using tuple_args_type = std::tuple<Args...>;
  109. + char data[sizeof(tuple_args_type)];
  110. + std::tuple<Args...>* tuples_pointer = new (data) tuple_args_type;
  111. +
  112. + *tuples_pointer = std::make_tuple(std::forward<Args>(args)...);
  113. +
  114. + R return_value;
  115. + m_invokeFunctionWapper(tuples_pointer, &return_value);
  116. + return return_value;
  117. + }
  118. +
  119. + Ptr getSharedPtr()
  120. + {
  121. + return shared_from_this();
  122. + }
  123. +
  124. +public:
  125. + /**
  126. + * @brief This struct encapsulates a function,
  127. + * essentially storing the return value and parameters in two variables
  128. + * which can unify the way the function is stored.
  129. + */
  130. + template<typename Function>
  131. + struct invoker
  132. + {
  133. + /**
  134. + * @brief
  135. + */
  136. + static inline void apply(const Function& func, void* bl, void* result)
  137. + {
  138. + using tuple_type = typename function_traits<Function>::tuple_type;
  139. + const tuple_type* tp = static_cast<tuple_type*>(bl);
  140. + call(func, *tp, result);
  141. + }
  142. +
  143. + /**
  144. + * @brief
  145. + */
  146. + template<typename F, typename ... Args>
  147. + static typename std::enable_if<std::is_void<typename std::result_of<F(Args...)>::type>::value>::type
  148. + call(const F& f, const std::tuple<Args...>& tp, void*)
  149. + {
  150. + call_helper(f, std::make_index_sequence<sizeof... (Args)>{}, tp);
  151. + }
  152. +
  153. + /**
  154. + * @brief
  155. + */
  156. + template<typename F, typename ... Args>
  157. + static typename std::enable_if<!std::is_void<typename std::result_of<F(Args...)>::type>::value>::type
  158. + call(const F& f, const std::tuple<Args...>& tp, void* result)
  159. + {
  160. + auto r = call_helper(f, std::make_index_sequence<sizeof... (Args)>{}, tp);
  161. + *(decltype(r)*)result = r;
  162. + }
  163. +
  164. + /**
  165. + * @brief
  166. + */
  167. + template<typename F, size_t... I, typename ... Args>
  168. + static auto call_helper(const F& f, const std::index_sequence<I...>& h, const std::tuple<Args...>& tup)
  169. + {
  170. + return f(std::get<I>(tup)...);
  171. + }
  172. + };
  173. +private:
  174. + /**
  175. + * @note m_invokeFunctions is an anonymous lamba expression that encapsulates a function
  176. + * Functions include Lamba expressions, member functions, funtor, ordinary functions, and function Pointers
  177. + */
  178. + FunctionWapper m_invokeFunctionWapper;
  179. +};
  180. diff --git a/src/actorprocessor.cpp b/src/actorprocessor.cpp
  181. new file mode 100644
  182. index 0000000..099d1f6
  183. --- /dev/null
  184. +++ b/src/actorprocessor.cpp
  185. @@ -0,0 +1,67 @@
  186. +#include "actorprocessor.h"
  187. +ActorProcessor::ActorProcessor():
  188. + m_actorMap(new std::unordered_map<std::string, Actor*>)
  189. +{}
  190. +
  191. +/**
  192. + * @brief
  193. + */
  194. +ActorProcessor::~ActorProcessor()
  195. +{
  196. + for (auto& item : (*m_actorMap))
  197. + {
  198. + if(item.second != nullptr)
  199. + delete item.second;
  200. + }
  201. + if (m_actorMap)
  202. + delete m_actorMap;
  203. +}
  204. +
  205. +/**
  206. + * @brief
  207. + */
  208. +void ActorProcessor::registerActor(const std::string &route, Actor *actor)
  209. +{
  210. + m_actorMap->insert(std::make_pair(route,actor));
  211. +}
  212. +
  213. +/**
  214. + * @brief
  215. + */
  216. +void ActorProcessor::removeActor(const std::string &route)
  217. +{
  218. + auto iter = (*m_actorMap).find(route);
  219. + if(iter != m_actorMap->end())
  220. + {
  221. + m_actorMap->erase(route);
  222. + delete iter->second;
  223. + }
  224. +}
  225. +
  226. +/**
  227. + * @brief
  228. + */
  229. +Actor *ActorProcessor::findActor(const std::string &route)
  230. +{
  231. + auto iter = (*m_actorMap).find(route);
  232. + if(iter != m_actorMap->end())
  233. + {
  234. + return (*m_actorMap)[route];
  235. + }
  236. + return nullptr;
  237. +}
  238. +
  239. +/**
  240. + * @brief
  241. + */
  242. +bool ActorProcessor::resetActor(const std::string &route, Actor *actor)
  243. +{
  244. + auto iter = (*m_actorMap).find(route);
  245. + if(iter != m_actorMap->end())
  246. + {
  247. + m_actorMap->erase(route);
  248. + delete iter->second;
  249. + return true;
  250. + }
  251. + return false;
  252. +}
  253. diff --git a/src/actorprocessor.h b/src/actorprocessor.h
  254. new file mode 100644
  255. index 0000000..9026909
  256. --- /dev/null
  257. +++ b/src/actorprocessor.h
  258. @@ -0,0 +1,67 @@
  259. +#ifndef EVENTPROCESSOR_H
  260. +#define EVENTPROCESSOR_H
  261. +
  262. +#include <string>
  263. +#include <functional>
  264. +#include <map>
  265. +#include <iostream>
  266. +#include <unordered_map>
  267. +#include "actor.h"
  268. +
  269. +class ActorProcessor
  270. +{
  271. +public:
  272. + ActorProcessor();
  273. + ~ActorProcessor();
  274. +public:
  275. +
  276. + /**
  277. + * @brief Register the callback function and construct the anonymous function with std::bind
  278. + */
  279. + template<typename ... Args>
  280. + void invoke(const std::string& route,Args&& ... args) const noexcept
  281. + {
  282. + if (m_actorMap->find(route) != m_actorMap->end())
  283. + (*m_actorMap)[route]->invoke(std::forward<Args>(args)...);
  284. + }
  285. +
  286. + /**
  287. + * @brief Register the callback function and construct the anonymous function with std::bind
  288. + */
  289. + template<typename R, typename ... Args>
  290. + R invoke(const std::string& route,Args&& ...args) const
  291. + {
  292. + if (m_actorMap->find(route) != m_actorMap->end())
  293. + return (*m_actorMap)[route]->invoke(std::forward<Args>(args)...);
  294. + return nullptr;
  295. + }
  296. +
  297. + /**
  298. + * @brief 注册一个actor,其中route是唯一的
  299. + */
  300. + void registerActor(const std::string& route, Actor*actor);
  301. +
  302. + /**
  303. + * @brief 删除一个actor
  304. + */
  305. + void removeActor(const std::string& route);
  306. +
  307. + /**
  308. + * @brief 查找一个actor, 返回其指针
  309. + */
  310. + Actor* findActor(const std::string& route);
  311. +
  312. + /**
  313. + * @brief 重置一个actor,注意原有的actor会被删除
  314. + */
  315. + bool resetActor(const std::string& route,Actor*actor);
  316. +
  317. +private:
  318. + std::unordered_map<std::string, Actor*>* m_actorMap;
  319. +private:
  320. + // not allow copy constroct
  321. + ActorProcessor(ActorProcessor&&)=delete;
  322. + ActorProcessor& operator=(const ActorProcessor&)=delete;
  323. +};
  324. +
  325. +#endif // EVENTPROCESSOR_H
  326. diff --git a/src/cceditor/ccnotepad.cpp b/src/cceditor/ccnotepad.cpp
  327. index eb3ad4f..b74f1ca 100755
  328. --- a/src/cceditor/ccnotepad.cpp
  329. +++ b/src/cceditor/ccnotepad.cpp
  330. @@ -32,6 +32,8 @@
  331. #include "pluginmgr.h"
  332. #include "plugin.h"
  333. #include "pluginGl.h"
  334. +#include "actor.h"
  335. +#include "actorprocessor.h"
  336. #endif
  337. #ifdef Q_OS_WIN
  338. @@ -1211,6 +1213,10 @@ CCNotePad::CCNotePad(bool isMainWindows, QWidget *parent)
  339. restoreGeometry(lastGeo);
  340. }
  341. #endif
  342. +
  343. +#ifdef NO_PLUGIN
  344. + processor = new ActorProcessor();
  345. +#endif
  346. }
  347. CCNotePad::~CCNotePad()
  348. @@ -1748,9 +1754,10 @@ void CCNotePad::onPlugFound(NDD_PROC_DATA& procData, QMenu* pUserData)
  349. {
  350. QAction* pAction = new QAction(procData.m_strPlugName, pMenu);
  351. pMenu->addAction(pAction);
  352. - pAction->setText(procData.m_strPlugName);
  353. - pAction->setData(procData.m_strFilePath);
  354. - connect(pAction, &QAction::triggered, this, &CCNotePad::onPlugWork);
  355. + pAction->setText(procData.m_strPlugName);
  356. + pAction->setData(procData.m_strFilePath);
  357. + connect(pAction, &QAction::triggered, this, &CCNotePad::onPlugWork);
  358. + connect(pAction, &QAction::triggered, this, &CCNotePad::onPlugWorkV2);
  359. }
  360. else if (procData.m_menuType == 1)
  361. {
  362. @@ -1761,6 +1768,7 @@ void CCNotePad::onPlugFound(NDD_PROC_DATA& procData, QMenu* pUserData)
  363. //菜单句柄通过procData传递到插件中
  364. procData.m_rootMenu = pluginMenu;
  365. sendParaToPlugin(procData);
  366. + sendParaToPluginV2(procData);
  367. }
  368. else
  369. {
  370. @@ -1796,6 +1804,39 @@ void CCNotePad::onPlugWork(bool check)
  371. }
  372. }
  373. +//真正执行插件的工作
  374. +void CCNotePad::onPlugWorkV2(bool check)
  375. +{
  376. +
  377. + qDebug() << "test1";
  378. + QAction* pAct = dynamic_cast<QAction*>(sender());
  379. + if (pAct != nullptr)
  380. + {
  381. + QString plugPath = pAct->data().toString();
  382. +
  383. + QLibrary* pLib = new QLibrary(plugPath);
  384. +
  385. + NDD_PROC_MAIN_V2_CALLBACK pMainCallBack;
  386. + pMainCallBack = (NDD_PROC_MAIN_V2_CALLBACK)pLib->resolve("NDD_PROC_MAIN_V2");
  387. +
  388. + if (pMainCallBack != NULL)
  389. + {
  390. + std::function<QsciScintilla* ()> foundCallBack = std::bind(&CCNotePad::getCurEditView, this);
  391. + Actor* actor = new Actor;
  392. +
  393. + actor->registerFunction([this](QString name, int num){openFile(name,num);});
  394. +
  395. + processor->registerActor("openFile",actor);
  396. + pMainCallBack(this, plugPath, processor, nullptr);
  397. + }
  398. + else
  399. + {
  400. + ui.statusBar->showMessage(tr("plugin %1 load failed !").arg(plugPath), 10000);
  401. + }
  402. +
  403. + }
  404. +}
  405. +
  406. //把插件需要的参数,传递到插件中去
  407. void CCNotePad::sendParaToPlugin(NDD_PROC_DATA& procData)
  408. {
  409. @@ -1818,6 +1859,32 @@ void CCNotePad::sendParaToPlugin(NDD_PROC_DATA& procData)
  410. }
  411. }
  412. +
  413. +void CCNotePad::sendParaToPluginV2(NDD_PROC_DATA& procData)
  414. +{
  415. + qDebug() <<"test5";
  416. + QString plugPath = procData.m_strFilePath;
  417. +
  418. + QLibrary* pLib = new QLibrary(plugPath);
  419. +
  420. + NDD_PROC_MAIN_V2_CALLBACK pMainCallBack;
  421. + pMainCallBack = (NDD_PROC_MAIN_V2_CALLBACK)pLib->resolve("NDD_PROC_MAIN_V2");
  422. +
  423. + if (pMainCallBack != NULL)
  424. + {
  425. + Actor* actor = new Actor;
  426. +
  427. + actor->registerFunction([this](QString name, int num){openFile(name,num);});
  428. +
  429. + processor->registerActor("openFile",actor);
  430. + pMainCallBack(this, plugPath, processor, &procData);
  431. + }
  432. + else
  433. + {
  434. + ui.statusBar->showMessage(tr("plugin %1 load failed !").arg(plugPath), 10000);
  435. + }
  436. +}
  437. +
  438. void CCNotePad::loadPluginProcs(QString strLibDir, QMenu* pMenu)
  439. {
  440. std::function<void(NDD_PROC_DATA&, QMenu*)> foundCallBack = std::bind(&CCNotePad::onPlugFound, this, std::placeholders::_1, std::placeholders::_2);
  441. diff --git a/src/cceditor/ccnotepad.h b/src/cceditor/ccnotepad.h
  442. index 58e5eec..d2939ad 100755
  443. --- a/src/cceditor/ccnotepad.h
  444. +++ b/src/cceditor/ccnotepad.h
  445. @@ -34,6 +34,7 @@ struct HexFileMgr;
  446. struct TextFileMgr;
  447. struct BigTextEditFileMgr;
  448. class QtLangSet;
  449. +class ActorProcessor;
  450. static const char* Tail_Thread = "tailthread";
  451. @@ -349,8 +350,10 @@ private slots:
  452. void on_loadReceneFile();
  453. void slot_pluginMgr();
  454. #ifdef NO_PLUGIN
  455. + void onPlugWorkV2(bool check);
  456. void onPlugWork(bool check);
  457. - void sendParaToPlugin(NDD_PROC_DATA& procData);
  458. + void sendParaToPlugin(NDD_PROC_DATA& procData);
  459. + void sendParaToPluginV2(NDD_PROC_DATA& procData);
  460. #endif
  461. void slot_showWebAddr(bool check);
  462. void slot_langFileSuffix();
  463. @@ -524,6 +527,10 @@ private:
  464. QSharedMemory* m_shareMem;
  465. +#ifdef NO_PLUGIN
  466. + //actor执行与存储单元
  467. + ActorProcessor* processor;
  468. +#endif
  469. //最近打开的对比文件和目录列表。做一个环形区
  470. diff --git a/src/functiontraits.h b/src/functiontraits.h
  471. new file mode 100644
  472. index 0000000..314b58b
  473. --- /dev/null
  474. +++ b/src/functiontraits.h
  475. @@ -0,0 +1,81 @@
  476. +#ifndef FUNCTIONTRAITS_H
  477. +#define FUNCTIONTRAITS_H
  478. +
  479. +#include <utility>
  480. +#include <functional>
  481. +#include <algorithm>
  482. +#include <tuple>
  483. +
  484. +template<typename T>
  485. +struct function_traits;
  486. +
  487. +template<typename ReturnType, typename... Args>
  488. +struct function_traits<ReturnType(Args...)>
  489. +{
  490. +public:
  491. + enum {
  492. + value = sizeof...(Args)
  493. + };
  494. + using function_type = ReturnType(*)(Args...);
  495. + using return_type = ReturnType;
  496. + using stl_function_type = std::function<function_type>;
  497. + using function_pointer_type = ReturnType(*)(Args...);
  498. + using lambda_function_type = ReturnType(*)(Args...);
  499. +
  500. + using tuple_type = std::tuple<std::remove_cv_t<std::remove_reference_t<Args>>...> ;
  501. + using bare_tuple_type = std::tuple<std::remove_const_t<std::remove_reference_t<Args>>...>;
  502. +
  503. + template<std::size_t N, typename = typename std::enable_if<(N < value)>::type>
  504. + using args = typename std::tuple_element<N, std::tuple<Args...>>;
  505. +
  506. + template <std::size_t N>
  507. + struct arguments
  508. + {
  509. + static_assert(N < value, "[error]:invalid parameter index.");
  510. + using type = typename std::tuple_element<N, std::tuple<Args...>>::type;
  511. + };
  512. +};
  513. +
  514. +template<typename ReturnType, typename... Args>
  515. +struct function_traits<ReturnType(*)(Args...)> : function_traits<ReturnType(Args...)> {};
  516. +
  517. +template<typename ReturnType, typename... Args>
  518. +struct function_traits<std::function<ReturnType(Args...)>> : function_traits<ReturnType(Args...)> {};
  519. +
  520. +template <typename ReturnType, typename ClassType, typename... Args>
  521. +struct function_traits<ReturnType(ClassType::*)(Args...)> : function_traits<ReturnType(Args...)>{};
  522. +
  523. +template <typename ReturnType, typename ClassType, typename... Args>
  524. +struct function_traits<ReturnType(ClassType::*)(Args...) const> : function_traits<ReturnType(Args...)> {};
  525. +
  526. +template <typename ReturnType, typename ClassType, typename... Args>
  527. +struct function_traits<ReturnType(ClassType::*)(Args...) volatile> : function_traits<ReturnType(Args...)> {};
  528. +
  529. +template <typename ReturnType, typename ClassType, typename... Args>
  530. +struct function_traits<ReturnType(ClassType::*)(Args...) const volatile> : function_traits<ReturnType(Args...)> {};
  531. +
  532. +template<typename Callable>
  533. +struct function_traits : function_traits<decltype(&Callable::operator())> {};
  534. +
  535. +template<typename Function>
  536. +typename function_traits<Function>::stl_function_type
  537. +function_cast(const Function& lambda)
  538. +{
  539. + return static_cast<typename function_traits<Function>::stl_function_type>(std::forward<Function>(lambda));
  540. +}
  541. +
  542. +template<typename Function>
  543. +typename function_traits<Function>::stl_function_type
  544. +function_cast(Function&& lambda)
  545. +{
  546. + return static_cast<typename function_traits<Function>::stl_function_type>(lambda);
  547. +}
  548. +
  549. +template<typename Function>
  550. +typename function_traits<Function>::function_pointer_type
  551. +function_cast(const Function& lambda)
  552. +{
  553. + return static_cast<typename function_traits<Function>::pointer>(lambda);
  554. +}
  555. +
  556. +#endif // FUNCTIONTRAITS_H
  557. diff --git a/src/plugin.h b/src/plugin.h
  558. index c2731be..0f417a9 100755
  559. --- a/src/plugin.h
  560. +++ b/src/plugin.h
  561. @@ -4,7 +4,9 @@
  562. class QMenu;
  563. class QsciScintilla;
  564. class QWidget;
  565. +class ActorProcessor;
  566. typedef int (*NDD_PROC_MAIN_CALLBACK)(QWidget* parent, const QString& strFileName, std::function<QsciScintilla*()>getCurEdit, NDD_PROC_DATA* procData);
  567. +typedef int (*NDD_PROC_MAIN_V2_CALLBACK)(QWidget* parent, const QString& strFileName,ActorProcessor*processor, NDD_PROC_DATA* procData);
  568. int loadProc(const QString& strDirOut, std::function<void(NDD_PROC_DATA&, QMenu*)> funcallback, QMenu* pUserData);
  569. diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt
  570. index c9b8d26..8e1db46 100644
  571. --- a/src/plugin/CMakeLists.txt
  572. +++ b/src/plugin/CMakeLists.txt
  573. @@ -1,4 +1,4 @@
  574. -
  575. +
  576. option(USE_NOTEPAD_PLUGIN "构建 Notepad-- 内部插件" ON)
  577. option(USE_NOTEPAD_PLUGIN_BASE "构建 Notepad-- 内部的插件基础模板" OFF)
  578. @@ -19,12 +19,12 @@ if(USE_NOTEPAD_PLUGIN)
  579. add_subdirectory(template-plugins/base-secondary-menu-ui-plugin-v1)
  580. endif(USE_NOTEPAD_PLUGIN_BASE)
  581. - # 一个简单的插件示例,但依赖于外部的 opencc 项目(基于 git)
  582. - add_subdirectory(opencc-demo-plugin)
  583. - # 一个简单的版本更新检查的插件
  584. - add_subdirectory(versionUpdate)
  585. - # 一个简单的可二次扩展的插件
  586. - add_subdirectory(external-plugin)
  587. +# # 一个简单的插件示例,但依赖于外部的 opencc 项目(基于 git)
  588. +# add_subdirectory(opencc-demo-plugin)
  589. +# # 一个简单的版本更新检查的插件
  590. +# add_subdirectory(versionUpdate)
  591. +# # 一个简单的可二次扩展的插件
  592. +# add_subdirectory(external-plugin)
  593. # Linux 可构建的插件
  594. if(UNIX AND NOT APPLE)
  595. @@ -33,6 +33,6 @@ if(USE_NOTEPAD_PLUGIN)
  596. endif(UNIX AND NOT APPLE)
  597. # TTS 语音合成
  598. - add_subdirectory(TTS-plugin)
  599. + add_subdirectory(filetreeview)
  600. endif(USE_NOTEPAD_PLUGIN)
  601. diff --git a/src/plugin/filetreeview/CMakeLists.txt b/src/plugin/filetreeview/CMakeLists.txt
  602. new file mode 100644
  603. index 0000000..d74905a
  604. --- /dev/null
  605. +++ b/src/plugin/filetreeview/CMakeLists.txt
  606. @@ -0,0 +1,74 @@
  607. +set(LOCAL_PLUGIN_NAME "filetreeview")
  608. +
  609. +# TTS-plugin 核心构建
  610. +# 在模块化构建中,这个部分代表着构建 TTS-plugin 插件
  611. +# 1. 默认构建时产出的目标为 TTS-plugin
  612. +# 2. 在此处可对 TTS-plugin 目标进行详细的构建计划
  613. +
  614. +if(TRUE)
  615. + # 准备构建 TTS-plugin 主程序扩展
  616. + spark_file_glob(LocalSources
  617. + ./*.h ./*.cpp ./*.ui
  618. + )
  619. + spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
  620. + target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE
  621. + ${PROJECT_SOURCE_DIR}/src
  622. + ${PROJECT_SOURCE_DIR}/src/cceditor
  623. +
  624. + ${PROJECT_SOURCE_DIR}/src/qscint/src
  625. + ${PROJECT_SOURCE_DIR}/src/qscint/src/Qsci
  626. + ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/src
  627. + ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/include
  628. + ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/lexlib
  629. + ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/boostregex
  630. + )
  631. + # target_link_libraries(${LOCAL_PLUGIN_NAME} QSci)
  632. + target_link_QSci(${LOCAL_PLUGIN_NAME})
  633. + if(USE_QT6)
  634. + # target_link_qt6_Core5Compat(${LOCAL_PLUGIN_NAME}) # 兼容性: Qt6 可使用 Core5Compat 少量更改 Qt5 部分
  635. + # target_link_qt6_PrintSupport(${LOCAL_PLUGIN_NAME})
  636. + # target_link_qt6_XmlPatterns(${LOCAL_PLUGIN_NAME}) # Bug 初期配置时无此依赖要求
  637. + else()
  638. + # target_link_qt5_PrintSupport(${LOCAL_PLUGIN_NAME})
  639. + # target_link_qt5_XmlPatterns(${LOCAL_PLUGIN_NAME})
  640. + endif(USE_QT6)
  641. +
  642. + # 确保生成到 Notepad-- 的相对 plugin 目录下
  643. + set_target_properties(${LOCAL_PLUGIN_NAME}
  644. + PROPERTIES
  645. + RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
  646. + LIBRARY_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
  647. + ARCHIVE_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin)
  648. +
  649. + # 控制是否安装到 bin/plugin 而各种配方之下,每个位置或许都不一样(特别是 Linux)
  650. + # install(TARGETS ${LOCAL_PLUGIN_NAME} DESTINATION bin/plugin)
  651. +endif(TRUE)
  652. +
  653. +
  654. +# ----------------- TTS-plugin 构建宏支持相关 ----------------- #
  655. +
  656. +if(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
  657. + # 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
  658. + target_compile_definitions(${LOCAL_PLUGIN_NAME}
  659. + PRIVATE
  660. + NOTEPAD_PLUGIN_MANAGER
  661. + QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
  662. + # 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
  663. + )
  664. +else()
  665. + # 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
  666. + target_compile_definitions(${LOCAL_PLUGIN_NAME}
  667. + PRIVATE
  668. + NOTEPAD_PLUGIN_MANAGER
  669. + # QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
  670. + # 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
  671. + )
  672. +endif(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
  673. +
  674. +if(UNIX)
  675. + # 默认在 Unix/Linux 中仅需要定义一个内部插件宏管理器
  676. + target_compile_definitions(${LOCAL_PLUGIN_NAME}
  677. + PRIVATE
  678. + NOTEPAD_PLUGIN_MANAGER
  679. + )
  680. +endif(UNIX)
  681. diff --git a/src/plugin/filetreeview/abstractfile.cpp b/src/plugin/filetreeview/abstractfile.cpp
  682. new file mode 100644
  683. index 0000000..9b8673f
  684. --- /dev/null
  685. +++ b/src/plugin/filetreeview/abstractfile.cpp
  686. @@ -0,0 +1,6 @@
  687. +#include "abstractfile.h"
  688. +
  689. +AbstractFile::AbstractFile()
  690. +{
  691. +
  692. +}
  693. diff --git a/src/plugin/filetreeview/abstractfile.h b/src/plugin/filetreeview/abstractfile.h
  694. new file mode 100644
  695. index 0000000..94ae7dc
  696. --- /dev/null
  697. +++ b/src/plugin/filetreeview/abstractfile.h
  698. @@ -0,0 +1,11 @@
  699. +#ifndef ABSTRACTFILE_H
  700. +#define ABSTRACTFILE_H
  701. +
  702. +
  703. +class AbstractFile
  704. +{
  705. +public:
  706. + AbstractFile();
  707. +};
  708. +
  709. +#endif // ABSTRACTFILE_H
  710. diff --git a/src/plugin/filetreeview/actor.h b/src/plugin/filetreeview/actor.h
  711. new file mode 100644
  712. index 0000000..d3901a2
  713. --- /dev/null
  714. +++ b/src/plugin/filetreeview/actor.h
  715. @@ -0,0 +1,120 @@
  716. +#pragma once
  717. +#include <cstdint>
  718. +#include <string>
  719. +#include <memory>
  720. +#include <tuple>
  721. +#include <functional>
  722. +
  723. +#include "functiontraits.h"
  724. +
  725. +/**
  726. + * @brief Actor class, which encapsulates the event model
  727. + * @note enable_shared_from_this allows us to get safe Pointers internally
  728. + */
  729. +class Actor : public std::enable_shared_from_this<Actor>
  730. +{
  731. +public:
  732. + using Ptr = std::shared_ptr<Actor>;
  733. + using FunctionWapper = std::function<void(void*, void*)>;
  734. +
  735. +public:
  736. + Actor(){}
  737. + ~Actor(){}
  738. +
  739. + /**
  740. + * @brief Register the callback function and construct the anonymous function with std::bind
  741. + */
  742. + template<typename Function>
  743. + void registerFunction(Function&& function_any) noexcept
  744. + {
  745. + m_invokeFunctionWapper = { std::bind(&invoker<Function>::apply, function_any, std::placeholders::_1, std::placeholders::_2) };
  746. + }
  747. +
  748. + /**
  749. + * @brief Register the callback function and construct the anonymous function with std::bind
  750. + */
  751. + template<typename ... Args>
  752. + void invoke(Args&& ... args) const noexcept
  753. + {
  754. + auto args_tuple = std::make_tuple(std::forward<Args>(args)...);
  755. + m_invokeFunctionWapper(&args_tuple, nullptr);
  756. + }
  757. +
  758. + /**
  759. + * @brief Register the callback function and construct the anonymous function with std::bind
  760. + */
  761. + template<typename R, typename ... Args>
  762. + R invoke(Args&& ...args) const
  763. + {
  764. + using tuple_args_type = std::tuple<Args...>;
  765. + char data[sizeof(tuple_args_type)];
  766. + std::tuple<Args...>* tuples_pointer = new (data) tuple_args_type;
  767. +
  768. + *tuples_pointer = std::make_tuple(std::forward<Args>(args)...);
  769. +
  770. + R return_value;
  771. + m_invokeFunctionWapper(tuples_pointer, &return_value);
  772. + return return_value;
  773. + }
  774. +
  775. + Ptr getSharedPtr()
  776. + {
  777. + return shared_from_this();
  778. + }
  779. +
  780. +public:
  781. + /**
  782. + * @brief This struct encapsulates a function,
  783. + * essentially storing the return value and parameters in two variables
  784. + * which can unify the way the function is stored.
  785. + */
  786. + template<typename Function>
  787. + struct invoker
  788. + {
  789. + /**
  790. + * @brief
  791. + */
  792. + static inline void apply(const Function& func, void* bl, void* result)
  793. + {
  794. + using tuple_type = typename function_traits<Function>::tuple_type;
  795. + const tuple_type* tp = static_cast<tuple_type*>(bl);
  796. + call(func, *tp, result);
  797. + }
  798. +
  799. + /**
  800. + * @brief
  801. + */
  802. + template<typename F, typename ... Args>
  803. + static typename std::enable_if<std::is_void<typename std::result_of<F(Args...)>::type>::value>::type
  804. + call(const F& f, const std::tuple<Args...>& tp, void*)
  805. + {
  806. + call_helper(f, std::make_index_sequence<sizeof... (Args)>{}, tp);
  807. + }
  808. +
  809. + /**
  810. + * @brief
  811. + */
  812. + template<typename F, typename ... Args>
  813. + static typename std::enable_if<!std::is_void<typename std::result_of<F(Args...)>::type>::value>::type
  814. + call(const F& f, const std::tuple<Args...>& tp, void* result)
  815. + {
  816. + auto r = call_helper(f, std::make_index_sequence<sizeof... (Args)>{}, tp);
  817. + *(decltype(r)*)result = r;
  818. + }
  819. +
  820. + /**
  821. + * @brief
  822. + */
  823. + template<typename F, size_t... I, typename ... Args>
  824. + static auto call_helper(const F& f, const std::index_sequence<I...>& h, const std::tuple<Args...>& tup)
  825. + {
  826. + return f(std::get<I>(tup)...);
  827. + }
  828. + };
  829. +private:
  830. + /**
  831. + * @note m_invokeFunctions is an anonymous lamba expression that encapsulates a function
  832. + * Functions include Lamba expressions, member functions, funtor, ordinary functions, and function Pointers
  833. + */
  834. + FunctionWapper m_invokeFunctionWapper;
  835. +};
  836. diff --git a/src/plugin/filetreeview/actorprocessor.cpp b/src/plugin/filetreeview/actorprocessor.cpp
  837. new file mode 100644
  838. index 0000000..099d1f6
  839. --- /dev/null
  840. +++ b/src/plugin/filetreeview/actorprocessor.cpp
  841. @@ -0,0 +1,67 @@
  842. +#include "actorprocessor.h"
  843. +ActorProcessor::ActorProcessor():
  844. + m_actorMap(new std::unordered_map<std::string, Actor*>)
  845. +{}
  846. +
  847. +/**
  848. + * @brief
  849. + */
  850. +ActorProcessor::~ActorProcessor()
  851. +{
  852. + for (auto& item : (*m_actorMap))
  853. + {
  854. + if(item.second != nullptr)
  855. + delete item.second;
  856. + }
  857. + if (m_actorMap)
  858. + delete m_actorMap;
  859. +}
  860. +
  861. +/**
  862. + * @brief
  863. + */
  864. +void ActorProcessor::registerActor(const std::string &route, Actor *actor)
  865. +{
  866. + m_actorMap->insert(std::make_pair(route,actor));
  867. +}
  868. +
  869. +/**
  870. + * @brief
  871. + */
  872. +void ActorProcessor::removeActor(const std::string &route)
  873. +{
  874. + auto iter = (*m_actorMap).find(route);
  875. + if(iter != m_actorMap->end())
  876. + {
  877. + m_actorMap->erase(route);
  878. + delete iter->second;
  879. + }
  880. +}
  881. +
  882. +/**
  883. + * @brief
  884. + */
  885. +Actor *ActorProcessor::findActor(const std::string &route)
  886. +{
  887. + auto iter = (*m_actorMap).find(route);
  888. + if(iter != m_actorMap->end())
  889. + {
  890. + return (*m_actorMap)[route];
  891. + }
  892. + return nullptr;
  893. +}
  894. +
  895. +/**
  896. + * @brief
  897. + */
  898. +bool ActorProcessor::resetActor(const std::string &route, Actor *actor)
  899. +{
  900. + auto iter = (*m_actorMap).find(route);
  901. + if(iter != m_actorMap->end())
  902. + {
  903. + m_actorMap->erase(route);
  904. + delete iter->second;
  905. + return true;
  906. + }
  907. + return false;
  908. +}
  909. diff --git a/src/plugin/filetreeview/actorprocessor.h b/src/plugin/filetreeview/actorprocessor.h
  910. new file mode 100644
  911. index 0000000..d057e6d
  912. --- /dev/null
  913. +++ b/src/plugin/filetreeview/actorprocessor.h
  914. @@ -0,0 +1,66 @@
  915. +#ifndef EVENTPROCESSOR_H
  916. +#define EVENTPROCESSOR_H
  917. +
  918. +#include <string>
  919. +#include <functional>
  920. +#include <map>
  921. +#include <iostream>
  922. +#include <unordered_map>
  923. +#include "actor.h"
  924. +
  925. +class ActorProcessor
  926. +{
  927. +public:
  928. + ActorProcessor();
  929. + ~ActorProcessor();
  930. +public:
  931. +
  932. + /**
  933. + * @brief Register the callback function and construct the anonymous function with std::bind
  934. + */
  935. + template<typename ... Args>
  936. + void invoke(const std::string& route,Args&& ... args) const noexcept
  937. + {
  938. + if (m_actorMap->find(route) != m_actorMap->end())
  939. + (*m_actorMap)[route]->invoke(std::forward<Args>(args)...);
  940. + }
  941. +
  942. + /**
  943. + * @brief Register the callback function and construct the anonymous function with std::bind
  944. + */
  945. + template<typename R, typename ... Args>
  946. + R invoke(const std::string& route,Args&& ...args) const
  947. + {
  948. + if (m_actorMap->find(route) != m_actorMap->end())
  949. + return (*m_actorMap)[route]->invoke(std::forward<Args>(args)...);
  950. + return nullptr;
  951. + }
  952. +
  953. + /**
  954. + * @brief 注册一个actor,其中route是唯一的
  955. + */
  956. + void registerActor(const std::string& route, Actor*actor);
  957. +
  958. + /**
  959. + * @brief 删除一个actor
  960. + */
  961. + void removeActor(const std::string& route);
  962. +
  963. + /**
  964. + * @brief 查找一个actor, 返回其指针
  965. + */
  966. + Actor* findActor(const std::string& route);
  967. +
  968. + /**
  969. + * @brief 重置一个actor,注意原有的actor会被删除
  970. + */
  971. + bool resetActor(const std::string& route,Actor*actor);
  972. +
  973. +private:
  974. + std::unordered_map<std::string, Actor*>* m_actorMap;
  975. +private:
  976. + ActorProcessor(ActorProcessor&&)=delete;
  977. + ActorProcessor& operator=(const ActorProcessor&)=delete;
  978. +};
  979. +
  980. +#endif // EVENTPROCESSOR_H
  981. diff --git a/src/plugin/filetreeview/filesystemmodel.cpp b/src/plugin/filetreeview/filesystemmodel.cpp
  982. new file mode 100644
  983. index 0000000..5b825b5
  984. --- /dev/null
  985. +++ b/src/plugin/filetreeview/filesystemmodel.cpp
  986. @@ -0,0 +1,526 @@
  987. +#include "filesystemmodel.h"
  988. +
  989. +#include <QFileInfo>
  990. +#include <QDir>
  991. +#include <QIcon>
  992. +#include <QFont>
  993. +#include <QFileIconProvider>
  994. +#include <QFileSystemWatcher>
  995. +#include <QMutexLocker>
  996. +#include <QDebug>
  997. +
  998. +FileNode::FileNode(FileSystemModel *model) :
  999. + m_model(model),
  1000. + m_parent(0),
  1001. + m_children(0),
  1002. + m_bWatcher(false)
  1003. +{
  1004. +
  1005. +}
  1006. +
  1007. +FileNode::FileNode(FileSystemModel *model, const QString &path, FileNode *parent) :
  1008. + m_model(model),
  1009. + m_parent(parent),
  1010. + m_children(0),
  1011. + m_path(path),
  1012. + m_bWatcher(false)
  1013. +{
  1014. + QFileInfo info(path);
  1015. + if (m_model->isRootPathNodeFillPath() && parent && parent->getNodeParent() == 0) {
  1016. + m_text = QDir::toNativeSeparators(info.filePath());
  1017. + } else {
  1018. + m_text = info.fileName();
  1019. + }
  1020. +}
  1021. +
  1022. +FileNode::~FileNode()
  1023. +{
  1024. + clear();
  1025. + if (m_children) {
  1026. + delete m_children;
  1027. + }
  1028. + if (m_bWatcher) {
  1029. + m_model->removeWatcher(m_path);
  1030. + }
  1031. +}
  1032. +
  1033. +QList<FileNode*>* FileNode::getChildrenList()
  1034. +{
  1035. + if (m_children == 0) {
  1036. + m_children = new QList<FileNode*>();
  1037. + if (!m_path.isEmpty()) {
  1038. + QFileInfo info(m_path);
  1039. + if (info.isDir()) {
  1040. + QDir dir(m_path);
  1041. + foreach(QFileInfo childInfo, dir.entryInfoList(this->m_model->filter(),this->m_model->dirSort())) {
  1042. + if (!this->m_model->isShowHideFiles() && childInfo.isDir() && childInfo.fileName().startsWith(".")) {
  1043. + continue;
  1044. + }
  1045. + m_children->append(new FileNode(this->m_model,childInfo.filePath(),this));
  1046. + }
  1047. + }
  1048. + }
  1049. + if (!m_children->isEmpty() && !m_bWatcher) {
  1050. + m_bWatcher = true;
  1051. + m_model->addWatcher(m_path);
  1052. + }
  1053. + }
  1054. + return m_children;
  1055. +}
  1056. +
  1057. +FileNode* FileNode::getNodeParent()
  1058. +{
  1059. + return m_parent;
  1060. +}
  1061. +
  1062. +FileNode* FileNode::getChild(int row)
  1063. +{
  1064. + return getChildrenList()->at(row);
  1065. +}
  1066. +
  1067. +int FileNode::childCount()
  1068. +{
  1069. + return getChildrenList()->count();
  1070. +}
  1071. +
  1072. +int FileNode::row() const
  1073. +{
  1074. + if (m_parent) {
  1075. + return m_parent->getChildrenList()->indexOf(const_cast<FileNode*>(this));
  1076. + }
  1077. + return 0;
  1078. +}
  1079. +
  1080. +QString FileNode::getNodePath() const
  1081. +{
  1082. + return m_path;
  1083. +}
  1084. +
  1085. +QString FileNode::text() const
  1086. +{
  1087. + return m_text;
  1088. +}
  1089. +
  1090. +bool FileNode::isDir() const
  1091. +{
  1092. + return QFileInfo(m_path).isDir();
  1093. +}
  1094. +
  1095. +bool FileNode::isFile() const
  1096. +{
  1097. + return QFileInfo(m_path).isFile();
  1098. +}
  1099. +
  1100. +QFileInfo FileNode::getFileInformation() const
  1101. +{
  1102. + return QFileInfo(m_path);
  1103. +}
  1104. +
  1105. +bool FileNode::isExist() const
  1106. +{
  1107. + return QFileInfo(m_path).exists();
  1108. +}
  1109. +
  1110. +void FileNode::clear()
  1111. +{
  1112. + if (m_children) {
  1113. + qDeleteAll(m_children->begin(),m_children->end());
  1114. + m_children->clear();
  1115. + }
  1116. +}
  1117. +
  1118. +void FileNode::reload()
  1119. +{
  1120. + clear();
  1121. + if (m_children == 0) {
  1122. + m_children = new QList<FileNode*>();
  1123. + }
  1124. + if (!m_path.isEmpty()) {
  1125. + QFileInfo info(m_path);
  1126. + if (info.isDir()) {
  1127. + QDir dir(m_path);
  1128. + foreach(QFileInfo childInfo, dir.entryInfoList(this->m_model->filter(),this->m_model->dirSort())) {
  1129. + if (!this->m_model->isShowHideFiles() && childInfo.isDir() && childInfo.fileName().startsWith(".")) {
  1130. + continue;
  1131. + }
  1132. + m_children->append(new FileNode(this->m_model,childInfo.filePath(),this));
  1133. + }
  1134. + }
  1135. + }
  1136. + if (!m_children->isEmpty() && !m_bWatcher) {
  1137. + m_bWatcher = true;
  1138. + m_model->addWatcher(m_path);
  1139. + }
  1140. +}
  1141. +
  1142. +FileNode *FileNode::findPath(const QString &path)
  1143. +{
  1144. + if (!path.startsWith(m_path)) {
  1145. + return 0;
  1146. + }
  1147. + if (path == m_path) {
  1148. + return this;
  1149. + }
  1150. + QStringList nameList = path.right(path.length()-m_path.length()).split("/",QString::SkipEmptyParts);
  1151. + FileNode *parent = this;
  1152. + bool find = false;
  1153. + foreach (QString name,nameList) {
  1154. + find = false;
  1155. + QList<FileNode*>* chilren = parent->getChildrenList();
  1156. + for (int i = 0; i < chilren->count(); i++) {
  1157. + FileNode *node = chilren->at(i);
  1158. + if (!node->isDir()) {
  1159. + continue;
  1160. + }
  1161. + if (node->m_text == name) {
  1162. + parent = node;
  1163. + find = true;
  1164. + break;
  1165. + }
  1166. + }
  1167. + if (!find) {
  1168. + return 0;
  1169. + }
  1170. + }
  1171. + return parent;
  1172. +}
  1173. +
  1174. +FileSystemModel::FileSystemModel(QObject *parent) :
  1175. + QAbstractItemModel(parent),
  1176. + m_rootNode(new FileNode(this)),
  1177. + m_iconProvider(new QFileIconProvider),
  1178. + m_fileWatcher(0)
  1179. +{
  1180. + m_dirFilter = QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot;
  1181. + m_sorts = QDir::DirsFirst | QDir::Name | QDir::IgnoreCase;// | QDir::Type;
  1182. + // connect(m_fileWatcher,SIGNAL(directoryChanged(QString)),this,SLOT(directoryChanged(QString)));
  1183. +}
  1184. +
  1185. +FileSystemModel::~FileSystemModel()
  1186. +{
  1187. + delete m_rootNode;
  1188. + delete m_iconProvider;
  1189. + if (m_fileWatcher) {
  1190. + delete m_fileWatcher;
  1191. + }
  1192. +}
  1193. +
  1194. +void FileSystemModel::reloadDirectory(const QString &path)
  1195. +{
  1196. + this->beginResetModel();
  1197. + QDir dir(path);
  1198. + bool b = dir.exists();
  1199. + if (!b) {
  1200. + m_fileWatcher->removePath(path);
  1201. + }
  1202. + foreach(QModelIndex index,this->findPaths(path)) {
  1203. + FileNode *node = nodeFromIndex(index);
  1204. + if (b) {
  1205. + node->reload();
  1206. + } else {
  1207. + FileNode *parent = node->getNodeParent();
  1208. + if (parent) {
  1209. + parent->reload();
  1210. + }
  1211. + }
  1212. + }
  1213. + this->endResetModel();
  1214. +}
  1215. +
  1216. +FileNode *FileSystemModel::nodeFromIndex(const QModelIndex &index) const
  1217. +{
  1218. + if (index.isValid()) {
  1219. + return static_cast<FileNode*>(index.internalPointer());
  1220. + }
  1221. + return m_rootNode;
  1222. +}
  1223. +
  1224. +void FileSystemModel::setStartIndex(const QModelIndex &index)
  1225. +{
  1226. + m_startPath = filePath(index);
  1227. +}
  1228. +
  1229. +void FileSystemModel::setStartPath(const QString &path)
  1230. +{
  1231. + m_startPath = path;
  1232. +}
  1233. +
  1234. +QModelIndex FileSystemModel::startIndex() const
  1235. +{
  1236. + return findPath(m_startPath);
  1237. +}
  1238. +
  1239. +QString FileSystemModel::startPath() const
  1240. +{
  1241. + return m_startPath;
  1242. +}
  1243. +
  1244. +QString FileSystemModel::filePath(const QModelIndex &index) const
  1245. +{
  1246. + return nodeFromIndex(index)->getNodePath();
  1247. +}
  1248. +
  1249. +void FileSystemModel::setFilter(QDir::Filters filters)
  1250. +{
  1251. + if (m_dirFilter != filters) {
  1252. + m_dirFilter = filters;
  1253. + this->reload();
  1254. + }
  1255. +}
  1256. +
  1257. +void FileSystemModel::setDirSort(QDir::SortFlags flags)
  1258. +{
  1259. + if (m_sorts != flags) {
  1260. + m_sorts = flags;
  1261. + this->reload();
  1262. + }
  1263. +}
  1264. +
  1265. +QDir::Filters FileSystemModel::filter() const
  1266. +{
  1267. + return m_dirFilter;
  1268. +}
  1269. +
  1270. +bool FileSystemModel::isShowHideFiles() const
  1271. +{
  1272. + return m_dirFilter & QDir::Hidden;
  1273. +}
  1274. +
  1275. +QDir::SortFlags FileSystemModel::dirSort() const
  1276. +{
  1277. + return m_sorts;
  1278. +}
  1279. +
  1280. +void FileSystemModel::clear()
  1281. +{
  1282. + this->beginResetModel();
  1283. + m_rootNode->clear();
  1284. + m_pathList.clear();
  1285. + m_startPath.clear();
  1286. + this->endResetModel();
  1287. +}
  1288. +
  1289. +void FileSystemModel::reload()
  1290. +{
  1291. + this->setRootPathList(this->rootPathList());
  1292. +}
  1293. +
  1294. +void FileSystemModel::setRootPath(const QString &path)
  1295. +{
  1296. + this->setRootPathList(QStringList() << path);
  1297. +}
  1298. +
  1299. +bool FileSystemModel::removeRootPath(const QString &path)
  1300. +{
  1301. + QString pathName = QDir::fromNativeSeparators(path);
  1302. + FileNode *node = 0;
  1303. + int index = -1;
  1304. + for (int i = 0; i < m_rootNode->childCount(); i++) {
  1305. + node = m_rootNode->getChildrenList()->at(i);
  1306. + if (node && (node->getNodePath() == pathName)) {
  1307. + index = i;
  1308. + break;
  1309. + }
  1310. + }
  1311. + if (index == -1) {
  1312. + return false;
  1313. + }
  1314. + if (!m_pathList.removeAll(pathName)) {
  1315. + return false;
  1316. + }
  1317. + this->beginRemoveRows(QModelIndex(),index,index);
  1318. + m_rootNode->getChildrenList()->removeAt(index);
  1319. + delete node;
  1320. + this->endRemoveRows();
  1321. + return true;
  1322. +}
  1323. +
  1324. +
  1325. +bool FileSystemModel::addRootPath(const QString &path)
  1326. +{
  1327. + QString pathName = QDir::fromNativeSeparators(QDir::cleanPath(path));
  1328. + if (m_pathList.contains(pathName)) {
  1329. + return false;
  1330. + }
  1331. + this->beginInsertRows(QModelIndex(),m_rootNode->childCount(),m_rootNode->childCount());
  1332. + m_pathList.append(pathName);
  1333. + m_rootNode->getChildrenList()->append(new FileNode(this,pathName,m_rootNode));
  1334. + this->endInsertRows();
  1335. + return true;
  1336. +}
  1337. +
  1338. +void FileSystemModel::setRootPathList(const QStringList &pathList)
  1339. +{
  1340. + this->beginResetModel();
  1341. + m_rootNode->clear();
  1342. + m_fileWatcherMap.clear();
  1343. + m_pathList.clear();
  1344. + if (m_fileWatcher) {
  1345. + disconnect(m_fileWatcher,0);
  1346. + delete m_fileWatcher;
  1347. + }
  1348. + m_fileWatcher = new QFileSystemWatcher;
  1349. + connect(m_fileWatcher,SIGNAL(directoryChanged(QString)),this,SIGNAL(direcotryChanged(QString)));
  1350. +
  1351. + foreach (QString path, pathList) {
  1352. + m_pathList.append(QDir::fromNativeSeparators(QDir::cleanPath(path)));
  1353. + }
  1354. + m_pathList.removeDuplicates();
  1355. +
  1356. + foreach(QString path, m_pathList) {
  1357. + m_rootNode->getChildrenList()->append(new FileNode(this,path,m_rootNode));
  1358. + }
  1359. +
  1360. + if (m_startPath.isEmpty() && !pathList.isEmpty()) {
  1361. + m_startPath = pathList.first();
  1362. + }
  1363. +
  1364. + this->endResetModel();
  1365. +}
  1366. +
  1367. +QStringList FileSystemModel::rootPathList() const
  1368. +{
  1369. + return m_pathList;
  1370. +}
  1371. +
  1372. +QModelIndex FileSystemModel::findPathHelper(const QString &path, const QModelIndex &parentIndex) const
  1373. +{
  1374. + FileNode *node = nodeFromIndex(parentIndex);
  1375. + if (!path.startsWith(node->getNodePath())) {
  1376. + return QModelIndex();
  1377. + }
  1378. + if (path == node->getNodePath()) {
  1379. + return parentIndex;
  1380. + }
  1381. + QStringList nameList = path.right(path.length()-node->getNodePath().length()).split("/",QString::SkipEmptyParts);
  1382. + QModelIndex parent = parentIndex;
  1383. + bool find = false;
  1384. + int count = nameList.count();
  1385. + for (int i = 0; i < count; i++) {
  1386. + find = false;
  1387. + for (int j = 0; j < this->rowCount(parent); j++) {
  1388. + QModelIndex index = this->index(j,0,parent);
  1389. + FileNode *node = nodeFromIndex(index);
  1390. + if ( ( (i == count-1) || node->isDir()) && node->text() == nameList.at(i)) {
  1391. + parent = index;
  1392. + find = true;
  1393. + break;
  1394. + }
  1395. + }
  1396. + if (!find) {
  1397. + return QModelIndex();
  1398. + }
  1399. + }
  1400. + return parent;
  1401. +}
  1402. +
  1403. +QList<QModelIndex> FileSystemModel::findPaths(const QString &path) const
  1404. +{
  1405. + QList<QModelIndex> list;
  1406. + QString cpath = QDir::fromNativeSeparators(QDir::cleanPath(path));
  1407. + for (int i = 0; i < this->rowCount(); i++) {
  1408. + QModelIndex find = findPathHelper(cpath,this->index(i,0));
  1409. + if (find.isValid()) {
  1410. + list.append(find);
  1411. + }
  1412. + }
  1413. + return list;
  1414. +}
  1415. +
  1416. +QModelIndex FileSystemModel::findPath(const QString &path) const
  1417. +{
  1418. + QList<QModelIndex> list = this->findPaths(path);
  1419. + if (!list.isEmpty()) {
  1420. + return list.last();
  1421. + }
  1422. + return QModelIndex();
  1423. +}
  1424. +
  1425. +int FileSystemModel::rowCount(const QModelIndex &parent) const
  1426. +{
  1427. + FileNode *node = nodeFromIndex(parent);
  1428. + return node->childCount();
  1429. +}
  1430. +
  1431. +int FileSystemModel::columnCount(const QModelIndex&) const
  1432. +{
  1433. + return 1;
  1434. +}
  1435. +
  1436. +QModelIndex FileSystemModel::parent(const QModelIndex &child) const
  1437. +{
  1438. + FileNode *node = nodeFromIndex(child);
  1439. + FileNode *parent = node->getNodeParent();
  1440. + if (parent == m_rootNode) {
  1441. + return QModelIndex();
  1442. + }
  1443. + return createIndex(parent->row(),0,parent);
  1444. +}
  1445. +
  1446. +QModelIndex FileSystemModel::index(int row, int column,const QModelIndex &parent) const
  1447. +{
  1448. + if (!hasIndex(row,column,parent))
  1449. + return QModelIndex();
  1450. + FileNode *node = nodeFromIndex(parent);
  1451. + return createIndex(row,column,node->getChild(row));
  1452. +}
  1453. +
  1454. +QVariant FileSystemModel::data(const QModelIndex &index, int role) const
  1455. +{
  1456. + FileNode *node = nodeFromIndex(index);
  1457. + if (!node) {
  1458. + return QVariant();
  1459. + }
  1460. + switch(role) {
  1461. + case Qt::DisplayRole:
  1462. + return node->text();
  1463. + case Qt::ToolTipRole:
  1464. + return QDir::toNativeSeparators(node->getNodePath());
  1465. + case Qt::DecorationRole:
  1466. + return m_iconProvider->icon(node->getFileInformation());
  1467. +/*
  1468. + case Qt::FontRole: {
  1469. + QFont font;
  1470. + if (node->path() == m_startPath) {
  1471. + font.setBold(true);
  1472. + }
  1473. + return font;
  1474. + }
  1475. +*/
  1476. + }
  1477. + return QVariant();
  1478. +}
  1479. +
  1480. +bool FileSystemModel::isRootPathNode(FileNode *node) const
  1481. +{
  1482. + return node->getNodeParent() == m_rootNode;
  1483. +}
  1484. +
  1485. +bool FileSystemModel::isRootPathNodeFillPath() const
  1486. +{
  1487. + return false;
  1488. +}
  1489. +
  1490. +void FileSystemModel::addWatcher(const QString &path)
  1491. +{
  1492. + QMutexLocker _(&m_mutex);
  1493. + QString cpath = QDir::fromNativeSeparators(QDir::cleanPath(path));
  1494. + int value = m_fileWatcherMap[cpath];
  1495. + value++;
  1496. + m_fileWatcherMap[cpath] = value;
  1497. + if (value > 1) {
  1498. + return;
  1499. + }
  1500. + m_fileWatcher->addPath(path);
  1501. +}
  1502. +void FileSystemModel::removeWatcher(const QString &path)
  1503. +{
  1504. + QMutexLocker _(&m_mutex);
  1505. + QString cpath = QDir::fromNativeSeparators(QDir::cleanPath(path));
  1506. + int value = m_fileWatcherMap[cpath];
  1507. + value--;
  1508. + m_fileWatcherMap[cpath] = value;
  1509. + if (value == 0) {
  1510. + m_fileWatcher->removePath(cpath);
  1511. + }
  1512. +}
  1513. diff --git a/src/plugin/filetreeview/filesystemmodel.h b/src/plugin/filetreeview/filesystemmodel.h
  1514. new file mode 100644
  1515. index 0000000..f8816f8
  1516. --- /dev/null
  1517. +++ b/src/plugin/filetreeview/filesystemmodel.h
  1518. @@ -0,0 +1,193 @@
  1519. +#ifndef FILESYSTEMMODEL_H
  1520. +#define FILESYSTEMMODEL_H
  1521. +
  1522. +#include <QAbstractItemModel>
  1523. +#include <QStringList>
  1524. +#include <QIcon>
  1525. +#include <QFileInfo>
  1526. +#include <QDir>
  1527. +#include <QMutex>
  1528. +
  1529. +class FileSystemModel;
  1530. +class QFileSystemWatcher;
  1531. +
  1532. +class QFileIconProvider;
  1533. +class QFileSystemWatcher;
  1534. +class QTreeView;
  1535. +
  1536. +class FileNode
  1537. +{
  1538. +public:
  1539. +
  1540. + FileNode(FileSystemModel *model);
  1541. + FileNode(FileSystemModel *model,const QString &path, FileNode *parent);
  1542. + virtual ~FileNode();
  1543. +
  1544. + // 返回父节点
  1545. + FileNode* getNodeParent();
  1546. +
  1547. + // 按照index返回
  1548. + FileNode* getChild(int row);
  1549. +
  1550. + //! returns the number of children this node has.
  1551. + int childCount();
  1552. +
  1553. + //! returns the row number of this node.
  1554. + int row() const;
  1555. +
  1556. + //! returns a list of all the children of this node. The list will be empty if this node has no children.
  1557. + QList<FileNode*>* getChildrenList();
  1558. +
  1559. + //! returns the path of this node.
  1560. + QString getNodePath() const;
  1561. +
  1562. + //! returns the text of this node.
  1563. + QString text() const;
  1564. +
  1565. + //! returns the QFileInfo for this node.
  1566. + QFileInfo getFileInformation() const;
  1567. +
  1568. + //! returns true if this node exists on the file system.
  1569. + bool isExist() const;
  1570. +
  1571. + //! returns true if this node is a directory.
  1572. + bool isDir() const;
  1573. +
  1574. + //! returns true if this node is a file.
  1575. + bool isFile() const;
  1576. +
  1577. + //! clears this node.
  1578. + void clear();
  1579. +
  1580. + //! recreates the node from the file system.
  1581. + void reload();
  1582. +
  1583. + //! returns the node for the path specified.
  1584. + FileNode *findPath(const QString &path);
  1585. +
  1586. +protected:
  1587. +
  1588. + //! The FileSystemModel is a QAbstractItemModel that provides a hierarchical view of the file system.
  1589. + FileSystemModel *m_model;
  1590. +
  1591. + //! The FileNode is a node in the tree of FileNodes.
  1592. + FileNode *m_parent;
  1593. +
  1594. + //! The list of FileNodes.
  1595. + QList<FileNode*> *m_children;
  1596. +
  1597. + //! The path of the FileNode.
  1598. + QString m_path;
  1599. +
  1600. + //! The text of the FileNode.
  1601. + QString m_text;
  1602. +
  1603. + //!< true if this node is being watched. If so, the model will watch the node and will need to be manually updated.
  1604. + bool m_bWatcher;
  1605. +};
  1606. +
  1607. +class FileSystemModel : public QAbstractItemModel
  1608. +{
  1609. + Q_OBJECT
  1610. +public:
  1611. + explicit FileSystemModel(QObject *parent = 0);
  1612. +
  1613. + ~FileSystemModel();
  1614. +
  1615. + void clear();
  1616. +
  1617. + void reload();
  1618. +
  1619. + void setFilter(QDir::Filters filters);
  1620. +
  1621. + void setDirSort(QDir::SortFlags flags);
  1622. +
  1623. + QDir::Filters filter() const;
  1624. +
  1625. + bool isShowHideFiles() const;
  1626. +
  1627. + QDir::SortFlags dirSort() const;
  1628. +
  1629. + bool removeRootPath(const QString &path);
  1630. +
  1631. + bool addRootPath(const QString &path);
  1632. +
  1633. + void setRootPathList(const QStringList &pathList);
  1634. +
  1635. + void setRootPath(const QString &path);
  1636. +
  1637. + QStringList rootPathList() const;
  1638. +
  1639. + QList<QModelIndex> findPaths(const QString &path) const;
  1640. +
  1641. + QModelIndex findPath(const QString &path) const;
  1642. +
  1643. + QString filePath(const QModelIndex &index) const;
  1644. +
  1645. + FileNode *nodeFromIndex(const QModelIndex &index) const;
  1646. +
  1647. + void setStartIndex(const QModelIndex &index);
  1648. +
  1649. + void setStartPath(const QString &path);
  1650. +
  1651. + QModelIndex startIndex() const;
  1652. +
  1653. + QString startPath() const;
  1654. +
  1655. + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
  1656. +
  1657. + virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
  1658. +
  1659. + virtual QModelIndex parent(const QModelIndex &child) const;
  1660. +
  1661. + virtual QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const;
  1662. +
  1663. + virtual QVariant data(const QModelIndex &index, int role) const;
  1664. +
  1665. + bool isRootPathNode(FileNode *node) const;
  1666. +
  1667. + bool isRootPathNodeFillPath() const;
  1668. +
  1669. + void addWatcher(const QString &path);
  1670. +
  1671. + void removeWatcher(const QString &path);
  1672. +signals:
  1673. + void direcotryChanged(QString);
  1674. +public slots:
  1675. + void reloadDirectory(const QString &path);
  1676. +protected:
  1677. + //! Finds the node at the given \a path in the model.
  1678. + QModelIndex findPathHelper(const QString &path, const QModelIndex &parentIndex) const;
  1679. +
  1680. + //! The list of paths that are currently being watched.
  1681. + QStringList m_pathList;
  1682. +
  1683. + //! The root node of the model.
  1684. + FileNode *m_rootNode;
  1685. +
  1686. + //! The path to the directory to watch.
  1687. + QString m_startPath;
  1688. +
  1689. + //! The file icon provider.
  1690. + QFileIconProvider *m_iconProvider;
  1691. +
  1692. + //! The file system watcher.
  1693. + QFileSystemWatcher *m_fileWatcher;
  1694. +
  1695. + //! A map of watched files and their watcher indices.
  1696. + QMap<QString,int> m_fileWatcherMap;
  1697. +
  1698. + //! The tree view.
  1699. + QTreeView *m_treeView;
  1700. +
  1701. + //! The filters to apply to the directory.
  1702. + QDir::Filters m_dirFilter;
  1703. +
  1704. + //! The sort order to apply to the directory.
  1705. + QDir::SortFlags m_sorts;
  1706. +
  1707. + //! The mutex to protect the model.
  1708. + QMutex m_mutex;
  1709. +};
  1710. +
  1711. +#endif // FILESYSTEMMODEL_H
  1712. diff --git a/src/plugin/filetreeview/filetreeview.cpp b/src/plugin/filetreeview/filetreeview.cpp
  1713. new file mode 100644
  1714. index 0000000..a1afb12
  1715. --- /dev/null
  1716. +++ b/src/plugin/filetreeview/filetreeview.cpp
  1717. @@ -0,0 +1,195 @@
  1718. +/**
  1719. + ** This file is part of the NoteBook project.
  1720. + ** Copyright 2022 ji wang <[email protected]>.
  1721. + **
  1722. + ** This program is free software: you can redistribute it and/or modify
  1723. + ** it under the terms of the GNU Lesser General Public License as
  1724. + ** published by the Free Software Foundation, either version 3 of the
  1725. + ** License, or (at your option) any later version.
  1726. + **
  1727. + ** This program is distributed in the hope that it will be useful,
  1728. + ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  1729. + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1730. + ** GNU Lesser General Public License for more details.
  1731. + **
  1732. + ** You should have received a copy of the GNU Lesser General Public License
  1733. + ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  1734. + **/
  1735. +
  1736. +#include "filetreeview.h"
  1737. +
  1738. +#include <QTreeView>
  1739. +#include <QJsonObject>
  1740. +#include <QFileDialog>
  1741. +#include <QMenu>
  1742. +#include <QApplication>
  1743. +#include <QMessageBox>
  1744. +#include <QProcess>
  1745. +
  1746. +#include"actorprocessor.h"
  1747. +#include "filesystemmodel.h"
  1748. +
  1749. +class FileTreeViewPrivate
  1750. +{
  1751. +public:
  1752. + FileTreeViewPrivate(FileTreeView *parent):
  1753. + q_ptr(parent)
  1754. + {}
  1755. +
  1756. +public:
  1757. + ActorProcessor* m_processor;
  1758. + QMenu* m_fileMenu;
  1759. + QMenu* m_dirMenu;
  1760. + QWidget* m_notepadWidget;
  1761. +
  1762. +private:
  1763. + FileTreeView * const q_ptr;
  1764. + Q_DECLARE_PUBLIC(FileTreeView);
  1765. +};
  1766. +
  1767. +FileTreeView::FileTreeView(QWidget *parent):
  1768. + d_ptr(new FileTreeViewPrivate(this)),
  1769. + QTreeView(parent)
  1770. +{
  1771. + bindAction();
  1772. + setContextMenuPolicy(Qt::CustomContextMenu);
  1773. + connect(this, SIGNAL(doubleClicked(QModelIndex)),this, SLOT(slotDoubleCliecked(QModelIndex)));
  1774. + connect(this,SIGNAL(customContextMenuRequested(const QPoint &)),this, SLOT(slotCustomContextMenu(const QPoint &)));
  1775. +}
  1776. +
  1777. +FileTreeView::~FileTreeView()
  1778. +{}
  1779. +
  1780. +void FileTreeView::onNewWorkspaceItem(bool)
  1781. +{
  1782. + QString srcDirPath = QFileDialog::getExistingDirectory(
  1783. + this, "choose src Directory",
  1784. + "/");
  1785. + if (srcDirPath.isEmpty()){
  1786. + return;
  1787. + }
  1788. + FileSystemModel* model = static_cast<FileSystemModel*> (this->model());
  1789. + model->addRootPath(srcDirPath);
  1790. + model->reload();
  1791. + this->update();
  1792. +}
  1793. +
  1794. +void FileTreeView::slotCustomContextMenu(const QPoint & pos)
  1795. +{
  1796. + Q_D(FileTreeView);
  1797. + auto model = static_cast<FileSystemModel*>(this->model());
  1798. + auto index= this->indexAt(pos);
  1799. + if (model->nodeFromIndex(index)->isDir()){
  1800. + d->m_dirMenu->exec(QCursor::pos());
  1801. + }
  1802. + else {
  1803. + d->m_fileMenu->exec(QCursor::pos());
  1804. + }
  1805. +}
  1806. +
  1807. +void FileTreeView::slotTerminal(bool)
  1808. +{
  1809. +}
  1810. +
  1811. +void FileTreeView::slotNewFile(bool)
  1812. +{
  1813. +
  1814. +}
  1815. +
  1816. +void FileTreeView::slotRemoveFile(bool)
  1817. +{
  1818. +}
  1819. +
  1820. +void FileTreeView::slotAddDir(bool)
  1821. +{
  1822. +
  1823. +}
  1824. +
  1825. +void FileTreeView::slotRemoveDir(bool)
  1826. +{
  1827. + Q_D(FileTreeView);
  1828. + auto model = static_cast<FileSystemModel*>(this->model());
  1829. + auto index= this->currentIndex();
  1830. + if (model->nodeFromIndex(index)->isDir()){
  1831. + (d->m_dirMenu)->exec(QCursor::pos());
  1832. + }
  1833. + else {
  1834. + (d->m_fileMenu)->exec(QCursor::pos());
  1835. + }
  1836. +}
  1837. +
  1838. +void FileTreeView::slotupdateDir(bool)
  1839. +{
  1840. + auto model = static_cast<FileSystemModel*>(this->model());
  1841. + auto index= this->currentIndex();
  1842. + if (model->nodeFromIndex(index)->isDir()){
  1843. + model->reloadDirectory(model->nodeFromIndex(index)->getNodePath());
  1844. + }
  1845. +}
  1846. +
  1847. +void FileTreeView::initMenuFile(QMenu *menu)
  1848. +{
  1849. + Q_D(FileTreeView);
  1850. + d->m_fileMenu = menu;
  1851. +}
  1852. +
  1853. +void FileTreeView::initDirMenu(QMenu *menu)
  1854. +{
  1855. + Q_D(FileTreeView);
  1856. + d->m_dirMenu = menu;
  1857. +}
  1858. +
  1859. +void FileTreeView::bindAction()
  1860. +{
  1861. + Q_D(FileTreeView);
  1862. + QMenu* fileTreeMenu = new QMenu("menu",this);
  1863. + QMenu* dirTreeMenu = new QMenu("file",this);
  1864. +
  1865. + QAction *fileRename = new QAction(tr("Rename"),fileTreeMenu);
  1866. + QAction *fileDelete = new QAction(tr("Delete"),fileTreeMenu);
  1867. + QAction *fileOpenInExporter = new QAction(tr("OpenInExporter"),fileTreeMenu);
  1868. +
  1869. + QAction *removeDir = new QAction(tr("Remove Dir"),dirTreeMenu);
  1870. + QAction *update = new QAction(tr("Update"),dirTreeMenu);
  1871. + QAction *fold = new QAction(tr("Fold Dir"),dirTreeMenu);
  1872. + QAction *unfold = new QAction(tr("Unfold Dir"),dirTreeMenu);
  1873. + QAction *terminal = new QAction(tr("terminal"));
  1874. +
  1875. + d->m_dirMenu = dirTreeMenu;
  1876. + d->m_dirMenu->addActions({removeDir,update,fold,unfold,terminal});
  1877. + d->m_fileMenu = fileTreeMenu;
  1878. + d->m_fileMenu->addActions({fileRename,fileDelete,fileOpenInExporter,terminal});
  1879. +}
  1880. +
  1881. +void FileTreeView::setActorProcessor(ActorProcessor *processor)
  1882. +{
  1883. + Q_D(FileTreeView);
  1884. + d->m_processor = processor;
  1885. +}
  1886. +
  1887. +void FileTreeView::setMainWindow(QWidget *notepadWidget)
  1888. +{
  1889. + Q_D(FileTreeView);
  1890. + d->m_notepadWidget = notepadWidget;
  1891. +}
  1892. +
  1893. +
  1894. +
  1895. +void FileTreeView::slotCliecked(const QModelIndex &index)
  1896. +{
  1897. +}
  1898. +
  1899. +void FileTreeView::slotDoubleCliecked(const QModelIndex &index)
  1900. +{
  1901. + Q_D(FileTreeView);
  1902. + auto model = static_cast<FileSystemModel*>(this->model());
  1903. + if (model->nodeFromIndex(index)->isDir()){
  1904. + }
  1905. + else {
  1906. + d->m_processor->invoke("openFile",model->nodeFromIndex(index)->getNodePath(),-1);
  1907. + }
  1908. +}
  1909. +
  1910. +
  1911. +
  1912. +
  1913. diff --git a/src/plugin/filetreeview/filetreeview.h b/src/plugin/filetreeview/filetreeview.h
  1914. new file mode 100644
  1915. index 0000000..0a0e5e1
  1916. --- /dev/null
  1917. +++ b/src/plugin/filetreeview/filetreeview.h
  1918. @@ -0,0 +1,73 @@
  1919. +/**
  1920. + ** This file is part of the NoteBook project.
  1921. + ** Copyright 2022 ji wang <[email protected]>.
  1922. + **
  1923. + ** This program is free software: you can redistribute it and/or modify
  1924. + ** it under the terms of the GNU Lesser General Public License as
  1925. + ** published by the Free Software Foundation, either version 3 of the
  1926. + ** License, or (at your option) any later version.
  1927. + **
  1928. + ** This program is distributed in the hope that it will be useful,
  1929. + ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  1930. + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1931. + ** GNU Lesser General Public License for more details.
  1932. + **
  1933. + ** You should have received a copy of the GNU Lesser General Public License
  1934. + ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  1935. + **/
  1936. +
  1937. +
  1938. +#ifndef WORKSPACE_H
  1939. +#define WORKSPACE_H
  1940. +
  1941. +#include <QObject>
  1942. +#include <QTreeView>
  1943. +
  1944. +class QModelIndex;
  1945. +class QWidget;
  1946. +class QMenu;
  1947. +class ActorProcessor;
  1948. +
  1949. +class FileTreeViewPrivate;
  1950. +
  1951. +class FileTreeView : public QTreeView
  1952. +{
  1953. + Q_OBJECT
  1954. +public:
  1955. + FileTreeView(QWidget* parent = nullptr);
  1956. +
  1957. + ~FileTreeView();
  1958. +
  1959. + void initMenuFile(QMenu*);
  1960. + void initDirMenu(QMenu*);
  1961. +
  1962. + void bindAction();
  1963. + void setActorProcessor(ActorProcessor*processor);
  1964. +
  1965. + void setMainWindow(QWidget* notepadWidget);
  1966. +
  1967. +public slots:
  1968. + void onNewWorkspaceItem(bool);
  1969. + void slotCliecked(const QModelIndex &);
  1970. + void slotDoubleCliecked(const QModelIndex &);
  1971. + void slotCustomContextMenu(const QPoint &);
  1972. + void slotTerminal(bool);
  1973. + void slotNewFile(bool);
  1974. + void slotRemoveFile(bool);
  1975. + void slotAddDir(bool);
  1976. + void slotRemoveDir(bool);
  1977. + void slotupdateDir(bool);
  1978. +signals:
  1979. + void signalNewFile();
  1980. + void signalRemoveFile();
  1981. + void signalAddDir();
  1982. +
  1983. +private:
  1984. + FileTreeViewPrivate * const d_ptr;
  1985. + Q_DECLARE_PRIVATE(FileTreeView);
  1986. +
  1987. + FileTreeView(const FileTreeView &) = delete;
  1988. + FileTreeView &operator=(const FileTreeView &) = delete;
  1989. +};
  1990. +
  1991. +#endif // WORKSPACE_H
  1992. diff --git a/src/plugin/filetreeview/filetreeviewexport.cpp b/src/plugin/filetreeview/filetreeviewexport.cpp
  1993. new file mode 100644
  1994. index 0000000..4c43c84
  1995. --- /dev/null
  1996. +++ b/src/plugin/filetreeview/filetreeviewexport.cpp
  1997. @@ -0,0 +1,77 @@
  1998. +#include <qobject.h>
  1999. +#include <qstring.h>
  2000. +#include <pluginGl.h>
  2001. +#include <functional>
  2002. +#include <qsciscintilla.h>
  2003. +#include <QAction>
  2004. +#include <QDebug>
  2005. +
  2006. +#include "filetreeviewplugin.h"
  2007. +#include "actorprocessor.h"
  2008. +#define NDD_EXPORTDLL
  2009. +
  2010. +#if defined(Q_OS_WIN)
  2011. +#if defined(NDD_EXPORTDLL)
  2012. +#define NDD_EXPORT __declspec(dllexport)
  2013. +#else
  2014. +#define NDD_EXPORT __declspec(dllimport)
  2015. +#endif
  2016. +#else
  2017. +#define NDD_EXPORT __attribute__((visibility("default")))
  2018. +#endif
  2019. +
  2020. +#ifdef __cplusplus
  2021. +extern "C" {
  2022. +#endif
  2023. +
  2024. +NDD_EXPORT bool NDD_PROC_IDENTIFY(NDD_PROC_DATA* pProcData);
  2025. +//NDD_EXPORT int NDD_PROC_MAIN(QWidget* pNotepad, const QString& strFileName, std::function<QsciScintilla* ()>getCurEdit, NDD_PROC_DATA* procData);
  2026. +NDD_EXPORT int NDD_PROC_MAIN_V2(QWidget* pNotepad, const QString& strFileName,ActorProcessor* processor, NDD_PROC_DATA* procData);
  2027. +
  2028. +#ifdef __cplusplus
  2029. +}
  2030. +#endif
  2031. +
  2032. +static NDD_PROC_DATA s_procData;
  2033. +static QWidget* s_pMainNotepad = nullptr;
  2034. +std::function<QsciScintilla* ()> s_getCurEdit;
  2035. +
  2036. +bool NDD_PROC_IDENTIFY(NDD_PROC_DATA* pProcData)
  2037. +{
  2038. + if(pProcData == NULL)
  2039. + {
  2040. + return false;
  2041. + }
  2042. + pProcData->m_strPlugName = QObject::tr("File Tree");
  2043. + pProcData->m_strComment = QObject::tr("file tree plugin");
  2044. +
  2045. + pProcData->m_version = QString("1.0");
  2046. + pProcData->m_auther = QString("[email protected]");
  2047. +
  2048. + pProcData->m_menuType = 1;
  2049. + return true;
  2050. +}
  2051. +
  2052. +int NDD_PROC_MAIN_V2(QWidget* pNotepad, const QString& strFileName,ActorProcessor* processor,NDD_PROC_DATA* pProcData)
  2053. +{
  2054. + qDebug() << "test plugin";
  2055. + //务必拷贝一份pProcData,在外面会释放。
  2056. + if (pProcData != nullptr)
  2057. + {
  2058. + s_procData = *pProcData;
  2059. + }
  2060. + else
  2061. + {
  2062. + return -1;
  2063. + }
  2064. +
  2065. + s_pMainNotepad = pNotepad;
  2066. + FileTreeViewPlugin* plugin = new FileTreeViewPlugin();
  2067. + plugin->setPluginModulePath(strFileName);
  2068. + plugin->setActorProcessor(processor);
  2069. + plugin->setTopMenu(pProcData->m_rootMenu);
  2070. + plugin->setMenuActions(s_procData.m_rootMenu);
  2071. + plugin->setNotepad(s_pMainNotepad);
  2072. +
  2073. + return 0;
  2074. +}
  2075. diff --git a/src/plugin/filetreeview/filetreeviewplugin.cpp b/src/plugin/filetreeview/filetreeviewplugin.cpp
  2076. new file mode 100644
  2077. index 0000000..97eda35
  2078. --- /dev/null
  2079. +++ b/src/plugin/filetreeview/filetreeviewplugin.cpp
  2080. @@ -0,0 +1,121 @@
  2081. +#include "filetreeviewplugin.h"
  2082. +
  2083. +#include <QDockWidget>
  2084. +#include <QObject>
  2085. +#include <QAction>
  2086. +#include <QFileInfo>
  2087. +#include <QMainWindow>
  2088. +#include <QDir>
  2089. +#include <QTreeView>
  2090. +#include <QDebug>
  2091. +
  2092. +#include <qsciscintilla.h>
  2093. +
  2094. +#include "filetreeview.h"
  2095. +#include "filesystemmodel.h"
  2096. +#include "qheaderview.h"
  2097. +#include "actorprocessor.h"
  2098. +
  2099. +class FileTreeViewPluginPrivate
  2100. +{
  2101. +public:
  2102. + FileTreeViewPluginPrivate(FileTreeViewPlugin *parent):
  2103. + q_ptr(parent)
  2104. + {}
  2105. +
  2106. +public:
  2107. + ActorProcessor* m_processor;
  2108. + QWidget* m_notepadWidget;
  2109. + QMenu* m_topMenu;
  2110. + QString m_pluginModulePath;
  2111. + QDockWidget* m_dockWidget;
  2112. + FileTreeView*m_treeview;
  2113. + FileSystemModel * m_model;
  2114. +
  2115. + std::function<QsciScintilla* ()> getCurrentEditFunc;
  2116. +
  2117. +private:
  2118. + FileTreeViewPlugin * const q_ptr;
  2119. + Q_DECLARE_PUBLIC(FileTreeViewPlugin);
  2120. +};
  2121. +
  2122. +FileTreeViewPlugin::FileTreeViewPlugin(QObject *parent):
  2123. + d_ptr(new FileTreeViewPluginPrivate(this))
  2124. +{}
  2125. +
  2126. +FileTreeViewPlugin::~FileTreeViewPlugin()
  2127. +{
  2128. +}
  2129. +
  2130. +void FileTreeViewPlugin::setActorProcessor(ActorProcessor *processor)
  2131. +{
  2132. + Q_D(FileTreeViewPlugin);
  2133. + d->m_processor = processor;
  2134. +}
  2135. +
  2136. +void FileTreeViewPlugin::setPluginModulePath(const QString &newPluginModulePath)
  2137. +{
  2138. + Q_D(FileTreeViewPlugin);
  2139. + d->m_pluginModulePath = newPluginModulePath;
  2140. +}
  2141. +
  2142. +void FileTreeViewPlugin::bindAction()
  2143. +{
  2144. +}
  2145. +
  2146. +void FileTreeViewPlugin::setTopMenu(QMenu *newTopMenu)
  2147. +{
  2148. + Q_D(FileTreeViewPlugin);
  2149. + d->m_topMenu = newTopMenu;
  2150. +}
  2151. +
  2152. +void FileTreeViewPlugin::setNotepad(QWidget *newNotepad)
  2153. +{
  2154. + Q_D(FileTreeViewPlugin);
  2155. + d->m_notepadWidget = newNotepad;
  2156. +}
  2157. +
  2158. +void FileTreeViewPlugin::setMenuActions(QMenu *menu)
  2159. +{
  2160. + Q_D(FileTreeViewPlugin);
  2161. + QAction* pAction = new QAction("File Tree", menu);
  2162. + menu->addAction(pAction);
  2163. + connect(pAction, SIGNAL(triggered()),this,SLOT(slotMenuItemClick()));
  2164. +}
  2165. +
  2166. +void FileTreeViewPlugin::setCurrentEditFunc(std::function<QsciScintilla *()> func)
  2167. +{
  2168. + Q_D(FileTreeViewPlugin);
  2169. + d->getCurrentEditFunc = func;
  2170. +}
  2171. +
  2172. +void FileTreeViewPlugin::slotMenuItemClick()
  2173. +{
  2174. + Q_D(FileTreeViewPlugin);
  2175. +
  2176. + auto action = qobject_cast<QAction*>(sender());
  2177. + auto mainWindow = dynamic_cast<QMainWindow*>(d->m_notepadWidget);
  2178. + if (!mainWindow)
  2179. + return;
  2180. +
  2181. + if (!d->m_dockWidget) {
  2182. + d->m_dockWidget = new QDockWidget(mainWindow);
  2183. + mainWindow->addDockWidget(Qt::LeftDockWidgetArea, d->m_dockWidget);
  2184. +
  2185. + d->m_treeview = new FileTreeView();
  2186. + d->m_treeview->setActorProcessor(d->m_processor);
  2187. + d->m_treeview->setMainWindow(d->m_notepadWidget);
  2188. + d->m_treeview->header()->setVisible(false);
  2189. + d->m_model = new FileSystemModel(d->m_treeview);
  2190. + d->m_model->setRootPath("C:");
  2191. +
  2192. + QAction* pAction = new QAction("Open Fold", d->m_topMenu);
  2193. + d->m_topMenu->addAction(pAction);
  2194. + connect(pAction, SIGNAL(triggered(bool)),d->m_treeview,SLOT(onNewWorkspaceItem(bool)));
  2195. + d->m_treeview->setModel(d->m_model);
  2196. + d->m_dockWidget->setWidget(d->m_treeview);
  2197. + }
  2198. +
  2199. + if (!d->m_dockWidget->isVisible())
  2200. + d->m_dockWidget->show();
  2201. +}
  2202. diff --git a/src/plugin/filetreeview/filetreeviewplugin.h b/src/plugin/filetreeview/filetreeviewplugin.h
  2203. new file mode 100644
  2204. index 0000000..fd35186
  2205. --- /dev/null
  2206. +++ b/src/plugin/filetreeview/filetreeviewplugin.h
  2207. @@ -0,0 +1,40 @@
  2208. +#ifndef FILETREEWIDGET_H
  2209. +#define FILETREEWIDGET_H
  2210. +
  2211. +#include <QWidget>
  2212. +#include <QMenu>
  2213. +#include <QString>
  2214. +
  2215. +class QsciScintilla;
  2216. +class FileTreeViewPluginPrivate;
  2217. +class ActorProcessor;
  2218. +
  2219. +class FileTreeViewPlugin :public QObject
  2220. +{
  2221. + Q_OBJECT
  2222. +public:
  2223. + FileTreeViewPlugin(QObject *parent = nullptr);
  2224. + ~FileTreeViewPlugin();
  2225. +
  2226. +public:
  2227. + void setActorProcessor(ActorProcessor*processor);
  2228. + void setMenuActions(QMenu *menu);
  2229. + void setCurrentEditFunc(std::function<QsciScintilla* ()> func);
  2230. + void setNotepad(QWidget *newNotepad);
  2231. + void setTopMenu(QMenu *newTopMenu);
  2232. + void setPluginModulePath(const QString &newPluginModulePath);
  2233. +private:
  2234. + void bindAction();
  2235. +
  2236. +public slots:
  2237. + void slotMenuItemClick();
  2238. +
  2239. +private:
  2240. + FileTreeViewPluginPrivate * const d_ptr;
  2241. + Q_DECLARE_PRIVATE(FileTreeViewPlugin);
  2242. +
  2243. + FileTreeViewPlugin(const FileTreeViewPlugin &) = delete;
  2244. + FileTreeViewPlugin &operator=(const FileTreeViewPlugin &) = delete;
  2245. +};
  2246. +
  2247. +#endif // FILETREEWIDGET_H
  2248. --
  2249. 2.33.1
  2250. From 527db1baa78809845ce4589841d4e327ae6b5c1b Mon Sep 17 00:00:00 2001
  2251. From: matheuter <[email protected]>
  2252. Date: Thu, 20 Apr 2023 17:01:50 +0800
  2253. Subject: [PATCH 2/4] add actor to plugin_v2
  2254. ---
  2255. src/plugin/filetreeview/actor.h | 35 +++++++++++++++++----------------
  2256. 1 file changed, 18 insertions(+), 17 deletions(-)
  2257. diff --git a/src/plugin/filetreeview/actor.h b/src/plugin/filetreeview/actor.h
  2258. index d3901a2..70cd9ff 100644
  2259. --- a/src/plugin/filetreeview/actor.h
  2260. +++ b/src/plugin/filetreeview/actor.h
  2261. @@ -1,3 +1,21 @@
  2262. +/**
  2263. + ** This file is part of ndd file tree view plugin
  2264. + ** Copyright 2022-2023 ji wang <[email protected]>.
  2265. + **
  2266. + ** This program is free software: you can redistribute it and/or modify
  2267. + ** it under the terms of the GNU Lesser General Public License as
  2268. + ** published by the Free Software Foundation, either version 3 of the
  2269. + ** License, or (at your option) any later version.
  2270. + **
  2271. + ** This program is distributed in the hope that it will be useful,
  2272. + ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  2273. + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2274. + ** GNU Lesser General Public License for more details.
  2275. + **
  2276. + ** You should have received a copy of the GNU Lesser General Public License
  2277. + ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  2278. + **/
  2279. +
  2280. #pragma once
  2281. #include <cstdint>
  2282. #include <string>
  2283. @@ -57,11 +75,6 @@ public:
  2284. return return_value;
  2285. }
  2286. - Ptr getSharedPtr()
  2287. - {
  2288. - return shared_from_this();
  2289. - }
  2290. -
  2291. public:
  2292. /**
  2293. * @brief This struct encapsulates a function,
  2294. @@ -71,9 +84,6 @@ public:
  2295. template<typename Function>
  2296. struct invoker
  2297. {
  2298. - /**
  2299. - * @brief
  2300. - */
  2301. static inline void apply(const Function& func, void* bl, void* result)
  2302. {
  2303. using tuple_type = typename function_traits<Function>::tuple_type;
  2304. @@ -81,9 +91,6 @@ public:
  2305. call(func, *tp, result);
  2306. }
  2307. - /**
  2308. - * @brief
  2309. - */
  2310. template<typename F, typename ... Args>
  2311. static typename std::enable_if<std::is_void<typename std::result_of<F(Args...)>::type>::value>::type
  2312. call(const F& f, const std::tuple<Args...>& tp, void*)
  2313. @@ -91,9 +98,6 @@ public:
  2314. call_helper(f, std::make_index_sequence<sizeof... (Args)>{}, tp);
  2315. }
  2316. - /**
  2317. - * @brief
  2318. - */
  2319. template<typename F, typename ... Args>
  2320. static typename std::enable_if<!std::is_void<typename std::result_of<F(Args...)>::type>::value>::type
  2321. call(const F& f, const std::tuple<Args...>& tp, void* result)
  2322. @@ -102,9 +106,6 @@ public:
  2323. *(decltype(r)*)result = r;
  2324. }
  2325. - /**
  2326. - * @brief
  2327. - */
  2328. template<typename F, size_t... I, typename ... Args>
  2329. static auto call_helper(const F& f, const std::index_sequence<I...>& h, const std::tuple<Args...>& tup)
  2330. {
  2331. --
  2332. 2.33.1
  2333. From 4ab86338f19fcd2e4d4b8565ba34af189174eb82 Mon Sep 17 00:00:00 2001
  2334. From: matheuter <[email protected]>
  2335. Date: Thu, 20 Apr 2023 17:19:00 +0800
  2336. Subject: [PATCH 3/4] update command
  2337. ---
  2338. src/actor.h | 24 +----------
  2339. src/actorprocessor.cpp | 19 ++-------
  2340. src/actorprocessor.h | 23 ++---------
  2341. src/plugin/filetreeview/abstractfile.cpp | 6 ---
  2342. src/plugin/filetreeview/abstractfile.h | 11 -----
  2343. src/plugin/filetreeview/actor.h | 5 ++-
  2344. src/plugin/filetreeview/actorprocessor.cpp | 19 +++++++++
  2345. src/plugin/filetreeview/actorprocessor.h | 41 ++++++++++---------
  2346. src/plugin/filetreeview/filetreeview.cpp | 4 +-
  2347. src/plugin/filetreeview/filetreeview.h | 5 +--
  2348. .../filetreeview/filetreeviewplugin.cpp | 18 ++++++++
  2349. src/plugin/filetreeview/filetreeviewplugin.h | 21 +++++++++-
  2350. 12 files changed, 93 insertions(+), 103 deletions(-)
  2351. delete mode 100644 src/plugin/filetreeview/abstractfile.cpp
  2352. delete mode 100644 src/plugin/filetreeview/abstractfile.h
  2353. diff --git a/src/actor.h b/src/actor.h
  2354. index 86378d0..0fb51c3 100644
  2355. --- a/src/actor.h
  2356. +++ b/src/actor.h
  2357. @@ -1,4 +1,4 @@
  2358. -#pragma once
  2359. +
  2360. #include <cstdint>
  2361. #include <string>
  2362. #include <memory>
  2363. @@ -7,10 +7,6 @@
  2364. #include "functiontraits.h"
  2365. -/**
  2366. - * @brief Actor class, which encapsulates the event model
  2367. - * @note enable_shared_from_this allows us to get safe Pointers internally
  2368. - */
  2369. class Actor : public std::enable_shared_from_this<Actor>
  2370. {
  2371. public:
  2372. @@ -21,27 +17,18 @@ public:
  2373. Actor(){}
  2374. ~Actor(){}
  2375. - /**
  2376. - * @brief Register the callback function and construct the anonymous function with std::bind
  2377. - */
  2378. template<typename Function>
  2379. void operator+=(Function&& function_any) noexcept
  2380. {
  2381. m_invokeFunctionWapper = { std::bind(&invoker<Function>::apply, function_any, std::placeholders::_1, std::placeholders::_2) };
  2382. }
  2383. - /**
  2384. - * @brief Register the callback function and construct the anonymous function with std::bind
  2385. - */
  2386. template<typename Function>
  2387. void registerFunction(Function&& function_any) noexcept
  2388. {
  2389. m_invokeFunctionWapper = { std::bind(&invoker<Function>::apply, function_any, std::placeholders::_1, std::placeholders::_2) };
  2390. }
  2391. - /**
  2392. - * @brief Register the callback function and construct the anonymous function with std::bind
  2393. - */
  2394. template<typename ... Args>
  2395. void invoke(Args&& ... args) const noexcept
  2396. {
  2397. @@ -49,9 +36,6 @@ public:
  2398. m_invokeFunctionWapper(&args_tuple, nullptr);
  2399. }
  2400. - /**
  2401. - * @brief Register the callback function and construct the anonymous function with std::bind
  2402. - */
  2403. template<typename R, typename ... Args>
  2404. R invoke(Args&& ...args) const
  2405. {
  2406. @@ -66,12 +50,8 @@ public:
  2407. return return_value;
  2408. }
  2409. - Ptr getSharedPtr()
  2410. - {
  2411. - return shared_from_this();
  2412. - }
  2413. -
  2414. public:
  2415. +
  2416. /**
  2417. * @brief This struct encapsulates a function,
  2418. * essentially storing the return value and parameters in two variables
  2419. diff --git a/src/actorprocessor.cpp b/src/actorprocessor.cpp
  2420. index 099d1f6..6dfd1f4 100644
  2421. --- a/src/actorprocessor.cpp
  2422. +++ b/src/actorprocessor.cpp
  2423. @@ -1,11 +1,9 @@
  2424. -#include "actorprocessor.h"
  2425. +#include "actorprocessor.h"
  2426. +
  2427. ActorProcessor::ActorProcessor():
  2428. m_actorMap(new std::unordered_map<std::string, Actor*>)
  2429. {}
  2430. -/**
  2431. - * @brief
  2432. - */
  2433. ActorProcessor::~ActorProcessor()
  2434. {
  2435. for (auto& item : (*m_actorMap))
  2436. @@ -17,17 +15,11 @@ ActorProcessor::~ActorProcessor()
  2437. delete m_actorMap;
  2438. }
  2439. -/**
  2440. - * @brief
  2441. - */
  2442. void ActorProcessor::registerActor(const std::string &route, Actor *actor)
  2443. {
  2444. m_actorMap->insert(std::make_pair(route,actor));
  2445. }
  2446. -/**
  2447. - * @brief
  2448. - */
  2449. void ActorProcessor::removeActor(const std::string &route)
  2450. {
  2451. auto iter = (*m_actorMap).find(route);
  2452. @@ -38,9 +30,6 @@ void ActorProcessor::removeActor(const std::string &route)
  2453. }
  2454. }
  2455. -/**
  2456. - * @brief
  2457. - */
  2458. Actor *ActorProcessor::findActor(const std::string &route)
  2459. {
  2460. auto iter = (*m_actorMap).find(route);
  2461. @@ -51,9 +40,7 @@ Actor *ActorProcessor::findActor(const std::string &route)
  2462. return nullptr;
  2463. }
  2464. -/**
  2465. - * @brief
  2466. - */
  2467. +
  2468. bool ActorProcessor::resetActor(const std::string &route, Actor *actor)
  2469. {
  2470. auto iter = (*m_actorMap).find(route);
  2471. diff --git a/src/actorprocessor.h b/src/actorprocessor.h
  2472. index 9026909..def5b06 100644
  2473. --- a/src/actorprocessor.h
  2474. +++ b/src/actorprocessor.h
  2475. @@ -1,5 +1,5 @@
  2476. -#ifndef EVENTPROCESSOR_H
  2477. -#define EVENTPROCESSOR_H
  2478. +#ifndef _PROCESSOR_H
  2479. +#define _PROCESSOR_H
  2480. #include <string>
  2481. #include <functional>
  2482. @@ -25,9 +25,6 @@ public:
  2483. (*m_actorMap)[route]->invoke(std::forward<Args>(args)...);
  2484. }
  2485. - /**
  2486. - * @brief Register the callback function and construct the anonymous function with std::bind
  2487. - */
  2488. template<typename R, typename ... Args>
  2489. R invoke(const std::string& route,Args&& ...args) const
  2490. {
  2491. @@ -36,30 +33,16 @@ public:
  2492. return nullptr;
  2493. }
  2494. - /**
  2495. - * @brief 注册一个actor,其中route是唯一的
  2496. - */
  2497. void registerActor(const std::string& route, Actor*actor);
  2498. - /**
  2499. - * @brief 删除一个actor
  2500. - */
  2501. void removeActor(const std::string& route);
  2502. -
  2503. - /**
  2504. - * @brief 查找一个actor, 返回其指针
  2505. - */
  2506. Actor* findActor(const std::string& route);
  2507. -
  2508. - /**
  2509. - * @brief 重置一个actor,注意原有的actor会被删除
  2510. - */
  2511. bool resetActor(const std::string& route,Actor*actor);
  2512. private:
  2513. std::unordered_map<std::string, Actor*>* m_actorMap;
  2514. +
  2515. private:
  2516. - // not allow copy constroct
  2517. ActorProcessor(ActorProcessor&&)=delete;
  2518. ActorProcessor& operator=(const ActorProcessor&)=delete;
  2519. };
  2520. diff --git a/src/plugin/filetreeview/abstractfile.cpp b/src/plugin/filetreeview/abstractfile.cpp
  2521. deleted file mode 100644
  2522. index 9b8673f..0000000
  2523. --- a/src/plugin/filetreeview/abstractfile.cpp
  2524. +++ /dev/null
  2525. @@ -1,6 +0,0 @@
  2526. -#include "abstractfile.h"
  2527. -
  2528. -AbstractFile::AbstractFile()
  2529. -{
  2530. -
  2531. -}
  2532. diff --git a/src/plugin/filetreeview/abstractfile.h b/src/plugin/filetreeview/abstractfile.h
  2533. deleted file mode 100644
  2534. index 94ae7dc..0000000
  2535. --- a/src/plugin/filetreeview/abstractfile.h
  2536. +++ /dev/null
  2537. @@ -1,11 +0,0 @@
  2538. -#ifndef ABSTRACTFILE_H
  2539. -#define ABSTRACTFILE_H
  2540. -
  2541. -
  2542. -class AbstractFile
  2543. -{
  2544. -public:
  2545. - AbstractFile();
  2546. -};
  2547. -
  2548. -#endif // ABSTRACTFILE_H
  2549. diff --git a/src/plugin/filetreeview/actor.h b/src/plugin/filetreeview/actor.h
  2550. index 70cd9ff..30b6f00 100644
  2551. --- a/src/plugin/filetreeview/actor.h
  2552. +++ b/src/plugin/filetreeview/actor.h
  2553. @@ -1,6 +1,6 @@
  2554. /**
  2555. - ** This file is part of ndd file tree view plugin
  2556. - ** Copyright 2022-2023 ji wang <[email protected]>.
  2557. + ** This file is part of ndd plugin file tree view
  2558. + ** Copyright ji wang <[email protected]>.
  2559. **
  2560. ** This program is free software: you can redistribute it and/or modify
  2561. ** it under the terms of the GNU Lesser General Public License as
  2562. @@ -16,6 +16,7 @@
  2563. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  2564. **/
  2565. +
  2566. #pragma once
  2567. #include <cstdint>
  2568. #include <string>
  2569. diff --git a/src/plugin/filetreeview/actorprocessor.cpp b/src/plugin/filetreeview/actorprocessor.cpp
  2570. index 099d1f6..96af367 100644
  2571. --- a/src/plugin/filetreeview/actorprocessor.cpp
  2572. +++ b/src/plugin/filetreeview/actorprocessor.cpp
  2573. @@ -1,3 +1,22 @@
  2574. +/**
  2575. + ** This file is part of ndd plugin file tree view
  2576. + ** Copyright ji wang <[email protected]>.
  2577. + **
  2578. + ** This program is free software: you can redistribute it and/or modify
  2579. + ** it under the terms of the GNU Lesser General Public License as
  2580. + ** published by the Free Software Foundation, either version 3 of the
  2581. + ** License, or (at your option) any later version.
  2582. + **
  2583. + ** This program is distributed in the hope that it will be useful,
  2584. + ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  2585. + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2586. + ** GNU Lesser General Public License for more details.
  2587. + **
  2588. + ** You should have received a copy of the GNU Lesser General Public License
  2589. + ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  2590. + **/
  2591. +
  2592. +
  2593. #include "actorprocessor.h"
  2594. ActorProcessor::ActorProcessor():
  2595. m_actorMap(new std::unordered_map<std::string, Actor*>)
  2596. diff --git a/src/plugin/filetreeview/actorprocessor.h b/src/plugin/filetreeview/actorprocessor.h
  2597. index d057e6d..76c6035 100644
  2598. --- a/src/plugin/filetreeview/actorprocessor.h
  2599. +++ b/src/plugin/filetreeview/actorprocessor.h
  2600. @@ -1,5 +1,24 @@
  2601. -#ifndef EVENTPROCESSOR_H
  2602. -#define EVENTPROCESSOR_H
  2603. +/**
  2604. + ** This file is part of ndd plugin file tree view
  2605. + ** Copyright ji wang <[email protected]>.
  2606. + **
  2607. + ** This program is free software: you can redistribute it and/or modify
  2608. + ** it under the terms of the GNU Lesser General Public License as
  2609. + ** published by the Free Software Foundation, either version 3 of the
  2610. + ** License, or (at your option) any later version.
  2611. + **
  2612. + ** This program is distributed in the hope that it will be useful,
  2613. + ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  2614. + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2615. + ** GNU Lesser General Public License for more details.
  2616. + **
  2617. + ** You should have received a copy of the GNU Lesser General Public License
  2618. + ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  2619. + **/
  2620. +
  2621. +
  2622. +#ifndef _PROCESSOR_H
  2623. +#define _PROCESSOR_H
  2624. #include <string>
  2625. #include <functional>
  2626. @@ -15,9 +34,6 @@ public:
  2627. ~ActorProcessor();
  2628. public:
  2629. - /**
  2630. - * @brief Register the callback function and construct the anonymous function with std::bind
  2631. - */
  2632. template<typename ... Args>
  2633. void invoke(const std::string& route,Args&& ... args) const noexcept
  2634. {
  2635. @@ -25,9 +41,6 @@ public:
  2636. (*m_actorMap)[route]->invoke(std::forward<Args>(args)...);
  2637. }
  2638. - /**
  2639. - * @brief Register the callback function and construct the anonymous function with std::bind
  2640. - */
  2641. template<typename R, typename ... Args>
  2642. R invoke(const std::string& route,Args&& ...args) const
  2643. {
  2644. @@ -36,24 +49,12 @@ public:
  2645. return nullptr;
  2646. }
  2647. - /**
  2648. - * @brief 注册一个actor,其中route是唯一的
  2649. - */
  2650. void registerActor(const std::string& route, Actor*actor);
  2651. - /**
  2652. - * @brief 删除一个actor
  2653. - */
  2654. void removeActor(const std::string& route);
  2655. - /**
  2656. - * @brief 查找一个actor, 返回其指针
  2657. - */
  2658. Actor* findActor(const std::string& route);
  2659. - /**
  2660. - * @brief 重置一个actor,注意原有的actor会被删除
  2661. - */
  2662. bool resetActor(const std::string& route,Actor*actor);
  2663. private:
  2664. diff --git a/src/plugin/filetreeview/filetreeview.cpp b/src/plugin/filetreeview/filetreeview.cpp
  2665. index a1afb12..1259296 100644
  2666. --- a/src/plugin/filetreeview/filetreeview.cpp
  2667. +++ b/src/plugin/filetreeview/filetreeview.cpp
  2668. @@ -1,6 +1,6 @@
  2669. /**
  2670. - ** This file is part of the NoteBook project.
  2671. - ** Copyright 2022 ji wang <[email protected]>.
  2672. + ** This file is part of ndd plugin file tree view
  2673. + ** Copyright ji wang <[email protected]>.
  2674. **
  2675. ** This program is free software: you can redistribute it and/or modify
  2676. ** it under the terms of the GNU Lesser General Public License as
  2677. diff --git a/src/plugin/filetreeview/filetreeview.h b/src/plugin/filetreeview/filetreeview.h
  2678. index 0a0e5e1..9a1eda2 100644
  2679. --- a/src/plugin/filetreeview/filetreeview.h
  2680. +++ b/src/plugin/filetreeview/filetreeview.h
  2681. @@ -1,6 +1,6 @@
  2682. /**
  2683. - ** This file is part of the NoteBook project.
  2684. - ** Copyright 2022 ji wang <[email protected]>.
  2685. + ** This file is part of ndd plugin file tree view
  2686. + ** Copyright ji wang <[email protected]>.
  2687. **
  2688. ** This program is free software: you can redistribute it and/or modify
  2689. ** it under the terms of the GNU Lesser General Public License as
  2690. @@ -16,7 +16,6 @@
  2691. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  2692. **/
  2693. -
  2694. #ifndef WORKSPACE_H
  2695. #define WORKSPACE_H
  2696. diff --git a/src/plugin/filetreeview/filetreeviewplugin.cpp b/src/plugin/filetreeview/filetreeviewplugin.cpp
  2697. index 97eda35..83efcec 100644
  2698. --- a/src/plugin/filetreeview/filetreeviewplugin.cpp
  2699. +++ b/src/plugin/filetreeview/filetreeviewplugin.cpp
  2700. @@ -8,6 +8,24 @@
  2701. #include <QDir>
  2702. #include <QTreeView>
  2703. #include <QDebug>
  2704. +/**
  2705. + ** This file is part of ndd plugin file tree view
  2706. + ** Copyright ji wang <[email protected]>.
  2707. + **
  2708. + ** This program is free software: you can redistribute it and/or modify
  2709. + ** it under the terms of the GNU Lesser General Public License as
  2710. + ** published by the Free Software Foundation, either version 3 of the
  2711. + ** License, or (at your option) any later version.
  2712. + **
  2713. + ** This program is distributed in the hope that it will be useful,
  2714. + ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  2715. + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2716. + ** GNU Lesser General Public License for more details.
  2717. + **
  2718. + ** You should have received a copy of the GNU Lesser General Public License
  2719. + ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  2720. + **/
  2721. +
  2722. #include <qsciscintilla.h>
  2723. diff --git a/src/plugin/filetreeview/filetreeviewplugin.h b/src/plugin/filetreeview/filetreeviewplugin.h
  2724. index fd35186..336bbc6 100644
  2725. --- a/src/plugin/filetreeview/filetreeviewplugin.h
  2726. +++ b/src/plugin/filetreeview/filetreeviewplugin.h
  2727. @@ -1,4 +1,23 @@
  2728. -#ifndef FILETREEWIDGET_H
  2729. +/**
  2730. + ** This file is part of ndd plugin file tree view
  2731. + ** Copyright ji wang <[email protected]>.
  2732. + **
  2733. + ** This program is free software: you can redistribute it and/or modify
  2734. + ** it under the terms of the GNU Lesser General Public License as
  2735. + ** published by the Free Software Foundation, either version 3 of the
  2736. + ** License, or (at your option) any later version.
  2737. + **
  2738. + ** This program is distributed in the hope that it will be useful,
  2739. + ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  2740. + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2741. + ** GNU Lesser General Public License for more details.
  2742. + **
  2743. + ** You should have received a copy of the GNU Lesser General Public License
  2744. + ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  2745. + **/
  2746. +
  2747. +
  2748. +#ifndef FILETREEWIDGET_H
  2749. #define FILETREEWIDGET_H
  2750. #include <QWidget>
  2751. --
  2752. 2.33.1
  2753. From 2ad291e9753690727cf92ae18c0bcaa87d5ac169 Mon Sep 17 00:00:00 2001
  2754. From: matheuter <[email protected]>
  2755. Date: Thu, 20 Apr 2023 17:31:42 +0800
  2756. Subject: [PATCH 4/4] fix actor error
  2757. ---
  2758. src/actor.h | 6 +++++-
  2759. src/plugin/filetreeview/actor.h | 5 ++++-
  2760. src/plugin/filetreeview/actorprocessor.cpp | 1 -
  2761. 3 files changed, 9 insertions(+), 3 deletions(-)
  2762. diff --git a/src/actor.h b/src/actor.h
  2763. index 0fb51c3..17f1f16 100644
  2764. --- a/src/actor.h
  2765. +++ b/src/actor.h
  2766. @@ -1,4 +1,6 @@
  2767. -
  2768. +#ifndef _ACTOR_H_
  2769. +#define _ACTOR_H_
  2770. +
  2771. #include <cstdint>
  2772. #include <string>
  2773. #include <memory>
  2774. @@ -107,3 +109,5 @@ private:
  2775. */
  2776. FunctionWapper m_invokeFunctionWapper;
  2777. };
  2778. +
  2779. +#endif
  2780. diff --git a/src/plugin/filetreeview/actor.h b/src/plugin/filetreeview/actor.h
  2781. index 30b6f00..4de5752 100644
  2782. --- a/src/plugin/filetreeview/actor.h
  2783. +++ b/src/plugin/filetreeview/actor.h
  2784. @@ -16,8 +16,9 @@
  2785. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  2786. **/
  2787. +#ifndef _ACTOR_H_
  2788. +#define _ACTOR_H_
  2789. -#pragma once
  2790. #include <cstdint>
  2791. #include <string>
  2792. #include <memory>
  2793. @@ -120,3 +121,5 @@ private:
  2794. */
  2795. FunctionWapper m_invokeFunctionWapper;
  2796. };
  2797. +
  2798. +#endif
  2799. diff --git a/src/plugin/filetreeview/actorprocessor.cpp b/src/plugin/filetreeview/actorprocessor.cpp
  2800. index 96af367..972af41 100644
  2801. --- a/src/plugin/filetreeview/actorprocessor.cpp
  2802. +++ b/src/plugin/filetreeview/actorprocessor.cpp
  2803. @@ -16,7 +16,6 @@
  2804. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  2805. **/
  2806. -
  2807. #include "actorprocessor.h"
  2808. ActorProcessor::ActorProcessor():
  2809. m_actorMap(new std::unordered_map<std::string, Actor*>)
  2810. --
  2811. 2.33.1