Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

typica.cpp 362KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377
  1. /*16:*/
  2. #line 757 "./typica.w"
  3. #define PROGRAM_NAME "Typica"
  4. /*18:*/
  5. #line 840 "./typica.w"
  6. #include <QtCore>
  7. #include <QtGui>
  8. #include <QtScript>
  9. #include <QtScriptTools>
  10. #include <QtXml>
  11. #include <QtSql>
  12. #include <QtDebug>
  13. #include <QtXmlPatterns>
  14. #include <QtWebKit>
  15. /*:18*//*19:*/
  16. #line 855 "./typica.w"
  17. #include "helpmenu.h"
  18. /*:19*//*680:*/
  19. #line 15692 "./typica.w"
  20. #include "qextserialport.h"
  21. #include "qextserialenumerator.h"
  22. /*:680*/
  23. #line 760 "./typica.w"
  24. /*33:*/
  25. #line 1146 "./typica.w"
  26. class ScriptQMainWindow:public QMainWindow
  27. {
  28. Q_OBJECT
  29. public:
  30. ScriptQMainWindow();
  31. public slots:
  32. void show();
  33. void saveSizeAndPosition(const QString&key);
  34. void restoreSizeAndPosition(const QString&key);
  35. void displayStatus(const QString&message= QString());
  36. protected:
  37. void closeEvent(QCloseEvent*event);
  38. void showEvent(QShowEvent*event);
  39. signals:
  40. void aboutToClose(void);
  41. };
  42. /*:33*//*136:*/
  43. #line 3265 "./typica.w"
  44. class SqlQueryConnection:public QSqlQuery
  45. {
  46. public:
  47. SqlQueryConnection(const QString&query= QString());
  48. ~SqlQueryConnection();
  49. QSqlQuery*operator->();
  50. private:
  51. QString connection;
  52. QSqlQuery*q;
  53. };
  54. /*:136*//*197:*/
  55. #line 5035 "./typica.w"
  56. class NumericDelegate:public QItemDelegate
  57. {
  58. Q_OBJECT
  59. public:
  60. NumericDelegate(QObject*parent= NULL);
  61. QWidget*createEditor(QWidget*parent,
  62. const QStyleOptionViewItem&option,
  63. const QModelIndex&index)const;
  64. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  65. void setModelData(QWidget*editor,QAbstractItemModel*model,
  66. const QModelIndex&index)const;
  67. void updateEditorGeometry(QWidget*editor,
  68. const QStyleOptionViewItem&option,
  69. const QModelIndex&index)const;
  70. };
  71. /*:197*//*227:*/
  72. #line 5675 "./typica.w"
  73. class Measurement
  74. {
  75. public:
  76. enum TemperatureUnits
  77. {
  78. Fahrenheit= 10144,
  79. Celsius= 10143,
  80. Kelvin= 10325,
  81. Rankine= 10145
  82. };
  83. private:
  84. double theTemperature;
  85. QTime theTime;
  86. TemperatureUnits unit;
  87. public:
  88. Measurement(double temperature= 0,QTime time= QTime(),
  89. TemperatureUnits sc= Fahrenheit);
  90. Measurement(double temperature);
  91. Measurement(const Measurement&x);
  92. Measurement&operator= (Measurement&x);
  93. ~Measurement();
  94. double temperature()const;
  95. QTime time()const;
  96. void setTemperature(double temperature);
  97. void setTime(QTime time);
  98. void setUnit(TemperatureUnits scale);
  99. TemperatureUnits scale();
  100. Measurement toFahrenheit();
  101. Measurement toCelsius();
  102. Measurement toKelvin();
  103. Measurement toRankine();
  104. };
  105. /*:227*//*239:*/
  106. #line 5977 "./typica.w"
  107. class Channel;
  108. class DAQImplementation;
  109. class DAQ:public QObject
  110. {
  111. Q_OBJECT
  112. Q_ENUMS(TemperatureUnits)
  113. Q_ENUMS(ThermocoupleType)
  114. DAQImplementation*imp;
  115. private slots:
  116. void threadFinished();
  117. public:
  118. DAQ(QString device,const QString&driver= QString("nidaqmxbase"));
  119. ~DAQ();
  120. Channel*newChannel(int units,int thermocouple);
  121. Q_INVOKABLE void setClockRate(double Hz);
  122. Q_INVOKABLE void start();
  123. Q_INVOKABLE void stop();
  124. enum TemperatureUnits
  125. {
  126. Fahrenheit= 10144,
  127. Celsius= 10143,
  128. Kelvin= 10325,
  129. Rankine= 10145
  130. };
  131. enum ThermocoupleType
  132. {
  133. TypeJ= 10072,
  134. TypeK= 10073,
  135. TypeN= 10077,
  136. TypeR= 10082,
  137. TypeS= 10085,
  138. TypeT= 10086,
  139. TypeB= 10047,
  140. TypeE= 10055
  141. };
  142. };
  143. /*:239*//*240:*/
  144. #line 6023 "./typica.w"
  145. class DAQImplementation:public QThread
  146. {
  147. Q_OBJECT
  148. public:
  149. DAQImplementation(const QString&driverinfo);
  150. ~DAQImplementation();
  151. void run();
  152. void measure();
  153. /*241:*/
  154. #line 6043 "./typica.w"
  155. typedef int(*daqfp)(...);
  156. daqfp read;
  157. daqfp errorInfo;
  158. daqfp startTask;
  159. daqfp createTask;
  160. daqfp createChannel;
  161. daqfp setClock;
  162. daqfp stopTask;
  163. daqfp clearTask;
  164. daqfp resetDevice;
  165. daqfp waitForMeasurement;
  166. /*:241*/
  167. #line 6032 "./typica.w"
  168. /*242:*/
  169. #line 6059 "./typica.w"
  170. bool useBase;
  171. QString device;
  172. QVector<Channel*> channelMap;
  173. unsigned int handle;
  174. int error;
  175. int channels;
  176. bool ready;
  177. QLibrary driver;
  178. QVector<Measurement::TemperatureUnits> unitMap;
  179. /*:242*/
  180. #line 6033 "./typica.w"
  181. };
  182. /*:240*//*258:*/
  183. #line 6556 "./typica.w"
  184. class FakeDAQImplementation:public QThread
  185. {
  186. Q_OBJECT
  187. public:
  188. FakeDAQImplementation();
  189. ~FakeDAQImplementation();
  190. void run();
  191. void measure();
  192. QVector<Channel*> channelMap;
  193. int channels;
  194. bool ready;
  195. double clockRate;
  196. };
  197. class FakeDAQ:public QObject
  198. {
  199. Q_OBJECT
  200. FakeDAQImplementation*imp;
  201. public:
  202. FakeDAQ(QString device);
  203. ~FakeDAQ();
  204. Channel*newChannel(int units,int thermocouple);
  205. Q_INVOKABLE void setClockRate(double Hz);
  206. Q_INVOKABLE void start();
  207. };
  208. /*:258*//*265:*/
  209. #line 6743 "./typica.w"
  210. class Channel:public QObject
  211. {
  212. Q_OBJECT
  213. public:
  214. Channel();
  215. ~Channel();
  216. public slots:
  217. void input(Measurement measurement);
  218. signals:
  219. void newData(Measurement);
  220. };
  221. /*:265*//*269:*/
  222. #line 6806 "./typica.w"
  223. class LinearCalibrator:public QObject
  224. {
  225. Q_OBJECT
  226. Q_PROPERTY(double measuredLower READ measuredLower
  227. WRITE setMeasuredLower)
  228. Q_PROPERTY(double measuredUpper READ measuredUpper
  229. WRITE setMeasuredUpper)
  230. Q_PROPERTY(double mappedLower READ mappedLower WRITE setMappedLower)
  231. Q_PROPERTY(double mappedUpper READ mappedUpper WRITE setMappedUpper)
  232. Q_PROPERTY(bool closedRange READ isClosedRange WRITE setClosedRange)
  233. Q_PROPERTY(double sensitivity READ sensitivity WRITE setSensitivity)
  234. public:
  235. LinearCalibrator(QObject*parent= NULL);
  236. double measuredLower();
  237. double measuredUpper();
  238. double mappedLower();
  239. double mappedUpper();
  240. bool isClosedRange();
  241. double sensitivity();
  242. public slots:
  243. void setMeasuredLower(double lower);
  244. void setMeasuredUpper(double upper);
  245. void setMappedLower(double lower);
  246. void setMappedUpper(double upper);
  247. void setClosedRange(bool closed);
  248. void setSensitivity(double sensitivity);
  249. void newMeasurement(Measurement measure);
  250. signals:
  251. void measurement(Measurement measure);
  252. private:
  253. double Lo1;
  254. double Lo2;
  255. double Up1;
  256. double Up2;
  257. double sensitivitySetting;
  258. bool clamp;
  259. };
  260. /*:269*//*276:*/
  261. #line 7000 "./typica.w"
  262. class LinearSplineInterpolator:public QObject
  263. {
  264. Q_OBJECT
  265. public:
  266. LinearSplineInterpolator(QObject*parent= NULL);
  267. Q_INVOKABLE void add_pair(double source,double destination);
  268. public slots:
  269. void newMeasurement(Measurement measure);
  270. signals:
  271. void newData(Measurement measure);
  272. private:
  273. void make_interpolators();
  274. QMap<double,double> *pairs;
  275. QList<LinearCalibrator*> *interpolators;
  276. };
  277. /*:276*//*281:*/
  278. #line 7135 "./typica.w"
  279. class TemperatureDisplay:public QLCDNumber
  280. {
  281. Q_OBJECT
  282. Q_ENUMS(DisplayUnits)
  283. int unit;
  284. public:
  285. enum DisplayUnits
  286. {
  287. Auto= -1,
  288. Fahrenheit= 10144,
  289. Celsius= 10143,
  290. Kelvin= 10325,
  291. Rankine= 10145
  292. };
  293. TemperatureDisplay(QWidget*parent= NULL);
  294. ~TemperatureDisplay();
  295. public slots:
  296. void setValue(Measurement temperature);
  297. void invalidate();
  298. void setDisplayUnits(DisplayUnits scale);
  299. };
  300. /*:281*//*290:*/
  301. #line 7311 "./typica.w"
  302. class MeasurementTimeOffset:public QObject
  303. {
  304. Q_OBJECT
  305. QTime epoch;
  306. QTime previous;
  307. bool hasPrevious;
  308. public:
  309. MeasurementTimeOffset(QTime zero);
  310. QTime zeroTime();
  311. public slots:
  312. void newMeasurement(Measurement measure);
  313. void setZeroTime(QTime zero);
  314. signals:
  315. void measurement(Measurement measure);
  316. };
  317. /*:290*//*297:*/
  318. #line 7461 "./typica.w"
  319. class ThresholdDetector:public QObject
  320. {
  321. Q_OBJECT
  322. Q_ENUMS(EdgeDirection)
  323. public:
  324. enum EdgeDirection{
  325. Ascending,Descending
  326. };
  327. ThresholdDetector(double value);
  328. public slots:
  329. void newMeasurement(Measurement measure);
  330. void setThreshold(double value);
  331. void setEdgeDirection(EdgeDirection direction);
  332. signals:
  333. void timeForValue(double);
  334. private:
  335. double previousValue;
  336. double threshold;
  337. EdgeDirection currentDirection;
  338. };
  339. /*:297*//*302:*/
  340. #line 7567 "./typica.w"
  341. class ZeroEmitter:public QObject
  342. {
  343. Q_OBJECT
  344. int col;
  345. double temp;
  346. public:
  347. ZeroEmitter(int tempcolumn);
  348. int column();
  349. double lastTemperature();
  350. public slots:
  351. void newMeasurement(Measurement measure);
  352. void setColumn(int column);
  353. void emitZero();
  354. signals:
  355. void measurement(Measurement measure,int tempcolumn);
  356. };
  357. /*:302*//*307:*/
  358. #line 7660 "./typica.w"
  359. class MeasurementAdapter:public QObject
  360. {
  361. Q_OBJECT
  362. int col;
  363. public:
  364. MeasurementAdapter(int tempcolumn);
  365. int column();
  366. public slots:
  367. void newMeasurement(Measurement measure);
  368. void setColumn(int column);
  369. signals:
  370. void measurement(Measurement measure,int tempcolumn);
  371. };
  372. /*:307*//*312:*/
  373. #line 7749 "./typica.w"
  374. class GraphView:public QGraphicsView
  375. {
  376. Q_OBJECT
  377. QGraphicsScene*theScene;
  378. QMap<int,QList<QGraphicsLineItem*> *> *graphLines;
  379. QMap<int,QPointF> *prevPoints;
  380. QMap<int,double> *translations;
  381. QList<QGraphicsItem*> *gridLinesF;
  382. QList<QGraphicsItem*> *gridLinesC;
  383. public:
  384. GraphView(QWidget*parent= NULL);
  385. void removeSeries(int column);
  386. protected:
  387. void resizeEvent(QResizeEvent*event);
  388. public slots:
  389. void newMeasurement(Measurement measure,int tempcolumn);
  390. void setSeriesTranslation(int column,double offset);
  391. void clear();
  392. void showF();
  393. void showC();
  394. };
  395. /*:312*//*327:*/
  396. #line 8100 "./typica.w"
  397. class MeasurementModel;
  398. class ZoomLog:public QTableView
  399. {
  400. Q_OBJECT
  401. /*328:*/
  402. #line 8148 "./typica.w"
  403. MeasurementModel*model_ms;
  404. MeasurementModel*model_1s;
  405. MeasurementModel*model_5s;
  406. MeasurementModel*model_10s;
  407. MeasurementModel*model_15s;
  408. MeasurementModel*model_30s;
  409. MeasurementModel*model_1m;
  410. QList<MeasurementModel*> modelSet;
  411. QHash<int,Measurement> lastMeasurement;
  412. MeasurementModel*currentModel;
  413. QList<int> saveTempCols;
  414. QList<int> saveNoteCols;
  415. QList<int> currentColumnSet;
  416. /*:328*/
  417. #line 8105 "./typica.w"
  418. void switchLOD(MeasurementModel*m);
  419. private slots:
  420. void centerOn(int row);
  421. void persistColumnResize(int column,int oldsize,int newsize);
  422. void restoreColumnWidths();
  423. public:
  424. ZoomLog();
  425. QVariant data(int row,int column)const;
  426. int rowCount();
  427. bool saveXML(QIODevice*device);
  428. bool saveCSV(QIODevice*device);
  429. QString lastTime(int series);
  430. Q_INVOKABLE int displayUnits();
  431. public slots:
  432. void setVisible(bool visibility);
  433. void setHeaderData(int section,QString text);
  434. void LOD_ms();
  435. void LOD_1s();
  436. void LOD_5s();
  437. void LOD_10s();
  438. void LOD_15s();
  439. void LOD_30s();
  440. void LOD_1m();
  441. void newMeasurement(Measurement measure,int tempcolumn);
  442. void newAnnotation(QString annotation,int tempcolumn,
  443. int annotationcolumn);
  444. void clear();
  445. void addOutputTemperatureColumn(int column);
  446. void addOutputAnnotationColumn(int column);
  447. void clearOutputColumns();
  448. void setDisplayUnits(int scale);
  449. void addToCurrentColumnSet(int column);
  450. void clearCurrentColumnSet();
  451. protected:
  452. virtual void showEvent(QShowEvent*event);
  453. };
  454. /*:327*//*352:*/
  455. #line 8794 "./typica.w"
  456. class MeasurementList;
  457. class MeasurementModel:public QAbstractItemModel
  458. {
  459. Q_OBJECT
  460. Q_ENUMS(DisplayUnits);
  461. int unit;
  462. QList<MeasurementList*> *entries;
  463. QStringList*hData;
  464. int colcount;
  465. QHash<int,int> *lastTemperature;
  466. QList<MeasurementList*> ::iterator lastInsertion;
  467. public:
  468. enum DisplayUnits
  469. {
  470. Auto= -1,
  471. Fahrenheit= 10144,
  472. Celsius= 10143,
  473. Kelvin= 10325,
  474. Rankine= 10145
  475. };
  476. MeasurementModel(QObject*parent= NULL);
  477. ~MeasurementModel();
  478. int rowCount(const QModelIndex&parent= QModelIndex())const;
  479. int columnCount(const QModelIndex&parent= QModelIndex())const;
  480. bool setHeaderData(int section,Qt::Orientation orientation,
  481. const QVariant&value,int role= Qt::DisplayRole);
  482. QVariant data(const QModelIndex&index,int role)const;
  483. bool setData(const QModelIndex&index,const QVariant&value,
  484. int role= Qt::EditRole);
  485. Qt::ItemFlags flags(const QModelIndex&index)const;
  486. QVariant headerData(int section,Qt::Orientation orientation,
  487. int role= Qt::DisplayRole)const;
  488. QModelIndex index(int row,int column,
  489. const QModelIndex&parent= QModelIndex())const;
  490. QModelIndex parent(const QModelIndex&index)const;
  491. int displayUnits();
  492. public slots:
  493. void newMeasurement(Measurement measure,int tempcolumn);
  494. void newAnnotation(QString annotation,int tempcolumn,
  495. int annotationColumn);
  496. void clear();
  497. void setDisplayUnits(int scale);
  498. signals:
  499. void rowChanged(int);
  500. };
  501. /*:352*//*353:*/
  502. #line 8846 "./typica.w"
  503. class MeasurementList:public QVariantList
  504. {
  505. public:
  506. bool operator<(const MeasurementList&other)const;
  507. bool operator==(const MeasurementList&other)const;
  508. };
  509. /*:353*//*379:*/
  510. #line 9483 "./typica.w"
  511. class AnnotationButton:public QPushButton
  512. {
  513. Q_OBJECT
  514. QString note;
  515. int tc;
  516. int ac;
  517. int count;
  518. public:
  519. AnnotationButton(const QString&text,QWidget*parent= NULL);
  520. public slots:
  521. void setAnnotation(const QString&annotation);
  522. void setTemperatureColumn(int tempcolumn);
  523. void setAnnotationColumn(int annotationcolumn);
  524. void annotate();
  525. void resetCount();
  526. signals:
  527. void annotation(QString annotation,int tempcolumn,
  528. int notecolumn);
  529. };
  530. /*:379*//*387:*/
  531. #line 9608 "./typica.w"
  532. class AnnotationSpinBox:public QDoubleSpinBox
  533. {
  534. Q_OBJECT
  535. QString pretext;
  536. QString posttext;
  537. int tc;
  538. int ac;
  539. bool change;
  540. public:
  541. AnnotationSpinBox(const QString&pret,const QString&postt,
  542. QWidget*parent= NULL);
  543. public slots:
  544. void setPretext(const QString&pret);
  545. void setPosttext(const QString&postt);
  546. void setTemperatureColumn(int tempcolumn);
  547. void setAnnotationColumn(int annotationcolumn);
  548. void annotate();
  549. void resetChange();
  550. signals:
  551. void annotation(QString annotation,int tempcolumn,
  552. int notecolumn);
  553. };
  554. /*:387*//*395:*/
  555. #line 9767 "./typica.w"
  556. class TimerDisplay:public QLCDNumber
  557. {
  558. Q_OBJECT
  559. /*396:*/
  560. #line 9817 "./typica.w"
  561. Q_PROPERTY(QTime seconds READ seconds WRITE setTimer)
  562. Q_PROPERTY(TimerMode mode READ mode WRITE setMode)
  563. Q_PROPERTY(bool running READ isRunning)
  564. Q_PROPERTY(QTime resetValue READ resetValue WRITE setResetValue)
  565. Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
  566. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  567. /*:396*/
  568. #line 9771 "./typica.w"
  569. private slots:
  570. void updateTime();
  571. void setCountUpMode();
  572. void setCountDownMode();
  573. void setClockMode();
  574. public:
  575. TimerDisplay(QWidget*parent= NULL);
  576. ~TimerDisplay();
  577. enum TimerMode
  578. {
  579. CountUp,
  580. CountDown,
  581. Clock
  582. };
  583. QString value();
  584. QTime seconds();
  585. TimerMode mode();
  586. bool isRunning();
  587. QTime resetValue();
  588. QString displayFormat();
  589. bool autoReset();
  590. public slots:
  591. void setTimer(QTime value= QTime(0,0,0));
  592. void setMode(TimerMode mode);
  593. void startTimer();
  594. void stopTimer();
  595. void copyTimer();
  596. void setResetValue(QTime value= QTime(0,0,0));
  597. void reset();
  598. void setDisplayFormat(QString format);
  599. void setAutoReset(bool reset);
  600. void updateDisplay();
  601. signals:
  602. void valueChanged(QTime);
  603. void runStateChanged(bool);
  604. private:
  605. /*397:*/
  606. #line 9827 "./typica.w"
  607. QTime s;
  608. QTime r;
  609. QTimer clock;
  610. TimerDisplay::TimerMode m;
  611. bool running;
  612. bool ar;
  613. QAction*startAction;
  614. QAction*stopAction;
  615. QAction*resetAction;
  616. QString f;
  617. QTime relative;
  618. QTime base;
  619. /*:397*/
  620. #line 9808 "./typica.w"
  621. };
  622. /*:395*//*417:*/
  623. #line 10186 "./typica.w"
  624. class PackLayout:public QLayout
  625. {
  626. int doLayout(const QRect&rect,bool testOnly)const;
  627. QList<QLayoutItem*> itemList;
  628. Qt::Orientations orientation;
  629. public:
  630. PackLayout(QWidget*parent,int margin= 0,int spacing= -1);
  631. PackLayout(int spacing= -1);
  632. ~PackLayout();
  633. void addItem(QLayoutItem*item);
  634. Qt::Orientations expandingDirections()const;
  635. bool hasHeightForWidth()const;
  636. int heightForWidth(int width)const;
  637. int count()const;
  638. QLayoutItem*itemAt(int index)const;
  639. QSize minimumSize()const;
  640. void setGeometry(const QRect&rect);
  641. void setOrientation(Qt::Orientations direction);
  642. QSize sizeHint()const;
  643. QLayoutItem*takeAt(int index);
  644. };
  645. /*:417*//*430:*/
  646. #line 10464 "./typica.w"
  647. class SceneButton:public QGraphicsScene
  648. {
  649. Q_OBJECT
  650. public:
  651. SceneButton();
  652. ~SceneButton();
  653. protected:
  654. void mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent);
  655. signals:
  656. void clicked(QPoint pos);
  657. };
  658. /*:430*//*432:*/
  659. #line 10506 "./typica.w"
  660. class WidgetDecorator:public QWidget
  661. {
  662. Q_OBJECT
  663. PackLayout*layout;
  664. QGraphicsView*label;
  665. QGraphicsTextItem*text;
  666. SceneButton*scene;
  667. public:
  668. WidgetDecorator(QWidget*widget,const QString&labeltext,
  669. Qt::Orientations orientation= Qt::Horizontal,
  670. QWidget*parent= NULL,Qt::WindowFlags f= 0);
  671. ~WidgetDecorator();
  672. void setBackgroundBrush(QBrush background);
  673. void setTextColor(QColor color);
  674. };
  675. /*:432*//*443:*/
  676. #line 10681 "./typica.w"
  677. class LogEditWindow:public QMainWindow
  678. {
  679. Q_OBJECT
  680. QWidget*centralWidget;
  681. PackLayout*mainLayout;
  682. QHBoxLayout*addRowsLayout;
  683. QLabel*startTimeLabel;
  684. QTimeEdit*startTime;
  685. QLabel*endTimeLabel;
  686. QTimeEdit*endTime;
  687. QLabel*intervalLabel;
  688. QSpinBox*interval;
  689. QPushButton*addRows;
  690. QAction*saveXml;
  691. QAction*saveCsv;
  692. QAction*openXml;
  693. MeasurementModel*model;
  694. QTableView*log;
  695. private slots:
  696. void addTheRows();
  697. void saveXML();
  698. void saveCSV();
  699. void openXML();
  700. protected:
  701. void closeEvent(QCloseEvent*event);
  702. public:
  703. LogEditWindow();
  704. };
  705. /*:443*//*457:*/
  706. #line 10989 "./typica.w"
  707. class XMLOutput:public QObject
  708. {
  709. Q_OBJECT
  710. MeasurementModel*data;
  711. QIODevice*out;
  712. int time;
  713. QMap<int,QString> temperatureColumns;
  714. QMap<int,QString> annotationColumns;
  715. public:
  716. XMLOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  717. void addTemperatureColumn(const QString&series,int column);
  718. void addAnnotationColumn(const QString&series,int column);
  719. void setModel(MeasurementModel*model);
  720. void setTimeColumn(int column);
  721. void setDevice(QIODevice*device);
  722. bool output();
  723. };
  724. /*:457*//*464:*/
  725. #line 11185 "./typica.w"
  726. class XMLInput:public QObject
  727. {
  728. Q_OBJECT
  729. int firstc;
  730. QIODevice*in;
  731. public:
  732. XMLInput(QIODevice*input,int c);
  733. void setFirstColumn(int column);
  734. void setDevice(QIODevice*device);
  735. bool input();
  736. signals:
  737. void measure(Measurement,int);
  738. void annotation(QString,int,int);
  739. void newTemperatureColumn(int,QString);
  740. void newAnnotationColumn(int,QString);
  741. void lastColumn(int);
  742. };
  743. /*:464*//*475:*/
  744. #line 11426 "./typica.w"
  745. class CSVOutput
  746. {
  747. MeasurementModel*data;
  748. QIODevice*out;
  749. int time;
  750. QMap<int,QString> temperatureColumns;
  751. QMap<int,QString> annotationColumns;
  752. public:
  753. CSVOutput(MeasurementModel*model,QIODevice*device,int timec= 0);
  754. void addTemperatureColumn(const QString&series,int column);
  755. void addAnnotationColumn(const QString&series,int column);
  756. void setModel(MeasurementModel*model);
  757. void setTimeColumn(int column);
  758. void setDevice(QIODevice*device);
  759. bool output();
  760. };
  761. /*:475*//*489:*/
  762. #line 11685 "./typica.w"
  763. #define AppInstance (qobject_cast<Application *> (qApp))
  764. class NodeInserter;
  765. class DeviceTreeModel;
  766. class Application:public QApplication
  767. {
  768. Q_OBJECT
  769. public:
  770. Application(int&argc,char**argv);
  771. QDomDocument*configuration();
  772. /*604:*/
  773. #line 14083 "./typica.w"
  774. QDomDocument deviceConfiguration();
  775. /*:604*//*637:*/
  776. #line 14756 "./typica.w"
  777. void registerDeviceConfigurationWidget(QString driver,QMetaObject widget);
  778. QWidget*deviceConfigurationWidget(DeviceTreeModel*model,
  779. const QModelIndex&index);
  780. /*:637*//*642:*/
  781. #line 14860 "./typica.w"
  782. QList<NodeInserter*> topLevelNodeInserters;
  783. /*:642*/
  784. #line 11696 "./typica.w"
  785. QSqlDatabase database();
  786. QScriptEngine*engine;
  787. public slots:
  788. /*605:*/
  789. #line 14090 "./typica.w"
  790. void saveDeviceConfiguration();
  791. /*:605*/
  792. #line 11700 "./typica.w"
  793. private:
  794. /*603:*/
  795. #line 14074 "./typica.w"
  796. QDomDocument deviceConfigurationDocument;
  797. /*:603*//*636:*/
  798. #line 14750 "./typica.w"
  799. QHash<QString,QMetaObject> deviceConfigurationWidgets;
  800. /*:636*/
  801. #line 11702 "./typica.w"
  802. QDomDocument conf;
  803. };
  804. /*:489*//*497:*/
  805. #line 11826 "./typica.w"
  806. class SaltModel:public QAbstractItemModel
  807. {
  808. Q_OBJECT
  809. QList<QList<QMap<int,QVariant> > > modelData;
  810. QStringList hData;
  811. int colcount;
  812. public:
  813. SaltModel(int columns);
  814. ~SaltModel();
  815. int rowCount(const QModelIndex&parent= QModelIndex())const;
  816. int columnCount(const QModelIndex&parent= QModelIndex())const;
  817. bool setHeaderData(int section,Qt::Orientation orientation,
  818. const QVariant&value,int role= Qt::DisplayRole);
  819. QVariant data(const QModelIndex&index,int role)const;
  820. bool setData(const QModelIndex&index,const QVariant&value,
  821. int role= Qt::EditRole);
  822. Qt::ItemFlags flags(const QModelIndex&index)const;
  823. QVariant headerData(int section,Qt::Orientation orientation,
  824. int role= Qt::DisplayRole)const;
  825. QModelIndex index(int row,int column,
  826. const QModelIndex&parent= QModelIndex())const;
  827. QModelIndex parent(const QModelIndex&index)const;
  828. QString arrayLiteral(int column,int role)const;
  829. QString quotedArrayLiteral(int column,int role)const;
  830. };
  831. /*:497*//*510:*/
  832. #line 12139 "./typica.w"
  833. class SqlComboBox:public QComboBox
  834. {
  835. Q_OBJECT
  836. int dataColumn;
  837. int displayColumn;
  838. bool dataColumnShown;
  839. public:
  840. SqlComboBox();
  841. ~SqlComboBox();
  842. SqlComboBox*clone(QWidget*parent);
  843. public slots:
  844. void addNullOption();
  845. void addSqlOptions(QString query);
  846. void setDataColumn(int column);
  847. void setDisplayColumn(int column);
  848. void showData(bool show);
  849. };
  850. /*:510*//*517:*/
  851. #line 12261 "./typica.w"
  852. class SqlComboBoxDelegate:public QItemDelegate
  853. {
  854. Q_OBJECT
  855. SqlComboBox*delegate;
  856. public:
  857. SqlComboBoxDelegate(QObject*parent= NULL);
  858. QWidget*createEditor(QWidget*parent,
  859. const QStyleOptionViewItem&option,
  860. const QModelIndex&index)const;
  861. void setEditorData(QWidget*editor,const QModelIndex&index)const;
  862. void setModelData(QWidget*editor,QAbstractItemModel*model,
  863. const QModelIndex&index)const;
  864. void setWidget(SqlComboBox*widget);
  865. virtual QSize sizeHint()const;
  866. void updateEditorGeometry(QWidget*editor,
  867. const QStyleOptionViewItem&option,
  868. const QModelIndex&index)const;
  869. };
  870. /*:517*//*529:*/
  871. #line 12431 "./typica.w"
  872. class SqlConnectionSetup:public QDialog
  873. {
  874. Q_OBJECT
  875. public:
  876. SqlConnectionSetup();
  877. ~SqlConnectionSetup();
  878. public slots:
  879. void testConnection();
  880. private:
  881. QFormLayout*formLayout;
  882. QComboBox*driver;
  883. QLineEdit*hostname;
  884. QLineEdit*dbname;
  885. QLineEdit*user;
  886. QLineEdit*password;
  887. QVBoxLayout*layout;
  888. QHBoxLayout*buttons;
  889. QPushButton*cancelButton;
  890. QPushButton*connectButton;
  891. };
  892. /*:529*//*534:*/
  893. #line 12559 "./typica.w"
  894. class SqlQueryView:public QTableView
  895. {
  896. Q_OBJECT
  897. public:
  898. SqlQueryView(QWidget*parent= NULL);
  899. void setQuery(const QString&query);
  900. bool setHeaderData(int section,Qt::Orientation orientation,
  901. const QVariant&value,int role);
  902. Q_INVOKABLE QVariant data(int row,int column,
  903. int role= Qt::DisplayRole);
  904. signals:
  905. void openEntry(QString key);
  906. void openEntryRow(int row);
  907. protected:
  908. virtual void showEvent(QShowEvent*event);
  909. private slots:
  910. void openRow(const QModelIndex&index);
  911. void persistColumnResize(int column,int oldsize,int newsize);
  912. };
  913. /*:534*//*549:*/
  914. #line 12807 "./typica.w"
  915. class ReportAction:public QAction
  916. {
  917. Q_OBJECT
  918. public:
  919. ReportAction(const QString&fileName,const QString&reportName,
  920. QObject*parent= NULL);
  921. private slots:
  922. void createReport();
  923. private:
  924. QString reportFile;
  925. };
  926. /*:549*//*561:*/
  927. #line 13016 "./typica.w"
  928. class ReportTable:public QObject
  929. {
  930. Q_OBJECT
  931. QTextFrame*area;
  932. QDomElement configuration;
  933. QMap<QString,QVariant> bindings;
  934. public:
  935. ReportTable(QTextFrame*frame,QDomElement description);
  936. ~ReportTable();
  937. Q_INVOKABLE void bind(QString placeholder,QVariant value);
  938. public slots:
  939. void refresh();
  940. };
  941. /*:561*//*573:*/
  942. #line 13252 "./typica.w"
  943. class FormArray:public QScrollArea
  944. {
  945. Q_OBJECT
  946. QDomElement configuration;
  947. QWidget itemContainer;
  948. QVBoxLayout itemLayout;
  949. int maxwidth;
  950. int maxheight;
  951. public:
  952. FormArray(QDomElement description);
  953. Q_INVOKABLE QWidget*elementAt(int index);
  954. Q_INVOKABLE int elements();
  955. public slots:
  956. void addElements(int copies= 1);
  957. void removeAllElements();
  958. void setMaximumElementWidth(int width);
  959. void setMaximumElementHeight(int height);
  960. };
  961. /*:573*//*583:*/
  962. #line 13468 "./typica.w"
  963. class ScaleControl:public QGraphicsView
  964. {
  965. Q_OBJECT
  966. Q_PROPERTY(double initialValue READ initialValue WRITE setInitialValue)
  967. Q_PROPERTY(double finalValue READ finalValue WRITE setFinalValue)
  968. /*584:*/
  969. #line 13494 "./typica.w"
  970. QGraphicsScene scene;
  971. QGraphicsPolygonItem initialDecrement;
  972. QGraphicsPolygonItem initialIncrement;
  973. QGraphicsPolygonItem finalDecrement;
  974. QGraphicsPolygonItem finalIncrement;
  975. QGraphicsPolygonItem initialIndicator;
  976. QGraphicsPolygonItem finalIndicator;
  977. QGraphicsPathItem scaleLine;
  978. QPolygonF left;
  979. QPolygonF right;
  980. QPolygonF down;
  981. QPolygonF up;
  982. QPainterPath scalePath;
  983. QBrush initialBrush;
  984. QBrush finalBrush;
  985. double nonScoredValue;
  986. double scoredValue;
  987. bool initialSet;
  988. bool finalSet;
  989. bool scaleDown;
  990. /*:584*/
  991. #line 13474 "./typica.w"
  992. public:
  993. ScaleControl();
  994. double initialValue(void);
  995. double finalValue(void);
  996. virtual QSize sizeHint()const;
  997. public slots:
  998. void setInitialValue(double value);
  999. void setFinalValue(double value);
  1000. signals:
  1001. void initialChanged(double);
  1002. void finalChanged(double);
  1003. protected:
  1004. virtual void mousePressEvent(QMouseEvent*event);
  1005. virtual void mouseReleaseEvent(QMouseEvent*event);
  1006. };
  1007. /*:583*//*595:*/
  1008. #line 13791 "./typica.w"
  1009. class IntensityControl:public QGraphicsView
  1010. {
  1011. Q_OBJECT
  1012. Q_PROPERTY(double value READ value WRITE setValue)
  1013. QGraphicsScene scene;
  1014. QGraphicsPolygonItem decrement;
  1015. QGraphicsPolygonItem increment;
  1016. QGraphicsPolygonItem indicator;
  1017. QGraphicsPathItem scaleLine;
  1018. QPolygonF left;
  1019. QPolygonF up;
  1020. QPolygonF down;
  1021. QPainterPath scalePath;
  1022. QBrush theBrush;
  1023. double theValue;
  1024. bool valueSet;
  1025. bool scaleDown;
  1026. public:
  1027. IntensityControl();
  1028. double value();
  1029. virtual QSize sizeHint()const;
  1030. public slots:
  1031. void setValue(double val);
  1032. signals:
  1033. void valueChanged(double);
  1034. protected:
  1035. virtual void mousePressEvent(QMouseEvent*event);
  1036. virtual void mouseReleaseEvent(QMouseEvent*event);
  1037. };
  1038. /*:595*//*611:*/
  1039. #line 14179 "./typica.w"
  1040. class DeviceTreeModelNode
  1041. {
  1042. public:
  1043. DeviceTreeModelNode(QDomNode&node,int row,
  1044. DeviceTreeModelNode*parent= NULL);
  1045. ~DeviceTreeModelNode();
  1046. DeviceTreeModelNode*child(int index);
  1047. DeviceTreeModelNode*parent();
  1048. QDomNode node()const;
  1049. int row();
  1050. private:
  1051. QDomNode domNode;
  1052. QHash<int,DeviceTreeModelNode*> children;
  1053. int rowNumber;
  1054. DeviceTreeModelNode*parentItem;
  1055. };
  1056. /*:611*//*613:*/
  1057. #line 14254 "./typica.w"
  1058. class DeviceTreeModel:public QAbstractItemModel
  1059. {
  1060. Q_OBJECT
  1061. public:
  1062. DeviceTreeModel(QObject*parent= NULL);
  1063. ~DeviceTreeModel();
  1064. QVariant data(const QModelIndex&index,int role)const;
  1065. Qt::ItemFlags flags(const QModelIndex&index)const;
  1066. QVariant headerData(int section,Qt::Orientation orientation,
  1067. int role= Qt::DisplayRole)const;
  1068. QModelIndex index(int row,int column,
  1069. const QModelIndex&parent= QModelIndex())const;
  1070. QModelIndex parent(const QModelIndex&child)const;
  1071. int rowCount(const QModelIndex&parent= QModelIndex())const;
  1072. int columnCount(const QModelIndex&parent= QModelIndex())const;
  1073. bool setData(const QModelIndex&index,const QVariant&value,
  1074. int role);
  1075. bool removeRows(int row,int count,const QModelIndex&parent);
  1076. QDomElement referenceElement(const QString&id);
  1077. public slots:
  1078. void newNode(const QString&name,const QString&driver,
  1079. const QModelIndex&parent);
  1080. private:
  1081. QDomDocument document;
  1082. DeviceTreeModelNode*root;
  1083. QDomNode referenceSection;
  1084. QDomNode treeRoot;
  1085. };
  1086. /*:613*//*632:*/
  1087. #line 14708 "./typica.w"
  1088. Q_DECLARE_METATYPE(QModelIndex)
  1089. /*:632*//*640:*/
  1090. #line 14815 "./typica.w"
  1091. class NodeInserter:public QAction
  1092. {
  1093. Q_OBJECT
  1094. public:
  1095. NodeInserter(const QString&title,const QString&name,
  1096. const QString&driver,QObject*parent= NULL);
  1097. signals:
  1098. void triggered(QString name,QString driver);
  1099. private slots:
  1100. void onTriggered();
  1101. private:
  1102. QString defaultNodeName;
  1103. QString driverString;
  1104. };
  1105. /*:640*//*643:*/
  1106. #line 14866 "./typica.w"
  1107. class DeviceConfigurationWindow:public QMainWindow
  1108. {
  1109. Q_OBJECT
  1110. public:
  1111. DeviceConfigurationWindow();
  1112. public slots:
  1113. void addDevice();
  1114. void removeNode();
  1115. void newSelection(const QModelIndex&index);
  1116. private slots:
  1117. void resizeColumn();
  1118. private:
  1119. QDomDocument document;
  1120. DeviceTreeModel*model;
  1121. QTreeView*view;
  1122. QScrollArea*configArea;
  1123. };
  1124. /*:643*//*652:*/
  1125. #line 15030 "./typica.w"
  1126. class BasicDeviceConfigurationWidget:public QWidget
  1127. {
  1128. Q_OBJECT
  1129. public:
  1130. BasicDeviceConfigurationWidget(DeviceTreeModel*model,
  1131. const QModelIndex&index);
  1132. public slots:
  1133. void insertChildNode(const QString&name,const QString&driver);
  1134. void updateAttribute(const QString&name,const QString&value);
  1135. protected:
  1136. DeviceTreeModel*deviceModel;
  1137. QModelIndex currentNode;
  1138. };
  1139. /*:652*//*656:*/
  1140. #line 15115 "./typica.w"
  1141. class RoasterConfWidget:public BasicDeviceConfigurationWidget
  1142. {
  1143. Q_OBJECT
  1144. public:
  1145. Q_INVOKABLE RoasterConfWidget(DeviceTreeModel*model,
  1146. const QModelIndex&index);
  1147. private slots:
  1148. void updateRoasterId(int id);
  1149. };
  1150. /*:656*//*661:*/
  1151. #line 15242 "./typica.w"
  1152. class NiDaqMxBaseDriverConfWidget:public BasicDeviceConfigurationWidget
  1153. {
  1154. Q_OBJECT
  1155. public:
  1156. Q_INVOKABLE NiDaqMxBaseDriverConfWidget(DeviceTreeModel*model,
  1157. const QModelIndex&index);
  1158. };
  1159. /*:661*//*663:*/
  1160. #line 15288 "./typica.w"
  1161. class NiDaqMxBase9211ConfWidget:public BasicDeviceConfigurationWidget
  1162. {
  1163. Q_OBJECT
  1164. public:
  1165. Q_INVOKABLE NiDaqMxBase9211ConfWidget(DeviceTreeModel*device,
  1166. const QModelIndex&index);
  1167. private slots:
  1168. void addChannel();
  1169. void updateDeviceId(const QString&newId);
  1170. };
  1171. /*:663*//*667:*/
  1172. #line 15374 "./typica.w"
  1173. class Ni9211TcConfWidget:public BasicDeviceConfigurationWidget
  1174. {
  1175. Q_OBJECT
  1176. public:
  1177. Q_INVOKABLE Ni9211TcConfWidget(DeviceTreeModel*device,
  1178. const QModelIndex&index);
  1179. private slots:
  1180. void updateThermocoupleType(const QString&type);
  1181. void updateColumnName(const QString&name);
  1182. };
  1183. /*:667*//*672:*/
  1184. #line 15476 "./typica.w"
  1185. class NiDaqMxDriverConfWidget:public BasicDeviceConfigurationWidget
  1186. {
  1187. Q_OBJECT
  1188. public:
  1189. Q_INVOKABLE NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  1190. const QModelIndex&index);
  1191. };
  1192. /*:672*//*674:*/
  1193. #line 15517 "./typica.w"
  1194. class NiDaqMx9211ConfWidget:public BasicDeviceConfigurationWidget
  1195. {
  1196. Q_OBJECT
  1197. public:
  1198. Q_INVOKABLE NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  1199. const QModelIndex&index);
  1200. private slots:
  1201. void addChannel();
  1202. void updateDeviceId(const QString&newId);
  1203. };
  1204. /*:674*//*676:*/
  1205. #line 15586 "./typica.w"
  1206. class NiDaqMxTc01ConfWidget:public BasicDeviceConfigurationWidget
  1207. {
  1208. Q_OBJECT
  1209. public:
  1210. Q_INVOKABLE NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  1211. const QModelIndex&index);
  1212. private slots:
  1213. void updateDeviceId(const QString&newId);
  1214. void updateThermocoupleType(const QString&type);
  1215. void updateColumnName(const QString&name);
  1216. };
  1217. /*:676*//*681:*/
  1218. #line 15703 "./typica.w"
  1219. class PortSelector:public QComboBox
  1220. {
  1221. Q_OBJECT
  1222. public:
  1223. PortSelector(QWidget*parent= NULL);
  1224. private slots:
  1225. void addDevice(QextPortInfo port);
  1226. private:
  1227. QextSerialEnumerator*lister;
  1228. };
  1229. /*:681*//*683:*/
  1230. #line 15747 "./typica.w"
  1231. class BaudSelector:public QComboBox
  1232. {
  1233. Q_OBJECT
  1234. Q_ENUMS(BaudRateType)
  1235. public:
  1236. BaudSelector(QWidget*parent= NULL);
  1237. enum BaudRateType
  1238. {
  1239. #if defined(Q_OS_UNIX) || defined(qdoc)
  1240. BAUD50= 50,
  1241. BAUD75= 75,
  1242. BAUD134= 134,
  1243. BAUD150= 150,
  1244. BAUD200= 200,
  1245. BAUD1800= 1800,
  1246. #if defined(B76800) || defined(qdoc)
  1247. BAUD76800= 76800,
  1248. #endif
  1249. #if (defined(B230400) && defined(B4000000)) || defined(qdoc)
  1250. BAUD230400= 230400,
  1251. BAUD460800= 460800,
  1252. BAUD500000= 500000,
  1253. BAUD576000= 576000,
  1254. BAUD921600= 921600,
  1255. BAUD1000000= 1000000,
  1256. BAUD1152000= 1152000,
  1257. BAUD1500000= 1500000,
  1258. BAUD2000000= 2000000,
  1259. BAUD2500000= 2500000,
  1260. BAUD3000000= 3000000,
  1261. BAUD3500000= 3500000,
  1262. BAUD4000000= 4000000,
  1263. #endif
  1264. #endif
  1265. #if defined(Q_OS_WIN) || defined(qdoc)
  1266. BAUD14400= 14400,
  1267. BAUD56000= 56000,
  1268. BAUD128000= 128000,
  1269. BAUD256000= 256000,
  1270. #endif
  1271. BAUD110= 110,
  1272. BAUD300= 300,
  1273. BAUD600= 600,
  1274. BAUD1200= 1200,
  1275. BAUD2400= 2400,
  1276. BAUD4800= 4800,
  1277. BAUD9600= 9600,
  1278. BAUD19200= 19200,
  1279. BAUD38400= 38400,
  1280. BAUD57600= 57600,
  1281. BAUD115200= 115200
  1282. };
  1283. };
  1284. /*:683*//*685:*/
  1285. #line 15818 "./typica.w"
  1286. class ParitySelector:public QComboBox
  1287. {
  1288. Q_OBJECT
  1289. Q_ENUMS(ParityType)
  1290. public:
  1291. ParitySelector(QWidget*parent= NULL);
  1292. enum ParityType
  1293. {
  1294. PAR_NONE,
  1295. PAR_ODD,
  1296. PAR_EVEN,
  1297. #if defined(Q_OS_WIN) || defined(qdoc)
  1298. PAR_MARK,
  1299. #endif
  1300. PAR_SPACE
  1301. };
  1302. };
  1303. /*:685*//*687:*/
  1304. #line 15856 "./typica.w"
  1305. class FlowSelector:public QComboBox
  1306. {
  1307. Q_OBJECT
  1308. Q_ENUMS(FlowType)
  1309. public:
  1310. FlowSelector(QWidget*parent= NULL);
  1311. enum FlowType
  1312. {
  1313. FLOW_OFF,
  1314. FLOW_HARDWARE,
  1315. FLOW_XONXOFF
  1316. };
  1317. };
  1318. /*:687*//*689:*/
  1319. #line 15889 "./typica.w"
  1320. class StopSelector:public QComboBox
  1321. {
  1322. Q_OBJECT
  1323. Q_ENUMS(StopBitsType)
  1324. public:
  1325. StopSelector(QWidget*parent= NULL);
  1326. enum StopBitsType
  1327. {
  1328. STOP_1,
  1329. #if defined(Q_OS_WIN) || defined(qdoc)
  1330. STOP_1_5,
  1331. #endif
  1332. STOP_2
  1333. };
  1334. };
  1335. /*:689*//*692:*/
  1336. #line 15942 "./typica.w"
  1337. class ShortHexSpinBox:public QSpinBox
  1338. {
  1339. Q_OBJECT
  1340. public:
  1341. ShortHexSpinBox(QWidget*parent= NULL);
  1342. virtual QValidator::State validate(QString&input,int&pos)const;
  1343. protected:
  1344. virtual int valueFromText(const QString&text)const;
  1345. virtual QString textFromValue(int value)const;
  1346. };
  1347. /*:692*//*694:*/
  1348. #line 16004 "./typica.w"
  1349. class ModbusRtuPortConfWidget:public BasicDeviceConfigurationWidget
  1350. {
  1351. Q_OBJECT
  1352. public:
  1353. Q_INVOKABLE ModbusRtuPortConfWidget(DeviceTreeModel*model,
  1354. const QModelIndex&index);
  1355. private slots:
  1356. void updatePort(const QString&newPort);
  1357. void updateBaudRate(const QString&newRate);
  1358. void updateParity(const QString&newParity);
  1359. void updateFlowControl(const QString&newFlow);
  1360. void updateStopBits(const QString&newStopBits);
  1361. };
  1362. /*:694*//*696:*/
  1363. #line 16155 "./typica.w"
  1364. class ModbusRtuDeviceConfWidget:public BasicDeviceConfigurationWidget
  1365. {
  1366. Q_OBJECT
  1367. public:
  1368. Q_INVOKABLE ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  1369. const QModelIndex&index);
  1370. private slots:
  1371. void updateStationNumber(int newStation);
  1372. void updateFixedUnit(bool newFixed);
  1373. void updateFixedDecimal(bool newFixed);
  1374. void updateUnit(const QString&newUnit);
  1375. void updateUnitAddress(int newAddress);
  1376. void updateValueF(int newValue);
  1377. void updateValueC(int newValue);
  1378. void updatePrecisionAddress(int newAddress);
  1379. void updatePrecisionValue(int newValue);
  1380. private:
  1381. QStackedLayout*unitSpecificationLayout;
  1382. QStackedLayout*decimalSpecificationLayout;
  1383. };
  1384. /*:696*//*698:*/
  1385. #line 16414 "./typica.w"
  1386. class ModbusRtuDeviceTPvConfWidget:public BasicDeviceConfigurationWidget
  1387. {
  1388. Q_OBJECT
  1389. public:
  1390. Q_INVOKABLE ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  1391. const QModelIndex&index);
  1392. private slots:
  1393. void updateAddress(int newAddress);
  1394. };
  1395. /*:698*//*700:*/
  1396. #line 16460 "./typica.w"
  1397. class ModbusRtuDeviceTSvConfWidget:public BasicDeviceConfigurationWidget
  1398. {
  1399. Q_OBJECT
  1400. public:
  1401. Q_INVOKABLE ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  1402. const QModelIndex&index);
  1403. private slots:
  1404. void updateReadAddress(int newAddress);
  1405. void updateWriteAddress(int newAddress);
  1406. void updateFixedRange(bool fixed);
  1407. void updateLower(const QString&lower);
  1408. void updateUpper(const QString&upper);
  1409. void updateLowerAddress(int newAddress);
  1410. void updateUpperAddress(int newAddress);
  1411. private:
  1412. QStackedLayout*boundsLayout;
  1413. };
  1414. /*:700*//*704:*/
  1415. #line 16654 "./typica.w"
  1416. class AnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1417. {
  1418. Q_OBJECT
  1419. public:
  1420. Q_INVOKABLE AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1421. private slots:
  1422. void updateButtonText(const QString&text);
  1423. void updateAnnotationText(const QString&text);
  1424. };
  1425. /*:704*//*708:*/
  1426. #line 16722 "./typica.w"
  1427. class ReconfigurableAnnotationButtonConfWidget:public BasicDeviceConfigurationWidget
  1428. {
  1429. Q_OBJECT
  1430. public:
  1431. Q_INVOKABLE ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1432. private slots:
  1433. void updateButtonText(const QString&text);
  1434. void updateAnnotationText(const QString&text);
  1435. };
  1436. /*:708*//*711:*/
  1437. #line 16796 "./typica.w"
  1438. class NoteSpinConfWidget:public BasicDeviceConfigurationWidget
  1439. {
  1440. Q_OBJECT
  1441. public:
  1442. Q_INVOKABLE NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1443. private slots:
  1444. void updateLabel(const QString&text);
  1445. void updateMinimum(const QString&minimum);
  1446. void updateMaximum(const QString&maximum);
  1447. void updatePrecision(int precision);
  1448. void updatePretext(const QString&text);
  1449. void updatePosttext(const QString&text);
  1450. };
  1451. /*:711*//*714:*/
  1452. #line 16917 "./typica.w"
  1453. class ModbusRTUDevice:public QObject
  1454. {
  1455. Q_OBJECT
  1456. public:
  1457. ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index);
  1458. ~ModbusRTUDevice();
  1459. void queueMessage(QByteArray request,QObject*object,const char*callback);
  1460. Q_INVOKABLE double SVLower();
  1461. Q_INVOKABLE double SVUpper();
  1462. Q_INVOKABLE int decimals();
  1463. QList<Channel*> channels;
  1464. public slots:
  1465. void outputSV(double sv);
  1466. signals:
  1467. void SVLowerChanged(double);
  1468. void SVUpperChanged(double);
  1469. void SVDecimalChanged(int);
  1470. void queueEmpty();
  1471. private slots:
  1472. void dataAvailable();
  1473. void sendNextMessage();
  1474. void decimalResponse(QByteArray response);
  1475. void unitResponse(QByteArray response);
  1476. void svlResponse(QByteArray response);
  1477. void svuResponse(QByteArray response);
  1478. void requestMeasurement();
  1479. void mResponse(QByteArray response);
  1480. void ignore(QByteArray response);
  1481. private:
  1482. QextSerialPort*port;
  1483. QByteArray responseBuffer;
  1484. QList<QByteArray> messageQueue;
  1485. QList<QObject*> retObjQueue;
  1486. QList<char*> callbackQueue;
  1487. quint16 calculateCRC(QByteArray data);
  1488. QTimer*messageDelayTimer;
  1489. int delayTime;
  1490. char station;
  1491. int decimalPosition;
  1492. int valueF;
  1493. int valueC;
  1494. bool unitIsF;
  1495. double outputSVLower;
  1496. double outputSVUpper;
  1497. QByteArray outputSVStub;
  1498. QByteArray pvStub;
  1499. QByteArray svStub;
  1500. QByteArray mStub;
  1501. quint16 pvaddress;
  1502. quint16 svaddress;
  1503. bool svenabled;
  1504. bool readingsv;
  1505. double savedpv;
  1506. bool waiting;
  1507. };
  1508. /*:714*//*729:*/
  1509. #line 17589 "./typica.w"
  1510. class ModbusConfigurator:public BasicDeviceConfigurationWidget
  1511. {
  1512. Q_OBJECT
  1513. public:
  1514. Q_INVOKABLE ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index);
  1515. private slots:
  1516. void updatePort(const QString&newPort);
  1517. void updateBaudRate(const QString&newRate);
  1518. void updateParity(const QString&newParity);
  1519. void updateFlowControl(const QString&newFlow);
  1520. void updateStopBits(const QString&newStopBits);
  1521. void updateStation(int station);
  1522. void updateFixedDecimal(bool fixed);
  1523. void updateDecimalAddress(int address);
  1524. void updateDecimalPosition(int position);
  1525. void updateFixedUnit(bool fixed);
  1526. void updateUnitAddress(int address);
  1527. void updateValueForF(int value);
  1528. void updateValueForC(int value);
  1529. void updateUnit(const QString&newUnit);
  1530. void updatePVAddress(int address);
  1531. void updateSVEnabled(bool enabled);
  1532. void updateSVReadAddress(int address);
  1533. void updateDeviceLimit(bool query);
  1534. void updateSVLowerAddress(int address);
  1535. void updateSVUpperAddress(int address);
  1536. void updateSVLower(double value);
  1537. void updateSVUpper(double value);
  1538. void updateSVWritable(bool canWriteSV);
  1539. void updateSVWriteAddress(int address);
  1540. void updatePVColumnName(const QString&name);
  1541. void updateSVColumnName(const QString&name);
  1542. private:
  1543. PortSelector*port;
  1544. BaudSelector*baud;
  1545. ParitySelector*parity;
  1546. FlowSelector*flow;
  1547. StopSelector*stop;
  1548. QSpinBox*station;
  1549. QCheckBox*decimalQuery;
  1550. ShortHexSpinBox*decimalAddress;
  1551. QSpinBox*decimalPosition;
  1552. QCheckBox*unitQuery;
  1553. ShortHexSpinBox*unitAddress;
  1554. QSpinBox*valueF;
  1555. QSpinBox*valueC;
  1556. QComboBox*fixedUnit;
  1557. ShortHexSpinBox*pVAddress;
  1558. QCheckBox*sVEnabled;
  1559. ShortHexSpinBox*sVReadAddress;
  1560. QCheckBox*deviceLimit;
  1561. ShortHexSpinBox*sVLowerAddr;
  1562. ShortHexSpinBox*sVUpperAddr;
  1563. QDoubleSpinBox*sVLower;
  1564. QDoubleSpinBox*sVUpper;
  1565. QCheckBox*sVWritable;
  1566. ShortHexSpinBox*sVOutputAddr;
  1567. QLineEdit*pVColumnName;
  1568. QLineEdit*sVColumnName;
  1569. };
  1570. /*:729*//*733:*/
  1571. #line 18095 "./typica.w"
  1572. class LinearSplineInterpolationConfWidget:public BasicDeviceConfigurationWidget
  1573. {
  1574. Q_OBJECT
  1575. public:
  1576. Q_INVOKABLE LinearSplineInterpolationConfWidget(DeviceTreeModel*model,
  1577. const QModelIndex&index);
  1578. private slots:
  1579. void updateSourceColumn(const QString&source);
  1580. void updateDestinationColumn(const QString&dest);
  1581. void updateKnots();
  1582. private:
  1583. SaltModel*knotmodel;
  1584. };
  1585. /*:733*//*739:*/
  1586. #line 18219 "./typica.w"
  1587. class TranslationConfWidget:public BasicDeviceConfigurationWidget
  1588. {
  1589. Q_OBJECT
  1590. public:
  1591. Q_INVOKABLE TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index);
  1592. private slots:
  1593. void updateMatchingColumn(const QString&column);
  1594. void updateTemperature();
  1595. private:
  1596. QDoubleSpinBox*temperatureValue;
  1597. QComboBox*unitSelector;
  1598. };
  1599. /*:739*/
  1600. #line 761 "./typica.w"
  1601. /*25:*/
  1602. #line 1010 "./typica.w"
  1603. void setQObjectProperties(QScriptValue value,QScriptEngine*engine);
  1604. /*:25*//*27:*/
  1605. #line 1025 "./typica.w"
  1606. void setQPaintDeviceProperties(QScriptValue value,QScriptEngine*engine);
  1607. void setQLayoutItemProperties(QScriptValue value,QScriptEngine*engine);
  1608. /*:27*//*29:*/
  1609. #line 1050 "./typica.w"
  1610. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine);
  1611. QScriptValue constructQWidget(QScriptContext*context,QScriptEngine*engine);
  1612. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*engine);
  1613. QScriptValue QWidget_activateWindow(QScriptContext*context,
  1614. QScriptEngine*engine);
  1615. /*:29*//*37:*/
  1616. #line 1248 "./typica.w"
  1617. QScriptValue constructQMainWindow(QScriptContext*context,
  1618. QScriptEngine*engine);
  1619. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  1620. QScriptEngine*engine);
  1621. QScriptValue QMainWindow_menuBar(QScriptContext*context,
  1622. QScriptEngine*engine);
  1623. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine);
  1624. /*:37*//*42:*/
  1625. #line 1347 "./typica.w"
  1626. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine);
  1627. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine);
  1628. /*:42*//*45:*/
  1629. #line 1392 "./typica.w"
  1630. void setQMenuProperties(QScriptValue value,QScriptEngine*engine);
  1631. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*engine);
  1632. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*engine);
  1633. /*:45*//*48:*/
  1634. #line 1458 "./typica.w"
  1635. void setQFrameProperties(QScriptValue value,QScriptEngine*engine);
  1636. QScriptValue constructQFrame(QScriptContext*context,QScriptEngine*engine);
  1637. /*:48*//*51:*/
  1638. #line 1491 "./typica.w"
  1639. void setQLabelProperties(QScriptValue value,QScriptEngine*engine);
  1640. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine);
  1641. /*:51*//*54:*/
  1642. #line 1532 "./typica.w"
  1643. QScriptValue constructQSplitter(QScriptContext*context,QScriptEngine*engine);
  1644. QScriptValue QSplitter_addWidget(QScriptContext*context,
  1645. QScriptEngine*engine);
  1646. QScriptValue QSplitter_saveState(QScriptContext*context,
  1647. QScriptEngine*engine);
  1648. QScriptValue QSplitter_restoreState(QScriptContext*context,
  1649. QScriptEngine*engine);
  1650. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine);
  1651. /*:54*//*59:*/
  1652. #line 1651 "./typica.w"
  1653. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine);
  1654. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  1655. /*:59*//*61:*/
  1656. #line 1706 "./typica.w"
  1657. QScriptValue constructQBoxLayout(QScriptContext*context,
  1658. QScriptEngine*engine);
  1659. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine);
  1660. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*engine);
  1661. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*engine);
  1662. /*:61*//*65:*/
  1663. #line 1819 "./typica.w"
  1664. QScriptValue constructQAction(QScriptContext*context,QScriptEngine*engine);
  1665. QScriptValue QAction_setShortcut(QScriptContext*context,
  1666. QScriptEngine*engine);
  1667. void setQActionProperties(QScriptValue value,QScriptEngine*engine);
  1668. /*:65*//*68:*/
  1669. #line 1875 "./typica.w"
  1670. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  1671. QScriptEngine*engine);
  1672. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  1673. QScriptEngine*engine);
  1674. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine);
  1675. void setQDialogProperties(QScriptValue value,QScriptEngine*engine);
  1676. /*:68*//*73:*/
  1677. #line 1986 "./typica.w"
  1678. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine);
  1679. void setQFileProperties(QScriptValue value,QScriptEngine*engine);
  1680. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine);
  1681. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine);
  1682. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*engine);
  1683. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*engine);
  1684. QScriptValue QIODevice_readToString(QScriptContext*context,
  1685. QScriptEngine*engine);
  1686. /*:73*//*80:*/
  1687. #line 2108 "./typica.w"
  1688. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine);
  1689. void setQBufferProperties(QScriptValue value,QScriptEngine*engine);
  1690. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*engine);
  1691. /*:80*//*83:*/
  1692. #line 2153 "./typica.w"
  1693. QScriptValue constructXQuery(QScriptContext*context,QScriptEngine*engine);
  1694. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*engine);
  1695. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*engine);
  1696. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*engine);
  1697. void setXQueryProperties(QScriptValue value,QScriptEngine*engine);
  1698. /*:83*//*89:*/
  1699. #line 2226 "./typica.w"
  1700. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine);
  1701. QScriptValue XmlWriter_setDevice(QScriptContext*context,
  1702. QScriptEngine*engine);
  1703. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,
  1704. QScriptEngine*engine);
  1705. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,
  1706. QScriptEngine*engine);
  1707. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,
  1708. QScriptEngine*engine);
  1709. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*engine);
  1710. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  1711. QScriptEngine*engine);
  1712. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  1713. QScriptEngine*engine);
  1714. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,
  1715. QScriptEngine*engine);
  1716. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  1717. QScriptEngine*engine);
  1718. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  1719. QScriptEngine*engine);
  1720. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  1721. QScriptEngine*engine);
  1722. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  1723. QScriptEngine*engine);
  1724. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  1725. QScriptEngine*engine);
  1726. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine);
  1727. /*:89*//*98:*/
  1728. #line 2444 "./typica.w"
  1729. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine);
  1730. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*engine);
  1731. QScriptValue XmlReader_attribute(QScriptContext*context,
  1732. QScriptEngine*engine);
  1733. QScriptValue XmlReader_hasAttribute(QScriptContext*context,
  1734. QScriptEngine*engine);
  1735. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*engine);
  1736. QScriptValue XmlReader_isStartElement(QScriptContext*context,
  1737. QScriptEngine*engine);
  1738. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*engine);
  1739. QScriptValue XmlReader_readElementText(QScriptContext*context,
  1740. QScriptEngine*engine);
  1741. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*engine);
  1742. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*engine);
  1743. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine);
  1744. /*:98*//*105:*/
  1745. #line 2579 "./typica.w"
  1746. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine);
  1747. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*engine);
  1748. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine);
  1749. /*:105*//*109:*/
  1750. #line 2661 "./typica.w"
  1751. QScriptValue constructQLCDNumber(QScriptContext*context,
  1752. QScriptEngine*engine);
  1753. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine);
  1754. /*:109*//*112:*/
  1755. #line 2699 "./typica.w"
  1756. QScriptValue constructQTime(QScriptContext*context,QScriptEngine*engine);
  1757. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine);
  1758. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine);
  1759. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine);
  1760. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine);
  1761. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine);
  1762. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine);
  1763. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine);
  1764. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine);
  1765. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine);
  1766. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine);
  1767. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine);
  1768. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine);
  1769. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine);
  1770. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*engine);
  1771. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine);
  1772. QScriptValue QTime_currentTime(QScriptContext*context,QScriptEngine*engine);
  1773. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine);
  1774. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*engine);
  1775. void setQTimeProperties(QScriptValue value,QScriptEngine*engine);
  1776. /*:112*//*127:*/
  1777. #line 3168 "./typica.w"
  1778. void setQAbstractScrollAreaProperties(QScriptValue value,
  1779. QScriptEngine*engine);
  1780. /*:127*//*129:*/
  1781. #line 3183 "./typica.w"
  1782. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine);
  1783. /*:129*//*131:*/
  1784. #line 3196 "./typica.w"
  1785. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine);
  1786. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine);
  1787. /*:131*//*133:*/
  1788. #line 3220 "./typica.w"
  1789. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine);
  1790. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine);
  1791. QScriptValue constructQPushButton(QScriptContext*context,
  1792. QScriptEngine*engine);
  1793. /*:133*//*140:*/
  1794. #line 3319 "./typica.w"
  1795. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine);
  1796. QScriptValue constructQSqlQuery(QScriptContext*context,QScriptEngine*engine);
  1797. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*engine);
  1798. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  1799. QScriptEngine*engine);
  1800. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  1801. QScriptEngine*engine);
  1802. QScriptValue QSqlQuery_exec(QScriptContext*context,
  1803. QScriptEngine*engine);
  1804. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,
  1805. QScriptEngine*engine);
  1806. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*engine);
  1807. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine);
  1808. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine);
  1809. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine);
  1810. /*:140*//*147:*/
  1811. #line 3489 "./typica.w"
  1812. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine);
  1813. QScriptValue dir(QScriptContext*context,QScriptEngine*engine);
  1814. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine);
  1815. QScriptValue setFont(QScriptContext*context,QScriptEngine*engine);
  1816. QScriptValue annotationFromRecord(QScriptContext*context,
  1817. QScriptEngine*engine);
  1818. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*engine);
  1819. /*:147*//*158:*/
  1820. #line 3772 "./typica.w"
  1821. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine);
  1822. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  1823. QStack<QLayout*> *layoutStack);
  1824. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1825. QStack<QLayout*> *layoutStack);
  1826. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1827. QStack<QLayout*> *layoutStack);
  1828. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  1829. QStack<QLayout*> *layoutStack);
  1830. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1831. QStack<QLayout*> *layoutStack);
  1832. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1833. QStack<QLayout*> *layoutStack);
  1834. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  1835. QStack<QLayout*> *layoutStack);
  1836. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  1837. QStack<QLayout*> *layoutStack);
  1838. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1839. QStack<QLayout*> *layoutStack);
  1840. void addTemperatureDisplayToSplitter(QDomElement element,
  1841. QStack<QWidget*> *widgetStack,
  1842. QStack<QLayout*> *layoutStack);
  1843. void addTemperatureDisplayToLayout(QDomElement element,
  1844. QStack<QWidget*> *widgetStack,
  1845. QStack<QLayout*> *layoutStack);
  1846. void addTimerDisplayToSplitter(QDomElement element,
  1847. QStack<QWidget*> *widgetStack,
  1848. QStack<QLayout*> *layoutStack);
  1849. void addTimerDisplayToLayout(QDomElement element,
  1850. QStack<QWidget*> *widgetStack,
  1851. QStack<QLayout*> *layoutStack);
  1852. void addDecorationToSplitter(QDomElement element,
  1853. QStack<QWidget*> *widgetStack,
  1854. QStack<QLayout*> *layoutStack);
  1855. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1856. QStack<QLayout*> *layoutStack);
  1857. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  1858. QStack<QLayout*> *layoutStack);
  1859. void addButtonToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1860. QStack<QLayout*> *layoutStack);
  1861. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  1862. QStack<QLayout*> *layoutStack);
  1863. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  1864. QStack<QLayout*> *layoutStack);
  1865. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1866. QStack<QLayout*> *layoutStack);
  1867. void addSaltToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1868. QStack<QLayout*> *layoutStack);
  1869. void addLineToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1870. QStack<QLayout*> *layoutStack);
  1871. void addTextToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1872. QStack<QLayout*> *layoutStack);
  1873. void addSqlQueryViewToLayout(QDomElement element,
  1874. QStack<QWidget*> *widgetStack,
  1875. QStack<QLayout*> *layoutStack);
  1876. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1877. QStack<QLayout*> *layoutStack);
  1878. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  1879. QStack<QLayout*> *layoutStack);
  1880. /*:158*//*209:*/
  1881. #line 5288 "./typica.w"
  1882. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine);
  1883. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine);
  1884. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,
  1885. QScriptEngine*engine);
  1886. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*engine);
  1887. QScriptValue QDateTimeEdit_month(QScriptContext*context,
  1888. QScriptEngine*engine);
  1889. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*engine);
  1890. /*:209*//*210:*/
  1891. #line 5303 "./typica.w"
  1892. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine);
  1893. /*:210*//*214:*/
  1894. #line 5430 "./typica.w"
  1895. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine);
  1896. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  1897. QScriptEngine*engine);
  1898. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  1899. QScriptEngine*engine);
  1900. QScriptValue SaltTable_columnSum(QScriptContext*context,
  1901. QScriptEngine*engine);
  1902. QScriptValue SaltTable_columnArray(QScriptContext*context,
  1903. QScriptEngine*engine);
  1904. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine);
  1905. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine);
  1906. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  1907. QScriptEngine*engine);
  1908. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*engine);
  1909. /*:214*//*221:*/
  1910. #line 5600 "./typica.w"
  1911. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  1912. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine);
  1913. QScriptValue QComboBox_currentData(QScriptContext*context,
  1914. QScriptEngine*engine);
  1915. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*engine);
  1916. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*engine);
  1917. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine);
  1918. /*:221*//*253:*/
  1919. #line 6478 "./typica.w"
  1920. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine);
  1921. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  1922. void setDAQProperties(QScriptValue value,QScriptEngine*engine);
  1923. /*:253*//*262:*/
  1924. #line 6676 "./typica.w"
  1925. QScriptValue constructFakeDAQ(QScriptContext*context,QScriptEngine*engine);
  1926. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine);
  1927. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine);
  1928. /*:262*//*267:*/
  1929. #line 6777 "./typica.w"
  1930. void setChannelProperties(QScriptValue value,QScriptEngine*engine);
  1931. /*:267*//*273:*/
  1932. #line 6953 "./typica.w"
  1933. QScriptValue constructLinearCalibrator(QScriptContext*context,
  1934. QScriptEngine*engine);
  1935. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine);
  1936. /*:273*//*278:*/
  1937. #line 7092 "./typica.w"
  1938. QScriptValue constructLinearSplineInterpolator(QScriptContext*context,QScriptEngine*engine);
  1939. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine);
  1940. /*:278*//*287:*/
  1941. #line 7274 "./typica.w"
  1942. QScriptValue constructTemperatureDisplay(QScriptContext*context,
  1943. QScriptEngine*engine);
  1944. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine);
  1945. /*:287*//*294:*/
  1946. #line 7411 "./typica.w"
  1947. QScriptValue constructMeasurementTimeOffset(QScriptContext*context,
  1948. QScriptEngine*engine);
  1949. void setMeasurementTimeOffsetProperties(QScriptValue value,
  1950. QScriptEngine*engine);
  1951. /*:294*//*299:*/
  1952. #line 7524 "./typica.w"
  1953. QScriptValue constructThresholdDetector(QScriptContext*context,QScriptEngine*engine);
  1954. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine);
  1955. /*:299*//*304:*/
  1956. #line 7621 "./typica.w"
  1957. QScriptValue constructZeroEmitter(QScriptContext*context,
  1958. QScriptEngine*engine);
  1959. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine);
  1960. /*:304*//*309:*/
  1961. #line 7700 "./typica.w"
  1962. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  1963. QScriptEngine*engine);
  1964. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine);
  1965. /*:309*//*324:*/
  1966. #line 8050 "./typica.w"
  1967. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine);
  1968. QScriptValue constructGraphView(QScriptContext*context,QScriptEngine*engine);
  1969. /*:324*//*347:*/
  1970. #line 8645 "./typica.w"
  1971. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine);
  1972. QScriptValue constructZoomLog(QScriptContext*context,QScriptEngine*engine);
  1973. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine);
  1974. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine);
  1975. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*engine);
  1976. QScriptValue ZoomLog_restoreState(QScriptContext*context,
  1977. QScriptEngine*engine);
  1978. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine);
  1979. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  1980. QScriptEngine*engnie);
  1981. /*:347*//*384:*/
  1982. #line 9570 "./typica.w"
  1983. QScriptValue constructAnnotationButton(QScriptContext*context,
  1984. QScriptEngine*engine);
  1985. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine);
  1986. /*:384*//*392:*/
  1987. #line 9710 "./typica.w"
  1988. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  1989. QScriptEngine*engine);
  1990. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  1991. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  1992. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine);
  1993. /*:392*//*413:*/
  1994. #line 10133 "./typica.w"
  1995. QScriptValue constructTimerDisplay(QScriptContext*context,
  1996. QScriptEngine*engine);
  1997. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine);
  1998. /*:413*//*440:*/
  1999. #line 10627 "./typica.w"
  2000. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine);
  2001. QScriptValue constructWidgetDecorator(QScriptContext*context,
  2002. QScriptEngine*engine);
  2003. /*:440*//*453:*/
  2004. #line 10910 "./typica.w"
  2005. QScriptValue constructLogEditWindow(QScriptContext*context,
  2006. QScriptEngine*engine);
  2007. /*:453*//*472:*/
  2008. #line 11384 "./typica.w"
  2009. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine);
  2010. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*engine);
  2011. /*:472*//*488:*/
  2012. #line 11667 "./typica.w"
  2013. QScriptValue constructWebView(QScriptContext*context,QScriptEngine*engine);
  2014. QScriptValue WebView_load(QScriptContext*context,QScriptEngine*engine);
  2015. QScriptValue WebView_print(QScriptContext*context,QScriptEngine*engine);
  2016. QScriptValue WebView_setContent(QScriptContext*context,QScriptEngine*engine);
  2017. QScriptValue WebView_setHtml(QScriptContext*context,QScriptEngine*engine);
  2018. QScriptValue WebView_saveXml(QScriptContext*context,QScriptEngine*);
  2019. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2020. QStack<QLayout*> *layoutStack);
  2021. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine);
  2022. /*:488*//*544:*/
  2023. #line 12694 "./typica.w"
  2024. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine);
  2025. QScriptValue constructSqlQueryView(QScriptContext*context,
  2026. QScriptEngine*engine);
  2027. QScriptValue SqlQueryView_setQuery(QScriptContext*context,
  2028. QScriptEngine*engine);
  2029. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  2030. QScriptEngine*engine);
  2031. /*:544*//*554:*/
  2032. #line 12923 "./typica.w"
  2033. void addReportToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2034. QStack<QLayout*> *layoutStack);
  2035. /*:554*//*570:*/
  2036. #line 13207 "./typica.w"
  2037. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine);
  2038. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*engine);
  2039. /*:570*//*580:*/
  2040. #line 13402 "./typica.w"
  2041. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  2042. QStack<QLayout*> *layoutStack);
  2043. /*:580*//*601:*/
  2044. #line 13986 "./typica.w"
  2045. void addScaleControlToLayout(QDomElement element,
  2046. QStack<QWidget*> *widgetStack,
  2047. QStack<QLayout*> *layoutStack);
  2048. void addIntensityControlToLayout(QDomElement element,
  2049. QStack<QWidget*> *widgetStack,
  2050. QStack<QLayout*> *layoutStack);
  2051. /*:601*//*627:*/
  2052. #line 14572 "./typica.w"
  2053. QScriptValue constructDeviceTreeModel(QScriptContext*context,
  2054. QScriptEngine*engine);
  2055. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine);
  2056. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine);
  2057. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  2058. QScriptEngine*engine);
  2059. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine);
  2060. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine);
  2061. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,QScriptEngine*engine);
  2062. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,QScriptEngine*engine);
  2063. /*:627*//*633:*/
  2064. #line 14714 "./typica.w"
  2065. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index);
  2066. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index);
  2067. /*:633*//*649:*/
  2068. #line 15002 "./typica.w"
  2069. QScriptValue constructDeviceConfigurationWindow(QScriptContext*context,
  2070. QScriptEngine*engine);
  2071. /*:649*//*724:*/
  2072. #line 17496 "./typica.w"
  2073. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine);
  2074. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine);
  2075. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine);
  2076. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine);
  2077. /*:724*/
  2078. #line 762 "./typica.w"
  2079. /*17:*/
  2080. #line 770 "./typica.w"
  2081. /*641:*/
  2082. #line 14835 "./typica.w"
  2083. NodeInserter::NodeInserter(const QString&title,const QString&name,
  2084. const QString&driver,QObject*parent):
  2085. QAction(title,parent),defaultNodeName(name),driverString(driver)
  2086. {
  2087. connect(this,SIGNAL(triggered()),this,SLOT(onTriggered()));
  2088. }
  2089. void NodeInserter::onTriggered()
  2090. {
  2091. emit triggered(defaultNodeName,driverString);
  2092. }
  2093. /*:641*/
  2094. #line 771 "./typica.w"
  2095. /*228:*/
  2096. #line 5715 "./typica.w"
  2097. Measurement::Measurement(double temperature,QTime time,
  2098. TemperatureUnits sc):
  2099. theTemperature(temperature),theTime(time),unit(sc)
  2100. {
  2101. }
  2102. Measurement::Measurement(double temperature):
  2103. theTemperature(temperature),theTime(QTime::currentTime()),
  2104. unit(Fahrenheit)
  2105. {
  2106. }
  2107. /*:228*//*230:*/
  2108. #line 5743 "./typica.w"
  2109. Measurement::Measurement(const Measurement&x):
  2110. theTemperature(x.temperature()),theTime(x.time()),
  2111. unit(x.unit)
  2112. {
  2113. }
  2114. Measurement::~Measurement()
  2115. {
  2116. }
  2117. /*:230*//*231:*/
  2118. #line 5759 "./typica.w"
  2119. Measurement&Measurement::operator= (Measurement&x)
  2120. {
  2121. theTemperature= x.temperature();
  2122. theTime= x.time();
  2123. unit= x.unit;
  2124. return*this;
  2125. }
  2126. /*:231*//*232:*/
  2127. #line 5773 "./typica.w"
  2128. double Measurement::temperature()const
  2129. {
  2130. return theTemperature;
  2131. }
  2132. QTime Measurement::time()const
  2133. {
  2134. return theTime;
  2135. }
  2136. void Measurement::setTemperature(double temperature)
  2137. {
  2138. theTemperature= temperature;
  2139. }
  2140. void Measurement::setTime(QTime time)
  2141. {
  2142. theTime= time;
  2143. }
  2144. /*:232*//*233:*/
  2145. #line 5799 "./typica.w"
  2146. void Measurement::setUnit(TemperatureUnits scale)
  2147. {
  2148. unit= scale;
  2149. }
  2150. Measurement::TemperatureUnits Measurement::scale()
  2151. {
  2152. return unit;
  2153. }
  2154. /*:233*//*234:*/
  2155. #line 5819 "./typica.w"
  2156. Measurement Measurement::toFahrenheit()
  2157. {
  2158. switch(unit)
  2159. {
  2160. case Celsius:
  2161. return Measurement(this->temperature()*9/5+32,this->time(),
  2162. Fahrenheit);
  2163. break;
  2164. case Kelvin:
  2165. return Measurement(this->temperature()*5/9-459.67,
  2166. this->time(),Fahrenheit);
  2167. break;
  2168. case Rankine:
  2169. return Measurement(this->temperature()-459.67,this->time(),
  2170. Fahrenheit);
  2171. break;
  2172. default:
  2173. return Measurement(this->temperature(),this->time(),Fahrenheit);
  2174. break;
  2175. }
  2176. }
  2177. /*:234*//*235:*/
  2178. #line 5844 "./typica.w"
  2179. Measurement Measurement::toCelsius()
  2180. {
  2181. switch(unit)
  2182. {
  2183. case Fahrenheit:
  2184. return Measurement((this->temperature()-32)*5/9,this->time(),
  2185. Celsius);
  2186. break;
  2187. case Kelvin:
  2188. return Measurement(this->temperature()-273.15,this->time(),
  2189. Celsius);
  2190. break;
  2191. case Rankine:
  2192. return Measurement((this->temperature()-491.67)*5/9,
  2193. this->time(),Celsius);
  2194. break;
  2195. default:
  2196. return Measurement(this->temperature(),this->time(),Celsius);
  2197. break;
  2198. }
  2199. }
  2200. /*:235*//*236:*/
  2201. #line 5870 "./typica.w"
  2202. Measurement Measurement::toKelvin()
  2203. {
  2204. switch(unit)
  2205. {
  2206. case Fahrenheit:
  2207. return Measurement((this->temperature()+459.67)*5/9,
  2208. this->time(),Kelvin);
  2209. break;
  2210. case Celsius:
  2211. return Measurement(this->temperature()+273.15,this->time(),
  2212. Kelvin);
  2213. break;
  2214. case Rankine:
  2215. return Measurement(this->temperature()*5/9,this->time(),
  2216. Kelvin);
  2217. break;
  2218. default:
  2219. return Measurement(this->temperature(),this->time(),Kelvin);
  2220. break;
  2221. }
  2222. }
  2223. /*:236*//*237:*/
  2224. #line 5895 "./typica.w"
  2225. Measurement Measurement::toRankine()
  2226. {
  2227. switch(unit)
  2228. {
  2229. case Fahrenheit:
  2230. return Measurement(this->temperature()+459.67,this->time(),
  2231. Rankine);
  2232. break;
  2233. case Celsius:
  2234. return Measurement((this->temperature()+273.15)*9/5,
  2235. this->time(),Rankine);
  2236. break;
  2237. case Kelvin:
  2238. return Measurement(this->temperature()*9/5,this->time(),
  2239. Rankine);
  2240. break;
  2241. default:
  2242. return Measurement(this->temperature(),this->time(),Rankine);
  2243. break;
  2244. }
  2245. }
  2246. /*:237*/
  2247. #line 772 "./typica.w"
  2248. /*243:*/
  2249. #line 6084 "./typica.w"
  2250. void DAQImplementation::measure()
  2251. {
  2252. int samplesRead= 0;
  2253. double buffer[channels];
  2254. error= read((unsigned int)(handle),(signed long)(1),(double)(10.0),
  2255. (unsigned long)(0),buffer,(unsigned long)(channels),
  2256. &samplesRead,(signed long)(0));
  2257. if(error)
  2258. {
  2259. ready= false;
  2260. }
  2261. else
  2262. {
  2263. if(samplesRead)
  2264. {
  2265. QTime time= QTime::currentTime();
  2266. for(int i= 0;i<samplesRead;i++)
  2267. {
  2268. for(int j= 0;j<channels;j++)
  2269. {
  2270. Measurement measure(buffer[j+(i*channels)],time,
  2271. unitMap[j]);
  2272. channelMap[j]->input(measure);
  2273. }
  2274. }
  2275. }
  2276. }
  2277. }
  2278. /*:243*//*244:*/
  2279. #line 6126 "./typica.w"
  2280. void DAQImplementation::run()
  2281. {
  2282. setPriority(QThread::TimeCriticalPriority);
  2283. while(ready)
  2284. {
  2285. measure();
  2286. }
  2287. }
  2288. /*:244*//*245:*/
  2289. #line 6142 "./typica.w"
  2290. void DAQ::threadFinished()
  2291. {
  2292. if(imp->error)
  2293. {
  2294. /*246:*/
  2295. #line 6193 "./typica.w"
  2296. imp->ready= false;
  2297. QMessageBox warning;
  2298. warning.setStandardButtons(QMessageBox::Cancel);
  2299. warning.setIcon(QMessageBox::Warning);
  2300. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2301. unsigned long bytes= imp->errorInfo(NULL,0);
  2302. char string[bytes];
  2303. imp->errorInfo(string,bytes);
  2304. warning.setInformativeText(QString(string));
  2305. warning.setWindowTitle(QString(PROGRAM_NAME));
  2306. warning.exec();
  2307. /*:246*/
  2308. #line 6147 "./typica.w"
  2309. }
  2310. }
  2311. /*:245*//*247:*/
  2312. #line 6218 "./typica.w"
  2313. void DAQ::start()
  2314. {
  2315. if(imp->ready)
  2316. {
  2317. imp->error= imp->startTask(imp->handle);
  2318. if(imp->error)
  2319. {
  2320. /*246:*/
  2321. #line 6193 "./typica.w"
  2322. imp->ready= false;
  2323. QMessageBox warning;
  2324. warning.setStandardButtons(QMessageBox::Cancel);
  2325. warning.setIcon(QMessageBox::Warning);
  2326. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2327. unsigned long bytes= imp->errorInfo(NULL,0);
  2328. char string[bytes];
  2329. imp->errorInfo(string,bytes);
  2330. warning.setInformativeText(QString(string));
  2331. warning.setWindowTitle(QString(PROGRAM_NAME));
  2332. warning.exec();
  2333. /*:246*/
  2334. #line 6226 "./typica.w"
  2335. }
  2336. else
  2337. {
  2338. connect(imp,SIGNAL(finished()),this,SLOT(threadFinished()));
  2339. imp->start();
  2340. }
  2341. }
  2342. }
  2343. void DAQ::stop()
  2344. {
  2345. if(imp->useBase)
  2346. {
  2347. imp->ready= false;
  2348. imp->wait(ULONG_MAX);
  2349. imp->stopTask(imp->handle);
  2350. }
  2351. else
  2352. {
  2353. imp->ready= false;
  2354. imp->error= imp->stopTask(imp->handle);
  2355. if(imp->error)
  2356. {
  2357. /*246:*/
  2358. #line 6193 "./typica.w"
  2359. imp->ready= false;
  2360. QMessageBox warning;
  2361. warning.setStandardButtons(QMessageBox::Cancel);
  2362. warning.setIcon(QMessageBox::Warning);
  2363. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2364. unsigned long bytes= imp->errorInfo(NULL,0);
  2365. char string[bytes];
  2366. imp->errorInfo(string,bytes);
  2367. warning.setInformativeText(QString(string));
  2368. warning.setWindowTitle(QString(PROGRAM_NAME));
  2369. warning.exec();
  2370. /*:246*/
  2371. #line 6250 "./typica.w"
  2372. }
  2373. imp->error= imp->clearTask(imp->handle);
  2374. if(imp->error)
  2375. {
  2376. /*246:*/
  2377. #line 6193 "./typica.w"
  2378. imp->ready= false;
  2379. QMessageBox warning;
  2380. warning.setStandardButtons(QMessageBox::Cancel);
  2381. warning.setIcon(QMessageBox::Warning);
  2382. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2383. unsigned long bytes= imp->errorInfo(NULL,0);
  2384. char string[bytes];
  2385. imp->errorInfo(string,bytes);
  2386. warning.setInformativeText(QString(string));
  2387. warning.setWindowTitle(QString(PROGRAM_NAME));
  2388. warning.exec();
  2389. /*:246*/
  2390. #line 6255 "./typica.w"
  2391. }
  2392. }
  2393. }
  2394. /*:247*//*248:*/
  2395. #line 6265 "./typica.w"
  2396. DAQ::DAQ(QString device,const QString&driver):imp(new DAQImplementation(driver))
  2397. {
  2398. imp->device= device;
  2399. imp->error= imp->createTask(device.toAscii().data(),&(imp->handle));
  2400. if(imp->error)
  2401. {
  2402. /*246:*/
  2403. #line 6193 "./typica.w"
  2404. imp->ready= false;
  2405. QMessageBox warning;
  2406. warning.setStandardButtons(QMessageBox::Cancel);
  2407. warning.setIcon(QMessageBox::Warning);
  2408. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2409. unsigned long bytes= imp->errorInfo(NULL,0);
  2410. char string[bytes];
  2411. imp->errorInfo(string,bytes);
  2412. warning.setInformativeText(QString(string));
  2413. warning.setWindowTitle(QString(PROGRAM_NAME));
  2414. warning.exec();
  2415. /*:246*/
  2416. #line 6272 "./typica.w"
  2417. }
  2418. else
  2419. {
  2420. imp->ready= true;
  2421. }
  2422. }
  2423. /*:248*//*249:*/
  2424. #line 6286 "./typica.w"
  2425. Channel*DAQ::newChannel(int units,int thermocouple)
  2426. {
  2427. Channel*retval= new Channel();
  2428. imp->channelMap[imp->channels]= retval;
  2429. imp->unitMap[imp->channels]= (Measurement::TemperatureUnits)units;
  2430. imp->channels++;
  2431. if(imp->ready)
  2432. {
  2433. if(imp->useBase)
  2434. {
  2435. imp->error= imp->createChannel(imp->handle,
  2436. QString("%1/ai%2").arg(imp->device).
  2437. arg(imp->channels-1).
  2438. toAscii().data(),
  2439. "",(double)(-1.0),(double)(100.0),
  2440. (signed long)(units),
  2441. (signed long)(thermocouple),
  2442. (signed long)(10200),(double)(0),
  2443. "");
  2444. }
  2445. else
  2446. {
  2447. imp->error= imp->createChannel(imp->handle,
  2448. QString("%1/ai%2").arg(imp->device).
  2449. arg(imp->channels-1).
  2450. toAscii().data(),
  2451. "",(double)(50.0),(double)(500.0),
  2452. (signed long)(units),
  2453. (signed long)(thermocouple),
  2454. (signed long)(10200),(double)(0),
  2455. "");
  2456. }
  2457. if(imp->error)
  2458. {
  2459. /*246:*/
  2460. #line 6193 "./typica.w"
  2461. imp->ready= false;
  2462. QMessageBox warning;
  2463. warning.setStandardButtons(QMessageBox::Cancel);
  2464. warning.setIcon(QMessageBox::Warning);
  2465. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2466. unsigned long bytes= imp->errorInfo(NULL,0);
  2467. char string[bytes];
  2468. imp->errorInfo(string,bytes);
  2469. warning.setInformativeText(QString(string));
  2470. warning.setWindowTitle(QString(PROGRAM_NAME));
  2471. warning.exec();
  2472. /*:246*/
  2473. #line 6321 "./typica.w"
  2474. }
  2475. }
  2476. return retval;
  2477. }
  2478. /*:249*//*250:*/
  2479. #line 6335 "./typica.w"
  2480. void DAQ::setClockRate(double Hz)
  2481. {
  2482. if(imp->ready)
  2483. {
  2484. imp->error= imp->setClock(imp->handle,"OnboardClock",Hz,
  2485. (signed long)(10280),(signed long)(10123),
  2486. (unsigned long long)(1));
  2487. if(imp->error)
  2488. {
  2489. /*246:*/
  2490. #line 6193 "./typica.w"
  2491. imp->ready= false;
  2492. QMessageBox warning;
  2493. warning.setStandardButtons(QMessageBox::Cancel);
  2494. warning.setIcon(QMessageBox::Warning);
  2495. warning.setText(QString(tr("Error: %1")).arg(imp->error));
  2496. unsigned long bytes= imp->errorInfo(NULL,0);
  2497. char string[bytes];
  2498. imp->errorInfo(string,bytes);
  2499. warning.setInformativeText(QString(string));
  2500. warning.setWindowTitle(QString(PROGRAM_NAME));
  2501. warning.exec();
  2502. /*:246*/
  2503. #line 6345 "./typica.w"
  2504. }
  2505. }
  2506. }
  2507. /*:250*//*251:*/
  2508. #line 6355 "./typica.w"
  2509. DAQ::~DAQ()
  2510. {
  2511. if(imp->useBase)
  2512. {
  2513. imp->resetDevice(imp->device.toAscii().data());
  2514. imp->clearTask(imp->handle);
  2515. }
  2516. else
  2517. {
  2518. if(imp->ready)
  2519. {
  2520. imp->ready= false;
  2521. imp->wait(ULONG_MAX);
  2522. imp->stopTask(imp->handle);
  2523. imp->resetDevice(imp->device.toAscii().data());
  2524. imp->clearTask(imp->handle);
  2525. }
  2526. }
  2527. delete imp;
  2528. }
  2529. /*:251*//*252:*/
  2530. #line 6386 "./typica.w"
  2531. DAQImplementation::DAQImplementation(const QString&driverinfo)
  2532. :QThread(NULL),channelMap(4),handle(0),error(0),channels(0),ready(false),
  2533. unitMap(4)
  2534. {
  2535. if(driverinfo=="nidaqmxbase")
  2536. {
  2537. useBase= true;
  2538. }
  2539. else
  2540. {
  2541. useBase= false;
  2542. }
  2543. if(useBase)
  2544. {
  2545. driver.setFileName("nidaqmxbase.framework/nidaqmxbase");
  2546. if(!driver.load())
  2547. {
  2548. driver.setFileName("nidaqmxbase");
  2549. if(!driver.load())
  2550. {
  2551. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  2552. tr("Failed to find nidaqmxbase. Please install it."));
  2553. QApplication::quit();
  2554. }
  2555. }
  2556. }
  2557. else
  2558. {
  2559. driver.setFileName("nicaiu");
  2560. if(!driver.load())
  2561. {
  2562. QMessageBox::critical(NULL,tr("Typica: Driver not found"),
  2563. tr("Failed to find nidaqmx. Please install it."));
  2564. QApplication::quit();
  2565. }
  2566. }
  2567. if(useBase)
  2568. {
  2569. if((createTask= (daqfp)driver.resolve("DAQmxBaseCreateTask"))==0||
  2570. (startTask= (daqfp)driver.resolve("DAQmxBaseStartTask"))==0||
  2571. (stopTask= (daqfp)driver.resolve("DAQmxBaseStopTask"))==0||
  2572. (clearTask= (daqfp)driver.resolve("DAQmxBaseClearTask"))==0||
  2573. (createChannel= (daqfp)driver.resolve("DAQmxBaseCreateAIThrmcplChan"))
  2574. ==0||
  2575. (setClock= (daqfp)driver.resolve("DAQmxBaseCfgSampClkTiming"))==
  2576. 0||
  2577. (read= (daqfp)driver.resolve("DAQmxBaseReadAnalogF64"))==0||
  2578. (errorInfo= (daqfp)driver.resolve("DAQmxBaseGetExtendedErrorInfo"))==
  2579. 0||
  2580. (resetDevice= (daqfp)driver.resolve("DAQmxBaseResetDevice"))==0)
  2581. {
  2582. waitForMeasurement= NULL;
  2583. QMessageBox::critical(NULL,tr("Typica: Link error"),
  2584. tr("Failed to link a required symbol in NI-DAQmxBase."));
  2585. QApplication::quit();
  2586. }
  2587. }
  2588. else
  2589. {
  2590. if((createTask= (daqfp)driver.resolve("DAQmxCreateTask"))==0||
  2591. (startTask= (daqfp)driver.resolve("DAQmxStartTask"))==0||
  2592. (stopTask= (daqfp)driver.resolve("DAQmxStopTask"))==0||
  2593. (clearTask= (daqfp)driver.resolve("DAQmxClearTask"))==0||
  2594. (createChannel= (daqfp)driver.resolve("DAQmxCreateAIThrmcplChan"))
  2595. ==0||
  2596. (setClock= (daqfp)driver.resolve("DAQmxCfgSampClkTiming"))==0||
  2597. (read= (daqfp)driver.resolve("DAQmxReadAnalogF64"))==0||
  2598. (errorInfo= (daqfp)driver.resolve("DAQmxGetExtendedErrorInfo"))==
  2599. 0||
  2600. (resetDevice= (daqfp)driver.resolve("DAQmxResetDevice"))==0||
  2601. (waitForMeasurement= (daqfp)driver.resolve("DAQmxWaitUntilTaskDone"))==0)
  2602. {
  2603. QMessageBox::critical(NULL,tr("Typica: Link error"),
  2604. tr("Failed to link a required symbol in NI-DAQmx."));
  2605. QApplication::quit();
  2606. }
  2607. }
  2608. }
  2609. DAQImplementation::~DAQImplementation()
  2610. {
  2611. driver.unload();
  2612. }
  2613. /*:252*/
  2614. #line 773 "./typica.w"
  2615. /*259:*/
  2616. #line 6588 "./typica.w"
  2617. void FakeDAQImplementation::measure()
  2618. {
  2619. msleep((int)(1000/clockRate));
  2620. QTime time= QTime::currentTime();
  2621. for(int i= 0;i<channels;i++)
  2622. {
  2623. Measurement measure(qrand()%500,time);
  2624. channelMap[i]->input(measure);
  2625. }
  2626. }
  2627. /*:259*//*260:*/
  2628. #line 6602 "./typica.w"
  2629. void FakeDAQImplementation::run()
  2630. {
  2631. setPriority(QThread::TimeCriticalPriority);
  2632. while(ready)
  2633. {
  2634. measure();
  2635. }
  2636. }
  2637. FakeDAQImplementation::FakeDAQImplementation():QThread(NULL),channelMap(4),
  2638. channels(0),ready(false),clockRate(1)
  2639. {
  2640. }
  2641. FakeDAQImplementation::~FakeDAQImplementation()
  2642. {
  2643. }
  2644. /*:260*//*261:*/
  2645. #line 6627 "./typica.w"
  2646. void FakeDAQ::start()
  2647. {
  2648. if(imp->ready)
  2649. {
  2650. imp->start();
  2651. }
  2652. }
  2653. FakeDAQ::FakeDAQ(QString):imp(new FakeDAQImplementation())
  2654. {
  2655. imp->ready= true;
  2656. }
  2657. Channel*FakeDAQ::newChannel(int,int)
  2658. {
  2659. Channel*retval;
  2660. if(imp->ready)
  2661. {
  2662. retval= new Channel();
  2663. imp->channelMap[imp->channels]= retval;
  2664. imp->channels++;
  2665. }
  2666. else
  2667. {
  2668. return NULL;
  2669. }
  2670. return retval;
  2671. }
  2672. void FakeDAQ::setClockRate(double Hz)
  2673. {
  2674. if(imp->ready)
  2675. {
  2676. imp->clockRate= Hz;
  2677. }
  2678. }
  2679. FakeDAQ::~FakeDAQ()
  2680. {
  2681. imp->ready= false;
  2682. imp->wait(ULONG_MAX);
  2683. delete imp;
  2684. }
  2685. /*:261*/
  2686. #line 774 "./typica.w"
  2687. /*266:*/
  2688. #line 6758 "./typica.w"
  2689. Channel::Channel():QObject(NULL)
  2690. {
  2691. }
  2692. Channel::~Channel()
  2693. {
  2694. }
  2695. void Channel::input(Measurement measurement)
  2696. {
  2697. emit newData(measurement);
  2698. }
  2699. /*:266*/
  2700. #line 775 "./typica.w"
  2701. /*282:*/
  2702. #line 7169 "./typica.w"
  2703. void TemperatureDisplay::setValue(Measurement temperature)
  2704. {
  2705. QString number;
  2706. switch(unit)
  2707. {
  2708. case Auto:
  2709. switch(temperature.scale())
  2710. {
  2711. case Fahrenheit:
  2712. display(QString("%1'F").
  2713. arg(number.setNum(temperature.temperature(),'f',2)));
  2714. break;
  2715. case Celsius:
  2716. display(QString("%1'C").
  2717. arg(number.setNum(temperature.temperature(),'f',2)));
  2718. break;
  2719. case Kelvin:
  2720. display(QString("%1").
  2721. arg(number.setNum(temperature.temperature(),'f',2)));
  2722. break;
  2723. case Rankine:
  2724. display(QString("%1'r").
  2725. arg(number.setNum(temperature.temperature(),'f',2)));
  2726. break;
  2727. }
  2728. break;
  2729. case Fahrenheit:
  2730. display(QString("%1'F").
  2731. arg(number.setNum(temperature.toFahrenheit().temperature(),'f',
  2732. 2)));
  2733. break;
  2734. case Celsius:
  2735. display(QString("%1'C").
  2736. arg(number.setNum(temperature.toCelsius().temperature(),'f',
  2737. 2)));
  2738. break;
  2739. case Kelvin:
  2740. display(QString("%1").
  2741. arg(number.setNum(temperature.toKelvin().temperature(),'f',
  2742. 2)));
  2743. break;
  2744. case Rankine:
  2745. display(QString("%1'r").
  2746. arg(number.setNum(temperature.toRankine().temperature(),'f',
  2747. 2)));
  2748. break;
  2749. }
  2750. }
  2751. /*:282*//*283:*/
  2752. #line 7229 "./typica.w"
  2753. TemperatureDisplay::TemperatureDisplay(QWidget*parent):
  2754. QLCDNumber(8,parent),unit(Auto)
  2755. {
  2756. setSegmentStyle(Filled);
  2757. display("---.--'F");
  2758. }
  2759. /*:283*//*284:*/
  2760. #line 7245 "./typica.w"
  2761. void TemperatureDisplay::invalidate()
  2762. {
  2763. display("---.--'F");
  2764. }
  2765. /*:284*//*285:*/
  2766. #line 7257 "./typica.w"
  2767. void TemperatureDisplay::setDisplayUnits(DisplayUnits scale)
  2768. {
  2769. unit= scale;
  2770. }
  2771. /*:285*//*286:*/
  2772. #line 7265 "./typica.w"
  2773. TemperatureDisplay::~TemperatureDisplay()
  2774. {
  2775. }
  2776. /*:286*/
  2777. #line 776 "./typica.w"
  2778. /*291:*/
  2779. #line 7345 "./typica.w"
  2780. void MeasurementTimeOffset::newMeasurement(Measurement measure)
  2781. {
  2782. if(measure.time()<epoch)
  2783. {
  2784. if(hasPrevious)
  2785. {
  2786. QTime jitBase(epoch.hour()-1,epoch.minute(),epoch.second(),
  2787. epoch.msec());
  2788. QTime jitComp(epoch.hour(),measure.time().minute(),
  2789. measure.time().second(),measure.time().msec());
  2790. int relTime= jitBase.msecsTo(jitComp);
  2791. /*292:*/
  2792. #line 7378 "./typica.w"
  2793. QTime newTime(0,0,0,0);
  2794. newTime= newTime.addMSecs(relTime);
  2795. if(newTime.hour()> 0)
  2796. {
  2797. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  2798. }
  2799. Measurement rel(measure.temperature(),newTime);
  2800. emit measurement(rel);
  2801. /*:292*/
  2802. #line 7357 "./typica.w"
  2803. }
  2804. else
  2805. {
  2806. Measurement rel(measure.temperature(),QTime(0,0,0,0));
  2807. emit measurement(rel);
  2808. }
  2809. }
  2810. else
  2811. {
  2812. int relTime= epoch.msecsTo(measure.time());
  2813. /*292:*/
  2814. #line 7378 "./typica.w"
  2815. QTime newTime(0,0,0,0);
  2816. newTime= newTime.addMSecs(relTime);
  2817. if(newTime.hour()> 0)
  2818. {
  2819. newTime.setHMS(0,newTime.minute(),newTime.second(),newTime.msec());
  2820. }
  2821. Measurement rel(measure.temperature(),newTime);
  2822. emit measurement(rel);
  2823. /*:292*/
  2824. #line 7368 "./typica.w"
  2825. }
  2826. hasPrevious= true;
  2827. previous= measure.time();
  2828. }
  2829. /*:291*//*293:*/
  2830. #line 7390 "./typica.w"
  2831. MeasurementTimeOffset::MeasurementTimeOffset(QTime zero):epoch(zero),
  2832. previous(0,0,0,0),hasPrevious(false)
  2833. {
  2834. }
  2835. QTime MeasurementTimeOffset::zeroTime()
  2836. {
  2837. return epoch;
  2838. }
  2839. void MeasurementTimeOffset::setZeroTime(QTime zero)
  2840. {
  2841. epoch= zero;
  2842. hasPrevious= false;
  2843. }
  2844. /*:293*/
  2845. #line 777 "./typica.w"
  2846. /*303:*/
  2847. #line 7587 "./typica.w"
  2848. ZeroEmitter::ZeroEmitter(int tempcolumn):QObject(NULL),col(tempcolumn),
  2849. temp(0)
  2850. {
  2851. }
  2852. int ZeroEmitter::column()
  2853. {
  2854. return col;
  2855. }
  2856. double ZeroEmitter::lastTemperature()
  2857. {
  2858. return temp;
  2859. }
  2860. void ZeroEmitter::newMeasurement(Measurement measure)
  2861. {
  2862. temp= measure.temperature();
  2863. }
  2864. void ZeroEmitter::setColumn(int column)
  2865. {
  2866. col= column;
  2867. }
  2868. void ZeroEmitter::emitZero()
  2869. {
  2870. emit measurement(Measurement(temp,QTime(0,0,0,0)),col);
  2871. }
  2872. /*:303*/
  2873. #line 778 "./typica.w"
  2874. /*308:*/
  2875. #line 7677 "./typica.w"
  2876. MeasurementAdapter::MeasurementAdapter(int tempcolumn):col(tempcolumn)
  2877. {
  2878. }
  2879. int MeasurementAdapter::column()
  2880. {
  2881. return col;
  2882. }
  2883. void MeasurementAdapter::newMeasurement(Measurement measure)
  2884. {
  2885. emit measurement(measure,col);
  2886. }
  2887. void MeasurementAdapter::setColumn(int column)
  2888. {
  2889. col= column;
  2890. }
  2891. /*:308*/
  2892. #line 779 "./typica.w"
  2893. /*313:*/
  2894. #line 7793 "./typica.w"
  2895. GraphView::GraphView(QWidget*parent):QGraphicsView(parent),
  2896. theScene(new QGraphicsScene),
  2897. graphLines(new QMap<int,QList<QGraphicsLineItem*> *> ),
  2898. prevPoints(new QMap<int,QPointF> ),
  2899. translations(new QMap<int,double> ),
  2900. gridLinesF(new QList<QGraphicsItem*> ),
  2901. gridLinesC(new QList<QGraphicsItem*> )
  2902. {
  2903. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  2904. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  2905. setScene(theScene);
  2906. setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  2907. /*314:*/
  2908. #line 7821 "./typica.w"
  2909. QGraphicsLineItem*tempaxis= new QGraphicsLineItem;
  2910. tempaxis->setLine(-10,-500,-10,0);
  2911. theScene->addItem(tempaxis);
  2912. QGraphicsLineItem*gridLine;
  2913. QGraphicsTextItem*label;
  2914. for(int y= -100;y> -600;y-= 100)
  2915. {
  2916. gridLine= new QGraphicsLineItem;
  2917. gridLine->setLine(0,y,1200,y);
  2918. theScene->addItem(gridLine);
  2919. label= new QGraphicsTextItem;
  2920. label->setHtml(QString("%1&deg;F").arg(-y));
  2921. label->setPos(-55,y-(label->boundingRect().height()/2));
  2922. theScene->addItem(label);
  2923. gridLinesF->append(gridLine);
  2924. gridLinesF->append(label);
  2925. }
  2926. for(int degC= 50;degC<=250;degC+= 50)
  2927. {
  2928. gridLine= new QGraphicsLineItem;
  2929. int y= -(degC*(9.0/5.0)+32);
  2930. gridLine->setLine(0,y,1200,y);
  2931. gridLine->hide();
  2932. theScene->addItem(gridLine);
  2933. gridLinesC->append(gridLine);
  2934. label= new QGraphicsTextItem;
  2935. label->setHtml(QString("%1&deg;C").arg(degC));
  2936. label->setPos(-55,y-(label->boundingRect().height()/2));
  2937. label->hide();
  2938. theScene->addItem(label);
  2939. gridLinesC->append(label);
  2940. }
  2941. /*:314*/
  2942. #line 7806 "./typica.w"
  2943. ;
  2944. /*316:*/
  2945. #line 7887 "./typica.w"
  2946. QGraphicsLineItem*timeaxis= new QGraphicsLineItem;
  2947. timeaxis->setLine(0,10,1200,10);
  2948. theScene->addItem(timeaxis);
  2949. for(int x= 0;x<1201;x+= 120)
  2950. {
  2951. QGraphicsLineItem*tick= new QGraphicsLineItem;
  2952. tick->setLine(x,0,x,20);
  2953. theScene->addItem(tick);
  2954. QGraphicsTextItem*label= new QGraphicsTextItem;
  2955. label->setPlainText(QString("%1").arg(x/60));
  2956. label->setPos(x-(label->boundingRect().width()/2),20);
  2957. theScene->addItem(label);
  2958. }
  2959. /*:316*/
  2960. #line 7807 "./typica.w"
  2961. ;
  2962. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  2963. }
  2964. /*:313*//*315:*/
  2965. #line 7857 "./typica.w"
  2966. void GraphView::showF()
  2967. {
  2968. for(int i= 0;i<gridLinesF->size();i++)
  2969. {
  2970. gridLinesF->at(i)->show();
  2971. }
  2972. for(int i= 0;i<gridLinesC->size();i++)
  2973. {
  2974. gridLinesC->at(i)->hide();
  2975. }
  2976. }
  2977. void GraphView::showC()
  2978. {
  2979. for(int i= 0;i<gridLinesF->size();i++)
  2980. {
  2981. gridLinesF->at(i)->hide();
  2982. }
  2983. for(int i= 0;i<gridLinesC->size();i++)
  2984. {
  2985. gridLinesC->at(i)->show();
  2986. }
  2987. }
  2988. /*:315*//*317:*/
  2989. #line 7906 "./typica.w"
  2990. void GraphView::resizeEvent(QResizeEvent*)
  2991. {
  2992. fitInView(theScene->sceneRect().adjusted(-50,-50,50,50));
  2993. }
  2994. /*:317*//*318:*/
  2995. #line 7917 "./typica.w"
  2996. #define FULLTIMETOINT(t) (t.msec() + (t.second() * 1000) + (t.minute() * 60 * 1000))
  2997. void GraphView::newMeasurement(Measurement measure,int tempcolumn)
  2998. {
  2999. double offset= 0;
  3000. if(translations->contains(tempcolumn))
  3001. {
  3002. offset= translations->value(tempcolumn);
  3003. }
  3004. if(prevPoints->contains(tempcolumn))
  3005. {
  3006. /*320:*/
  3007. #line 7976 "./typica.w"
  3008. QGraphicsLineItem*segment= new QGraphicsLineItem;
  3009. QPointF nextPoint(FULLTIMETOINT(measure.time())/1000,measure.temperature());
  3010. segment->setLine(prevPoints->value(tempcolumn).x()+offset,
  3011. -(prevPoints->value(tempcolumn).y()),
  3012. nextPoint.x()+offset,-(nextPoint.y()));
  3013. static QColor p[12]= {Qt::yellow,Qt::blue,Qt::cyan,Qt::red,Qt::magenta,
  3014. Qt::green,Qt::darkGreen,Qt::darkMagenta,
  3015. Qt::darkRed,Qt::darkCyan,Qt::darkBlue,
  3016. Qt::darkYellow};
  3017. segment->setPen(p[tempcolumn%12]);
  3018. theScene->addItem(segment);
  3019. prevPoints->insert(tempcolumn,nextPoint);
  3020. /*:320*/
  3021. #line 7929 "./typica.w"
  3022. if(graphLines->contains(tempcolumn))
  3023. {
  3024. graphLines->value(tempcolumn)->append(segment);
  3025. }
  3026. else
  3027. {
  3028. QList<QGraphicsLineItem*> *newLine=
  3029. new QList<QGraphicsLineItem*> ;
  3030. newLine->append(segment);
  3031. graphLines->insert(tempcolumn,newLine);
  3032. }
  3033. }
  3034. else
  3035. {
  3036. /*319:*/
  3037. #line 7965 "./typica.w"
  3038. int x= FULLTIMETOINT(measure.time())/1000;
  3039. prevPoints->insert(tempcolumn,QPointF(x,measure.temperature()));
  3040. /*:319*/
  3041. #line 7946 "./typica.w"
  3042. }
  3043. }
  3044. /*:318*//*321:*/
  3045. #line 7993 "./typica.w"
  3046. void GraphView::clear()
  3047. {
  3048. int i;
  3049. foreach(i,prevPoints->keys())
  3050. {
  3051. removeSeries(i);
  3052. }
  3053. translations->clear();
  3054. }
  3055. /*:321*//*322:*/
  3056. #line 8007 "./typica.w"
  3057. void GraphView::removeSeries(int column)
  3058. {
  3059. if(graphLines->contains(column))
  3060. {
  3061. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  3062. QGraphicsLineItem*segment;
  3063. foreach(segment,*series)
  3064. {
  3065. theScene->removeItem(segment);
  3066. }
  3067. qDeleteAll(*series);
  3068. }
  3069. graphLines->remove(column);
  3070. prevPoints->remove(column);
  3071. }
  3072. /*:322*//*323:*/
  3073. #line 8026 "./typica.w"
  3074. void GraphView::setSeriesTranslation(int column,double offset)
  3075. {
  3076. if(graphLines->contains(column))
  3077. {
  3078. QList<QGraphicsLineItem*> *series= graphLines->value(column);
  3079. QGraphicsLineItem*segment;
  3080. foreach(segment,*series)
  3081. {
  3082. segment->setPos(segment->pos().x()+offset,segment->pos().y());
  3083. }
  3084. }
  3085. if(translations->contains(column))
  3086. {
  3087. translations->insert(column,offset+translations->value(column));
  3088. }
  3089. else
  3090. {
  3091. translations->insert(column,offset);
  3092. }
  3093. }
  3094. /*:323*/
  3095. #line 780 "./typica.w"
  3096. /*329:*/
  3097. #line 8176 "./typica.w"
  3098. void ZoomLog::newMeasurement(Measurement measure,int tempcolumn)
  3099. {
  3100. /*331:*/
  3101. #line 8247 "./typica.w"
  3102. if(lastMeasurement[tempcolumn].time()<measure.time())
  3103. {
  3104. QList<QTime> timelist;
  3105. for(QTime i= lastMeasurement[tempcolumn].time().addSecs(1);i<measure.time();i= i.addSecs(1))
  3106. {
  3107. timelist.append(i);
  3108. }
  3109. for(int i= 0;i<timelist.size();i++)
  3110. {
  3111. newMeasurement(Measurement(measure.temperature(),timelist[i],measure.scale()),tempcolumn);
  3112. }
  3113. }
  3114. /*:331*/
  3115. #line 8179 "./typica.w"
  3116. model_ms->newMeasurement(measure,tempcolumn);
  3117. if(lastMeasurement.contains(tempcolumn))
  3118. {
  3119. if(measure.time().second()!=
  3120. lastMeasurement.value(tempcolumn).time().second())
  3121. {
  3122. Measurement adjusted(measure.temperature(),
  3123. QTime(0,measure.time().minute(),
  3124. measure.time().second(),0));
  3125. model_1s->newMeasurement(adjusted,tempcolumn);
  3126. if(adjusted.time().second()%5==0)
  3127. {
  3128. model_5s->newMeasurement(adjusted,tempcolumn);
  3129. if(adjusted.time().second()%10==0)
  3130. {
  3131. model_10s->newMeasurement(adjusted,tempcolumn);
  3132. }
  3133. if(adjusted.time().second()%15==0)
  3134. {
  3135. model_15s->newMeasurement(adjusted,tempcolumn);
  3136. if(adjusted.time().second()%30==0)
  3137. {
  3138. model_30s->newMeasurement(adjusted,tempcolumn);
  3139. if(adjusted.time().second()==0)
  3140. {
  3141. model_1m->newMeasurement(adjusted,tempcolumn);
  3142. }
  3143. }
  3144. }
  3145. }
  3146. }
  3147. /*333:*/
  3148. #line 8286 "./typica.w"
  3149. if(currentColumnSet.contains(tempcolumn))
  3150. {
  3151. int replicationcolumn;
  3152. foreach(replicationcolumn,currentColumnSet)
  3153. {
  3154. if(replicationcolumn!=tempcolumn)
  3155. {
  3156. if(lastMeasurement.contains(replicationcolumn))
  3157. {
  3158. if(measure.time()> lastMeasurement.value(replicationcolumn).time())
  3159. {
  3160. Measurement synthetic(lastMeasurement.value(replicationcolumn).temperature(),
  3161. measure.time());
  3162. model_ms->newMeasurement(synthetic,replicationcolumn);
  3163. if(synthetic.time().second()!=lastMeasurement.value(replicationcolumn).time().second())
  3164. {
  3165. Measurement adjusted(synthetic.temperature(),QTime(0,synthetic.time().minute(),synthetic.time().second(),0));
  3166. model_1s->newMeasurement(adjusted,replicationcolumn);
  3167. if(adjusted.time().second()%5==0)
  3168. {
  3169. model_5s->newMeasurement(adjusted,replicationcolumn);
  3170. if(adjusted.time().second()%10==0)
  3171. {
  3172. model_10s->newMeasurement(adjusted,replicationcolumn);
  3173. }
  3174. if(adjusted.time().second()%15==0)
  3175. {
  3176. model_15s->newMeasurement(adjusted,replicationcolumn);
  3177. if(adjusted.time().second()%30==0)
  3178. {
  3179. model_30s->newMeasurement(adjusted,replicationcolumn);
  3180. if(adjusted.time().second()==0)
  3181. {
  3182. model_1m->newMeasurement(adjusted,replicationcolumn);
  3183. }
  3184. }
  3185. }
  3186. }
  3187. }
  3188. lastMeasurement[replicationcolumn]= synthetic;
  3189. }
  3190. }
  3191. }
  3192. }
  3193. }
  3194. /*:333*/
  3195. #line 8211 "./typica.w"
  3196. }
  3197. else
  3198. {
  3199. /*330:*/
  3200. #line 8223 "./typica.w"
  3201. MeasurementModel*m;
  3202. foreach(m,modelSet)
  3203. {
  3204. m->newMeasurement(measure,tempcolumn);
  3205. }
  3206. /*:330*/
  3207. #line 8215 "./typica.w"
  3208. }
  3209. lastMeasurement[tempcolumn]= measure;
  3210. }
  3211. /*:329*//*332:*/
  3212. #line 8272 "./typica.w"
  3213. void ZoomLog::addToCurrentColumnSet(int column)
  3214. {
  3215. currentColumnSet.append(column);
  3216. }
  3217. void ZoomLog::clearCurrentColumnSet()
  3218. {
  3219. currentColumnSet.clear();
  3220. }
  3221. /*:332*//*334:*/
  3222. #line 8355 "./typica.w"
  3223. void ZoomLog::newAnnotation(QString annotation,int tempcolumn,
  3224. int annotationcolumn)
  3225. {
  3226. model_ms->newAnnotation(annotation,tempcolumn,annotationcolumn);
  3227. MeasurementModel*m;
  3228. if(lastMeasurement.contains(tempcolumn))
  3229. {
  3230. foreach(m,modelSet)
  3231. {
  3232. m->newMeasurement(lastMeasurement.value(tempcolumn),tempcolumn);
  3233. }
  3234. }
  3235. foreach(m,modelSet)
  3236. {
  3237. m->newAnnotation(annotation,tempcolumn,annotationcolumn);
  3238. }
  3239. }
  3240. /*:334*//*335:*/
  3241. #line 8379 "./typica.w"
  3242. void ZoomLog::centerOn(int row)
  3243. {
  3244. scrollTo(currentModel->index(row,0),QAbstractItemView::PositionAtCenter);
  3245. }
  3246. /*:335*//*336:*/
  3247. #line 8389 "./typica.w"
  3248. void ZoomLog::clear()
  3249. {
  3250. MeasurementModel*m;
  3251. foreach(m,modelSet)
  3252. {
  3253. m->clear();
  3254. }
  3255. lastMeasurement.clear();
  3256. saveTempCols.clear();
  3257. saveNoteCols.clear();
  3258. }
  3259. /*:336*//*337:*/
  3260. #line 8406 "./typica.w"
  3261. QVariant ZoomLog::data(int row,int column)const
  3262. {
  3263. return model_ms->data(model_ms->index(row,column,QModelIndex()),
  3264. Qt::DisplayRole);
  3265. }
  3266. int ZoomLog::rowCount()
  3267. {
  3268. return model_ms->rowCount();
  3269. }
  3270. /*:337*//*338:*/
  3271. #line 8429 "./typica.w"
  3272. bool ZoomLog::saveXML(QIODevice*device)
  3273. {
  3274. int prevUnits= model_ms->displayUnits();
  3275. if(prevUnits!=10144)
  3276. {
  3277. model_ms->setDisplayUnits(10144);
  3278. }
  3279. XMLOutput writer(model_ms,device,0);
  3280. int c;
  3281. foreach(c,saveTempCols)
  3282. {
  3283. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  3284. toString(),c);
  3285. }
  3286. foreach(c,saveNoteCols)
  3287. {
  3288. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  3289. toString(),c);
  3290. }
  3291. bool retval= writer.output();
  3292. if(prevUnits!=10144)
  3293. {
  3294. model_ms->setDisplayUnits(prevUnits);
  3295. }
  3296. return retval;
  3297. }
  3298. /*:338*//*339:*/
  3299. #line 8460 "./typica.w"
  3300. bool ZoomLog::saveCSV(QIODevice*device)
  3301. {
  3302. CSVOutput writer(currentModel,device,0);
  3303. int c;
  3304. foreach(c,saveTempCols)
  3305. {
  3306. writer.addTemperatureColumn(model_ms->headerData(c,Qt::Horizontal).
  3307. toString(),c);
  3308. }
  3309. foreach(c,saveNoteCols)
  3310. {
  3311. writer.addAnnotationColumn(model_ms->headerData(c,Qt::Horizontal).
  3312. toString(),c);
  3313. }
  3314. return writer.output();
  3315. }
  3316. /*:339*//*340:*/
  3317. #line 8484 "./typica.w"
  3318. void ZoomLog::switchLOD(MeasurementModel*m)
  3319. {
  3320. disconnect(currentModel,SIGNAL(rowChanged(int)),this,0);
  3321. setModel(m);
  3322. currentModel= m;
  3323. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  3324. }
  3325. void ZoomLog::LOD_ms()
  3326. {
  3327. switchLOD(model_ms);
  3328. }
  3329. void ZoomLog::LOD_1s()
  3330. {
  3331. switchLOD(model_1s);
  3332. }
  3333. void ZoomLog::LOD_5s()
  3334. {
  3335. switchLOD(model_5s);
  3336. }
  3337. void ZoomLog::LOD_10s()
  3338. {
  3339. switchLOD(model_10s);
  3340. }
  3341. void ZoomLog::LOD_15s()
  3342. {
  3343. switchLOD(model_15s);
  3344. }
  3345. void ZoomLog::LOD_30s()
  3346. {
  3347. switchLOD(model_30s);
  3348. }
  3349. void ZoomLog::LOD_1m()
  3350. {
  3351. switchLOD(model_1m);
  3352. }
  3353. /*:340*//*341:*/
  3354. #line 8532 "./typica.w"
  3355. void ZoomLog::setDisplayUnits(int scale)
  3356. {
  3357. model_ms->setDisplayUnits(scale);
  3358. model_1s->setDisplayUnits(scale);
  3359. model_5s->setDisplayUnits(scale);
  3360. model_10s->setDisplayUnits(scale);
  3361. model_15s->setDisplayUnits(scale);
  3362. model_30s->setDisplayUnits(scale);
  3363. model_1m->setDisplayUnits(scale);
  3364. }
  3365. int ZoomLog::displayUnits()
  3366. {
  3367. return model_ms->displayUnits();
  3368. }
  3369. /*:341*//*342:*/
  3370. #line 8552 "./typica.w"
  3371. QString ZoomLog::lastTime(int series)
  3372. {
  3373. Measurement measure= lastMeasurement.value(series);
  3374. QTime time= measure.time();
  3375. return time.toString("h:mm:ss.zzz");
  3376. }
  3377. /*:342*//*343:*/
  3378. #line 8562 "./typica.w"
  3379. ZoomLog::ZoomLog():QTableView(NULL),model_ms(new MeasurementModel(this)),
  3380. model_1s(new MeasurementModel(this)),model_5s(new MeasurementModel(this)),
  3381. model_10s(new MeasurementModel(this)),model_15s(new MeasurementModel(this)),
  3382. model_30s(new MeasurementModel(this)),model_1m(new MeasurementModel(this))
  3383. {
  3384. setEditTriggers(QAbstractItemView::NoEditTriggers);
  3385. setSelectionMode(QAbstractItemView::NoSelection);
  3386. modelSet<<model_ms<<model_1s<<model_5s<<model_10s<<model_15s<<
  3387. model_30s<<model_1m;
  3388. currentModel= model_30s;
  3389. setModel(currentModel);
  3390. connect(currentModel,SIGNAL(rowChanged(int)),this,SLOT(centerOn(int)));
  3391. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  3392. this,SLOT(persistColumnResize(int,int,int)));
  3393. connect(horizontalHeader(),SIGNAL(sectionCountChanged(int,int)),
  3394. this,SLOT(restoreColumnWidths()));
  3395. }
  3396. /*:343*//*344:*/
  3397. #line 8585 "./typica.w"
  3398. void ZoomLog::setHeaderData(int section,QString text)
  3399. {
  3400. MeasurementModel*m;
  3401. foreach(m,modelSet)
  3402. {
  3403. m->setHeaderData(section,Qt::Horizontal,QVariant(text));
  3404. }
  3405. }
  3406. /*:344*//*345:*/
  3407. #line 8599 "./typica.w"
  3408. void ZoomLog::addOutputTemperatureColumn(int column)
  3409. {
  3410. saveTempCols.append(column);
  3411. }
  3412. void ZoomLog::addOutputAnnotationColumn(int column)
  3413. {
  3414. saveNoteCols.append(column);
  3415. }
  3416. void ZoomLog::clearOutputColumns()
  3417. {
  3418. saveTempCols.clear();
  3419. saveNoteCols.clear();
  3420. }
  3421. /*:345*//*346:*/
  3422. #line 8619 "./typica.w"
  3423. void ZoomLog::persistColumnResize(int column,int,int newsize)
  3424. {
  3425. /*537:*/
  3426. #line 12608 "./typica.w"
  3427. QSettings settings;
  3428. /*538:*/
  3429. #line 12621 "./typica.w"
  3430. QWidget*topLevelWidget= this;
  3431. while(topLevelWidget->parentWidget())
  3432. {
  3433. topLevelWidget= topLevelWidget->parentWidget();
  3434. }
  3435. /*:538*/
  3436. #line 12610 "./typica.w"
  3437. settings.setValue(QString("columnWidths/%1/%2/%3").
  3438. arg(topLevelWidget->objectName()).
  3439. arg(objectName()).arg(column),
  3440. QVariant(newsize));
  3441. /*:537*/
  3442. #line 8622 "./typica.w"
  3443. }
  3444. void ZoomLog::restoreColumnWidths()
  3445. {
  3446. /*540:*/
  3447. #line 12641 "./typica.w"
  3448. QSettings settings;
  3449. /*538:*/
  3450. #line 12621 "./typica.w"
  3451. QWidget*topLevelWidget= this;
  3452. while(topLevelWidget->parentWidget())
  3453. {
  3454. topLevelWidget= topLevelWidget->parentWidget();
  3455. }
  3456. /*:538*/
  3457. #line 12643 "./typica.w"
  3458. QString baseKey=
  3459. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  3460. arg(objectName());
  3461. for(int i= 0;i<model()->columnCount();i++)
  3462. {
  3463. QString key= QString("%1/%2").arg(baseKey).arg(i);
  3464. if(settings.contains(key))
  3465. {
  3466. setColumnWidth(i,settings.value(key).toInt());
  3467. }
  3468. }
  3469. /*:540*/
  3470. #line 8627 "./typica.w"
  3471. }
  3472. void ZoomLog::setVisible(bool visibility)
  3473. {
  3474. QTableView::setVisible(visibility);
  3475. }
  3476. void ZoomLog::showEvent(QShowEvent*)
  3477. {
  3478. /*540:*/
  3479. #line 12641 "./typica.w"
  3480. QSettings settings;
  3481. /*538:*/
  3482. #line 12621 "./typica.w"
  3483. QWidget*topLevelWidget= this;
  3484. while(topLevelWidget->parentWidget())
  3485. {
  3486. topLevelWidget= topLevelWidget->parentWidget();
  3487. }
  3488. /*:538*/
  3489. #line 12643 "./typica.w"
  3490. QString baseKey=
  3491. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  3492. arg(objectName());
  3493. for(int i= 0;i<model()->columnCount();i++)
  3494. {
  3495. QString key= QString("%1/%2").arg(baseKey).arg(i);
  3496. if(settings.contains(key))
  3497. {
  3498. setColumnWidth(i,settings.value(key).toInt());
  3499. }
  3500. }
  3501. /*:540*/
  3502. #line 8637 "./typica.w"
  3503. }
  3504. /*:346*/
  3505. #line 781 "./typica.w"
  3506. /*354:*/
  3507. #line 8859 "./typica.w"
  3508. bool MeasurementList::operator<(const MeasurementList&other)const
  3509. {
  3510. return this->first().toTime()<other.first().toTime();
  3511. }
  3512. bool MeasurementList::operator==(const MeasurementList&other)const
  3513. {
  3514. return this->first().toTime()==other.first().toTime();
  3515. }
  3516. /*:354*//*355:*/
  3517. #line 8875 "./typica.w"
  3518. QModelIndex MeasurementModel::parent(const QModelIndex&)const
  3519. {
  3520. return QModelIndex();
  3521. }
  3522. /*:355*//*356:*/
  3523. #line 8885 "./typica.w"
  3524. void MeasurementModel::newMeasurement(Measurement measure,int tempcolumn)
  3525. {
  3526. MeasurementList*temp;
  3527. temp= new MeasurementList;
  3528. temp->append(QVariant(measure.time()));
  3529. /*357:*/
  3530. #line 8936 "./typica.w"
  3531. /*358:*/
  3532. #line 8981 "./typica.w"
  3533. QList<MeasurementList*> ::iterator i= lastInsertion;
  3534. bool quickscan= false;
  3535. if(entries->size()> 5)
  3536. {
  3537. if(**i<*temp)
  3538. {
  3539. i+= 1;
  3540. for(int j= 10;j> 0;j--)
  3541. {
  3542. if(i!=entries->end())
  3543. {
  3544. if(**i<*temp)
  3545. {
  3546. i+= 1;
  3547. }
  3548. else
  3549. {
  3550. quickscan= true;
  3551. break;
  3552. }
  3553. }
  3554. else
  3555. {
  3556. quickscan= true;
  3557. break;
  3558. }
  3559. }
  3560. }
  3561. else
  3562. {
  3563. if(**i==*temp)
  3564. {
  3565. quickscan= true;
  3566. }
  3567. }
  3568. }
  3569. /*:358*/
  3570. #line 8937 "./typica.w"
  3571. if(quickscan==false)
  3572. {
  3573. i= entries->begin();
  3574. QList<MeasurementList*> ::iterator u= entries->end();
  3575. QList<MeasurementList*> ::iterator midpoint;
  3576. int n= u-i;
  3577. int rA;
  3578. while(n> 0)
  3579. {
  3580. rA= n>>1;
  3581. midpoint= i+rA;
  3582. if(**midpoint<*temp)
  3583. {
  3584. i= midpoint+1;
  3585. n-= rA+1;
  3586. }
  3587. else
  3588. {
  3589. n= rA;
  3590. }
  3591. }
  3592. }
  3593. /*:357*/
  3594. #line 8891 "./typica.w"
  3595. MeasurementList*newEntry;
  3596. int insertion;
  3597. if(i!=entries->end())
  3598. {
  3599. insertion= entries->indexOf(*i);
  3600. if((*i)->first().toTime()==measure.time())
  3601. {
  3602. /*359:*/
  3603. #line 9023 "./typica.w"
  3604. if((*i)->size()<tempcolumn+1)
  3605. {
  3606. for(int j= (*i)->size()-1;j<tempcolumn+1;j++)
  3607. {
  3608. (*i)->append(QVariant());
  3609. }
  3610. }
  3611. (*i)->replace(tempcolumn,measure.temperature());
  3612. lastInsertion= i;
  3613. emit dataChanged(createIndex(insertion,tempcolumn),
  3614. createIndex(insertion,tempcolumn));
  3615. lastTemperature->insert(tempcolumn,insertion);
  3616. /*:359*/
  3617. #line 8899 "./typica.w"
  3618. }
  3619. else
  3620. {
  3621. /*360:*/
  3622. #line 9041 "./typica.w"
  3623. beginInsertRows(QModelIndex(),insertion,insertion);
  3624. newEntry= new MeasurementList;
  3625. newEntry->append(QVariant(measure.time()));
  3626. for(int j= 0;j<tempcolumn+1;j++)
  3627. {
  3628. newEntry->append(QVariant());
  3629. }
  3630. newEntry->replace(tempcolumn,measure.temperature());
  3631. lastInsertion= entries->insert(i,newEntry);
  3632. endInsertRows();
  3633. lastTemperature->insert(tempcolumn,insertion);
  3634. /*:360*/
  3635. #line 8903 "./typica.w"
  3636. }
  3637. }
  3638. else
  3639. {
  3640. /*361:*/
  3641. #line 9059 "./typica.w"
  3642. insertion= entries->size();
  3643. /*360:*/
  3644. #line 9041 "./typica.w"
  3645. beginInsertRows(QModelIndex(),insertion,insertion);
  3646. newEntry= new MeasurementList;
  3647. newEntry->append(QVariant(measure.time()));
  3648. for(int j= 0;j<tempcolumn+1;j++)
  3649. {
  3650. newEntry->append(QVariant());
  3651. }
  3652. newEntry->replace(tempcolumn,measure.temperature());
  3653. lastInsertion= entries->insert(i,newEntry);
  3654. endInsertRows();
  3655. lastTemperature->insert(tempcolumn,insertion);
  3656. /*:360*/
  3657. #line 9061 "./typica.w"
  3658. /*:361*/
  3659. #line 8908 "./typica.w"
  3660. }
  3661. if(tempcolumn>=colcount)
  3662. {
  3663. colcount= tempcolumn+1;
  3664. }
  3665. emit rowChanged(insertion);
  3666. delete temp;
  3667. }
  3668. /*:356*//*362:*/
  3669. #line 9070 "./typica.w"
  3670. void MeasurementModel::newAnnotation(QString annotation,int tempcolumn,
  3671. int annotationColumn)
  3672. {
  3673. int r;
  3674. if(lastTemperature->contains(tempcolumn))
  3675. {
  3676. r= lastTemperature->value(tempcolumn);
  3677. }
  3678. else
  3679. {
  3680. r= 0;
  3681. }
  3682. if(r==0&&entries->size()==0)
  3683. {
  3684. /*363:*/
  3685. #line 9108 "./typica.w"
  3686. beginInsertRows(QModelIndex(),0,0);
  3687. MeasurementList*newEntry= new MeasurementList;
  3688. newEntry->append(QVariant(QTime(0,0,0,0)));
  3689. entries->append(newEntry);
  3690. endInsertRows();
  3691. /*:363*/
  3692. #line 9085 "./typica.w"
  3693. }
  3694. MeasurementList*row= entries->at(r);
  3695. if(row->size()<=annotationColumn)
  3696. {
  3697. for(int i= row->size()-1;i<annotationColumn+1;i++)
  3698. {
  3699. row->append(QVariant());
  3700. }
  3701. }
  3702. row->replace(annotationColumn,annotation);
  3703. emit dataChanged(createIndex(r,annotationColumn),
  3704. createIndex(r,annotationColumn));
  3705. emit rowChanged(r);
  3706. if(annotationColumn> colcount-1)
  3707. {
  3708. colcount= annotationColumn+1;
  3709. }
  3710. }
  3711. /*:362*//*364:*/
  3712. #line 9119 "./typica.w"
  3713. void MeasurementModel::clear()
  3714. {
  3715. beginRemoveRows(QModelIndex(),0,entries->size());
  3716. while(entries->size()!=0)
  3717. {
  3718. MeasurementList*row= entries->takeFirst();
  3719. delete row;
  3720. }
  3721. endRemoveRows();
  3722. colcount= hData->size();
  3723. lastTemperature->clear();
  3724. reset();
  3725. }
  3726. /*:364*//*365:*/
  3727. #line 9145 "./typica.w"
  3728. bool MeasurementModel::setData(const QModelIndex&index,
  3729. const QVariant&value,int role)
  3730. {
  3731. if(role!=Qt::EditRole&&role!=Qt::DisplayRole)
  3732. {
  3733. return false;
  3734. }
  3735. /*366:*/
  3736. #line 9177 "./typica.w"
  3737. bool valid= false;
  3738. if(index.isValid())
  3739. {
  3740. if(index.row()<entries->size())
  3741. {
  3742. if(index.column()<colcount)
  3743. {
  3744. valid= true;
  3745. }
  3746. }
  3747. }
  3748. /*:366*/
  3749. #line 9153 "./typica.w"
  3750. if(!valid)
  3751. {
  3752. return false;
  3753. }
  3754. MeasurementList*row= entries->at(index.row());
  3755. if(index.column()>=row->size())
  3756. {
  3757. /*367:*/
  3758. #line 9194 "./typica.w"
  3759. for(int i= row->size()-1;i<index.column();i++)
  3760. {
  3761. row->append(QVariant());
  3762. }
  3763. /*:367*/
  3764. #line 9161 "./typica.w"
  3765. }
  3766. if(index.column()==0)
  3767. {
  3768. /*368:*/
  3769. #line 9209 "./typica.w"
  3770. QTime time;
  3771. if(!(time= QTime::fromString(value.toString(),"m:s.z")).isValid())
  3772. {
  3773. if(!(time= QTime::fromString(value.toString(),"m:s")).isValid())
  3774. {
  3775. return false;
  3776. }
  3777. }
  3778. row= entries->takeAt(index.row());
  3779. row->replace(index.column(),QVariant(time));
  3780. MeasurementList*temp= row;
  3781. /*357:*/
  3782. #line 8936 "./typica.w"
  3783. /*358:*/
  3784. #line 8981 "./typica.w"
  3785. QList<MeasurementList*> ::iterator i= lastInsertion;
  3786. bool quickscan= false;
  3787. if(entries->size()> 5)
  3788. {
  3789. if(**i<*temp)
  3790. {
  3791. i+= 1;
  3792. for(int j= 10;j> 0;j--)
  3793. {
  3794. if(i!=entries->end())
  3795. {
  3796. if(**i<*temp)
  3797. {
  3798. i+= 1;
  3799. }
  3800. else
  3801. {
  3802. quickscan= true;
  3803. break;
  3804. }
  3805. }
  3806. else
  3807. {
  3808. quickscan= true;
  3809. break;
  3810. }
  3811. }
  3812. }
  3813. else
  3814. {
  3815. if(**i==*temp)
  3816. {
  3817. quickscan= true;
  3818. }
  3819. }
  3820. }
  3821. /*:358*/
  3822. #line 8937 "./typica.w"
  3823. if(quickscan==false)
  3824. {
  3825. i= entries->begin();
  3826. QList<MeasurementList*> ::iterator u= entries->end();
  3827. QList<MeasurementList*> ::iterator midpoint;
  3828. int n= u-i;
  3829. int rA;
  3830. while(n> 0)
  3831. {
  3832. rA= n>>1;
  3833. midpoint= i+rA;
  3834. if(**midpoint<*temp)
  3835. {
  3836. i= midpoint+1;
  3837. n-= rA+1;
  3838. }
  3839. else
  3840. {
  3841. n= rA;
  3842. }
  3843. }
  3844. }
  3845. /*:357*/
  3846. #line 9221 "./typica.w"
  3847. entries->insert(i,row);
  3848. int newRow= entries->indexOf(*i);
  3849. if(newRow<index.row())
  3850. {
  3851. emit dataChanged(createIndex(newRow,index.column()),index);
  3852. }
  3853. else
  3854. {
  3855. emit dataChanged(index,createIndex(newRow,index.column()));
  3856. }
  3857. /*:368*/
  3858. #line 9165 "./typica.w"
  3859. }
  3860. else
  3861. {
  3862. /*369:*/
  3863. #line 9235 "./typica.w"
  3864. row->replace(index.column(),value);
  3865. emit dataChanged(index,index);
  3866. /*:369*/
  3867. #line 9169 "./typica.w"
  3868. }
  3869. return true;
  3870. }
  3871. /*:365*//*370:*/
  3872. #line 9243 "./typica.w"
  3873. MeasurementModel::MeasurementModel(QObject*parent):QAbstractItemModel(parent),
  3874. unit(Fahrenheit),hData(new QStringList),
  3875. lastTemperature(new QHash<int,int> )
  3876. {
  3877. colcount= 1;
  3878. entries= new QList<MeasurementList*> ;
  3879. lastInsertion= entries->begin();
  3880. hData->append(tr("Time"));
  3881. }
  3882. /*:370*//*371:*/
  3883. #line 9256 "./typica.w"
  3884. MeasurementModel::~MeasurementModel()
  3885. {
  3886. clear();
  3887. delete entries;
  3888. delete hData;
  3889. }
  3890. /*:371*//*372:*/
  3891. #line 9268 "./typica.w"
  3892. int MeasurementModel::rowCount(const QModelIndex&parent)const
  3893. {
  3894. if(parent==QModelIndex())
  3895. {
  3896. return entries->size();
  3897. }
  3898. return 0;
  3899. }
  3900. int MeasurementModel::columnCount(const QModelIndex&parent)const
  3901. {
  3902. if(parent==QModelIndex())
  3903. {
  3904. return colcount;
  3905. }
  3906. return 0;
  3907. }
  3908. /*:372*//*373:*/
  3909. #line 9295 "./typica.w"
  3910. bool MeasurementModel::setHeaderData(int section,Qt::Orientation orientation,
  3911. const QVariant&value,int)
  3912. {
  3913. if(orientation==Qt::Horizontal)
  3914. {
  3915. if(hData->size()<section+1)
  3916. {
  3917. for(int i= hData->size();i<section+1;i++)
  3918. {
  3919. if(colcount<i)
  3920. {
  3921. beginInsertColumns(QModelIndex(),i,i);
  3922. }
  3923. hData->append(QString());
  3924. if(colcount<i)
  3925. {
  3926. endInsertColumns();
  3927. }
  3928. }
  3929. }
  3930. hData->replace(section,value.toString());
  3931. emit headerDataChanged(orientation,section,section);
  3932. if(colcount<section+1)
  3933. {
  3934. colcount= section+1;
  3935. }
  3936. return true;
  3937. }
  3938. return false;
  3939. }
  3940. /*:373*//*374:*/
  3941. #line 9335 "./typica.w"
  3942. void MeasurementModel::setDisplayUnits(int scale)
  3943. {
  3944. beginResetModel();
  3945. unit= scale;
  3946. endResetModel();
  3947. }
  3948. int MeasurementModel::displayUnits()
  3949. {
  3950. return unit;
  3951. }
  3952. /*:374*//*375:*/
  3953. #line 9359 "./typica.w"
  3954. QVariant MeasurementModel::data(const QModelIndex&index,int role)const
  3955. {
  3956. /*366:*/
  3957. #line 9177 "./typica.w"
  3958. bool valid= false;
  3959. if(index.isValid())
  3960. {
  3961. if(index.row()<entries->size())
  3962. {
  3963. if(index.column()<colcount)
  3964. {
  3965. valid= true;
  3966. }
  3967. }
  3968. }
  3969. /*:366*/
  3970. #line 9362 "./typica.w"
  3971. if(!valid)
  3972. {
  3973. return QVariant();
  3974. }
  3975. if(role==Qt::DisplayRole||role==Qt::EditRole)
  3976. {
  3977. MeasurementList*row= entries->at(index.row());
  3978. if(index.column()> row->size())
  3979. {
  3980. return QVariant();
  3981. }
  3982. else
  3983. {
  3984. if(index.column()==0)
  3985. {
  3986. return QVariant(row->at(0).toTime().toString("mm:ss.zzz"));
  3987. }
  3988. else if(lastTemperature->contains(index.column()))
  3989. {
  3990. if(row->at(index.column()).toString().isEmpty())
  3991. {
  3992. return QVariant();
  3993. }
  3994. switch(unit)
  3995. {
  3996. case Auto:
  3997. case Fahrenheit:
  3998. return QVariant(row->at(index.column()).toString());
  3999. break;
  4000. case Celsius:
  4001. return QVariant((row->at(index.column()).toDouble()-
  4002. 32)*5/9);
  4003. break;
  4004. case Kelvin:
  4005. return QVariant((row->at(index.column()).toDouble()+
  4006. 459.67)*5/9);
  4007. break;
  4008. case Rankine:
  4009. return QVariant(row->at(index.column()).toDouble()+
  4010. 459.67);
  4011. break;
  4012. default:
  4013. break;
  4014. }
  4015. }
  4016. return QVariant(row->at(index.column()).toString());
  4017. }
  4018. }
  4019. return QVariant();
  4020. }
  4021. /*:375*//*376:*/
  4022. #line 9416 "./typica.w"
  4023. QVariant MeasurementModel::headerData(int section,Qt::Orientation orientation,
  4024. int role)const
  4025. {
  4026. if(orientation==Qt::Horizontal)
  4027. {
  4028. if(role==Qt::DisplayRole)
  4029. {
  4030. if(section<hData->size())
  4031. {
  4032. return QVariant(hData->at(section));
  4033. }
  4034. }
  4035. }
  4036. return QVariant();
  4037. }
  4038. /*:376*//*377:*/
  4039. #line 9443 "./typica.w"
  4040. Qt::ItemFlags MeasurementModel::flags(const QModelIndex&index)const
  4041. {
  4042. /*366:*/
  4043. #line 9177 "./typica.w"
  4044. bool valid= false;
  4045. if(index.isValid())
  4046. {
  4047. if(index.row()<entries->size())
  4048. {
  4049. if(index.column()<colcount)
  4050. {
  4051. valid= true;
  4052. }
  4053. }
  4054. }
  4055. /*:366*/
  4056. #line 9446 "./typica.w"
  4057. if(valid)
  4058. {
  4059. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  4060. }
  4061. return 0;
  4062. }
  4063. /*:377*//*378:*/
  4064. #line 9458 "./typica.w"
  4065. QModelIndex MeasurementModel::index(int row,int column,
  4066. const QModelIndex&parent)const
  4067. {
  4068. if(parent==QModelIndex())
  4069. {
  4070. if(row<entries->size()&&entries->isEmpty()==false)
  4071. {
  4072. if(column<entries->at(row)->size())
  4073. {
  4074. return createIndex(row,column);
  4075. }
  4076. }
  4077. }
  4078. return QModelIndex();
  4079. }
  4080. /*:378*/
  4081. #line 782 "./typica.w"
  4082. /*380:*/
  4083. #line 9509 "./typica.w"
  4084. AnnotationButton::AnnotationButton(const QString&text,QWidget*parent):
  4085. QPushButton(text,parent),note(""),tc(0),ac(0),count(0)
  4086. {
  4087. connect(this,SIGNAL(clicked()),this,SLOT(annotate()));
  4088. }
  4089. /*:380*//*381:*/
  4090. #line 9524 "./typica.w"
  4091. void AnnotationButton::annotate()
  4092. {
  4093. if(note.contains("%1"))
  4094. {
  4095. count++;
  4096. emit annotation(note.arg(count),tc,ac);
  4097. }
  4098. else
  4099. {
  4100. emit annotation(note,tc,ac);
  4101. }
  4102. }
  4103. /*:381*//*382:*/
  4104. #line 9542 "./typica.w"
  4105. void AnnotationButton::setTemperatureColumn(int tempcolumn)
  4106. {
  4107. tc= tempcolumn;
  4108. }
  4109. void AnnotationButton::setAnnotationColumn(int annotationcolumn)
  4110. {
  4111. ac= annotationcolumn;
  4112. }
  4113. void AnnotationButton::setAnnotation(const QString&annotation)
  4114. {
  4115. note= annotation;
  4116. }
  4117. /*:382*//*383:*/
  4118. #line 9561 "./typica.w"
  4119. void AnnotationButton::resetCount()
  4120. {
  4121. count= 0;
  4122. }
  4123. /*:383*/
  4124. #line 783 "./typica.w"
  4125. /*388:*/
  4126. #line 9644 "./typica.w"
  4127. AnnotationSpinBox::AnnotationSpinBox(const QString&pret,
  4128. const QString&postt,
  4129. QWidget*parent)
  4130. :QDoubleSpinBox(parent),pretext(pret),posttext(postt)
  4131. {
  4132. resetChange();
  4133. connect(this,SIGNAL(editingFinished()),this,SLOT(annotate()));
  4134. connect(this,SIGNAL(valueChanged(double)),this,SLOT(resetChange()));
  4135. }
  4136. /*:388*//*389:*/
  4137. #line 9661 "./typica.w"
  4138. void AnnotationSpinBox::resetChange()
  4139. {
  4140. change= true;
  4141. }
  4142. /*:389*//*390:*/
  4143. #line 9672 "./typica.w"
  4144. void AnnotationSpinBox::annotate()
  4145. {
  4146. if(change)
  4147. {
  4148. change= false;
  4149. emit annotation(QString("%1%2%3").arg(pretext).
  4150. arg(value()).arg(posttext),tc,ac);
  4151. }
  4152. }
  4153. /*:390*//*391:*/
  4154. #line 9685 "./typica.w"
  4155. void AnnotationSpinBox::setTemperatureColumn(int tempcolumn)
  4156. {
  4157. tc= tempcolumn;
  4158. }
  4159. void AnnotationSpinBox::setAnnotationColumn(int annotationcolumn)
  4160. {
  4161. ac= annotationcolumn;
  4162. }
  4163. void AnnotationSpinBox::setPretext(const QString&pret)
  4164. {
  4165. pretext= pret;
  4166. }
  4167. void AnnotationSpinBox::setPosttext(const QString&postt)
  4168. {
  4169. posttext= postt;
  4170. }
  4171. /*:391*/
  4172. #line 784 "./typica.w"
  4173. /*398:*/
  4174. #line 9853 "./typica.w"
  4175. TimerDisplay::TimerDisplay(QWidget*parent):QLCDNumber(8,parent),
  4176. s(QTime(0,0,0)),r(QTime(0,0,0)),clock(NULL),m(TimerDisplay::CountUp),
  4177. running(false),ar(false),startAction(new QAction(tr("Start"),NULL)),
  4178. stopAction(new QAction(tr("Stop"),NULL)),
  4179. resetAction(new QAction(tr("Reset"),NULL)),f(QString("hh:mm:ss")),
  4180. relative(QTime::currentTime()),base(QTime(0,0,0))
  4181. {
  4182. connect(startAction,SIGNAL(triggered(bool)),this,SLOT(startTimer()));
  4183. connect(stopAction,SIGNAL(triggered(bool)),this,SLOT(stopTimer()));
  4184. connect(resetAction,SIGNAL(triggered(bool)),this,SLOT(reset()));
  4185. clock.setInterval(500);
  4186. clock.setSingleShot(false);
  4187. connect(&clock,SIGNAL(timeout()),this,SLOT(updateTime()));
  4188. setSegmentStyle(Filled);
  4189. updateDisplay();
  4190. }
  4191. /*:398*//*399:*/
  4192. #line 9874 "./typica.w"
  4193. void TimerDisplay::updateTime()
  4194. {
  4195. QTime time;
  4196. int cseconds= 0;
  4197. int oseconds= 0;
  4198. int r= 0;
  4199. QTime nt= QTime(0,0,0);
  4200. int n= 0;
  4201. int bseconds= 0;
  4202. switch(m)
  4203. {
  4204. case TimerDisplay::CountUp:
  4205. /*400:*/
  4206. #line 9906 "./typica.w"
  4207. /*401:*/
  4208. #line 9919 "./typica.w"
  4209. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  4210. time= QTime::currentTime();
  4211. cseconds= TIMETOINT(time);
  4212. oseconds= TIMETOINT(relative);
  4213. r= cseconds-oseconds;
  4214. /*:401*/
  4215. #line 9907 "./typica.w"
  4216. nt= nt.addSecs(r);
  4217. if(nt!=s)
  4218. {
  4219. s= nt;
  4220. emit valueChanged(s);
  4221. }
  4222. /*:400*/
  4223. #line 9887 "./typica.w"
  4224. ;
  4225. break;
  4226. case TimerDisplay::CountDown:
  4227. /*402:*/
  4228. #line 9931 "./typica.w"
  4229. if(s> QTime(0,0,0))
  4230. {
  4231. /*401:*/
  4232. #line 9919 "./typica.w"
  4233. #define TIMETOINT(t) ((t.hour() * 60 * 60) + (t.minute() * 60) + (t.second()))
  4234. time= QTime::currentTime();
  4235. cseconds= TIMETOINT(time);
  4236. oseconds= TIMETOINT(relative);
  4237. r= cseconds-oseconds;
  4238. /*:401*/
  4239. #line 9934 "./typica.w"
  4240. bseconds= TIMETOINT(base);
  4241. n= bseconds-r;
  4242. nt= nt.addSecs(n);
  4243. if(nt!=s)
  4244. {
  4245. s= nt;
  4246. emit valueChanged(s);
  4247. }
  4248. }
  4249. /*:402*/
  4250. #line 9890 "./typica.w"
  4251. ;
  4252. break;
  4253. case TimerDisplay::Clock:
  4254. /*403:*/
  4255. #line 9948 "./typica.w"
  4256. time= QTime::currentTime();
  4257. if(time!=s)
  4258. {
  4259. s= time;
  4260. emit valueChanged(s);
  4261. }
  4262. /*:403*/
  4263. #line 9893 "./typica.w"
  4264. ;
  4265. break;
  4266. default:
  4267. Q_ASSERT_X(false,"updateTime","invalid timer mode");
  4268. break;
  4269. }
  4270. updateDisplay();
  4271. }
  4272. /*:399*//*404:*/
  4273. #line 9960 "./typica.w"
  4274. #define TIMESUBTRACT(t1, t2) (t1.addSecs(-(TIMETOINT(t2))).addSecs(-t2.msec()))
  4275. void TimerDisplay::startTimer()
  4276. {
  4277. if(!running)
  4278. {
  4279. relative= QTime::currentTime();
  4280. if(ar)
  4281. {
  4282. reset();
  4283. }
  4284. else
  4285. {
  4286. relative= TIMESUBTRACT(relative,s);
  4287. }
  4288. if(m==Clock)
  4289. {
  4290. updateTime();
  4291. }
  4292. base= s;
  4293. clock.start();
  4294. running= true;
  4295. emit runStateChanged(true);
  4296. }
  4297. }
  4298. /*:404*//*405:*/
  4299. #line 9990 "./typica.w"
  4300. void TimerDisplay::stopTimer()
  4301. {
  4302. if(running)
  4303. {
  4304. clock.stop();
  4305. running= false;
  4306. emit runStateChanged(false);
  4307. }
  4308. }
  4309. /*:405*//*406:*/
  4310. #line 10003 "./typica.w"
  4311. TimerDisplay::~TimerDisplay()
  4312. {
  4313. clock.stop();
  4314. }
  4315. /*:406*//*407:*/
  4316. #line 10012 "./typica.w"
  4317. void TimerDisplay::setCountUpMode()
  4318. {
  4319. m= TimerDisplay::CountUp;
  4320. }
  4321. void TimerDisplay::setCountDownMode()
  4322. {
  4323. m= TimerDisplay::CountDown;
  4324. }
  4325. void TimerDisplay::setClockMode()
  4326. {
  4327. m= TimerDisplay::Clock;
  4328. }
  4329. /*:407*//*408:*/
  4330. #line 10030 "./typica.w"
  4331. QString TimerDisplay::value()
  4332. {
  4333. return s.toString(f);
  4334. }
  4335. QTime TimerDisplay::seconds()
  4336. {
  4337. return s;
  4338. }
  4339. TimerDisplay::TimerMode TimerDisplay::mode()
  4340. {
  4341. return m;
  4342. }
  4343. bool TimerDisplay::isRunning()
  4344. {
  4345. return running;
  4346. }
  4347. QTime TimerDisplay::resetValue()
  4348. {
  4349. return r;
  4350. }
  4351. QString TimerDisplay::displayFormat()
  4352. {
  4353. return f;
  4354. }
  4355. bool TimerDisplay::autoReset()
  4356. {
  4357. return ar;
  4358. }
  4359. /*:408*//*409:*/
  4360. #line 10068 "./typica.w"
  4361. void TimerDisplay::setTimer(QTime value)
  4362. {
  4363. if(value.isValid())
  4364. {
  4365. s= value;
  4366. updateDisplay();
  4367. emit valueChanged(value);
  4368. }
  4369. }
  4370. void TimerDisplay::setMode(TimerDisplay::TimerMode mode)
  4371. {
  4372. m= mode;
  4373. }
  4374. void TimerDisplay::setResetValue(QTime value)
  4375. {
  4376. r= value;
  4377. }
  4378. void TimerDisplay::setDisplayFormat(QString format)
  4379. {
  4380. f= format;
  4381. setNumDigits(format.length());
  4382. }
  4383. void TimerDisplay::setAutoReset(bool reset)
  4384. {
  4385. ar= reset;
  4386. }
  4387. /*:409*//*410:*/
  4388. #line 10103 "./typica.w"
  4389. void TimerDisplay::copyTimer()
  4390. {
  4391. QApplication::clipboard()->setText(value());
  4392. }
  4393. /*:410*//*411:*/
  4394. #line 10112 "./typica.w"
  4395. void TimerDisplay::reset()
  4396. {
  4397. if(!running)
  4398. {
  4399. s= r;
  4400. updateDisplay();
  4401. }
  4402. }
  4403. /*:411*//*412:*/
  4404. #line 10125 "./typica.w"
  4405. void TimerDisplay::updateDisplay()
  4406. {
  4407. display(value());
  4408. }
  4409. /*:412*/
  4410. #line 785 "./typica.w"
  4411. /*418:*/
  4412. #line 10219 "./typica.w"
  4413. int PackLayout::doLayout(const QRect&rect,bool testOnly)const
  4414. {
  4415. int x= rect.x();
  4416. int y= rect.y();
  4417. QLayoutItem*item;
  4418. if(orientation==Qt::Horizontal)
  4419. {
  4420. /*419:*/
  4421. #line 10243 "./typica.w"
  4422. foreach(item,itemList)
  4423. {
  4424. int nextX= x+item->sizeHint().width()+spacing();
  4425. int right= x+item->sizeHint().width();
  4426. if(item==itemList.last())
  4427. {
  4428. right= rect.right();
  4429. }
  4430. int bottom= rect.bottom();
  4431. if(!testOnly)
  4432. {
  4433. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  4434. }
  4435. x= nextX;
  4436. }
  4437. /*:419*/
  4438. #line 10227 "./typica.w"
  4439. }
  4440. else
  4441. {
  4442. /*420:*/
  4443. #line 10262 "./typica.w"
  4444. foreach(item,itemList)
  4445. {
  4446. int nextY= y+item->sizeHint().height()+spacing();
  4447. int bottom= y+item->sizeHint().height();
  4448. if(item==itemList.last())
  4449. {
  4450. bottom= rect.bottom();
  4451. }
  4452. int right= rect.right();
  4453. if(!testOnly)
  4454. {
  4455. item->setGeometry(QRect(QPoint(x,y),QPoint(right,bottom)));
  4456. }
  4457. y= nextY;
  4458. }
  4459. /*:420*/
  4460. #line 10231 "./typica.w"
  4461. }
  4462. return y;
  4463. }
  4464. /*:418*//*421:*/
  4465. #line 10286 "./typica.w"
  4466. QSize PackLayout::minimumSize()const
  4467. {
  4468. QSize size;
  4469. QLayoutItem*item;
  4470. foreach(item,itemList)
  4471. {
  4472. if(orientation==Qt::Horizontal)
  4473. {
  4474. size+= QSize(item->minimumSize().width(),0);
  4475. if(size.height()<item->minimumSize().height())
  4476. {
  4477. size.setHeight(item->minimumSize().height());
  4478. }
  4479. }
  4480. else
  4481. {
  4482. size+= QSize(0,item->minimumSize().height());
  4483. if(size.width()<item->minimumSize().width())
  4484. {
  4485. size.setWidth(item->minimumSize().width());
  4486. }
  4487. }
  4488. }
  4489. size+= QSize(2*margin(),2*margin());
  4490. return size;
  4491. }
  4492. /*:421*//*422:*/
  4493. #line 10318 "./typica.w"
  4494. PackLayout::PackLayout(QWidget*parent,int margin,int spacing):
  4495. QLayout(parent)
  4496. {
  4497. setMargin(margin);
  4498. setSpacing(spacing);
  4499. setOrientation(Qt::Horizontal);
  4500. }
  4501. PackLayout::PackLayout(int spacing)
  4502. {
  4503. setSpacing(spacing);
  4504. setOrientation(Qt::Horizontal);
  4505. }
  4506. /*:422*//*423:*/
  4507. #line 10336 "./typica.w"
  4508. PackLayout::~PackLayout()
  4509. {
  4510. QLayoutItem*item;
  4511. while((item= takeAt(0)))
  4512. {
  4513. delete item;
  4514. }
  4515. }
  4516. /*:423*//*424:*/
  4517. #line 10350 "./typica.w"
  4518. QLayoutItem*PackLayout::takeAt(int index)
  4519. {
  4520. if(index>=0&&index<itemList.size())
  4521. {
  4522. return itemList.takeAt(index);
  4523. }
  4524. else
  4525. {
  4526. return NULL;
  4527. }
  4528. }
  4529. /*:424*//*425:*/
  4530. #line 10366 "./typica.w"
  4531. QLayoutItem*PackLayout::itemAt(int index)const
  4532. {
  4533. if(index>=0&&index<itemList.size())
  4534. {
  4535. return itemList.at(index);
  4536. }
  4537. else
  4538. {
  4539. return NULL;
  4540. }
  4541. }
  4542. /*:425*//*426:*/
  4543. #line 10389 "./typica.w"
  4544. void PackLayout::addItem(QLayoutItem*item)
  4545. {
  4546. itemList.append(item);
  4547. }
  4548. /*:426*//*427:*/
  4549. #line 10397 "./typica.w"
  4550. int PackLayout::count()const
  4551. {
  4552. return itemList.size();
  4553. }
  4554. /*:427*//*428:*/
  4555. #line 10409 "./typica.w"
  4556. Qt::Orientations PackLayout::expandingDirections()const
  4557. {
  4558. return Qt::Vertical|Qt::Horizontal;
  4559. }
  4560. bool PackLayout::hasHeightForWidth()const
  4561. {
  4562. return false;
  4563. }
  4564. int PackLayout::heightForWidth(int width)const
  4565. {
  4566. return doLayout(QRect(0,0,width,0),true);
  4567. }
  4568. void PackLayout::setGeometry(const QRect&rect)
  4569. {
  4570. QLayout::setGeometry(rect);
  4571. doLayout(rect,false);
  4572. }
  4573. QSize PackLayout::sizeHint()const
  4574. {
  4575. return minimumSize();
  4576. }
  4577. /*:428*//*429:*/
  4578. #line 10440 "./typica.w"
  4579. void PackLayout::setOrientation(Qt::Orientations direction)
  4580. {
  4581. orientation= direction;
  4582. doLayout(geometry(),false);
  4583. }
  4584. /*:429*/
  4585. #line 786 "./typica.w"
  4586. /*431:*/
  4587. #line 10479 "./typica.w"
  4588. SceneButton::SceneButton():QGraphicsScene()
  4589. {
  4590. }
  4591. SceneButton::~SceneButton()
  4592. {
  4593. }
  4594. void SceneButton::mousePressEvent(QGraphicsSceneMouseEvent*mouseEvent)
  4595. {
  4596. emit clicked(mouseEvent->buttonDownScreenPos(mouseEvent->button()));
  4597. }
  4598. /*:431*/
  4599. #line 787 "./typica.w"
  4600. /*433:*/
  4601. #line 10525 "./typica.w"
  4602. WidgetDecorator::WidgetDecorator(QWidget*widget,const QString&labeltext,
  4603. Qt::Orientations orientation,
  4604. QWidget*parent,Qt::WindowFlags f):
  4605. QWidget(parent,f),label(new QGraphicsView()),
  4606. scene(new SceneButton())
  4607. {
  4608. layout= new PackLayout(this);
  4609. layout->setOrientation(orientation);
  4610. /*434:*/
  4611. #line 10545 "./typica.w"
  4612. label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4613. label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  4614. label->setFrameShape(QFrame::NoFrame);
  4615. label->setInteractive(true);
  4616. /*:434*/
  4617. #line 10534 "./typica.w"
  4618. /*435:*/
  4619. #line 10556 "./typica.w"
  4620. scene->setBackgroundBrush(Qt::cyan);
  4621. text= scene->addText(labeltext);
  4622. if(orientation==Qt::Horizontal)
  4623. {
  4624. text->rotate(270.0);
  4625. }
  4626. label->setScene(scene);
  4627. /*:435*/
  4628. #line 10535 "./typica.w"
  4629. /*436:*/
  4630. #line 10574 "./typica.w"
  4631. if(orientation==Qt::Horizontal)
  4632. {
  4633. label->setMaximumWidth((int)(text->boundingRect().height()+1));
  4634. }
  4635. else
  4636. {
  4637. label->setMaximumHeight((int)(text->boundingRect().height()+1));
  4638. }
  4639. label->centerOn(text);
  4640. /*:436*/
  4641. #line 10536 "./typica.w"
  4642. /*437:*/
  4643. #line 10589 "./typica.w"
  4644. layout->addWidget(label);
  4645. layout->addWidget(widget);
  4646. if(orientation==Qt::Horizontal)
  4647. {
  4648. setMinimumSize(widget->sizeHint().width()+label->sizeHint().width(),
  4649. widget->sizeHint().height());
  4650. }
  4651. else
  4652. {
  4653. setMinimumSize(widget->sizeHint().width(),
  4654. widget->sizeHint().height()+label->sizeHint().height());
  4655. }
  4656. /*:437*/
  4657. #line 10537 "./typica.w"
  4658. }
  4659. /*:433*//*438:*/
  4660. #line 10606 "./typica.w"
  4661. void WidgetDecorator::setBackgroundBrush(QBrush background)
  4662. {
  4663. scene->setBackgroundBrush(background);
  4664. }
  4665. void WidgetDecorator::setTextColor(QColor color)
  4666. {
  4667. text->setDefaultTextColor(color);
  4668. }
  4669. /*:438*//*439:*/
  4670. #line 10619 "./typica.w"
  4671. WidgetDecorator::~WidgetDecorator()
  4672. {
  4673. }
  4674. /*:439*/
  4675. #line 788 "./typica.w"
  4676. /*444:*/
  4677. #line 10718 "./typica.w"
  4678. void LogEditWindow::addTheRows()
  4679. {
  4680. QTime s= startTime->time();
  4681. while(s<endTime->time())
  4682. {
  4683. model->newMeasurement(Measurement(0,s),1);
  4684. s= s.addSecs(interval->value());
  4685. }
  4686. model->newMeasurement(Measurement(0,endTime->time()),1);
  4687. }
  4688. /*:444*//*445:*/
  4689. #line 10732 "./typica.w"
  4690. LogEditWindow::LogEditWindow():QMainWindow(NULL),
  4691. centralWidget(new QWidget(NULL)),mainLayout(new PackLayout(0)),
  4692. addRowsLayout(new QHBoxLayout(NULL)),
  4693. startTimeLabel(new QLabel("Start Time")),
  4694. startTime(new QTimeEdit(QTime(0,0,0,0))),
  4695. endTimeLabel(new QLabel("End Time")),
  4696. endTime(new QTimeEdit(QTime(0,20,0,0))),
  4697. intervalLabel(new QLabel("Interval (seconds)")),
  4698. interval(new QSpinBox()),
  4699. addRows(new QPushButton("Add Rows")),
  4700. saveXml(new QAction(tr("Save Profile As..."),NULL)),
  4701. saveCsv(new QAction(tr("Export CSV"),NULL)),
  4702. openXml(new QAction(tr("Load Target Profile..."),NULL)),
  4703. model(new MeasurementModel()),
  4704. log(new QTableView())
  4705. {
  4706. /*446:*/
  4707. #line 10769 "./typica.w"
  4708. QSettings settings;
  4709. resize(settings.value("logSize",QSize(620,400)).toSize());
  4710. move(settings.value("logPos",QPoint(200,60)).toPoint());
  4711. /*:446*/
  4712. #line 10749 "./typica.w"
  4713. /*447:*/
  4714. #line 10782 "./typica.w"
  4715. mainLayout->setOrientation(Qt::Vertical);
  4716. addRowsLayout->addSpacing(10);
  4717. addRowsLayout->addWidget(startTimeLabel);
  4718. addRowsLayout->addWidget(startTime);
  4719. addRowsLayout->addSpacing(10);
  4720. startTime->setDisplayFormat("mm:ss");
  4721. addRowsLayout->addWidget(endTimeLabel);
  4722. addRowsLayout->addWidget(endTime);
  4723. addRowsLayout->addSpacing(10);
  4724. endTime->setDisplayFormat("mm:ss");
  4725. addRowsLayout->addWidget(intervalLabel);
  4726. addRowsLayout->addWidget(interval);
  4727. addRowsLayout->addSpacing(10);
  4728. interval->setRange(0,60);
  4729. interval->setValue(30);
  4730. addRowsLayout->addWidget(addRows);
  4731. addRowsLayout->addSpacing(10);
  4732. connect(addRows,SIGNAL(clicked()),this,SLOT(addTheRows()));
  4733. /*:447*/
  4734. #line 10750 "./typica.w"
  4735. /*448:*/
  4736. #line 10805 "./typica.w"
  4737. model->setHeaderData(0,Qt::Horizontal,"Time");
  4738. model->setHeaderData(1,Qt::Horizontal,"Temperature");
  4739. model->setHeaderData(2,Qt::Horizontal,"Annotation");
  4740. model->clear();
  4741. /*:448*/
  4742. #line 10751 "./typica.w"
  4743. /*449:*/
  4744. #line 10814 "./typica.w"
  4745. log->setModel(model);
  4746. log->setColumnWidth(0,100);
  4747. log->setColumnWidth(1,100);
  4748. log->setColumnWidth(2,100);
  4749. /*:449*/
  4750. #line 10752 "./typica.w"
  4751. mainLayout->addItem(addRowsLayout);
  4752. mainLayout->addWidget(log);
  4753. centralWidget->setLayout(mainLayout);
  4754. setCentralWidget(centralWidget);
  4755. QMenu*fileMenu= menuBar()->addMenu(tr("&File"));
  4756. fileMenu->addAction(openXml);
  4757. connect(openXml,SIGNAL(triggered()),this,SLOT(openXML()));
  4758. fileMenu->addAction(saveXml);
  4759. connect(saveXml,SIGNAL(triggered()),this,SLOT(saveXML()));
  4760. fileMenu->addAction(saveCsv);
  4761. connect(saveCsv,SIGNAL(triggered()),this,SLOT(saveCSV()));
  4762. }
  4763. /*:445*//*450:*/
  4764. #line 10825 "./typica.w"
  4765. void LogEditWindow::saveXML()
  4766. {
  4767. QSettings settings;
  4768. QString lastDir= settings.value("lastDirectory").toString();
  4769. QString filename= QFileDialog::getSaveFileName(this,tr("Save Log As..."),
  4770. lastDir,"",0);
  4771. QFile file(filename);
  4772. XMLOutput writer(model,&file,0);
  4773. writer.addTemperatureColumn("Temperature",1);
  4774. writer.addAnnotationColumn("Annotation",2);
  4775. if(writer.output())
  4776. {
  4777. QFileInfo info(filename);
  4778. QDir directory= info.dir();
  4779. lastDir= directory.path();
  4780. settings.setValue("lastDirectory",lastDir);
  4781. }
  4782. }
  4783. void LogEditWindow::saveCSV()
  4784. {
  4785. QSettings settings;
  4786. QString lastDir= settings.value("lastDirectory").toString();
  4787. QString filename= QFileDialog::getSaveFileName(this,tr("Export As..."),
  4788. lastDir,"",0);
  4789. QFile file(filename);
  4790. CSVOutput writer(model,&file,0);
  4791. writer.addTemperatureColumn("Temperature",1);
  4792. writer.addAnnotationColumn("Annotation",2);
  4793. if(writer.output())
  4794. {
  4795. QFileInfo info(filename);
  4796. QDir directory= info.dir();
  4797. lastDir= directory.path();
  4798. settings.setValue("lastDirectory",lastDir);
  4799. }
  4800. }
  4801. /*:450*//*451:*/
  4802. #line 10868 "./typica.w"
  4803. void LogEditWindow::openXML()
  4804. {
  4805. QSettings settings;
  4806. QString lastDir= settings.value("lastDirectory").toString();
  4807. QString filename= QFileDialog::getOpenFileName(this,tr("Open XML Log..."),
  4808. lastDir,"",0);
  4809. if(filename.isNull())
  4810. {
  4811. return;
  4812. }
  4813. QFile file(filename);
  4814. XMLInput reader(&file,1);
  4815. connect(&reader,SIGNAL(measure(Measurement,int)),
  4816. model,SLOT(newMeasurement(Measurement,int)));
  4817. connect(&reader,SIGNAL(annotation(QString,int,int)),
  4818. model,SLOT(newAnnotation(QString,int,int)));
  4819. if(reader.input())
  4820. {
  4821. QFileInfo info(filename);
  4822. setWindowTitle(QString(tr("%1 - %2")).
  4823. arg(QCoreApplication::applicationName()).arg(info.baseName()));
  4824. QDir directory= info.dir();
  4825. lastDir= directory.path();
  4826. settings.setValue("lastDirectory",lastDir);
  4827. }
  4828. }
  4829. /*:451*//*452:*/
  4830. #line 10899 "./typica.w"
  4831. void LogEditWindow::closeEvent(QCloseEvent*event)
  4832. {
  4833. QSettings settings;
  4834. settings.setValue("logSize",size());
  4835. settings.setValue("logPos",pos());
  4836. event->accept();
  4837. }
  4838. /*:452*/
  4839. #line 789 "./typica.w"
  4840. /*458:*/
  4841. #line 11012 "./typica.w"
  4842. bool XMLOutput::output()
  4843. {
  4844. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  4845. {
  4846. return false;
  4847. }
  4848. QXmlStreamWriter xmlout(out);
  4849. xmlout.writeStartDocument("1.0");
  4850. xmlout.writeDTD("<!DOCTYPE roastlog2.0>");
  4851. xmlout.writeStartElement("roastlog");
  4852. /*459:*/
  4853. #line 11045 "./typica.w"
  4854. foreach(int c,temperatureColumns.keys())
  4855. {
  4856. xmlout.writeStartElement("tempseries");
  4857. xmlout.writeAttribute("name",temperatureColumns.value(c));
  4858. xmlout.writeEndElement();
  4859. }
  4860. foreach(int c,annotationColumns.keys())
  4861. {
  4862. xmlout.writeStartElement("noteseries");
  4863. xmlout.writeAttribute("name",annotationColumns.value(c));
  4864. xmlout.writeEndElement();
  4865. }
  4866. /*:459*/
  4867. #line 11023 "./typica.w"
  4868. xmlout.writeStartElement("roast");
  4869. bool oresult;
  4870. for(int i= 0;i<data->rowCount();i++)
  4871. {
  4872. /*460:*/
  4873. #line 11064 "./typica.w"
  4874. oresult= false;
  4875. foreach(int c,temperatureColumns.keys())
  4876. {
  4877. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  4878. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  4879. {
  4880. oresult= true;
  4881. break;
  4882. }
  4883. }
  4884. if(oresult==false)
  4885. {
  4886. foreach(int c,annotationColumns.keys())
  4887. {
  4888. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  4889. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  4890. isEmpty()))
  4891. {
  4892. oresult= true;
  4893. break;
  4894. }
  4895. }
  4896. }
  4897. /*:460*/
  4898. #line 11028 "./typica.w"
  4899. if(oresult)
  4900. {
  4901. /*461:*/
  4902. #line 11094 "./typica.w"
  4903. xmlout.writeStartElement("tuple");
  4904. xmlout.writeTextElement("time",data->data(data->index(i,time),
  4905. Qt::DisplayRole).toString());
  4906. foreach(int c,temperatureColumns.keys())
  4907. {
  4908. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  4909. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  4910. {
  4911. xmlout.writeStartElement("temperature");
  4912. xmlout.writeAttribute("series",temperatureColumns.value(c));
  4913. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  4914. toString());
  4915. xmlout.writeEndElement();
  4916. }
  4917. }
  4918. foreach(int c,annotationColumns.keys())
  4919. {
  4920. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  4921. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  4922. {
  4923. xmlout.writeStartElement("annotation");
  4924. xmlout.writeAttribute("series",annotationColumns.value(c));
  4925. xmlout.writeCharacters(data->data(data->index(i,c),Qt::DisplayRole).
  4926. toString());
  4927. xmlout.writeEndElement();
  4928. }
  4929. }
  4930. xmlout.writeEndElement();
  4931. /*:461*/
  4932. #line 11031 "./typica.w"
  4933. }
  4934. }
  4935. xmlout.writeEndElement();
  4936. xmlout.writeEndElement();
  4937. xmlout.writeEndDocument();
  4938. out->close();
  4939. return true;
  4940. }
  4941. /*:458*//*462:*/
  4942. #line 11126 "./typica.w"
  4943. XMLOutput::XMLOutput(MeasurementModel*model,QIODevice*device,int timec)
  4944. :QObject(NULL),data(model),out(device),time(timec)
  4945. {
  4946. }
  4947. void XMLOutput::setModel(MeasurementModel*model)
  4948. {
  4949. data= model;
  4950. }
  4951. void XMLOutput::setTimeColumn(int column)
  4952. {
  4953. time= column;
  4954. }
  4955. void XMLOutput::setDevice(QIODevice*device)
  4956. {
  4957. out= device;
  4958. }
  4959. /*:462*//*463:*/
  4960. #line 11155 "./typica.w"
  4961. void XMLOutput::addTemperatureColumn(const QString&series,int column)
  4962. {
  4963. temperatureColumns.insert(column,series);
  4964. }
  4965. void XMLOutput::addAnnotationColumn(const QString&series,int column)
  4966. {
  4967. annotationColumns.insert(column,series);
  4968. }
  4969. /*:463*/
  4970. #line 790 "./typica.w"
  4971. /*465:*/
  4972. #line 11207 "./typica.w"
  4973. bool XMLInput::input()
  4974. {
  4975. if(!in->open(QIODevice::ReadOnly|QIODevice::Text))
  4976. {
  4977. return false;
  4978. }
  4979. QXmlStreamReader xmlin(in);
  4980. QMap<QString,int> temperatureColumns;
  4981. QMap<QString,int> annotationColumns;
  4982. int nextColumn= firstc;
  4983. /*466:*/
  4984. #line 11238 "./typica.w"
  4985. while(!xmlin.isDTD())
  4986. {
  4987. xmlin.readNext();
  4988. }
  4989. if(xmlin.isDTD())
  4990. {
  4991. if(xmlin.text()=="<!DOCTYPE roastlog>")
  4992. {
  4993. /*467:*/
  4994. #line 11260 "./typica.w"
  4995. emit newTemperatureColumn(firstc,"Bean");
  4996. emit newAnnotationColumn(firstc+1,"Note");
  4997. emit lastColumn(firstc+1);
  4998. /*:467*/
  4999. #line 11247 "./typica.w"
  5000. }
  5001. else
  5002. {
  5003. xmlin.readNext();
  5004. /*468:*/
  5005. #line 11269 "./typica.w"
  5006. while(xmlin.name()!="roast")
  5007. {
  5008. if(xmlin.isStartElement())
  5009. {
  5010. if(xmlin.name()=="tempseries")
  5011. {
  5012. temperatureColumns.insert(xmlin.attributes().value("name").
  5013. toString(),
  5014. nextColumn);
  5015. emit newTemperatureColumn(nextColumn,
  5016. xmlin.attributes().value("name").
  5017. toString());
  5018. nextColumn++;
  5019. }
  5020. else if(xmlin.name()=="noteseries")
  5021. {
  5022. annotationColumns.insert(xmlin.attributes().value("name").
  5023. toString(),nextColumn);
  5024. emit newAnnotationColumn(nextColumn,
  5025. xmlin.attributes().value("name").
  5026. toString());
  5027. nextColumn++;
  5028. }
  5029. }
  5030. xmlin.readNext();
  5031. }
  5032. emit lastColumn(nextColumn-1);
  5033. /*:468*/
  5034. #line 11252 "./typica.w"
  5035. }
  5036. }
  5037. /*:466*/
  5038. #line 11218 "./typica.w"
  5039. QTime timeval= QTime();
  5040. double tempval= 0;
  5041. QString noteval= QString();
  5042. int column;
  5043. int counter= 0;
  5044. while(!xmlin.atEnd())
  5045. {
  5046. /*469:*/
  5047. #line 11310 "./typica.w"
  5048. xmlin.readNext();
  5049. if(xmlin.isStartElement())
  5050. {
  5051. /*470:*/
  5052. #line 11336 "./typica.w"
  5053. if(xmlin.name()=="time")
  5054. {
  5055. timeval= QTime::fromString(xmlin.readElementText(),"mm:ss.zzz");
  5056. }
  5057. else if(xmlin.name()=="temperature")
  5058. {
  5059. column= xmlin.attributes().value("series").toString().isEmpty()?
  5060. firstc:temperatureColumns.value(xmlin.attributes().
  5061. value("series").toString());
  5062. tempval= xmlin.readElementText().toDouble();
  5063. Measurement measurement(tempval,timeval);
  5064. emit measure(measurement,column);
  5065. }
  5066. else if(xmlin.name()=="annotation")
  5067. {
  5068. column= xmlin.attributes().value("series").toString().isEmpty()?
  5069. firstc+1:annotationColumns.value(xmlin.attributes().
  5070. value("series").toString());
  5071. noteval= xmlin.readElementText();
  5072. if(!noteval.isEmpty())
  5073. {
  5074. emit annotation(noteval,firstc,column);
  5075. }
  5076. }
  5077. /*:470*/
  5078. #line 11314 "./typica.w"
  5079. }
  5080. counter++;
  5081. if(counter%100==0)
  5082. {
  5083. QCoreApplication::processEvents();
  5084. }
  5085. /*:469*/
  5086. #line 11226 "./typica.w"
  5087. }
  5088. return true;
  5089. }
  5090. /*:465*//*471:*/
  5091. #line 11364 "./typica.w"
  5092. XMLInput::XMLInput(QIODevice*input,int c):
  5093. firstc(c),in(input)
  5094. {
  5095. }
  5096. void XMLInput::setFirstColumn(int column)
  5097. {
  5098. firstc= column;
  5099. }
  5100. void XMLInput::setDevice(QIODevice*device)
  5101. {
  5102. in= device;
  5103. }
  5104. /*:471*/
  5105. #line 791 "./typica.w"
  5106. /*476:*/
  5107. #line 11453 "./typica.w"
  5108. bool CSVOutput::output()
  5109. {
  5110. if(!out->open(QIODevice::WriteOnly|QIODevice::Text))
  5111. {
  5112. return false;
  5113. }
  5114. QTextStream output(out);
  5115. /*477:*/
  5116. #line 11477 "./typica.w"
  5117. output<<"Time";
  5118. foreach(int c,temperatureColumns.keys())
  5119. {
  5120. output<<','<<temperatureColumns.value(c);
  5121. }
  5122. foreach(int c,annotationColumns.keys())
  5123. {
  5124. output<<','<<annotationColumns.value(c);
  5125. }
  5126. output<<'\n';
  5127. /*:477*/
  5128. #line 11461 "./typica.w"
  5129. bool oresult;
  5130. for(int i= 0;i<data->rowCount();i++)
  5131. {
  5132. /*460:*/
  5133. #line 11064 "./typica.w"
  5134. oresult= false;
  5135. foreach(int c,temperatureColumns.keys())
  5136. {
  5137. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5138. !(data->data(data->index(i,c),Qt::DisplayRole).toString().isEmpty()))
  5139. {
  5140. oresult= true;
  5141. break;
  5142. }
  5143. }
  5144. if(oresult==false)
  5145. {
  5146. foreach(int c,annotationColumns.keys())
  5147. {
  5148. if(data->data(data->index(i,c),Qt::DisplayRole).isValid()&&
  5149. !(data->data(data->index(i,c),Qt::DisplayRole).toString().
  5150. isEmpty()))
  5151. {
  5152. oresult= true;
  5153. break;
  5154. }
  5155. }
  5156. }
  5157. /*:460*/
  5158. #line 11465 "./typica.w"
  5159. if(oresult)
  5160. {
  5161. /*478:*/
  5162. #line 11498 "./typica.w"
  5163. output<<data->data(data->index(i,time),Qt::DisplayRole).toString();
  5164. foreach(int c,temperatureColumns.keys())
  5165. {
  5166. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  5167. }
  5168. foreach(int c,annotationColumns.keys())
  5169. {
  5170. output<<','<<data->data(data->index(i,c),Qt::DisplayRole).toString();
  5171. }
  5172. output<<'\n';
  5173. /*:478*/
  5174. #line 11468 "./typica.w"
  5175. }
  5176. }
  5177. out->close();
  5178. return true;
  5179. }
  5180. /*:476*//*479:*/
  5181. #line 11513 "./typica.w"
  5182. CSVOutput::CSVOutput(MeasurementModel*model,QIODevice*device,int timec):
  5183. data(model),out(device),time(timec)
  5184. {
  5185. }
  5186. void CSVOutput::setModel(MeasurementModel*model)
  5187. {
  5188. data= model;
  5189. }
  5190. void CSVOutput::setTimeColumn(int column)
  5191. {
  5192. time= column;
  5193. }
  5194. void CSVOutput::addTemperatureColumn(const QString&series,int column)
  5195. {
  5196. temperatureColumns.insert(column,series);
  5197. }
  5198. void CSVOutput::addAnnotationColumn(const QString&series,int column)
  5199. {
  5200. annotationColumns.insert(column,series);
  5201. }
  5202. void CSVOutput::setDevice(QIODevice*device)
  5203. {
  5204. out= device;
  5205. }
  5206. /*:479*/
  5207. #line 792 "./typica.w"
  5208. /*498:*/
  5209. #line 11895 "./typica.w"
  5210. QString SaltModel::arrayLiteral(int column,int role)const
  5211. {
  5212. QString literal= "'{";
  5213. for(int i= 0;i<rowCount();i++)
  5214. {
  5215. QString datum= data(index(i,column),role).toString();
  5216. if(!datum.isEmpty())
  5217. {
  5218. literal.append(datum);
  5219. literal.append(", ");
  5220. }
  5221. }
  5222. if(literal.size()> 2)
  5223. {
  5224. literal.chop(2);
  5225. }
  5226. literal.append("}'");
  5227. return literal;
  5228. }
  5229. QString SaltModel::quotedArrayLiteral(int column,int role)const
  5230. {
  5231. QString literal= "'{";
  5232. for(int i= 0;i<rowCount();i++)
  5233. {
  5234. QString datum= data(index(i,column),role).toString();
  5235. if(!datum.isEmpty())
  5236. {
  5237. literal.append("\"");
  5238. literal.append(datum);
  5239. literal.append("\", ");
  5240. }
  5241. }
  5242. if(literal.size()> 2)
  5243. {
  5244. literal.chop(2);
  5245. }
  5246. literal.append("}'");
  5247. return literal;
  5248. }
  5249. /*:498*//*499:*/
  5250. #line 11939 "./typica.w"
  5251. QModelIndex SaltModel::parent(const QModelIndex&)const
  5252. {
  5253. return QModelIndex();
  5254. }
  5255. /*:499*//*500:*/
  5256. #line 11958 "./typica.w"
  5257. bool SaltModel::setData(const QModelIndex&index,const QVariant&value,
  5258. int role)
  5259. {
  5260. /*501:*/
  5261. #line 11989 "./typica.w"
  5262. bool valid= false;
  5263. if(index.isValid())
  5264. {
  5265. if(index.row()<modelData.size())
  5266. {
  5267. if(index.column()<colcount)
  5268. {
  5269. valid= true;
  5270. }
  5271. }
  5272. }
  5273. /*:501*/
  5274. #line 11962 "./typica.w"
  5275. if(!valid)
  5276. {
  5277. return false;
  5278. }
  5279. if(index.row()==modelData.size()-1)
  5280. {
  5281. beginInsertRows(QModelIndex(),modelData.size(),modelData.size());
  5282. /*502:*/
  5283. #line 12005 "./typica.w"
  5284. QList<QMap<int,QVariant> > newRow;
  5285. QMap<int,QVariant> defaults;
  5286. for(int i= 0;i<colcount;i++)
  5287. {
  5288. newRow.append(defaults);
  5289. }
  5290. modelData.append(newRow);
  5291. /*:502*/
  5292. #line 11970 "./typica.w"
  5293. endInsertRows();
  5294. }
  5295. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  5296. QMap<int,QVariant> cell= row.at(index.column());
  5297. cell.insert(role,value);
  5298. if(role==Qt::EditRole)
  5299. {
  5300. cell.insert(Qt::DisplayRole,value);
  5301. }
  5302. row.replace(index.column(),cell);
  5303. modelData.replace(index.row(),row);
  5304. emit dataChanged(index,index);
  5305. return true;
  5306. }
  5307. /*:500*//*503:*/
  5308. #line 12016 "./typica.w"
  5309. SaltModel::SaltModel(int columns):QAbstractItemModel(),colcount(columns)
  5310. {
  5311. for(int i= 0;i<columns;i++)
  5312. {
  5313. hData<<"";
  5314. }
  5315. /*502:*/
  5316. #line 12005 "./typica.w"
  5317. QList<QMap<int,QVariant> > newRow;
  5318. QMap<int,QVariant> defaults;
  5319. for(int i= 0;i<colcount;i++)
  5320. {
  5321. newRow.append(defaults);
  5322. }
  5323. modelData.append(newRow);
  5324. /*:502*/
  5325. #line 12023 "./typica.w"
  5326. }
  5327. /*:503*//*504:*/
  5328. #line 12028 "./typica.w"
  5329. SaltModel::~SaltModel()
  5330. {
  5331. }
  5332. /*:504*//*505:*/
  5333. #line 12038 "./typica.w"
  5334. int SaltModel::rowCount(const QModelIndex&parent)const
  5335. {
  5336. return(parent==QModelIndex()?modelData.size():0);
  5337. }
  5338. int SaltModel::columnCount(const QModelIndex&parent)const
  5339. {
  5340. return(parent==QModelIndex()?colcount:0);
  5341. }
  5342. /*:505*//*506:*/
  5343. #line 12051 "./typica.w"
  5344. bool SaltModel::setHeaderData(int section,Qt::Orientation orientation,
  5345. const QVariant&value,int)
  5346. {
  5347. if(orientation==Qt::Horizontal&&section<colcount)
  5348. {
  5349. hData.replace(section,value.toString());
  5350. emit headerDataChanged(orientation,section,section);
  5351. return true;
  5352. }
  5353. return false;
  5354. }
  5355. /*:506*//*507:*/
  5356. #line 12066 "./typica.w"
  5357. QVariant SaltModel::data(const QModelIndex&index,int role)const
  5358. {
  5359. /*501:*/
  5360. #line 11989 "./typica.w"
  5361. bool valid= false;
  5362. if(index.isValid())
  5363. {
  5364. if(index.row()<modelData.size())
  5365. {
  5366. if(index.column()<colcount)
  5367. {
  5368. valid= true;
  5369. }
  5370. }
  5371. }
  5372. /*:501*/
  5373. #line 12069 "./typica.w"
  5374. if(!valid)
  5375. {
  5376. return QVariant();
  5377. }
  5378. QList<QMap<int,QVariant> > row= modelData.at(index.row());
  5379. QMap<int,QVariant> cell= row.at(index.column());
  5380. return cell.value(role,QVariant());
  5381. }
  5382. QVariant SaltModel::headerData(int section,Qt::Orientation orientation,
  5383. int role)const
  5384. {
  5385. if(orientation==Qt::Horizontal&&role==Qt::DisplayRole&&
  5386. section<colcount)
  5387. {
  5388. return QVariant(hData.at(section));
  5389. }
  5390. return QVariant();
  5391. }
  5392. /*:507*//*508:*/
  5393. #line 12093 "./typica.w"
  5394. Qt::ItemFlags SaltModel::flags(const QModelIndex&index)const
  5395. {
  5396. /*501:*/
  5397. #line 11989 "./typica.w"
  5398. bool valid= false;
  5399. if(index.isValid())
  5400. {
  5401. if(index.row()<modelData.size())
  5402. {
  5403. if(index.column()<colcount)
  5404. {
  5405. valid= true;
  5406. }
  5407. }
  5408. }
  5409. /*:501*/
  5410. #line 12096 "./typica.w"
  5411. if(valid)
  5412. {
  5413. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
  5414. }
  5415. return 0;
  5416. }
  5417. /*:508*//*509:*/
  5418. #line 12107 "./typica.w"
  5419. QModelIndex SaltModel::index(int row,int column,
  5420. const QModelIndex&parent)const
  5421. {
  5422. if(parent==QModelIndex())
  5423. {
  5424. if(row<modelData.size()&&column<colcount)
  5425. {
  5426. return createIndex(row,column);
  5427. }
  5428. }
  5429. return QModelIndex();
  5430. }
  5431. /*:509*/
  5432. #line 793 "./typica.w"
  5433. /*511:*/
  5434. #line 12162 "./typica.w"
  5435. SqlComboBox*SqlComboBox::clone(QWidget*parent)
  5436. {
  5437. SqlComboBox*widget= new SqlComboBox();
  5438. widget->setParent(parent);
  5439. for(int i= 0;i<count();i++)
  5440. {
  5441. widget->addItem(itemText(i),itemData(i));
  5442. }
  5443. return widget;
  5444. }
  5445. /*:511*//*512:*/
  5446. #line 12179 "./typica.w"
  5447. void SqlComboBox::showData(bool show)
  5448. {
  5449. dataColumnShown= show;
  5450. }
  5451. /*:512*//*513:*/
  5452. #line 12190 "./typica.w"
  5453. void SqlComboBox::addNullOption()
  5454. {
  5455. addItem(tr("Unknown"),QVariant(QVariant::String));
  5456. }
  5457. /*:513*//*514:*/
  5458. #line 12203 "./typica.w"
  5459. void SqlComboBox::setDataColumn(int column)
  5460. {
  5461. dataColumn= column;
  5462. }
  5463. void SqlComboBox::setDisplayColumn(int column)
  5464. {
  5465. displayColumn= column;
  5466. }
  5467. /*:514*//*515:*/
  5468. #line 12217 "./typica.w"
  5469. void SqlComboBox::addSqlOptions(QString query)
  5470. {
  5471. SqlQueryConnection*dbquery= new SqlQueryConnection;
  5472. if(!dbquery->exec(query))
  5473. {
  5474. QSqlError error= dbquery->lastError();
  5475. qDebug()<<error.databaseText();
  5476. qDebug()<<error.driverText();
  5477. qDebug()<<error.text();
  5478. qDebug()<<dbquery->lastQuery();
  5479. }
  5480. while(dbquery->next())
  5481. {
  5482. QString displayValue(dbquery->value(displayColumn).toString());
  5483. QString dataValue(dbquery->value(dataColumn).toString());
  5484. if(dataColumnShown)
  5485. {
  5486. displayValue.append(QString(" (%1)").arg(dataValue));
  5487. }
  5488. addItem(displayValue,dataValue);
  5489. }
  5490. delete dbquery;
  5491. }
  5492. /*:515*//*516:*/
  5493. #line 12246 "./typica.w"
  5494. SqlComboBox::SqlComboBox():
  5495. dataColumn(0),displayColumn(0),dataColumnShown(false)
  5496. {
  5497. }
  5498. SqlComboBox::~SqlComboBox()
  5499. {
  5500. }
  5501. /*:516*/
  5502. #line 794 "./typica.w"
  5503. /*518:*/
  5504. #line 12284 "./typica.w"
  5505. void SqlComboBoxDelegate::setWidget(SqlComboBox*widget)
  5506. {
  5507. delegate= widget;
  5508. }
  5509. /*:518*//*519:*/
  5510. #line 12293 "./typica.w"
  5511. QWidget*SqlComboBoxDelegate::createEditor(QWidget*parent,
  5512. const QStyleOptionViewItem&,
  5513. const QModelIndex&)const
  5514. {
  5515. return delegate->clone(parent);
  5516. }
  5517. /*:519*//*520:*/
  5518. #line 12304 "./typica.w"
  5519. void SqlComboBoxDelegate::setEditorData(QWidget*editor,
  5520. const QModelIndex&index)const
  5521. {
  5522. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  5523. self->setCurrentIndex(self->findData(
  5524. index.model()->data(index,
  5525. Qt::UserRole).toString()));
  5526. }
  5527. /*:520*//*521:*/
  5528. #line 12317 "./typica.w"
  5529. void SqlComboBoxDelegate::setModelData(QWidget*editor,
  5530. QAbstractItemModel*model,
  5531. const QModelIndex&index)const
  5532. {
  5533. SqlComboBox*self= qobject_cast<SqlComboBox*> (editor);
  5534. model->setData(index,self->itemData(self->currentIndex(),Qt::UserRole),
  5535. Qt::UserRole);
  5536. model->setData(index,self->currentText(),Qt::DisplayRole);
  5537. }
  5538. /*:521*//*522:*/
  5539. #line 12330 "./typica.w"
  5540. void SqlComboBoxDelegate::updateEditorGeometry(QWidget*editor,
  5541. const QStyleOptionViewItem&option,
  5542. const QModelIndex&)const
  5543. {
  5544. editor->setGeometry(option.rect);
  5545. }
  5546. /*:522*//*523:*/
  5547. #line 12341 "./typica.w"
  5548. QSize SqlComboBoxDelegate::sizeHint()const
  5549. {
  5550. return delegate->sizeHint();
  5551. }
  5552. /*:523*//*524:*/
  5553. #line 12349 "./typica.w"
  5554. SqlComboBoxDelegate::SqlComboBoxDelegate(QObject*parent)
  5555. :QItemDelegate(parent)
  5556. {
  5557. }
  5558. /*:524*/
  5559. #line 795 "./typica.w"
  5560. /*490:*/
  5561. #line 11709 "./typica.w"
  5562. Application::Application(int&argc,char**argv):QApplication(argc,argv)
  5563. {
  5564. /*491:*/
  5565. #line 11724 "./typica.w"
  5566. setOrganizationName("Wilson's Coffee & Tea");
  5567. setOrganizationDomain("wilsonscoffee.com");
  5568. setApplicationName(PROGRAM_NAME);
  5569. /*:491*/
  5570. #line 11712 "./typica.w"
  5571. /*492:*/
  5572. #line 11733 "./typica.w"
  5573. QTranslator base;
  5574. if(base.load(QString("qt_%1").arg(QLocale::system().name())))
  5575. {
  5576. installTranslator(&base);
  5577. }
  5578. QTranslator app;
  5579. if(app.load(QString("%1_%2").arg("Typica").arg(QLocale::system().name())))
  5580. {
  5581. installTranslator(&app);
  5582. }
  5583. /*:492*/
  5584. #line 11713 "./typica.w"
  5585. /*229:*/
  5586. #line 5736 "./typica.w"
  5587. qRegisterMetaType<Measurement> ("Measurement");
  5588. /*:229*/
  5589. #line 11714 "./typica.w"
  5590. /*671:*/
  5591. #line 15460 "./typica.w"
  5592. NodeInserter*inserter= new NodeInserter(tr("NI DAQmx Base Device"),
  5593. tr("NI DAQmx Base"),
  5594. "nidaqmxbase",NULL);
  5595. topLevelNodeInserters.append(inserter);
  5596. /*:671*//*679:*/
  5597. #line 15677 "./typica.w"
  5598. #ifdef Q_OS_WIN32
  5599. inserter= new NodeInserter(tr("NI DAQmx Device"),tr("NI DAQmx"),"nidaqmx",NULL);
  5600. topLevelNodeInserters.append(inserter);
  5601. #endif
  5602. /*:679*//*703:*/
  5603. #line 16636 "./typica.w"
  5604. #if 0
  5605. inserter= new NodeInserter(tr("Modbus RTU Port"),tr("Modbus RTU Port"),"modbusrtuport",NULL);
  5606. topLevelNodeInserters.append(inserter);
  5607. #endif
  5608. /*:703*//*732:*/
  5609. #line 18086 "./typica.w"
  5610. inserter= new NodeInserter(tr("Modbus RTU Device"),tr("Modbus RTU Device"),"modbusrtu",NULL);
  5611. topLevelNodeInserters.append(inserter);
  5612. /*:732*/
  5613. #line 11715 "./typica.w"
  5614. }
  5615. /*:490*//*494:*/
  5616. #line 11756 "./typica.w"
  5617. QDomDocument*Application::configuration()
  5618. {
  5619. return&conf;
  5620. }
  5621. /*:494*//*495:*/
  5622. #line 11765 "./typica.w"
  5623. QSqlDatabase Application::database()
  5624. {
  5625. QString connectionName;
  5626. QSqlDatabase connection= QSqlDatabase::database();
  5627. do
  5628. {
  5629. connectionName= QUuid::createUuid().toString();
  5630. }while(QSqlDatabase::connectionNames().contains(connectionName));
  5631. return QSqlDatabase::cloneDatabase(connection,connectionName);
  5632. }
  5633. /*:495*//*606:*/
  5634. #line 14095 "./typica.w"
  5635. void Application::saveDeviceConfiguration()
  5636. {
  5637. QSettings settings;
  5638. settings.setValue("DeviceConfiguration",
  5639. QVariant(deviceConfigurationDocument.toByteArray()));
  5640. }
  5641. /*:606*//*607:*/
  5642. #line 14107 "./typica.w"
  5643. QDomDocument Application::deviceConfiguration()
  5644. {
  5645. if(deviceConfigurationDocument.isNull())
  5646. {
  5647. /*608:*/
  5648. #line 14121 "./typica.w"
  5649. QSettings settings;
  5650. QByteArray document= settings.value("DeviceConfiguration").toByteArray();
  5651. QString etext;
  5652. int eline;
  5653. int ecol;
  5654. if(document.length()==0)
  5655. {
  5656. qDebug()<<"Loaded settings length is 0. Creating new configuration.";
  5657. /*609:*/
  5658. #line 14145 "./typica.w"
  5659. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  5660. emptyDocument.open(QIODevice::ReadOnly);
  5661. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  5662. &etext,&eline,&ecol))
  5663. {
  5664. /*610:*/
  5665. #line 14162 "./typica.w"
  5666. qDebug()<<QString(tr("An error occurred loading device configuration."));
  5667. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  5668. qDebug()<<etext;
  5669. /*:610*/
  5670. #line 14151 "./typica.w"
  5671. }
  5672. else
  5673. {
  5674. saveDeviceConfiguration();
  5675. }
  5676. /*:609*/
  5677. #line 14130 "./typica.w"
  5678. }
  5679. else
  5680. {
  5681. if(!deviceConfigurationDocument.setContent(document,false,
  5682. &etext,&eline,&ecol))
  5683. {
  5684. /*610:*/
  5685. #line 14162 "./typica.w"
  5686. qDebug()<<QString(tr("An error occurred loading device configuration."));
  5687. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  5688. qDebug()<<etext;
  5689. /*:610*/
  5690. #line 14137 "./typica.w"
  5691. /*609:*/
  5692. #line 14145 "./typica.w"
  5693. QFile emptyDocument(":/resources/xml/EmptyDeviceConfiguration.xml");
  5694. emptyDocument.open(QIODevice::ReadOnly);
  5695. if(!deviceConfigurationDocument.setContent(&emptyDocument,false,
  5696. &etext,&eline,&ecol))
  5697. {
  5698. /*610:*/
  5699. #line 14162 "./typica.w"
  5700. qDebug()<<QString(tr("An error occurred loading device configuration."));
  5701. qDebug()<<QString(tr("Line %1, Column %2")).arg(eline).arg(ecol);
  5702. qDebug()<<etext;
  5703. /*:610*/
  5704. #line 14151 "./typica.w"
  5705. }
  5706. else
  5707. {
  5708. saveDeviceConfiguration();
  5709. }
  5710. /*:609*/
  5711. #line 14138 "./typica.w"
  5712. }
  5713. }
  5714. /*:608*/
  5715. #line 14112 "./typica.w"
  5716. }
  5717. return deviceConfigurationDocument;
  5718. }
  5719. /*:607*//*638:*/
  5720. #line 14763 "./typica.w"
  5721. void Application::registerDeviceConfigurationWidget(QString driver,
  5722. QMetaObject widget)
  5723. {
  5724. deviceConfigurationWidgets.insert(driver,widget);
  5725. }
  5726. /*:638*//*639:*/
  5727. #line 14779 "./typica.w"
  5728. QWidget*Application::deviceConfigurationWidget(DeviceTreeModel*model,
  5729. const QModelIndex&index)
  5730. {
  5731. QVariant nodeReference= index.data(Qt::UserRole);
  5732. QDomElement referenceElement= model->referenceElement(
  5733. model->data(index,Qt::UserRole).toString());
  5734. QMetaObject metaObject=
  5735. deviceConfigurationWidgets.value(referenceElement.attribute("driver"),
  5736. QWidget::staticMetaObject);
  5737. QWidget*editor;
  5738. if(metaObject.className()==QWidget::staticMetaObject.className())
  5739. {
  5740. editor= NULL;
  5741. }
  5742. else
  5743. {
  5744. editor= qobject_cast<QWidget*> (
  5745. metaObject.newInstance(Q_ARG(DeviceTreeModel*,model),
  5746. Q_ARG(QModelIndex,index)));
  5747. }
  5748. return editor;
  5749. }
  5750. /*:639*/
  5751. #line 796 "./typica.w"
  5752. /*530:*/
  5753. #line 12455 "./typica.w"
  5754. SqlConnectionSetup::SqlConnectionSetup():
  5755. formLayout(new QFormLayout),driver(new QComboBox),hostname(new QLineEdit),
  5756. dbname(new QLineEdit),user(new QLineEdit),password(new QLineEdit),
  5757. layout(new QVBoxLayout),buttons(new QHBoxLayout),
  5758. cancelButton(new QPushButton(tr("Cancel"))),
  5759. connectButton(new QPushButton(tr("Connect")))
  5760. {
  5761. driver->addItem("PostgreSQL","QPSQL");
  5762. formLayout->addRow(tr("Database driver:"),driver);
  5763. formLayout->addRow(tr("Host name:"),hostname);
  5764. formLayout->addRow(tr("Database name:"),dbname);
  5765. formLayout->addRow(tr("User name:"),user);
  5766. password->setEchoMode(QLineEdit::Password);
  5767. formLayout->addRow(tr("Password:"),password);
  5768. layout->addLayout(formLayout);
  5769. buttons->addStretch(1);
  5770. buttons->addWidget(cancelButton);
  5771. connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(reject()));
  5772. buttons->addWidget(connectButton);
  5773. layout->addLayout(buttons);
  5774. connect(connectButton,SIGNAL(clicked(bool)),this,SLOT(testConnection()));
  5775. setLayout(layout);
  5776. setModal(true);
  5777. }
  5778. SqlConnectionSetup::~SqlConnectionSetup()
  5779. {
  5780. }
  5781. /*:530*//*531:*/
  5782. #line 12489 "./typica.w"
  5783. void SqlConnectionSetup::testConnection()
  5784. {
  5785. QSqlDatabase database=
  5786. QSqlDatabase::addDatabase(driver->itemData(driver->currentIndex()).
  5787. toString());
  5788. database.setHostName(hostname->text());
  5789. database.setDatabaseName(dbname->text());
  5790. database.setUserName(user->text());
  5791. database.setPassword(password->text());
  5792. if(database.open())
  5793. {
  5794. QSettings settings;
  5795. settings.setValue("database/exists","true");
  5796. settings.setValue("database/driver",
  5797. driver->itemData(driver->currentIndex()).toString());
  5798. settings.setValue("database/hostname",hostname->text());
  5799. settings.setValue("database/dbname",dbname->text());
  5800. settings.setValue("database/user",user->text());
  5801. settings.setValue("database/password",password->text());
  5802. accept();
  5803. }
  5804. else
  5805. {
  5806. QMessageBox::information(this,tr("Database connection failed"),
  5807. tr("Failed to connect to database."));
  5808. }
  5809. }
  5810. /*:531*/
  5811. #line 797 "./typica.w"
  5812. /*535:*/
  5813. #line 12584 "./typica.w"
  5814. SqlQueryView::SqlQueryView(QWidget*parent):QTableView(parent)
  5815. {
  5816. setModel(new QSqlQueryModel);
  5817. connect(this,SIGNAL(doubleClicked(QModelIndex)),
  5818. this,SLOT(openRow(QModelIndex)));
  5819. connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)),
  5820. this,SLOT(persistColumnResize(int,int,int)));
  5821. }
  5822. /*:535*//*536:*/
  5823. #line 12599 "./typica.w"
  5824. void SqlQueryView::persistColumnResize(int column,int,int newsize)
  5825. {
  5826. /*537:*/
  5827. #line 12608 "./typica.w"
  5828. QSettings settings;
  5829. /*538:*/
  5830. #line 12621 "./typica.w"
  5831. QWidget*topLevelWidget= this;
  5832. while(topLevelWidget->parentWidget())
  5833. {
  5834. topLevelWidget= topLevelWidget->parentWidget();
  5835. }
  5836. /*:538*/
  5837. #line 12610 "./typica.w"
  5838. settings.setValue(QString("columnWidths/%1/%2/%3").
  5839. arg(topLevelWidget->objectName()).
  5840. arg(objectName()).arg(column),
  5841. QVariant(newsize));
  5842. /*:537*/
  5843. #line 12602 "./typica.w"
  5844. }
  5845. /*:536*//*539:*/
  5846. #line 12631 "./typica.w"
  5847. void SqlQueryView::showEvent(QShowEvent*event)
  5848. {
  5849. /*540:*/
  5850. #line 12641 "./typica.w"
  5851. QSettings settings;
  5852. /*538:*/
  5853. #line 12621 "./typica.w"
  5854. QWidget*topLevelWidget= this;
  5855. while(topLevelWidget->parentWidget())
  5856. {
  5857. topLevelWidget= topLevelWidget->parentWidget();
  5858. }
  5859. /*:538*/
  5860. #line 12643 "./typica.w"
  5861. QString baseKey=
  5862. QString("columnWidths/%1/%2").arg(topLevelWidget->objectName()).
  5863. arg(objectName());
  5864. for(int i= 0;i<model()->columnCount();i++)
  5865. {
  5866. QString key= QString("%1/%2").arg(baseKey).arg(i);
  5867. if(settings.contains(key))
  5868. {
  5869. setColumnWidth(i,settings.value(key).toInt());
  5870. }
  5871. }
  5872. /*:540*/
  5873. #line 12634 "./typica.w"
  5874. event->accept();
  5875. }
  5876. /*:539*//*541:*/
  5877. #line 12658 "./typica.w"
  5878. void SqlQueryView::openRow(const QModelIndex&index)
  5879. {
  5880. emit openEntry(((QSqlQueryModel*)model())->record(index.row()).value(0).toString());
  5881. emit openEntryRow(index.row());
  5882. }
  5883. /*:541*//*542:*/
  5884. #line 12669 "./typica.w"
  5885. void SqlQueryView::setQuery(const QString&query)
  5886. {
  5887. QSqlDatabase database= AppInstance->database();
  5888. database.open();
  5889. QSqlQuery q(query,database);
  5890. ((QSqlQueryModel*)model())->setQuery(q);
  5891. }
  5892. bool SqlQueryView::setHeaderData(int section,Qt::Orientation orientation,
  5893. const QVariant&value,int role)
  5894. {
  5895. return model()->setHeaderData(section,orientation,value,role);
  5896. }
  5897. /*:542*//*543:*/
  5898. #line 12686 "./typica.w"
  5899. QVariant SqlQueryView::data(int row,int column,int role)
  5900. {
  5901. return model()->data(model()->index(row,column),role);
  5902. }
  5903. /*:543*/
  5904. #line 798 "./typica.w"
  5905. /*137:*/
  5906. #line 3283 "./typica.w"
  5907. SqlQueryConnection::SqlQueryConnection(const QString&query)
  5908. {
  5909. QSqlDatabase database= AppInstance->database();
  5910. database.open();
  5911. q= new QSqlQuery(query,database);
  5912. connection= database.connectionName();
  5913. }
  5914. /*:137*//*138:*/
  5915. #line 3296 "./typica.w"
  5916. SqlQueryConnection::~SqlQueryConnection()
  5917. {
  5918. delete q;
  5919. {
  5920. QSqlDatabase database= QSqlDatabase::database(connection);
  5921. database.close();
  5922. }
  5923. QSqlDatabase::removeDatabase(connection);
  5924. }
  5925. /*:138*//*139:*/
  5926. #line 3310 "./typica.w"
  5927. QSqlQuery*SqlQueryConnection::operator->()
  5928. {
  5929. return q;
  5930. }
  5931. /*:139*/
  5932. #line 799 "./typica.w"
  5933. /*562:*/
  5934. #line 13035 "./typica.w"
  5935. ReportTable::ReportTable(QTextFrame*frame,QDomElement description):
  5936. area(frame),configuration(description)
  5937. {
  5938. refresh();
  5939. }
  5940. ReportTable::~ReportTable()
  5941. {
  5942. }
  5943. /*:562*//*563:*/
  5944. #line 13051 "./typica.w"
  5945. void ReportTable::bind(QString placeholder,QVariant value)
  5946. {
  5947. bindings.insert(placeholder,value);
  5948. }
  5949. /*:563*//*564:*/
  5950. #line 13061 "./typica.w"
  5951. void ReportTable::refresh()
  5952. {
  5953. /*565:*/
  5954. #line 13082 "./typica.w"
  5955. QTextCursor cursor= area->firstCursorPosition();
  5956. while(cursor<area->lastCursorPosition())
  5957. {
  5958. cursor.movePosition(QTextCursor::Right,QTextCursor::KeepAnchor);
  5959. }
  5960. cursor.removeSelectedText();
  5961. /*:565*/
  5962. #line 13064 "./typica.w"
  5963. int rows= 1;
  5964. int columns= 1;
  5965. int currentRow= 0;
  5966. QTextTable*table= cursor.insertTable(rows,columns);
  5967. /*566:*/
  5968. #line 13095 "./typica.w"
  5969. QTextTableFormat format= table->format();
  5970. format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
  5971. if(configuration.hasAttribute("align"))
  5972. {
  5973. if(configuration.attribute("align")=="center")
  5974. {
  5975. format.setAlignment(Qt::AlignHCenter);
  5976. }
  5977. }
  5978. table->setFormat(format);
  5979. /*:566*/
  5980. #line 13069 "./typica.w"
  5981. /*567:*/
  5982. #line 13109 "./typica.w"
  5983. QDomNodeList children= configuration.childNodes();
  5984. for(int i= 0;i<children.count();i++)
  5985. {
  5986. QDomNode current;
  5987. QDomElement currentElement;
  5988. current= children.at(i);
  5989. if(current.isElement())
  5990. {
  5991. currentElement= current.toElement();
  5992. if(currentElement.tagName()=="query")
  5993. {
  5994. /*568:*/
  5995. #line 13136 "./typica.w"
  5996. SqlQueryConnection query;
  5997. query.prepare(currentElement.text());
  5998. foreach(QString key,bindings.uniqueKeys())
  5999. {
  6000. if(currentElement.text().contains(key))
  6001. {
  6002. query.bindValue(key,bindings.value(key));
  6003. }
  6004. }
  6005. query.exec();
  6006. if(!query.next())
  6007. {
  6008. continue;
  6009. }
  6010. if(query.record().count()> columns)
  6011. {
  6012. table->appendColumns(query.record().count()-columns);
  6013. }
  6014. do
  6015. {
  6016. table->appendRows(1);
  6017. rows++;
  6018. currentRow++;
  6019. for(int j= 0;j<query.record().count();j++)
  6020. {
  6021. QTextTableCell cell= table->cellAt(currentRow,j);
  6022. cursor= cell.firstCursorPosition();
  6023. cursor.insertText(query.value(j).toString());
  6024. }
  6025. }while(query.next());
  6026. /*:568*/
  6027. #line 13121 "./typica.w"
  6028. }
  6029. else if(currentElement.tagName()=="row")
  6030. {
  6031. /*569:*/
  6032. #line 13175 "./typica.w"
  6033. table->appendRows(1);
  6034. currentRow++;
  6035. rows++;
  6036. QDomNodeList rowChildren= currentElement.childNodes();
  6037. int currentColumn= 0;
  6038. for(int j= 0;j<rowChildren.count();j++)
  6039. {
  6040. QDomNode node;
  6041. QDomElement nodeElement;
  6042. node= rowChildren.at(j);
  6043. if(node.isElement())
  6044. {
  6045. nodeElement= node.toElement();
  6046. if(nodeElement.tagName()=="cell")
  6047. {
  6048. if(currentColumn==columns)
  6049. {
  6050. table->appendColumns(1);
  6051. columns++;
  6052. }
  6053. QTextTableCell cell= table->cellAt(currentRow,currentColumn);
  6054. cursor= cell.firstCursorPosition();
  6055. cursor.insertText(nodeElement.text());
  6056. currentColumn++;
  6057. }
  6058. }
  6059. }
  6060. /*:569*/
  6061. #line 13125 "./typica.w"
  6062. }
  6063. }
  6064. }
  6065. /*:567*/
  6066. #line 13070 "./typica.w"
  6067. if(rows> 1)
  6068. {
  6069. table->removeRows(0,1);
  6070. }
  6071. }
  6072. /*:564*/
  6073. #line 800 "./typica.w"
  6074. /*574:*/
  6075. #line 13277 "./typica.w"
  6076. FormArray::FormArray(QDomElement description):configuration(description),
  6077. maxwidth(-1),maxheight(-1)
  6078. {
  6079. setWidget(&itemContainer);
  6080. itemContainer.setLayout(&itemLayout);
  6081. }
  6082. /*:574*//*575:*/
  6083. #line 13294 "./typica.w"
  6084. void FormArray::addElements(int copies)
  6085. {
  6086. QStack<QWidget*> *widgetStack= new QStack<QWidget*> ;
  6087. QStack<QLayout*> *layoutStack= new QStack<QLayout*> ;
  6088. QWidget*widget;
  6089. for(int i= 0;i<copies;i++)
  6090. {
  6091. widget= new QWidget;
  6092. if(maxwidth> -1)
  6093. {
  6094. widget->setMaximumWidth(maxwidth);
  6095. }
  6096. if(maxheight> -1)
  6097. {
  6098. widget->setMaximumHeight(maxheight);
  6099. }
  6100. if(configuration.hasChildNodes())
  6101. {
  6102. widgetStack->push(widget);
  6103. populateWidget(configuration,widgetStack,layoutStack);
  6104. widgetStack->pop();
  6105. widget->setMinimumHeight(widget->sizeHint().height());
  6106. itemLayout.addWidget(widget);
  6107. if(widget->sizeHint().height()> maxheight&&maxheight> -1)
  6108. {
  6109. itemContainer.setMinimumHeight(maxheight*elements()+50);
  6110. }
  6111. else
  6112. {
  6113. itemContainer.setMinimumHeight(itemContainer.sizeHint().height()
  6114. +widget->sizeHint().height());
  6115. }
  6116. if(maxwidth> -1)
  6117. {
  6118. itemContainer.setMinimumWidth(maxwidth+50);
  6119. }
  6120. else
  6121. {
  6122. itemContainer.setMinimumWidth(widget->sizeHint().width()+50);
  6123. }
  6124. }
  6125. }
  6126. }
  6127. /*:575*//*576:*/
  6128. #line 13344 "./typica.w"
  6129. QWidget*FormArray::elementAt(int index)
  6130. {
  6131. if(index<itemLayout.count())
  6132. {
  6133. QLayoutItem*item= itemLayout.itemAt(index);
  6134. return item->widget();
  6135. }
  6136. else
  6137. {
  6138. return NULL;
  6139. }
  6140. }
  6141. /*:576*//*577:*/
  6142. #line 13361 "./typica.w"
  6143. void FormArray::removeAllElements()
  6144. {
  6145. while(itemLayout.count()> 0)
  6146. {
  6147. QLayoutItem*item;
  6148. item= itemLayout.itemAt(0);
  6149. item->widget()->hide();
  6150. itemLayout.removeWidget(item->widget());
  6151. }
  6152. itemContainer.setMinimumHeight(0);
  6153. }
  6154. /*:577*//*578:*/
  6155. #line 13377 "./typica.w"
  6156. int FormArray::elements()
  6157. {
  6158. return itemLayout.count();
  6159. }
  6160. /*:578*//*579:*/
  6161. #line 13388 "./typica.w"
  6162. void FormArray::setMaximumElementWidth(int width)
  6163. {
  6164. maxwidth= width;
  6165. }
  6166. void FormArray::setMaximumElementHeight(int height)
  6167. {
  6168. maxheight= height;
  6169. }
  6170. /*:579*/
  6171. #line 801 "./typica.w"
  6172. /*585:*/
  6173. #line 13519 "./typica.w"
  6174. ScaleControl::ScaleControl():QGraphicsView(NULL,NULL),nonScoredValue(-1),
  6175. scoredValue(-1),initialSet(false),finalSet(false),scaleDown(false)
  6176. {
  6177. left<<QPointF(0,5)<<QPointF(10,0)<<QPointF(10,10)<<
  6178. QPointF(0,5);
  6179. right<<QPointF(10,5)<<QPointF(0,0)<<QPointF(0,10)<<
  6180. QPointF(10,5);
  6181. down<<QPointF(0,0)<<QPointF(-5,-10)<<QPointF(5,-10)<<
  6182. QPointF(0,0);
  6183. up<<QPointF(0,0)<<QPointF(-5,10)<<QPointF(4,10)<<QPointF(0,0);
  6184. initialBrush.setColor(QColor(170,170,255));
  6185. initialBrush.setStyle(Qt::SolidPattern);
  6186. finalBrush.setColor(Qt::blue);
  6187. finalBrush.setStyle(Qt::SolidPattern);
  6188. initialDecrement.setPolygon(left);
  6189. initialDecrement.setBrush(initialBrush);
  6190. initialDecrement.setPos(0,0);
  6191. scene.addItem(&initialDecrement);
  6192. initialIncrement.setPolygon(right);
  6193. initialIncrement.setBrush(initialBrush);
  6194. initialIncrement.setPos(122,0);
  6195. scene.addItem(&initialIncrement);
  6196. finalDecrement.setPolygon(left);
  6197. finalDecrement.setBrush(finalBrush);
  6198. finalDecrement.setPos(0,12);
  6199. scene.addItem(&finalDecrement);
  6200. finalIncrement.setPolygon(right);
  6201. finalIncrement.setBrush(finalBrush);
  6202. finalIncrement.setPos(122,12);
  6203. scene.addItem(&finalIncrement);
  6204. scalePath.moveTo(0,10);
  6205. scalePath.lineTo(100,10);
  6206. scalePath.moveTo(0,0);
  6207. scalePath.lineTo(0,20);
  6208. scalePath.moveTo(10,5);
  6209. scalePath.lineTo(10,15);
  6210. scalePath.moveTo(20,5);
  6211. scalePath.lineTo(20,15);
  6212. scalePath.moveTo(30,5);
  6213. scalePath.lineTo(30,15);
  6214. scalePath.moveTo(40,5);
  6215. scalePath.lineTo(40,15);
  6216. scalePath.moveTo(50,0);
  6217. scalePath.lineTo(50,20);
  6218. scalePath.moveTo(60,5);
  6219. scalePath.lineTo(60,15);
  6220. scalePath.moveTo(70,5);
  6221. scalePath.lineTo(70,15);
  6222. scalePath.moveTo(80,5);
  6223. scalePath.lineTo(80,15);
  6224. scalePath.moveTo(90,5);
  6225. scalePath.lineTo(90,15);
  6226. scalePath.moveTo(100,0);
  6227. scalePath.lineTo(100,20);
  6228. scaleLine.setPath(scalePath);
  6229. scaleLine.setPos(16,1);
  6230. scene.addItem(&scaleLine);
  6231. setScene(&scene);
  6232. initialIndicator.setPolygon(down);
  6233. initialIndicator.setBrush(initialBrush);
  6234. finalIndicator.setPolygon(up);
  6235. finalIndicator.setBrush(finalBrush);
  6236. setMinimumSize(sizeHint());
  6237. setMaximumSize(sizeHint());
  6238. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6239. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6240. setMinimumSize(sizeHint());
  6241. }
  6242. /*:585*//*586:*/
  6243. #line 13592 "./typica.w"
  6244. QSize ScaleControl::sizeHint()const
  6245. {
  6246. return QSize(140,30);
  6247. }
  6248. /*:586*//*587:*/
  6249. #line 13601 "./typica.w"
  6250. void ScaleControl::setInitialValue(double value)
  6251. {
  6252. if(value>=0&&value<=10)
  6253. {
  6254. nonScoredValue= value;
  6255. if(!initialSet)
  6256. {
  6257. scene.addItem(&initialIndicator);
  6258. }
  6259. initialSet= true;
  6260. initialIndicator.setPos(value*10+16,10);
  6261. emit initialChanged(value);
  6262. if(!finalSet)
  6263. {
  6264. setFinalValue(value);
  6265. }
  6266. }
  6267. }
  6268. void ScaleControl::setFinalValue(double value)
  6269. {
  6270. if(value>=0&&value<=10)
  6271. {
  6272. scoredValue= value;
  6273. if(!finalSet)
  6274. {
  6275. scene.addItem(&finalIndicator);
  6276. }
  6277. finalSet= true;
  6278. finalIndicator.setPos(value*10+16,11);
  6279. emit finalChanged(value);
  6280. }
  6281. }
  6282. /*:587*//*588:*/
  6283. #line 13638 "./typica.w"
  6284. double ScaleControl::initialValue(void)
  6285. {
  6286. return nonScoredValue;
  6287. }
  6288. double ScaleControl::finalValue(void)
  6289. {
  6290. return scoredValue;
  6291. }
  6292. /*:588*//*589:*/
  6293. #line 13659 "./typica.w"
  6294. void ScaleControl::mousePressEvent(QMouseEvent*event)
  6295. {
  6296. /*590:*/
  6297. #line 13671 "./typica.w"
  6298. if(event->button()!=Qt::LeftButton)
  6299. {
  6300. event->ignore();
  6301. return;
  6302. }
  6303. /*:590*/
  6304. #line 13662 "./typica.w"
  6305. scaleDown= true;
  6306. event->accept();
  6307. }
  6308. /*:589*//*591:*/
  6309. #line 13682 "./typica.w"
  6310. void ScaleControl::mouseReleaseEvent(QMouseEvent*event)
  6311. {
  6312. /*590:*/
  6313. #line 13671 "./typica.w"
  6314. if(event->button()!=Qt::LeftButton)
  6315. {
  6316. event->ignore();
  6317. return;
  6318. }
  6319. /*:590*/
  6320. #line 13685 "./typica.w"
  6321. if(!scaleDown)
  6322. {
  6323. event->ignore();
  6324. return;
  6325. }
  6326. scaleDown= false;
  6327. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  6328. /*592:*/
  6329. #line 13707 "./typica.w"
  6330. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=10)
  6331. {
  6332. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  6333. {
  6334. if(initialSet)
  6335. {
  6336. setInitialValue(nonScoredValue-0.05);
  6337. }
  6338. event->accept();
  6339. return;
  6340. }
  6341. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  6342. {
  6343. if(finalSet)
  6344. {
  6345. setFinalValue(scoredValue-0.05);
  6346. event->accept();
  6347. return;
  6348. }
  6349. }
  6350. }
  6351. /*:592*/
  6352. #line 13693 "./typica.w"
  6353. /*593:*/
  6354. #line 13733 "./typica.w"
  6355. else if(sceneCoordinate.x()>=122&&sceneCoordinate.x()<=132)
  6356. {
  6357. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  6358. {
  6359. if(initialSet)
  6360. {
  6361. setInitialValue(nonScoredValue+0.05);
  6362. event->accept();
  6363. return;
  6364. }
  6365. }
  6366. else if(sceneCoordinate.y()>=12&&sceneCoordinate.y()<=22)
  6367. {
  6368. if(finalSet)
  6369. {
  6370. setFinalValue(scoredValue+0.05);
  6371. event->accept();
  6372. return;
  6373. }
  6374. }
  6375. }
  6376. /*:593*/
  6377. #line 13694 "./typica.w"
  6378. /*594:*/
  6379. #line 13759 "./typica.w"
  6380. double relativeX= sceneCoordinate.x()-16;
  6381. if(initialSet)
  6382. {
  6383. if(relativeX>=0&&relativeX<=100)
  6384. {
  6385. setFinalValue(relativeX/10.0);
  6386. event->accept();
  6387. return;
  6388. }
  6389. }
  6390. else
  6391. {
  6392. if(relativeX>=0&&relativeX<=100)
  6393. {
  6394. setInitialValue(relativeX/10.0);
  6395. event->accept();
  6396. return;
  6397. }
  6398. }
  6399. /*:594*/
  6400. #line 13695 "./typica.w"
  6401. event->ignore();
  6402. return;
  6403. }
  6404. /*:591*/
  6405. #line 802 "./typica.w"
  6406. /*596:*/
  6407. #line 13825 "./typica.w"
  6408. IntensityControl::IntensityControl():QGraphicsView(NULL,NULL),theValue(-1),
  6409. valueSet(false),scaleDown(false)
  6410. {
  6411. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6412. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  6413. left<<QPointF(0,0)<<QPointF(10,-5)<<QPointF(10,5)<<QPointF(0,0);
  6414. down<<QPointF(0,0)<<QPointF(10,0)<<QPointF(5,10)<<QPointF(0,0);
  6415. up<<QPointF(0,10)<<QPointF(10,10)<<QPointF(5,0)<<QPointF(0,10);
  6416. theBrush.setColor(Qt::blue);
  6417. theBrush.setStyle(Qt::SolidPattern);
  6418. increment.setPolygon(up);
  6419. increment.setBrush(theBrush);
  6420. increment.setPos(0,0);
  6421. scene.addItem(&increment);
  6422. decrement.setPolygon(down);
  6423. decrement.setBrush(theBrush);
  6424. decrement.setPos(0,122);
  6425. scene.addItem(&decrement);
  6426. scalePath.moveTo(5,0);
  6427. scalePath.lineTo(5,100);
  6428. scalePath.moveTo(0,0);
  6429. scalePath.lineTo(10,0);
  6430. scalePath.moveTo(0,10);
  6431. scalePath.lineTo(10,10);
  6432. scalePath.moveTo(0,20);
  6433. scalePath.lineTo(10,20);
  6434. scalePath.moveTo(0,30);
  6435. scalePath.lineTo(10,30);
  6436. scalePath.moveTo(0,40);
  6437. scalePath.lineTo(10,40);
  6438. scalePath.moveTo(0,50);
  6439. scalePath.lineTo(10,50);
  6440. scalePath.moveTo(0,60);
  6441. scalePath.lineTo(10,60);
  6442. scalePath.moveTo(0,70);
  6443. scalePath.lineTo(10,70);
  6444. scalePath.moveTo(0,80);
  6445. scalePath.lineTo(10,80);
  6446. scalePath.moveTo(0,90);
  6447. scalePath.lineTo(10,90);
  6448. scalePath.moveTo(0,100);
  6449. scalePath.lineTo(10,100);
  6450. scaleLine.setPath(scalePath);
  6451. scaleLine.setPos(0,16);
  6452. scene.addItem(&scaleLine);
  6453. setScene(&scene);
  6454. indicator.setPolygon(left);
  6455. indicator.setBrush(theBrush);
  6456. setMinimumSize(sizeHint());
  6457. setMaximumSize(sizeHint());
  6458. }
  6459. /*:596*//*597:*/
  6460. #line 13880 "./typica.w"
  6461. QSize IntensityControl::sizeHint()const
  6462. {
  6463. return QSize(25,160);
  6464. }
  6465. /*:597*//*598:*/
  6466. #line 13895 "./typica.w"
  6467. void IntensityControl::setValue(double val)
  6468. {
  6469. if(val>=0&&val<=10)
  6470. {
  6471. theValue= val;
  6472. if(!valueSet)
  6473. {
  6474. scene.addItem(&indicator);
  6475. }
  6476. valueSet= true;
  6477. indicator.setPos(6,(100-(val*10))+16);
  6478. emit(valueChanged(val));
  6479. }
  6480. else if(val<1)
  6481. {
  6482. setValue(0);
  6483. }
  6484. else
  6485. {
  6486. setValue(10);
  6487. }
  6488. }
  6489. double IntensityControl::value()
  6490. {
  6491. return theValue;
  6492. }
  6493. /*:598*//*599:*/
  6494. #line 13927 "./typica.w"
  6495. void IntensityControl::mousePressEvent(QMouseEvent*event)
  6496. {
  6497. /*590:*/
  6498. #line 13671 "./typica.w"
  6499. if(event->button()!=Qt::LeftButton)
  6500. {
  6501. event->ignore();
  6502. return;
  6503. }
  6504. /*:590*/
  6505. #line 13930 "./typica.w"
  6506. scaleDown= true;
  6507. event->accept();
  6508. }
  6509. /*:599*//*600:*/
  6510. #line 13941 "./typica.w"
  6511. void IntensityControl::mouseReleaseEvent(QMouseEvent*event)
  6512. {
  6513. /*590:*/
  6514. #line 13671 "./typica.w"
  6515. if(event->button()!=Qt::LeftButton)
  6516. {
  6517. event->ignore();
  6518. return;
  6519. }
  6520. /*:590*/
  6521. #line 13944 "./typica.w"
  6522. if(!scaleDown)
  6523. {
  6524. event->ignore();
  6525. return;
  6526. }
  6527. scaleDown= false;
  6528. QPointF sceneCoordinate= mapToScene(event->x(),event->y());
  6529. if(sceneCoordinate.x()>=0&&sceneCoordinate.x()<=16)
  6530. {
  6531. if(sceneCoordinate.y()>=0&&sceneCoordinate.y()<=10)
  6532. {
  6533. if(valueSet)
  6534. {
  6535. setValue(theValue+0.05);
  6536. }
  6537. event->accept();
  6538. return;
  6539. }
  6540. else if(sceneCoordinate.y()>=122&&sceneCoordinate.y()<=132)
  6541. {
  6542. if(valueSet)
  6543. {
  6544. setValue(theValue-0.05);
  6545. }
  6546. event->accept();
  6547. return;
  6548. }
  6549. else if(sceneCoordinate.y()>=16&&sceneCoordinate.y()<=116)
  6550. {
  6551. setValue(10-((sceneCoordinate.y()-16)/10.0));
  6552. event->accept();
  6553. return;
  6554. }
  6555. }
  6556. }
  6557. /*:600*/
  6558. #line 803 "./typica.w"
  6559. /*298:*/
  6560. #line 7486 "./typica.w"
  6561. void ThresholdDetector::newMeasurement(Measurement measure)
  6562. {
  6563. if((currentDirection==Ascending&&previousValue<threshold&&
  6564. previousValue>=0)||(currentDirection==Descending&&
  6565. previousValue> threshold&&previousValue>=0))
  6566. {
  6567. if((currentDirection==Ascending&&measure.temperature()>=threshold)||
  6568. (currentDirection==Descending&&measure.temperature()<=threshold))
  6569. {
  6570. double offset= measure.time().hour()*60*60;
  6571. offset+= measure.time().minute()*60;
  6572. offset+= measure.time().second();
  6573. offset+= measure.time().msec()/1000;
  6574. emit timeForValue(offset);
  6575. }
  6576. }
  6577. previousValue= measure.temperature();
  6578. }
  6579. ThresholdDetector::ThresholdDetector(double value):QObject(NULL),
  6580. previousValue(-1),threshold(value),currentDirection(Ascending)
  6581. {
  6582. }
  6583. void ThresholdDetector::setThreshold(double value)
  6584. {
  6585. threshold= value;
  6586. }
  6587. void ThresholdDetector::setEdgeDirection(EdgeDirection direction)
  6588. {
  6589. currentDirection= direction;
  6590. }
  6591. /*:298*/
  6592. #line 804 "./typica.w"
  6593. /*682:*/
  6594. #line 15717 "./typica.w"
  6595. PortSelector::PortSelector(QWidget*parent):QComboBox(parent),
  6596. lister(new QextSerialEnumerator)
  6597. {
  6598. QList<QextPortInfo> ports= QextSerialEnumerator::getPorts();
  6599. QextPortInfo port;
  6600. foreach(port,ports)
  6601. {
  6602. addItem(port.portName);
  6603. }
  6604. lister->setUpNotifications();
  6605. connect(lister,SIGNAL(deviceDiscovered(QextPortInfo)),
  6606. this,SLOT(addDevice(QextPortInfo)));
  6607. setEditable(true);
  6608. }
  6609. void PortSelector::addDevice(QextPortInfo port)
  6610. {
  6611. addItem(port.portName);
  6612. }
  6613. /*:682*/
  6614. #line 805 "./typica.w"
  6615. /*684:*/
  6616. #line 15805 "./typica.w"
  6617. BaudSelector::BaudSelector(QWidget*parent):QComboBox(parent)
  6618. {
  6619. QMetaObject meta= BaudSelector::staticMetaObject;
  6620. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("BaudRateType"));
  6621. for(int i= 0;i<type.keyCount();i++)
  6622. {
  6623. addItem(QString("%1").arg(type.value(i)));
  6624. }
  6625. }
  6626. /*:684*/
  6627. #line 806 "./typica.w"
  6628. /*686:*/
  6629. #line 15843 "./typica.w"
  6630. ParitySelector::ParitySelector(QWidget*parent):QComboBox(parent)
  6631. {
  6632. QMetaObject meta= ParitySelector::staticMetaObject;
  6633. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("ParityType"));
  6634. for(int i= 0;i<type.keyCount();i++)
  6635. {
  6636. addItem(QString(type.key(i)),QVariant(type.value(i)));
  6637. }
  6638. }
  6639. /*:686*/
  6640. #line 807 "./typica.w"
  6641. /*688:*/
  6642. #line 15873 "./typica.w"
  6643. FlowSelector::FlowSelector(QWidget*parent):QComboBox(parent)
  6644. {
  6645. QMetaObject meta= FlowSelector::staticMetaObject;
  6646. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("FlowType"));
  6647. for(int i= 0;i<type.keyCount();i++)
  6648. {
  6649. addItem(QString(type.key(i)),QVariant(type.value(i)));
  6650. }
  6651. }
  6652. /*:688*/
  6653. #line 808 "./typica.w"
  6654. /*690:*/
  6655. #line 15908 "./typica.w"
  6656. StopSelector::StopSelector(QWidget*parent):QComboBox(parent)
  6657. {
  6658. QMetaObject meta= StopSelector::staticMetaObject;
  6659. QMetaEnum type= meta.enumerator(meta.indexOfEnumerator("StopBitsType"));
  6660. for(int i= 0;i<type.keyCount();i++)
  6661. {
  6662. addItem(QString(type.key(i)),QVariant(type.value(i)));
  6663. }
  6664. }
  6665. /*:690*/
  6666. #line 809 "./typica.w"
  6667. /*730:*/
  6668. #line 17653 "./typica.w"
  6669. ModbusConfigurator::ModbusConfigurator(DeviceTreeModel*model,const QModelIndex&index)
  6670. :BasicDeviceConfigurationWidget(model,index),
  6671. port(new PortSelector),baud(new BaudSelector),parity(new ParitySelector),
  6672. flow(new FlowSelector),stop(new StopSelector),station(new QSpinBox),
  6673. decimalQuery(new QCheckBox(tr("Enable"))),
  6674. decimalAddress(new ShortHexSpinBox),decimalPosition(new QSpinBox),
  6675. unitQuery(new QCheckBox(tr("Enable"))),
  6676. unitAddress(new ShortHexSpinBox),valueF(new QSpinBox),
  6677. valueC(new QSpinBox),fixedUnit(new QComboBox),
  6678. pVAddress(new ShortHexSpinBox),
  6679. sVEnabled(new QCheckBox(tr("Enable"))),
  6680. sVReadAddress(new ShortHexSpinBox),
  6681. deviceLimit(new QCheckBox(tr("Enable"))),
  6682. sVLowerAddr(new ShortHexSpinBox),sVUpperAddr(new ShortHexSpinBox),
  6683. sVLower(new QDoubleSpinBox),sVUpper(new QDoubleSpinBox),
  6684. sVWritable(new QCheckBox(tr("Enable"))),
  6685. sVOutputAddr(new ShortHexSpinBox),
  6686. pVColumnName(new QLineEdit),sVColumnName(new QLineEdit)
  6687. {
  6688. QHBoxLayout*layout= new QHBoxLayout;
  6689. QWidget*form= new QWidget;
  6690. QHBoxLayout*masterLayout= new QHBoxLayout;
  6691. QVBoxLayout*portAndDeviceLayout= new QVBoxLayout;
  6692. QVBoxLayout*seriesLayout= new QVBoxLayout;
  6693. QFormLayout*serialSection= new QFormLayout;
  6694. serialSection->addRow(QString(tr("Port:")),port);
  6695. serialSection->addRow(QString(tr("Baud rate:")),baud);
  6696. serialSection->addRow(QString(tr("Parity:")),parity);
  6697. serialSection->addRow(QString(tr("Flow control:")),flow);
  6698. serialSection->addRow(QString(tr("Stop bits:")),stop);
  6699. QGroupBox*serialSectionBox= new QGroupBox(tr("Serial Port Configuration"));
  6700. serialSectionBox->setLayout(serialSection);
  6701. portAndDeviceLayout->addWidget(serialSectionBox);
  6702. QFormLayout*deviceSection= new QFormLayout;
  6703. station->setMinimum(1);
  6704. station->setMaximum(255);
  6705. decimalPosition->setMinimum(0);
  6706. decimalPosition->setMaximum(9);
  6707. valueF->setMinimum(0);
  6708. valueF->setMaximum(0xFFFF);
  6709. valueC->setMinimum(0);
  6710. valueC->setMaximum(0xFFFF);
  6711. fixedUnit->addItem(tr("Fahrenheit"),QVariant(QString("F")));
  6712. fixedUnit->addItem(tr("Celsius"),QVariant(QString("C")));
  6713. deviceSection->addRow(tr("Station:"),station);
  6714. deviceSection->addRow(tr("Decimal position from device:"),decimalQuery);
  6715. deviceSection->addRow(tr("Decimal position relative address:"),decimalAddress);
  6716. deviceSection->addRow(tr("Fixed decimal position:"),decimalPosition);
  6717. deviceSection->addRow(tr("Measurement unit from device:"),unitQuery);
  6718. deviceSection->addRow(tr("Current unit relative address:"),unitAddress);
  6719. deviceSection->addRow(tr("Value for Fahrenheit:"),valueF);
  6720. deviceSection->addRow(tr("Value for Celsius:"),valueC);
  6721. deviceSection->addRow(tr("Fixed unit:"),fixedUnit);
  6722. QGroupBox*deviceSectionBox= new QGroupBox(tr("Device Configuration"));
  6723. deviceSectionBox->setLayout(deviceSection);
  6724. portAndDeviceLayout->addWidget(deviceSectionBox);
  6725. QFormLayout*pVSection= new QFormLayout;
  6726. pVSection->addRow(tr("Value relative address:"),pVAddress);
  6727. pVSection->addRow(tr("PV column name:"),pVColumnName);
  6728. QGroupBox*processValueBox= new QGroupBox(tr("Process Value"));
  6729. processValueBox->setLayout(pVSection);
  6730. seriesLayout->addWidget(processValueBox);
  6731. QFormLayout*sVSection= new QFormLayout;
  6732. sVLower->setDecimals(1);
  6733. sVLower->setMinimum(0.0);
  6734. sVLower->setMaximum(999.9);
  6735. sVUpper->setDecimals(1);
  6736. sVUpper->setMinimum(0.0);
  6737. sVUpper->setMaximum(999.9);
  6738. sVSection->addRow(tr("Set value:"),sVEnabled);
  6739. sVSection->addRow(tr("Read relative address:"),sVReadAddress);
  6740. sVSection->addRow(tr("SV column name:"),sVColumnName);
  6741. sVSection->addRow(tr("Limits from device:"),deviceLimit);
  6742. sVSection->addRow(tr("Lower limit relative address:"),sVLowerAddr);
  6743. sVSection->addRow(tr("Upper limit relative address:"),sVUpperAddr);
  6744. sVSection->addRow(tr("Lower limit:"),sVLower);
  6745. sVSection->addRow(tr("Upper limit:"),sVUpper);
  6746. sVSection->addRow(tr("Output set value:"),sVWritable);
  6747. sVSection->addRow(tr("Output relative address:"),sVOutputAddr);
  6748. QGroupBox*setValueBox= new QGroupBox(tr("Set Value"));
  6749. setValueBox->setLayout(sVSection);
  6750. seriesLayout->addWidget(setValueBox);
  6751. masterLayout->addLayout(portAndDeviceLayout);
  6752. masterLayout->addLayout(seriesLayout);
  6753. form->setLayout(masterLayout);
  6754. /*658:*/
  6755. #line 15201 "./typica.w"
  6756. QDomElement referenceElement=
  6757. model->referenceElement(model->data(index,Qt::UserRole).toString());
  6758. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  6759. QDomElement node;
  6760. /*:658*/
  6761. #line 17739 "./typica.w"
  6762. for(int i= 0;i<configData.size();i++)
  6763. {
  6764. node= configData.at(i).toElement();
  6765. if(node.attribute("name")=="port")
  6766. {
  6767. QString portname= node.attribute("value");
  6768. int idx= port->findText(portname);
  6769. if(idx>=0)
  6770. {
  6771. port->setCurrentIndex(idx);
  6772. }
  6773. else
  6774. {
  6775. port->addItem(portname);
  6776. }
  6777. }
  6778. else if(node.attribute("name")=="baud")
  6779. {
  6780. baud->setCurrentIndex(baud->findText(node.attribute("value")));
  6781. }
  6782. else if(node.attribute("name")=="parity")
  6783. {
  6784. parity->setCurrentIndex(parity->findData(node.attribute("value")));
  6785. }
  6786. else if(node.attribute("name")=="flow")
  6787. {
  6788. flow->setCurrentIndex(flow->findData(node.attribute("value")));
  6789. }
  6790. else if(node.attribute("name")=="stop")
  6791. {
  6792. stop->setCurrentIndex(stop->findData(node.attribute("value")));
  6793. }
  6794. else if(node.attribute("name")=="station")
  6795. {
  6796. station->setValue(node.attribute("value").toInt());
  6797. }
  6798. else if(node.attribute("name")=="decimalQuery")
  6799. {
  6800. if(node.attribute("value")=="true")
  6801. {
  6802. decimalQuery->setChecked(true);
  6803. }
  6804. else
  6805. {
  6806. decimalQuery->setChecked(false);
  6807. }
  6808. }
  6809. else if(node.attribute("name")=="decimalAddress")
  6810. {
  6811. decimalAddress->setValue(node.attribute("value").toInt());
  6812. }
  6813. else if(node.attribute("name")=="decimalPosition")
  6814. {
  6815. decimalPosition->setValue(node.attribute("value").toInt());
  6816. }
  6817. else if(node.attribute("name")=="unitQuery")
  6818. {
  6819. if(node.attribute("value")=="true")
  6820. {
  6821. unitQuery->setChecked(true);
  6822. }
  6823. else
  6824. {
  6825. unitQuery->setChecked(false);
  6826. }
  6827. }
  6828. else if(node.attribute("name")=="unitAddress")
  6829. {
  6830. unitAddress->setValue(node.attribute("value").toInt());
  6831. }
  6832. else if(node.attribute("name")=="valueF")
  6833. {
  6834. valueF->setValue(node.attribute("value").toInt());
  6835. }
  6836. else if(node.attribute("name")=="valueC")
  6837. {
  6838. valueC->setValue(node.attribute("value").toInt());
  6839. }
  6840. else if(node.attribute("name")=="fixedUnit")
  6841. {
  6842. fixedUnit->setCurrentIndex(fixedUnit->findText(node.attribute("value")));
  6843. }
  6844. else if(node.attribute("name")=="pVAddress")
  6845. {
  6846. pVAddress->setValue(node.attribute("value").toInt());
  6847. }
  6848. else if(node.attribute("name")=="sVEnabled")
  6849. {
  6850. if(node.attribute("value")=="true")
  6851. {
  6852. sVEnabled->setChecked(true);
  6853. }
  6854. else
  6855. {
  6856. sVEnabled->setChecked(false);
  6857. }
  6858. }
  6859. else if(node.attribute("name")=="sVReadAddress")
  6860. {
  6861. sVReadAddress->setValue(node.attribute("value").toInt());
  6862. }
  6863. else if(node.attribute("name")=="deviceLimit")
  6864. {
  6865. if(node.attribute("value")=="true")
  6866. {
  6867. deviceLimit->setChecked(true);
  6868. }
  6869. else
  6870. {
  6871. deviceLimit->setChecked(false);
  6872. }
  6873. }
  6874. else if(node.attribute("name")=="sVLowerAddr")
  6875. {
  6876. sVLowerAddr->setValue(node.attribute("value").toInt());
  6877. }
  6878. else if(node.attribute("name")=="sVUpperAddr")
  6879. {
  6880. sVUpperAddr->setValue(node.attribute("value").toInt());
  6881. }
  6882. else if(node.attribute("name")=="sVLower")
  6883. {
  6884. sVLower->setValue(node.attribute("value").toDouble());
  6885. }
  6886. else if(node.attribute("name")=="sVUpper")
  6887. {
  6888. sVUpper->setValue(node.attribute("value").toDouble());
  6889. }
  6890. else if(node.attribute("name")=="sVWritable")
  6891. {
  6892. if(node.attribute("value")=="true")
  6893. {
  6894. sVWritable->setChecked(true);
  6895. }
  6896. else
  6897. {
  6898. sVWritable->setChecked(false);
  6899. }
  6900. }
  6901. else if(node.attribute("name")=="sVOutputAddr")
  6902. {
  6903. sVOutputAddr->setValue(node.attribute("value").toInt());
  6904. }
  6905. else if(node.attribute("name")=="pvcolname")
  6906. {
  6907. pVColumnName->setText(node.attribute("value"));
  6908. }
  6909. else if(node.attribute("name")=="svcolname")
  6910. {
  6911. sVColumnName->setText(node.attribute("value"));
  6912. }
  6913. }
  6914. updatePort(port->currentText());
  6915. updateBaudRate(baud->currentText());
  6916. updateParity(parity->itemData(parity->currentIndex()).toString());
  6917. updateFlowControl(flow->itemData(flow->currentIndex()).toString());
  6918. updateStopBits(stop->itemData(stop->currentIndex()).toString());
  6919. updateStation(station->value());
  6920. updateFixedDecimal(decimalQuery->isChecked());
  6921. updateDecimalAddress(decimalAddress->value());
  6922. updateDecimalPosition(decimalPosition->value());
  6923. updateFixedUnit(unitQuery->isChecked());
  6924. updateUnitAddress(unitAddress->value());
  6925. updateValueForF(valueF->value());
  6926. updateValueForC(valueC->value());
  6927. updateUnit(fixedUnit->currentText());
  6928. updatePVAddress(pVAddress->value());
  6929. updateSVEnabled(sVEnabled->isChecked());
  6930. updateSVReadAddress(sVReadAddress->value());
  6931. updateDeviceLimit(deviceLimit->isChecked());
  6932. updateSVLowerAddress(sVLowerAddr->value());
  6933. updateSVUpperAddress(sVUpperAddr->value());
  6934. updateSVLower(sVLower->value());
  6935. updateSVUpper(sVUpper->value());
  6936. updateSVWritable(sVWritable->isChecked());
  6937. updateSVWriteAddress(sVOutputAddr->value());
  6938. updatePVColumnName(pVColumnName->text());
  6939. updateSVColumnName(sVColumnName->text());
  6940. connect(port,SIGNAL(currentIndexChanged(QString)),this,SLOT(updatePort(QString)));
  6941. connect(port,SIGNAL(editTextChanged(QString)),this,SLOT(updatePort(QString)));
  6942. connect(baud,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateBaudRate(QString)));
  6943. connect(parity,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateParity(QString)));
  6944. connect(flow,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateFlowControl(QString)));
  6945. connect(stop,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateStopBits(QString)));
  6946. connect(station,SIGNAL(valueChanged(int)),this,SLOT(updateStation(int)));
  6947. connect(decimalQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedDecimal(bool)));
  6948. connect(decimalAddress,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalAddress(int)));
  6949. connect(decimalPosition,SIGNAL(valueChanged(int)),this,SLOT(updateDecimalPosition(int)));
  6950. connect(unitQuery,SIGNAL(toggled(bool)),this,SLOT(updateFixedUnit(bool)));
  6951. connect(unitAddress,SIGNAL(valueChanged(int)),this,SLOT(updateUnitAddress(int)));
  6952. connect(valueF,SIGNAL(valueChanged(int)),this,SLOT(updateValueForF(int)));
  6953. connect(valueC,SIGNAL(valueChanged(int)),this,SLOT(updateValueForC(int)));
  6954. connect(fixedUnit,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateUnit(QString)));
  6955. connect(pVAddress,SIGNAL(valueChanged(int)),this,SLOT(updatePVAddress(int)));
  6956. connect(sVEnabled,SIGNAL(toggled(bool)),this,SLOT(updateSVEnabled(bool)));
  6957. connect(sVReadAddress,SIGNAL(valueChanged(int)),this,SLOT(updateSVReadAddress(int)));
  6958. connect(deviceLimit,SIGNAL(toggled(bool)),this,SLOT(updateDeviceLimit(bool)));
  6959. connect(sVLowerAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVLowerAddress(int)));
  6960. connect(sVUpperAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVUpperAddress(int)));
  6961. connect(sVLower,SIGNAL(valueChanged(double)),this,SLOT(updateSVLower(double)));
  6962. connect(sVUpper,SIGNAL(valueChanged(double)),this,SLOT(updateSVUpper(double)));
  6963. connect(sVWritable,SIGNAL(toggled(bool)),this,SLOT(updateSVWritable(bool)));
  6964. connect(sVOutputAddr,SIGNAL(valueChanged(int)),this,SLOT(updateSVWriteAddress(int)));
  6965. connect(pVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updatePVColumnName(QString)));
  6966. connect(sVColumnName,SIGNAL(textEdited(QString)),this,SLOT(updateSVColumnName(QString)));
  6967. layout->addWidget(form);
  6968. setLayout(layout);
  6969. }
  6970. void ModbusConfigurator::updatePort(const QString&newPort)
  6971. {
  6972. updateAttribute("port",newPort);
  6973. }
  6974. void ModbusConfigurator::updateBaudRate(const QString&newRate)
  6975. {
  6976. updateAttribute("baud",newRate);
  6977. }
  6978. void ModbusConfigurator::updateParity(const QString&)
  6979. {
  6980. updateAttribute("parity",parity->itemData(parity->currentIndex()).toString());
  6981. }
  6982. void ModbusConfigurator::updateFlowControl(const QString&)
  6983. {
  6984. updateAttribute("flow",flow->itemData(flow->currentIndex()).toString());
  6985. }
  6986. void ModbusConfigurator::updateStopBits(const QString&)
  6987. {
  6988. updateAttribute("stop",stop->itemData(stop->currentIndex()).toString());
  6989. }
  6990. void ModbusConfigurator::updateStation(int station)
  6991. {
  6992. updateAttribute("station",QString("%1").arg(station));
  6993. }
  6994. void ModbusConfigurator::updateFixedDecimal(bool fixed)
  6995. {
  6996. updateAttribute("decimalQuery",fixed?"true":"false");
  6997. }
  6998. void ModbusConfigurator::updateDecimalAddress(int address)
  6999. {
  7000. updateAttribute("decimalAddress",QString("%1").arg(address));
  7001. }
  7002. void ModbusConfigurator::updateDecimalPosition(int position)
  7003. {
  7004. updateAttribute("decimalPosition",QString("%1").arg(position));
  7005. }
  7006. void ModbusConfigurator::updateFixedUnit(bool fixed)
  7007. {
  7008. updateAttribute("unitQuery",fixed?"true":"false");
  7009. }
  7010. void ModbusConfigurator::updateUnitAddress(int address)
  7011. {
  7012. updateAttribute("unitAddress",QString("%1").arg(address));
  7013. }
  7014. void ModbusConfigurator::updateValueForF(int value)
  7015. {
  7016. updateAttribute("valueF",QString("%1").arg(value));
  7017. }
  7018. void ModbusConfigurator::updateValueForC(int value)
  7019. {
  7020. updateAttribute("valueC",QString("%1").arg(value));
  7021. }
  7022. void ModbusConfigurator::updateUnit(const QString&newUnit)
  7023. {
  7024. updateAttribute("fixedUnit",newUnit);
  7025. }
  7026. void ModbusConfigurator::updatePVAddress(int address)
  7027. {
  7028. updateAttribute("pVAddress",QString("%1").arg(address));
  7029. }
  7030. void ModbusConfigurator::updateSVEnabled(bool enabled)
  7031. {
  7032. updateAttribute("sVEnabled",enabled?"true":"false");
  7033. }
  7034. void ModbusConfigurator::updateSVReadAddress(int address)
  7035. {
  7036. updateAttribute("sVReadAddress",QString("%1").arg(address));
  7037. }
  7038. void ModbusConfigurator::updateDeviceLimit(bool query)
  7039. {
  7040. updateAttribute("deviceLimit",query?"true":"false");
  7041. }
  7042. void ModbusConfigurator::updateSVLowerAddress(int address)
  7043. {
  7044. updateAttribute("sVLowerAddr",QString("%1").arg(address));
  7045. }
  7046. void ModbusConfigurator::updateSVUpperAddress(int address)
  7047. {
  7048. updateAttribute("sVUpperAddr",QString("%1").arg(address));
  7049. }
  7050. void ModbusConfigurator::updateSVLower(double value)
  7051. {
  7052. updateAttribute("sVLower",QString("%1").arg(value));
  7053. }
  7054. void ModbusConfigurator::updateSVUpper(double value)
  7055. {
  7056. updateAttribute("sVUpper",QString("%1").arg(value));
  7057. }
  7058. void ModbusConfigurator::updateSVWritable(bool canWriteSV)
  7059. {
  7060. updateAttribute("sVWritable",canWriteSV?"true":"false");
  7061. }
  7062. void ModbusConfigurator::updateSVWriteAddress(int address)
  7063. {
  7064. updateAttribute("sVOutputAddr",QString("%1").arg(address));
  7065. }
  7066. void ModbusConfigurator::updatePVColumnName(const QString&name)
  7067. {
  7068. updateAttribute("pvcolname",name);
  7069. }
  7070. void ModbusConfigurator::updateSVColumnName(const QString&name)
  7071. {
  7072. updateAttribute("svcolname",name);
  7073. }
  7074. /*:730*/
  7075. #line 810 "./typica.w"
  7076. /*693:*/
  7077. #line 15957 "./typica.w"
  7078. ShortHexSpinBox::ShortHexSpinBox(QWidget*parent):QSpinBox(parent)
  7079. {
  7080. setMinimum(0);
  7081. setMaximum(0xFFFF);
  7082. setPrefix("0x");
  7083. setMinimumWidth(65);
  7084. }
  7085. QValidator::State ShortHexSpinBox::validate(QString&input,int&)const
  7086. {
  7087. if(input.size()==2)
  7088. {
  7089. return QValidator::Intermediate;
  7090. }
  7091. bool okay;
  7092. input.toInt(&okay,16);
  7093. if(okay)
  7094. {
  7095. return QValidator::Acceptable;
  7096. }
  7097. return QValidator::Invalid;
  7098. }
  7099. int ShortHexSpinBox::valueFromText(const QString&text)const
  7100. {
  7101. return text.toInt(NULL,16);
  7102. }
  7103. QString ShortHexSpinBox::textFromValue(int value)const
  7104. {
  7105. QString retval;
  7106. retval.setNum(value,16);
  7107. while(retval.size()<4)
  7108. {
  7109. retval.prepend("0");
  7110. }
  7111. return retval.toUpper();
  7112. }
  7113. /*:693*/
  7114. #line 811 "./typica.w"
  7115. /*715:*/
  7116. #line 16983 "./typica.w"
  7117. ModbusRTUDevice::ModbusRTUDevice(DeviceTreeModel*model,const QModelIndex&index)
  7118. :QObject(NULL),messageDelayTimer(new QTimer),unitIsF(true),readingsv(false),
  7119. waiting(false)
  7120. {
  7121. QDomElement portReferenceElement= model->referenceElement(model->data(index,
  7122. Qt::UserRole).toString());
  7123. QDomNodeList portConfigData= portReferenceElement.elementsByTagName("attribute");
  7124. QDomElement node;
  7125. QVariantMap attributes;
  7126. for(int i= 0;i<portConfigData.size();i++)
  7127. {
  7128. node= portConfigData.at(i).toElement();
  7129. attributes.insert(node.attribute("name"),node.attribute("value"));
  7130. }
  7131. port= new QextSerialPort(attributes.value("port").toString(),
  7132. QextSerialPort::EventDriven);
  7133. int baudRate= attributes.value("baud").toInt();
  7134. port->setBaudRate((BaudRateType)baudRate);
  7135. double temp= ((double)(1)/(double)(baudRate))*48;
  7136. delayTime= (int)(temp*3000);
  7137. messageDelayTimer->setSingleShot(true);
  7138. connect(messageDelayTimer,SIGNAL(timeout()),this,SLOT(sendNextMessage()));
  7139. port->setDataBits(DATA_8);
  7140. port->setParity((ParityType)attributes.value("parity").toInt());
  7141. port->setStopBits((StopBitsType)attributes.value("stop").toInt());
  7142. port->setFlowControl((FlowType)attributes.value("flow").toInt());
  7143. connect(port,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  7144. port->open(QIODevice::ReadWrite);
  7145. station= (char)attributes.value("station").toInt();
  7146. if(attributes.value("decimalQuery")=="true")
  7147. {
  7148. decimalPosition= 0;
  7149. QByteArray message;
  7150. message.append(station);
  7151. message.append((char)0x03);
  7152. quint16 address= (quint16)attributes.value("decimalAddress").toInt();
  7153. char*addressBytes= (char*)&address;
  7154. message.append(addressBytes[1]);
  7155. message.append(addressBytes[0]);
  7156. message.append((char)0x00);
  7157. message.append((char)0x01);
  7158. queueMessage(message,this,"decimalResponse(QByteArray)");
  7159. }
  7160. else
  7161. {
  7162. decimalPosition= attributes.value("decimalPosition").toInt();
  7163. }
  7164. valueF= attributes.value("valueF").toInt();
  7165. valueC= attributes.value("valueC").toInt();
  7166. if(attributes.value("unitQuery")=="true")
  7167. {
  7168. QByteArray message;
  7169. message.append(station);
  7170. message.append((char)0x03);
  7171. quint16 address= (quint16)attributes.value("unitAddress").toInt();
  7172. char*addressBytes= (char*)&address;
  7173. message.append(addressBytes[1]);
  7174. message.append(addressBytes[0]);
  7175. message.append((char)0x00);
  7176. message.append((char)0x01);
  7177. queueMessage(message,this,"unitResponse(QByteArray)");
  7178. }
  7179. else
  7180. {
  7181. if(attributes.value("fixedUnit")=="Celsius")
  7182. {
  7183. unitIsF= false;
  7184. }
  7185. }
  7186. if(attributes.value("sVWritable")=="true")
  7187. {
  7188. if(attributes.value("deviceLimit")=="true")
  7189. {
  7190. QByteArray lmessage;
  7191. lmessage.append(station);
  7192. lmessage.append((char)0x03);
  7193. quint16 laddress= (quint16)attributes.value("sVLowerAddr").toInt();
  7194. char*addressBytes= (char*)&laddress;
  7195. lmessage.append(addressBytes[1]);
  7196. lmessage.append(addressBytes[0]);
  7197. lmessage.append((char)0x00);
  7198. lmessage.append((char)0x01);
  7199. queueMessage(lmessage,this,"svlResponse(QByteArray)");
  7200. QByteArray umessage;
  7201. umessage.append(station);
  7202. umessage.append((char)0x03);
  7203. quint16 uaddress= (quint16)attributes.value("sVUpperAddr").toInt();
  7204. addressBytes= (char*)&uaddress;
  7205. umessage.append(addressBytes[1]);
  7206. umessage.append(addressBytes[0]);
  7207. umessage.append((char)0x00);
  7208. umessage.append((char)0x01);
  7209. queueMessage(umessage,this,"svuResponse(QByteArray)");
  7210. }
  7211. else
  7212. {
  7213. outputSVLower= attributes.value("sVLower").toDouble();
  7214. outputSVUpper= attributes.value("sVUpper").toDouble();
  7215. }
  7216. outputSVStub.append(station);
  7217. outputSVStub.append((char)0x06);
  7218. quint16 address= (quint16)attributes.value("sVOutputAddr").toInt();
  7219. char*addressBytes= (char*)&address;
  7220. outputSVStub.append(addressBytes[1]);
  7221. outputSVStub.append(addressBytes[0]);
  7222. }
  7223. Channel*pv= new Channel;
  7224. channels.append(pv);
  7225. pvStub.append(station);
  7226. pvStub.append((char)0x04);
  7227. pvaddress= (quint16)attributes.value("pVAddress").toInt();
  7228. char*pvac= (char*)&pvaddress;
  7229. pvStub.append(pvac[1]);
  7230. pvStub.append(pvac[0]);
  7231. pvStub.append((char)0x00);
  7232. pvStub.append((char)0x01);
  7233. svenabled= attributes.value("sVEnabled").toBool();
  7234. if(svenabled)
  7235. {
  7236. Channel*sv= new Channel;
  7237. channels.append(sv);
  7238. svStub.append(station);
  7239. svStub.append((char)0x04);
  7240. svaddress= (quint16)attributes.value("sVReadAddress").toInt();
  7241. char*svac= (char*)&svaddress;
  7242. svStub.append(svac[1]);
  7243. svStub.append(svac[0]);
  7244. svStub.append((char)0x00);
  7245. svStub.append((char)0x01);
  7246. if(svaddress-pvaddress==1)
  7247. {
  7248. mStub.append(station);
  7249. mStub.append((char)0x04);
  7250. mStub.append(pvac[1]);
  7251. mStub.append(pvac[0]);
  7252. mStub.append((char)0x00);
  7253. mStub.append((char)0x02);
  7254. }
  7255. }
  7256. connect(this,SIGNAL(queueEmpty()),this,SLOT(requestMeasurement()));
  7257. requestMeasurement();
  7258. }
  7259. double ModbusRTUDevice::SVLower()
  7260. {
  7261. return outputSVLower;
  7262. }
  7263. double ModbusRTUDevice::SVUpper()
  7264. {
  7265. return outputSVUpper;
  7266. }
  7267. int ModbusRTUDevice::decimals()
  7268. {
  7269. return decimalPosition;
  7270. }
  7271. void ModbusRTUDevice::decimalResponse(QByteArray response)
  7272. {
  7273. quint16 temp;
  7274. char*tchar= (char*)&temp;
  7275. tchar[1]= response.at(3);
  7276. tchar[0]= response.at(4);
  7277. decimalPosition= temp;
  7278. emit SVDecimalChanged(decimalPosition);
  7279. qDebug()<<"Received decimal response";
  7280. }
  7281. void ModbusRTUDevice::unitResponse(QByteArray response)
  7282. {
  7283. quint16 temp;
  7284. char*tchar= (char*)&temp;
  7285. tchar[1]= response.at(3);
  7286. tchar[0]= response.at(4);
  7287. int value= temp;
  7288. if(value==valueF)
  7289. {
  7290. unitIsF= true;
  7291. }
  7292. else
  7293. {
  7294. unitIsF= false;
  7295. }
  7296. }
  7297. void ModbusRTUDevice::svlResponse(QByteArray response)
  7298. {
  7299. quint16 temp;
  7300. char*tchar= (char*)&temp;
  7301. tchar[1]= response.at(3);
  7302. tchar[0]= response.at(4);
  7303. outputSVLower= (double)temp;
  7304. for(int i= 0;i<decimalPosition;i++)
  7305. {
  7306. outputSVLower/= 10;
  7307. }
  7308. emit SVLowerChanged(outputSVLower);
  7309. }
  7310. void ModbusRTUDevice::svuResponse(QByteArray response)
  7311. {
  7312. quint16 temp;
  7313. char*tchar= (char*)&temp;
  7314. tchar[1]= response.at(3);
  7315. tchar[0]= response.at(4);
  7316. outputSVUpper= (double)temp;
  7317. for(int i= 0;i<decimalPosition;i++)
  7318. {
  7319. outputSVUpper/= 10;
  7320. }
  7321. emit SVUpperChanged(outputSVUpper);
  7322. }
  7323. void ModbusRTUDevice::requestMeasurement()
  7324. {
  7325. if(mStub.length()> 0)
  7326. {
  7327. queueMessage(mStub,this,"mResponse(QByteArray)");
  7328. }
  7329. else
  7330. {
  7331. queueMessage(pvStub,this,"mResponse(QByteArray)");
  7332. if(svenabled)
  7333. {
  7334. queueMessage(svStub,this,"mResponse(QByteArray)");
  7335. }
  7336. }
  7337. }
  7338. void ModbusRTUDevice::mResponse(QByteArray response)
  7339. {
  7340. QTime time= QTime::currentTime();
  7341. if(response.at(2)==0x04)
  7342. {
  7343. /*716:*/
  7344. #line 17232 "./typica.w"
  7345. quint16 pv;
  7346. quint16 sv;
  7347. char*pvBytes= (char*)&pv;
  7348. char*svBytes= (char*)&sv;
  7349. pvBytes[1]= response.at(3);
  7350. pvBytes[0]= response.at(4);
  7351. svBytes[1]= response.at(5);
  7352. svBytes[0]= response.at(6);
  7353. double pvOut= (double)pv;
  7354. double svOut= (double)sv;
  7355. for(int i= 0;i<decimalPosition;i++)
  7356. {
  7357. pvOut/= 10;
  7358. svOut/= 10;
  7359. }
  7360. if(!unitIsF)
  7361. {
  7362. pvOut= pvOut*9/5+32;
  7363. svOut= svOut*9/5+32;
  7364. }
  7365. Measurement pvm(pvOut,time,Measurement::Fahrenheit);
  7366. Measurement svm(svOut,time,Measurement::Fahrenheit);
  7367. channels.at(0)->input(pvm);
  7368. channels.at(1)->input(svm);
  7369. /*:716*/
  7370. #line 17219 "./typica.w"
  7371. }
  7372. else
  7373. {
  7374. /*717:*/
  7375. #line 17262 "./typica.w"
  7376. quint16 value;
  7377. char*valueBytes= (char*)&value;
  7378. valueBytes[1]= response.at(3);
  7379. valueBytes[0]= response.at(4);
  7380. double valueOut= (double)value;
  7381. for(int i= 0;i<decimalPosition;i++)
  7382. {
  7383. valueOut/= 10;
  7384. }
  7385. if(!unitIsF)
  7386. {
  7387. valueOut= valueOut*9/5+32;
  7388. }
  7389. if(!svenabled)
  7390. {
  7391. Measurement vm(valueOut,time,Measurement::Fahrenheit);
  7392. channels.at(0)->input(vm);
  7393. }
  7394. else
  7395. {
  7396. if(readingsv)
  7397. {
  7398. Measurement pvm(savedpv,time,Measurement::Fahrenheit);
  7399. Measurement svm(valueOut,time,Measurement::Fahrenheit);
  7400. channels.at(0)->input(pvm);
  7401. channels.at(1)->input(svm);
  7402. readingsv= false;
  7403. }
  7404. else
  7405. {
  7406. savedpv= valueOut;
  7407. readingsv= true;
  7408. }
  7409. }
  7410. /*:717*/
  7411. #line 17223 "./typica.w"
  7412. }
  7413. }
  7414. /*:715*//*718:*/
  7415. #line 17300 "./typica.w"
  7416. ModbusRTUDevice::~ModbusRTUDevice()
  7417. {
  7418. messageDelayTimer->stop();
  7419. port->close();
  7420. }
  7421. /*:718*//*719:*/
  7422. #line 17322 "./typica.w"
  7423. void ModbusRTUDevice::dataAvailable()
  7424. {
  7425. if(messageDelayTimer->isActive())
  7426. {
  7427. messageDelayTimer->stop();
  7428. }
  7429. responseBuffer.append(port->readAll());
  7430. /*720:*/
  7431. #line 17367 "./typica.w"
  7432. if(responseBuffer.size()<5)
  7433. {
  7434. return;
  7435. }
  7436. switch(responseBuffer.at(1))
  7437. {
  7438. case 0x01:
  7439. case 0x02:
  7440. if(responseBuffer.size()<6)
  7441. {
  7442. return;
  7443. }
  7444. responseBuffer= responseBuffer.left(6);
  7445. break;
  7446. case 0x03:
  7447. case 0x04:
  7448. if(responseBuffer.size()<5+responseBuffer.at(2))
  7449. {
  7450. return;
  7451. }
  7452. responseBuffer= responseBuffer.left(5+responseBuffer.at(2));
  7453. break;
  7454. case 0x05:
  7455. case 0x06:
  7456. case 0x10:
  7457. if(responseBuffer.size()<8)
  7458. {
  7459. return;
  7460. }
  7461. responseBuffer= responseBuffer.left(8);
  7462. break;
  7463. }
  7464. /*:720*/
  7465. #line 17330 "./typica.w"
  7466. if(calculateCRC(responseBuffer)==0)
  7467. {
  7468. QObject*object= retObjQueue.at(0);
  7469. char*method= callbackQueue.at(0);
  7470. QMetaMethod metamethod= object->metaObject()->
  7471. method(object->metaObject()->
  7472. indexOfMethod(QMetaObject::normalizedSignature(method)));
  7473. metamethod.invoke(object,Qt::QueuedConnection,
  7474. Q_ARG(QByteArray,responseBuffer));
  7475. messageQueue.removeAt(0);
  7476. retObjQueue.removeAt(0);
  7477. callbackQueue.removeAt(0);
  7478. messageDelayTimer->start(delayTime);
  7479. }
  7480. else
  7481. {
  7482. qDebug()<<"CRC failed";
  7483. }
  7484. waiting= false;
  7485. responseBuffer.clear();
  7486. }
  7487. /*:719*//*721:*/
  7488. #line 17409 "./typica.w"
  7489. quint16 ModbusRTUDevice::calculateCRC(QByteArray data)
  7490. {
  7491. quint16 retval= 0xFFFF;
  7492. int i= 0;
  7493. while(i<data.size())
  7494. {
  7495. retval^= 0x00FF&(quint16)data.at(i);
  7496. for(int j= 0;j<8;j++)
  7497. {
  7498. if(retval&1)
  7499. {
  7500. retval= (retval>>1)^0xA001;
  7501. }
  7502. else
  7503. {
  7504. retval>>= 1;
  7505. }
  7506. }
  7507. i++;
  7508. }
  7509. return retval;
  7510. }
  7511. /*:721*//*722:*/
  7512. #line 17440 "./typica.w"
  7513. void ModbusRTUDevice::queueMessage(QByteArray request,QObject*object,
  7514. const char*callback)
  7515. {
  7516. messageQueue.append(request);
  7517. retObjQueue.append(object);
  7518. callbackQueue.append(const_cast<char*> (callback));
  7519. if(messageQueue.size()==1&&!(messageDelayTimer->isActive()))
  7520. {
  7521. sendNextMessage();
  7522. }
  7523. }
  7524. void ModbusRTUDevice::sendNextMessage()
  7525. {
  7526. if(messageQueue.size()> 0&&!waiting)
  7527. {
  7528. QByteArray message= messageQueue.at(0);
  7529. quint16 crc= calculateCRC(message);
  7530. char*check= (char*)&crc;
  7531. message.append(check[0]);
  7532. message.append(check[1]);
  7533. port->write(message);
  7534. messageDelayTimer->start(delayTime);
  7535. waiting= true;
  7536. }
  7537. else
  7538. {
  7539. emit queueEmpty();
  7540. }
  7541. }
  7542. void ModbusRTUDevice::outputSV(double value)
  7543. {
  7544. for(int i= 0;i<decimalPosition;i++)
  7545. {
  7546. value*= 10;
  7547. }
  7548. quint16 outval= (quint16)value;
  7549. QByteArray message(outputSVStub);
  7550. char*valBytes= (char*)&outval;
  7551. message.append(valBytes[1]);
  7552. message.append(valBytes[0]);
  7553. queueMessage(message,this,"ignore(QByteArray)");
  7554. }
  7555. /*:722*//*723:*/
  7556. #line 17488 "./typica.w"
  7557. void ModbusRTUDevice::ignore(QByteArray)
  7558. {
  7559. return;
  7560. }
  7561. /*:723*/
  7562. #line 812 "./typica.w"
  7563. /*612:*/
  7564. #line 14199 "./typica.w"
  7565. DeviceTreeModelNode::DeviceTreeModelNode(QDomNode&node,int row,
  7566. DeviceTreeModelNode*parent)
  7567. :domNode(node),rowNumber(row),parentItem(parent)
  7568. {
  7569. }
  7570. DeviceTreeModelNode::~DeviceTreeModelNode()
  7571. {
  7572. QHash<int,DeviceTreeModelNode*> ::iterator i;
  7573. for(i= children.begin();i!=children.end();i++)
  7574. {
  7575. delete i.value();
  7576. }
  7577. }
  7578. DeviceTreeModelNode*DeviceTreeModelNode::parent()
  7579. {
  7580. return parentItem;
  7581. }
  7582. int DeviceTreeModelNode::row()
  7583. {
  7584. return rowNumber;
  7585. }
  7586. QDomNode DeviceTreeModelNode::node()const
  7587. {
  7588. return domNode;
  7589. }
  7590. DeviceTreeModelNode*DeviceTreeModelNode::child(int index)
  7591. {
  7592. if(children.contains(index))
  7593. {
  7594. return children[index];
  7595. }
  7596. if(index>=0&&index<domNode.childNodes().count())
  7597. {
  7598. QDomNode childNode= domNode.childNodes().item(index);
  7599. DeviceTreeModelNode*childItem= new DeviceTreeModelNode(childNode,
  7600. index,this);
  7601. children[index]= childItem;
  7602. return childItem;
  7603. }
  7604. return NULL;
  7605. }
  7606. /*:612*/
  7607. #line 813 "./typica.w"
  7608. /*614:*/
  7609. #line 14288 "./typica.w"
  7610. DeviceTreeModel::DeviceTreeModel(QObject*parent)
  7611. :QAbstractItemModel(parent)
  7612. {
  7613. document= AppInstance->deviceConfiguration();
  7614. QDomNodeList elements= document.elementsByTagName("devices");
  7615. if(elements.size()!=1)
  7616. {
  7617. qDebug()<<"Unexpected result when loading device map.";
  7618. }
  7619. treeRoot= elements.at(0);
  7620. root= new DeviceTreeModelNode(treeRoot,0);
  7621. elements= document.elementsByTagName("references");
  7622. if(elements.size()!=1)
  7623. {
  7624. qDebug()<<"No references section. Creating.";
  7625. referenceSection= document.createElement("references");
  7626. document.appendChild(referenceSection);
  7627. }
  7628. else
  7629. {
  7630. referenceSection= elements.at(0);
  7631. }
  7632. connect(this,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
  7633. AppInstance,SLOT(saveDeviceConfiguration()));
  7634. connect(this,SIGNAL(modelReset()),
  7635. AppInstance,SLOT(saveDeviceConfiguration()));
  7636. connect(this,SIGNAL(rowsInserted(QModelIndex,int,int)),
  7637. AppInstance,SLOT(saveDeviceConfiguration()));
  7638. }
  7639. /*:614*//*615:*/
  7640. #line 14323 "./typica.w"
  7641. int DeviceTreeModel::columnCount(const QModelIndex&)const
  7642. {
  7643. return 1;
  7644. }
  7645. int DeviceTreeModel::rowCount(const QModelIndex&parent)const
  7646. {
  7647. if(parent.column()> 0)
  7648. {
  7649. return 0;
  7650. }
  7651. /*616:*/
  7652. #line 14342 "./typica.w"
  7653. DeviceTreeModelNode*parentItem;
  7654. if(!parent.isValid())
  7655. {
  7656. parentItem= root;
  7657. }
  7658. else
  7659. {
  7660. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  7661. }
  7662. /*:616*/
  7663. #line 14335 "./typica.w"
  7664. return parentItem->node().childNodes().count();
  7665. }
  7666. /*:615*//*617:*/
  7667. #line 14356 "./typica.w"
  7668. QModelIndex DeviceTreeModel::index(int row,int column,
  7669. const QModelIndex&parent)const
  7670. {
  7671. if(!hasIndex(row,column,parent))
  7672. {
  7673. return QModelIndex();
  7674. }
  7675. /*616:*/
  7676. #line 14342 "./typica.w"
  7677. DeviceTreeModelNode*parentItem;
  7678. if(!parent.isValid())
  7679. {
  7680. parentItem= root;
  7681. }
  7682. else
  7683. {
  7684. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  7685. }
  7686. /*:616*/
  7687. #line 14364 "./typica.w"
  7688. DeviceTreeModelNode*childItem= parentItem->child(row);
  7689. if(childItem)
  7690. {
  7691. return createIndex(row,column,childItem);
  7692. }
  7693. return QModelIndex();
  7694. }
  7695. /*:617*//*618:*/
  7696. #line 14375 "./typica.w"
  7697. QModelIndex DeviceTreeModel::parent(const QModelIndex&child)const
  7698. {
  7699. if(!child.isValid())
  7700. {
  7701. return QModelIndex();
  7702. }
  7703. DeviceTreeModelNode*childItem=
  7704. static_cast<DeviceTreeModelNode*> (child.internalPointer());
  7705. DeviceTreeModelNode*parentItem= childItem->parent();
  7706. if(!parentItem||parentItem==root)
  7707. {
  7708. return QModelIndex();
  7709. }
  7710. return createIndex(parentItem->row(),0,parentItem);
  7711. }
  7712. /*:618*//*619:*/
  7713. #line 14394 "./typica.w"
  7714. Qt::ItemFlags DeviceTreeModel::flags(const QModelIndex&index)const
  7715. {
  7716. if(!index.isValid())
  7717. {
  7718. return 0;
  7719. }
  7720. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable;
  7721. }
  7722. /*:619*//*620:*/
  7723. #line 14409 "./typica.w"
  7724. QVariant DeviceTreeModel::data(const QModelIndex&index,int role)const
  7725. {
  7726. if(!index.isValid())
  7727. {
  7728. return QVariant();
  7729. }
  7730. if(role!=Qt::DisplayRole&&role!=Qt::UserRole&&role!=Qt::EditRole)
  7731. {
  7732. return QVariant();
  7733. }
  7734. DeviceTreeModelNode*item=
  7735. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  7736. QDomNode node= item->node();
  7737. QDomElement element= node.toElement();
  7738. switch(role)
  7739. {
  7740. case Qt::DisplayRole:
  7741. case Qt::EditRole:
  7742. return QVariant(element.attribute("name"));
  7743. case Qt::UserRole:
  7744. return QVariant(element.attribute("reference"));
  7745. default:
  7746. return QVariant();
  7747. }
  7748. return QVariant();
  7749. }
  7750. /*:620*//*621:*/
  7751. #line 14441 "./typica.w"
  7752. bool DeviceTreeModel::setData(const QModelIndex&index,
  7753. const QVariant&value,int)
  7754. {
  7755. if(!index.isValid())
  7756. {
  7757. return false;
  7758. }
  7759. DeviceTreeModelNode*item=
  7760. static_cast<DeviceTreeModelNode*> (index.internalPointer());
  7761. QDomNode node= item->node();
  7762. QDomElement element= node.toElement();
  7763. element.setAttribute("name",value.toString());
  7764. emit dataChanged(index,index);
  7765. return true;
  7766. }
  7767. /*:621*//*622:*/
  7768. #line 14464 "./typica.w"
  7769. void DeviceTreeModel::newNode(const QString&name,const QString&driver,
  7770. const QModelIndex&parent)
  7771. {
  7772. QString referenceID= QUuid::createUuid().toString();
  7773. /*616:*/
  7774. #line 14342 "./typica.w"
  7775. DeviceTreeModelNode*parentItem;
  7776. if(!parent.isValid())
  7777. {
  7778. parentItem= root;
  7779. }
  7780. else
  7781. {
  7782. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  7783. }
  7784. /*:616*/
  7785. #line 14469 "./typica.w"
  7786. QDomNode parentNode= parentItem->node();
  7787. int newRowNumber= rowCount(parent);
  7788. beginInsertRows(parent,newRowNumber,newRowNumber);
  7789. QDomElement deviceElement= document.createElement("node");
  7790. deviceElement.setAttribute("name",name);
  7791. deviceElement.setAttribute("reference",referenceID);
  7792. parentNode.appendChild(deviceElement);
  7793. QDomElement referenceElement= document.createElement("reference");
  7794. referenceElement.setAttribute("id",referenceID);
  7795. referenceElement.setAttribute("driver",driver);
  7796. referenceSection.appendChild(referenceElement);
  7797. endInsertRows();
  7798. }
  7799. /*:622*//*623:*/
  7800. #line 14487 "./typica.w"
  7801. bool DeviceTreeModel::removeRows(int row,int count,const QModelIndex&parent)
  7802. {
  7803. /*616:*/
  7804. #line 14342 "./typica.w"
  7805. DeviceTreeModelNode*parentItem;
  7806. if(!parent.isValid())
  7807. {
  7808. parentItem= root;
  7809. }
  7810. else
  7811. {
  7812. parentItem= static_cast<DeviceTreeModelNode*> (parent.internalPointer());
  7813. }
  7814. /*:616*/
  7815. #line 14490 "./typica.w"
  7816. QDomNode parentNode= parentItem->node();
  7817. QDomNodeList childNodes= parentNode.childNodes();
  7818. if(childNodes.size()<row+count)
  7819. {
  7820. return false;
  7821. }
  7822. beginRemoveRows(parent,row,row+count-1);
  7823. QList<QDomElement> removalList;
  7824. for(int i= row;i<row+count;i++)
  7825. {
  7826. removalList.append(childNodes.at(i).toElement());
  7827. }
  7828. QDomElement element;
  7829. QDomElement reference;
  7830. for(int i= 0;i<count;i++)
  7831. {
  7832. element= removalList.at(i);
  7833. if(element.hasAttribute("reference"))
  7834. {
  7835. reference= referenceElement(element.attribute("reference"));
  7836. if(!reference.isNull())
  7837. {
  7838. referenceSection.removeChild(reference);
  7839. }
  7840. }
  7841. parentNode.removeChild(element);
  7842. }
  7843. endRemoveRows();
  7844. beginResetModel();
  7845. delete root;
  7846. root= new DeviceTreeModelNode(treeRoot,0);
  7847. endResetModel();
  7848. return true;
  7849. }
  7850. /*:623*//*624:*/
  7851. #line 14529 "./typica.w"
  7852. QDomElement DeviceTreeModel::referenceElement(const QString&id)
  7853. {
  7854. QDomNodeList childNodes= referenceSection.childNodes();
  7855. QDomElement element;
  7856. for(int i= 0;i<childNodes.size();i++)
  7857. {
  7858. element= childNodes.at(i).toElement();
  7859. if(element.hasAttribute("id"))
  7860. {
  7861. if(element.attribute("id")==id)
  7862. {
  7863. return element;
  7864. }
  7865. }
  7866. }
  7867. return QDomElement();
  7868. }
  7869. /*:624*//*625:*/
  7870. #line 14550 "./typica.w"
  7871. QVariant DeviceTreeModel::headerData(int,Qt::Orientation,int)const
  7872. {
  7873. return QVariant();
  7874. }
  7875. /*:625*//*626:*/
  7876. #line 14559 "./typica.w"
  7877. DeviceTreeModel::~DeviceTreeModel()
  7878. {
  7879. delete root;
  7880. }
  7881. /*:626*/
  7882. #line 814 "./typica.w"
  7883. /*653:*/
  7884. #line 15049 "./typica.w"
  7885. BasicDeviceConfigurationWidget::BasicDeviceConfigurationWidget(
  7886. DeviceTreeModel*model,const QModelIndex&index)
  7887. :QWidget(NULL),deviceModel(model),currentNode(index)
  7888. {
  7889. }
  7890. /*:653*//*654:*/
  7891. #line 15061 "./typica.w"
  7892. void BasicDeviceConfigurationWidget::updateAttribute(const QString&name,
  7893. const QString&value)
  7894. {
  7895. QDomElement referenceElement= deviceModel->referenceElement(
  7896. deviceModel->data(currentNode,Qt::UserRole).toString());
  7897. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  7898. QDomElement node;
  7899. bool found= false;
  7900. for(int i= 0;i<configData.size();i++)
  7901. {
  7902. node= configData.at(i).toElement();
  7903. if(node.attribute("name")==name)
  7904. {
  7905. node.setAttribute("value",value);
  7906. found= true;
  7907. break;
  7908. }
  7909. }
  7910. if(!found)
  7911. {
  7912. node= AppInstance->deviceConfiguration().createElement("attribute");
  7913. node.setAttribute("name",name);
  7914. node.setAttribute("value",value);
  7915. referenceElement.appendChild(node);
  7916. }
  7917. AppInstance->saveDeviceConfiguration();
  7918. }
  7919. /*:654*//*655:*/
  7920. #line 15095 "./typica.w"
  7921. void BasicDeviceConfigurationWidget::insertChildNode(const QString&name,
  7922. const QString&driver)
  7923. {
  7924. deviceModel->newNode(name,driver,currentNode);
  7925. }
  7926. /*:655*/
  7927. #line 815 "./typica.w"
  7928. /*644:*/
  7929. #line 14899 "./typica.w"
  7930. DeviceConfigurationWindow::DeviceConfigurationWindow():QMainWindow(NULL),
  7931. view(new QTreeView),configArea(new QScrollArea)
  7932. {
  7933. QSplitter*splitter= new QSplitter;
  7934. QWidget*leftWidget= new QWidget;
  7935. leftWidget->setMinimumWidth(200);
  7936. QVBoxLayout*left= new QVBoxLayout;
  7937. view->setAnimated(true);
  7938. view->setSelectionMode(QAbstractItemView::SingleSelection);
  7939. document= AppInstance->deviceConfiguration();
  7940. model= new DeviceTreeModel;
  7941. view->setModel(model);
  7942. view->setTextElideMode(Qt::ElideNone);
  7943. view->expandAll();
  7944. view->resizeColumnToContents(0);
  7945. connect(model,SIGNAL(modelReset()),view,SLOT(expandAll()));
  7946. QHBoxLayout*treeButtons= new QHBoxLayout;
  7947. QToolButton*addDeviceButton= new QToolButton;
  7948. addDeviceButton->setIcon(QIcon::fromTheme("list-add"));
  7949. addDeviceButton->setToolTip(tr("New Roaster"));
  7950. connect(addDeviceButton,SIGNAL(clicked()),
  7951. this,SLOT(addDevice()));
  7952. QToolButton*removeNodeButton= new QToolButton;
  7953. removeNodeButton->setIcon(QIcon::fromTheme("list-remove"));
  7954. removeNodeButton->setToolTip(tr("Delete Selection"));
  7955. connect(removeNodeButton,SIGNAL(clicked()),this,SLOT(removeNode()));
  7956. treeButtons->addWidget(addDeviceButton);
  7957. treeButtons->addWidget(removeNodeButton);
  7958. left->addWidget(view);
  7959. left->addLayout(treeButtons);
  7960. leftWidget->setLayout(left);
  7961. splitter->addWidget(leftWidget);
  7962. configArea->setMinimumWidth(580);
  7963. configArea->setMinimumHeight(460);
  7964. splitter->addWidget(configArea);
  7965. setCentralWidget(splitter);
  7966. connect(view,SIGNAL(activated(QModelIndex)),
  7967. this,SLOT(newSelection(QModelIndex)));
  7968. connect(view,SIGNAL(clicked(QModelIndex)),
  7969. this,SLOT(newSelection(QModelIndex)));
  7970. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  7971. view,SLOT(expand(QModelIndex)));
  7972. connect(model,SIGNAL(rowsInserted(QModelIndex,int,int)),
  7973. this,SLOT(resizeColumn()));
  7974. connect(model,SIGNAL(rowsRemoved(QModelIndex,int,int)),
  7975. this,SLOT(resizeColumn()));
  7976. }
  7977. /*:644*//*645:*/
  7978. #line 14951 "./typica.w"
  7979. void DeviceConfigurationWindow::addDevice()
  7980. {
  7981. model->newNode(tr("New Roaster"),"roaster",QModelIndex());
  7982. }
  7983. /*:645*//*646:*/
  7984. #line 14959 "./typica.w"
  7985. void DeviceConfigurationWindow::removeNode()
  7986. {
  7987. QModelIndex index= view->currentIndex();
  7988. if(index.isValid())
  7989. {
  7990. int row= index.row();
  7991. QModelIndex parent= index.parent();
  7992. model->removeRow(row,parent);
  7993. }
  7994. }
  7995. /*:646*//*647:*/
  7996. #line 14975 "./typica.w"
  7997. void DeviceConfigurationWindow::newSelection(const QModelIndex&index)
  7998. {
  7999. QWidget*editor= AppInstance->deviceConfigurationWidget(model,index);
  8000. if(editor)
  8001. {
  8002. configArea->setWidget(editor);
  8003. editor->show();
  8004. }
  8005. }
  8006. /*:647*//*648:*/
  8007. #line 14992 "./typica.w"
  8008. void DeviceConfigurationWindow::resizeColumn()
  8009. {
  8010. view->resizeColumnToContents(0);
  8011. }
  8012. /*:648*/
  8013. #line 816 "./typica.w"
  8014. /*668:*/
  8015. #line 15391 "./typica.w"
  8016. Ni9211TcConfWidget::Ni9211TcConfWidget(DeviceTreeModel*model,
  8017. const QModelIndex&index):
  8018. BasicDeviceConfigurationWidget(model,index)
  8019. {
  8020. QFormLayout*layout= new QFormLayout;
  8021. QLineEdit*columnName= new QLineEdit;
  8022. layout->addRow(tr("Column Name:"),columnName);
  8023. QComboBox*typeSelector= new QComboBox;
  8024. typeSelector->addItem("J");
  8025. typeSelector->addItem("K");
  8026. typeSelector->addItem("T");
  8027. typeSelector->addItem("B");
  8028. typeSelector->addItem("E");
  8029. typeSelector->addItem("N");
  8030. typeSelector->addItem("R");
  8031. typeSelector->addItem("S");
  8032. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  8033. setLayout(layout);
  8034. /*658:*/
  8035. #line 15201 "./typica.w"
  8036. QDomElement referenceElement=
  8037. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8038. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8039. QDomElement node;
  8040. /*:658*/
  8041. #line 15410 "./typica.w"
  8042. for(int i= 0;i<configData.size();i++)
  8043. {
  8044. node= configData.at(i).toElement();
  8045. if(node.attribute("name")=="type")
  8046. {
  8047. typeSelector->setCurrentIndex(
  8048. typeSelector->findText(node.attribute("value")));
  8049. }
  8050. else if(node.attribute("name")=="columnname")
  8051. {
  8052. columnName->setText(node.attribute("value"));
  8053. }
  8054. }
  8055. updateThermocoupleType(typeSelector->currentText());
  8056. updateColumnName(columnName->text());
  8057. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),
  8058. this,SLOT(updateThermocoupleType(QString)));
  8059. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  8060. }
  8061. /*:668*//*669:*/
  8062. #line 15434 "./typica.w"
  8063. void Ni9211TcConfWidget::updateThermocoupleType(const QString&type)
  8064. {
  8065. updateAttribute("type",type);
  8066. }
  8067. void Ni9211TcConfWidget::updateColumnName(const QString&name)
  8068. {
  8069. updateAttribute("columnname",name);
  8070. }
  8071. /*:669*/
  8072. #line 817 "./typica.w"
  8073. /*664:*/
  8074. #line 15306 "./typica.w"
  8075. NiDaqMxBase9211ConfWidget::NiDaqMxBase9211ConfWidget(DeviceTreeModel*model,
  8076. const QModelIndex&index)
  8077. :BasicDeviceConfigurationWidget(model,index)
  8078. {
  8079. QVBoxLayout*layout= new QVBoxLayout;
  8080. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  8081. QLabel*label= new QLabel(tr("Device ID:"));
  8082. QLineEdit*deviceId= new QLineEdit;
  8083. deviceIdLayout->addWidget(label);
  8084. deviceIdLayout->addWidget(deviceId);
  8085. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  8086. layout->addLayout(deviceIdLayout);
  8087. layout->addWidget(addChannelButton);
  8088. /*658:*/
  8089. #line 15201 "./typica.w"
  8090. QDomElement referenceElement=
  8091. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8092. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8093. QDomElement node;
  8094. /*:658*/
  8095. #line 15320 "./typica.w"
  8096. for(int i= 0;i<configData.size();i++)
  8097. {
  8098. node= configData.at(i).toElement();
  8099. if(node.attribute("name")=="deviceID")
  8100. {
  8101. deviceId->setText(node.attribute("value","Dev1"));
  8102. break;
  8103. }
  8104. }
  8105. updateDeviceId(deviceId->text());
  8106. connect(addChannelButton,SIGNAL(clicked()),
  8107. this,SLOT(addChannel()));
  8108. connect(deviceId,SIGNAL(textEdited(QString)),
  8109. this,SLOT(updateDeviceId(QString)));
  8110. setLayout(layout);
  8111. }
  8112. /*:664*//*665:*/
  8113. #line 15342 "./typica.w"
  8114. void NiDaqMxBase9211ConfWidget::updateDeviceId(const QString&newId)
  8115. {
  8116. updateAttribute("deviceID",newId);
  8117. }
  8118. /*:665*//*666:*/
  8119. #line 15350 "./typica.w"
  8120. void NiDaqMxBase9211ConfWidget::addChannel()
  8121. {
  8122. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  8123. }
  8124. /*:666*/
  8125. #line 818 "./typica.w"
  8126. /*662:*/
  8127. #line 15257 "./typica.w"
  8128. NiDaqMxBaseDriverConfWidget::NiDaqMxBaseDriverConfWidget(
  8129. DeviceTreeModel*model,const QModelIndex&index):
  8130. BasicDeviceConfigurationWidget(model,index)
  8131. {
  8132. QHBoxLayout*layout= new QHBoxLayout;
  8133. QToolButton*addDeviceButton= new QToolButton;
  8134. addDeviceButton->setText(tr("Add Device"));
  8135. NodeInserter*add9211= new NodeInserter("NI USB 9211","NI USB 9211",
  8136. "nidaqmxbase9211series");
  8137. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  8138. "nidaqmxbase9211series");
  8139. connect(add9211,SIGNAL(triggered(QString,QString)),
  8140. this,SLOT(insertChildNode(QString,QString)));
  8141. connect(add9211a,SIGNAL(triggered(QString,QString)),
  8142. this,SLOT(insertChildNode(QString,QString)));
  8143. QMenu*deviceMenu= new QMenu;
  8144. deviceMenu->addAction(add9211);
  8145. deviceMenu->addAction(add9211a);
  8146. addDeviceButton->setMenu(deviceMenu);
  8147. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  8148. layout->addWidget(addDeviceButton);
  8149. setLayout(layout);
  8150. }
  8151. /*:662*/
  8152. #line 819 "./typica.w"
  8153. /*550:*/
  8154. #line 12824 "./typica.w"
  8155. ReportAction::ReportAction(const QString&fileName,const QString&reportName,
  8156. QObject*parent):
  8157. QAction(reportName,parent),reportFile(fileName)
  8158. {
  8159. connect(this,SIGNAL(triggered()),this,SLOT(createReport()));
  8160. }
  8161. /*:550*//*551:*/
  8162. #line 12840 "./typica.w"
  8163. void ReportAction::createReport()
  8164. {
  8165. QFile file(reportFile);
  8166. QDomDocument document;
  8167. if(file.open(QIODevice::ReadOnly))
  8168. {
  8169. document.setContent(&file,true);
  8170. QDomElement element= document.documentElement();
  8171. QScriptEngine*engine= AppInstance->engine;
  8172. QScriptContext*context= engine->pushContext();
  8173. QScriptValue object;
  8174. QString targetID= reportFile;
  8175. /*162:*/
  8176. #line 3897 "./typica.w"
  8177. ScriptQMainWindow*window= new ScriptQMainWindow;
  8178. window->setObjectName(targetID);
  8179. object= engine->newQObject(window);
  8180. setQMainWindowProperties(object,engine);
  8181. QWidget*central= new(QWidget);
  8182. central->setParent(window);
  8183. central->setObjectName("centralWidget");
  8184. window->setCentralWidget(central);
  8185. if(element.hasChildNodes())
  8186. {
  8187. /*163:*/
  8188. #line 3932 "./typica.w"
  8189. QStack<QWidget*> widgetStack;
  8190. QStack<QLayout*> layoutStack;
  8191. QString windowScript;
  8192. widgetStack.push(central);
  8193. QDomNodeList windowChildren= element.childNodes();
  8194. int i= 0;
  8195. while(i<windowChildren.count())
  8196. {
  8197. QDomNode current;
  8198. QDomElement element;
  8199. current= windowChildren.at(i);
  8200. if(current.isElement())
  8201. {
  8202. element= current.toElement();
  8203. if(element.tagName()=="program")
  8204. {
  8205. windowScript.append(element.text());
  8206. }
  8207. else if(element.tagName()=="layout")
  8208. {
  8209. addLayoutToWidget(element,&widgetStack,&layoutStack);
  8210. }
  8211. else if(element.tagName()=="menu")
  8212. {
  8213. /*164:*/
  8214. #line 3979 "./typica.w"
  8215. QMenuBar*bar= window->menuBar();
  8216. bar->setParent(window);
  8217. bar->setObjectName("menuBar");
  8218. if(element.hasAttribute("name"))
  8219. {
  8220. QMenu*menu= bar->addMenu(element.attribute("name"));
  8221. menu->setParent(bar);
  8222. if(element.hasAttribute("type"))
  8223. {
  8224. if(element.attribute("type")=="reports")
  8225. {
  8226. if(element.hasAttribute("src"))
  8227. {
  8228. /*548:*/
  8229. #line 12787 "./typica.w"
  8230. QSettings settings;
  8231. QDir directory(QString("%1/%2").arg(settings.value("config").toString()).
  8232. arg(element.attribute("src")));
  8233. directory.setFilter(QDir::Files);
  8234. directory.setSorting(QDir::Name);
  8235. QStringList nameFilter;
  8236. nameFilter<<"*.xml";
  8237. directory.setNameFilters(nameFilter);
  8238. QFileInfoList reportFiles= directory.entryInfoList();
  8239. for(int i= 0;i<reportFiles.size();i++)
  8240. {
  8241. QFileInfo reportFile= reportFiles.at(i);
  8242. /*552:*/
  8243. #line 12864 "./typica.w"
  8244. QString path= reportFile.absoluteFilePath();
  8245. QFile file(path);
  8246. if(file.open(QIODevice::ReadOnly))
  8247. {
  8248. QDomDocument document;
  8249. document.setContent(&file,true);
  8250. QDomElement root= document.documentElement();
  8251. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  8252. if(!titleNode.isNull())
  8253. {
  8254. QDomElement titleElement= titleNode.toElement();
  8255. QString title= titleElement.text();
  8256. if(!title.isEmpty())
  8257. {
  8258. QStringList hierarchy= title.split(":->");
  8259. QMenu*insertionPoint= menu;
  8260. /*553:*/
  8261. #line 12891 "./typica.w"
  8262. for(int j= 0;j<hierarchy.size()-1;j++)
  8263. {
  8264. QObjectList menuList= insertionPoint->children();
  8265. bool menuFound= false;
  8266. for(int k= 0;k<menuList.size();k++)
  8267. {
  8268. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  8269. if(currentItem)
  8270. {
  8271. if(currentItem->title()==hierarchy.at(j))
  8272. {
  8273. menuFound= true;
  8274. insertionPoint= currentItem;
  8275. break;
  8276. }
  8277. }
  8278. }
  8279. if(!menuFound)
  8280. {
  8281. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  8282. }
  8283. }
  8284. /*:553*/
  8285. #line 12881 "./typica.w"
  8286. ReportAction*action= new ReportAction(path,hierarchy.last());
  8287. insertionPoint->addAction(action);
  8288. }
  8289. }
  8290. }
  8291. /*:552*/
  8292. #line 12800 "./typica.w"
  8293. }
  8294. /*:548*/
  8295. #line 3993 "./typica.w"
  8296. }
  8297. }
  8298. }
  8299. if(element.hasChildNodes())
  8300. {
  8301. /*165:*/
  8302. #line 4006 "./typica.w"
  8303. QDomNodeList menuItems= element.childNodes();
  8304. int j= 0;
  8305. while(j<menuItems.count())
  8306. {
  8307. QDomNode item= menuItems.at(j);
  8308. if(item.isElement())
  8309. {
  8310. QDomElement itemElement= item.toElement();
  8311. if(itemElement.tagName()=="item")
  8312. {
  8313. QAction*itemAction= new QAction(itemElement.text(),menu);
  8314. if(itemElement.hasAttribute("id"))
  8315. {
  8316. itemAction->setObjectName(itemElement.attribute("id"));
  8317. }
  8318. if(itemElement.hasAttribute("shortcut"))
  8319. {
  8320. itemAction->setShortcut(itemElement.attribute("shortcut"));
  8321. }
  8322. menu->addAction(itemAction);
  8323. }
  8324. else if(itemElement.tagName()=="separator")
  8325. {
  8326. menu->addSeparator();
  8327. }
  8328. }
  8329. j++;
  8330. }
  8331. #line 1 "./helpmenu.w"
  8332. /*:165*/
  8333. #line 3999 "./typica.w"
  8334. }
  8335. }
  8336. /*:164*/
  8337. #line 3957 "./typica.w"
  8338. }
  8339. }
  8340. i++;
  8341. }
  8342. QScriptValue oldThis= context->thisObject();
  8343. context->setThisObject(object);
  8344. QScriptValue result= engine->evaluate(windowScript);
  8345. /*157:*/
  8346. #line 3746 "./typica.w"
  8347. if(engine->hasUncaughtException())
  8348. {
  8349. int line= engine->uncaughtExceptionLineNumber();
  8350. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  8351. result.toString();
  8352. QString trace;
  8353. foreach(trace,engine->uncaughtExceptionBacktrace())
  8354. {
  8355. qDebug()<<trace;
  8356. }
  8357. }
  8358. /*:157*/
  8359. #line 3965 "./typica.w"
  8360. context->setThisObject(oldThis);
  8361. /*:163*/
  8362. #line 3908 "./typica.w"
  8363. }
  8364. /*166:*/
  8365. #line 9 "./helpmenu.w"
  8366. HelpMenu*helpMenu= new HelpMenu();
  8367. window->menuBar()->addMenu(helpMenu);
  8368. /*:166*/
  8369. #line 3910 "./typica.w"
  8370. window->show();
  8371. /*:162*/
  8372. #line 12853 "./typica.w"
  8373. file.close();
  8374. engine->popContext();
  8375. }
  8376. }
  8377. /*:551*/
  8378. #line 820 "./typica.w"
  8379. /*198:*/
  8380. #line 5054 "./typica.w"
  8381. NumericDelegate::NumericDelegate(QObject*parent):
  8382. QItemDelegate(parent)
  8383. {
  8384. }
  8385. /*:198*//*199:*/
  8386. #line 5066 "./typica.w"
  8387. void NumericDelegate::setEditorData(QWidget*editor,
  8388. const QModelIndex&index)const
  8389. {
  8390. QString value= index.model()->data(index,Qt::EditRole).toString();
  8391. QLineEdit*line= static_cast<QLineEdit*> (editor);
  8392. line->setText(value);
  8393. }
  8394. /*:199*//*200:*/
  8395. #line 5081 "./typica.w"
  8396. void NumericDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,
  8397. const QModelIndex&index)const
  8398. {
  8399. QLineEdit*line= static_cast<QLineEdit*> (editor);
  8400. model->setData(index,line->text(),Qt::EditRole);
  8401. QScriptEngine*engine= AppInstance->engine;
  8402. engine->pushContext();
  8403. QString script= QString("Number(%1)").arg(line->text());
  8404. QScriptValue result= engine->evaluate(line->text());
  8405. if(result.isNumber())
  8406. {
  8407. model->setData(index,result.toVariant(),Qt::DisplayRole);
  8408. }
  8409. else
  8410. {
  8411. model->setData(index,QVariant(),Qt::DisplayRole);
  8412. }
  8413. engine->popContext();
  8414. }
  8415. /*:200*//*201:*/
  8416. #line 5104 "./typica.w"
  8417. QWidget*NumericDelegate::createEditor(QWidget*parent,
  8418. const QStyleOptionViewItem&,
  8419. const QModelIndex&)const
  8420. {
  8421. return(new QLineEdit(parent));
  8422. }
  8423. /*:201*//*202:*/
  8424. #line 5115 "./typica.w"
  8425. void NumericDelegate::updateEditorGeometry(QWidget*editor,
  8426. const QStyleOptionViewItem&option,
  8427. const QModelIndex&)const
  8428. {
  8429. editor->setGeometry(option.rect);
  8430. }
  8431. /*:202*/
  8432. #line 821 "./typica.w"
  8433. /*673:*/
  8434. #line 15488 "./typica.w"
  8435. NiDaqMxDriverConfWidget::NiDaqMxDriverConfWidget(DeviceTreeModel*model,
  8436. const QModelIndex&index)
  8437. :BasicDeviceConfigurationWidget(model,index)
  8438. {
  8439. QHBoxLayout*layout= new QHBoxLayout;
  8440. QToolButton*addDeviceButton= new QToolButton;
  8441. addDeviceButton->setText(tr("Add Device"));
  8442. NodeInserter*add9211a= new NodeInserter("NI USB 9211A","NI USB 9211A",
  8443. "nidaqmx9211series");
  8444. NodeInserter*addtc01= new NodeInserter("NI USB TC01","NI USB TC01",
  8445. "nidaqmxtc01");
  8446. connect(add9211a,SIGNAL(triggered(QString,QString)),
  8447. this,SLOT(insertChildNode(QString,QString)));
  8448. connect(addtc01,SIGNAL(triggered(QString,QString)),
  8449. this,SLOT(insertChildNode(QString,QString)));
  8450. QMenu*deviceMenu= new QMenu;
  8451. deviceMenu->addAction(add9211a);
  8452. deviceMenu->addAction(addtc01);
  8453. addDeviceButton->setMenu(deviceMenu);
  8454. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  8455. layout->addWidget(addDeviceButton);
  8456. setLayout(layout);
  8457. }
  8458. /*:673*/
  8459. #line 822 "./typica.w"
  8460. /*675:*/
  8461. #line 15537 "./typica.w"
  8462. NiDaqMx9211ConfWidget::NiDaqMx9211ConfWidget(DeviceTreeModel*model,
  8463. const QModelIndex&index)
  8464. :BasicDeviceConfigurationWidget(model,index)
  8465. {
  8466. QVBoxLayout*layout= new QVBoxLayout;
  8467. QHBoxLayout*deviceIdLayout= new QHBoxLayout;
  8468. QLabel*label= new QLabel(tr("Device ID:"));
  8469. QLineEdit*deviceId= new QLineEdit;
  8470. deviceIdLayout->addWidget(label);
  8471. deviceIdLayout->addWidget(deviceId);
  8472. QPushButton*addChannelButton= new QPushButton(tr("Add Channel"));
  8473. layout->addLayout(deviceIdLayout);
  8474. layout->addWidget(addChannelButton);
  8475. /*658:*/
  8476. #line 15201 "./typica.w"
  8477. QDomElement referenceElement=
  8478. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8479. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8480. QDomElement node;
  8481. /*:658*/
  8482. #line 15551 "./typica.w"
  8483. for(int i= 0;i<configData.size();i++)
  8484. {
  8485. node= configData.at(i).toElement();
  8486. if(node.attribute("name")=="deviceID")
  8487. {
  8488. deviceId->setText(node.attribute("value","Dev1"));
  8489. break;
  8490. }
  8491. }
  8492. updateDeviceId(deviceId->text());
  8493. connect(addChannelButton,SIGNAL(clicked()),this,SLOT(addChannel()));
  8494. connect(deviceId,SIGNAL(textEdited(QString)),
  8495. this,SLOT(updateDeviceId(QString)));
  8496. setLayout(layout);
  8497. }
  8498. void NiDaqMx9211ConfWidget::updateDeviceId(const QString&newId)
  8499. {
  8500. updateAttribute("deviceID",newId);
  8501. }
  8502. void NiDaqMx9211ConfWidget::addChannel()
  8503. {
  8504. insertChildNode(tr("Thermocouple channel"),"ni9211seriestc");
  8505. }
  8506. /*:675*/
  8507. #line 823 "./typica.w"
  8508. /*677:*/
  8509. #line 15601 "./typica.w"
  8510. NiDaqMxTc01ConfWidget::NiDaqMxTc01ConfWidget(DeviceTreeModel*model,
  8511. const QModelIndex&index)
  8512. :BasicDeviceConfigurationWidget(model,index)
  8513. {
  8514. QFormLayout*layout= new QFormLayout;
  8515. QLineEdit*deviceId= new QLineEdit;
  8516. layout->addRow(tr("Device ID:"),deviceId);
  8517. QLineEdit*columnName= new QLineEdit;
  8518. layout->addRow(tr("Column Name:"),columnName);
  8519. QComboBox*typeSelector= new QComboBox;
  8520. typeSelector->addItem("J");
  8521. typeSelector->addItem("K");
  8522. typeSelector->addItem("T");
  8523. typeSelector->addItem("B");
  8524. typeSelector->addItem("E");
  8525. typeSelector->addItem("N");
  8526. typeSelector->addItem("R");
  8527. typeSelector->addItem("S");
  8528. layout->addRow(tr("Thermocouple Type:"),typeSelector);
  8529. /*658:*/
  8530. #line 15201 "./typica.w"
  8531. QDomElement referenceElement=
  8532. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8533. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8534. QDomElement node;
  8535. /*:658*/
  8536. #line 15621 "./typica.w"
  8537. for(int i= 0;i<configData.size();i++)
  8538. {
  8539. node= configData.at(i).toElement();
  8540. if(node.attribute("name")=="deviceID")
  8541. {
  8542. deviceId->setText(node.attribute("value"));
  8543. }
  8544. else if(node.attribute("name")=="type")
  8545. {
  8546. typeSelector->setCurrentIndex(typeSelector->findText(node.attribute("value")));
  8547. }
  8548. else if(node.attribute("name")=="columnname")
  8549. {
  8550. columnName->setText(node.attribute("value"));
  8551. }
  8552. }
  8553. updateDeviceId(deviceId->text());
  8554. updateThermocoupleType(typeSelector->currentText());
  8555. updateColumnName(columnName->text());
  8556. connect(deviceId,SIGNAL(textEdited(QString)),this,SLOT(updateDeviceId(QString)));
  8557. connect(typeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateThermocoupleType(QString)));
  8558. connect(columnName,SIGNAL(textEdited(QString)),this,SLOT(updateColumnName(QString)));
  8559. setLayout(layout);
  8560. }
  8561. void NiDaqMxTc01ConfWidget::updateDeviceId(const QString&newId)
  8562. {
  8563. updateAttribute("deviceID",newId);
  8564. }
  8565. void NiDaqMxTc01ConfWidget::updateThermocoupleType(const QString&type)
  8566. {
  8567. updateAttribute("type",type);
  8568. }
  8569. void NiDaqMxTc01ConfWidget::updateColumnName(const QString&name)
  8570. {
  8571. updateAttribute("columnname",name);
  8572. }
  8573. /*:677*/
  8574. #line 824 "./typica.w"
  8575. /*695:*/
  8576. #line 16022 "./typica.w"
  8577. ModbusRtuPortConfWidget::ModbusRtuPortConfWidget(DeviceTreeModel*model,
  8578. const QModelIndex&index)
  8579. :BasicDeviceConfigurationWidget(model,index)
  8580. {
  8581. QFormLayout*layout= new QFormLayout;
  8582. QToolButton*addDeviceButton= new QToolButton;
  8583. addDeviceButton->setText(tr("Add Device"));
  8584. NodeInserter*addModbusRtuDevice= new NodeInserter("Modbus RTU Device",
  8585. "Modbus RTU Device",
  8586. "modbusrtudevice");
  8587. connect(addModbusRtuDevice,SIGNAL(triggered(QString,QString)),
  8588. this,SLOT(insertChildNode(QString,QString)));
  8589. QMenu*deviceMenu= new QMenu;
  8590. deviceMenu->addAction(addModbusRtuDevice);
  8591. addDeviceButton->setMenu(deviceMenu);
  8592. addDeviceButton->setPopupMode(QToolButton::InstantPopup);
  8593. layout->addRow(QString(),addDeviceButton);
  8594. PortSelector*port= new PortSelector;
  8595. layout->addRow(tr("Port:"),port);
  8596. connect(port,SIGNAL(currentIndexChanged(QString)),
  8597. this,SLOT(updatePort(QString)));
  8598. connect(port,SIGNAL(editTextChanged(QString)),
  8599. this,SLOT(updatePort(QString)));
  8600. BaudSelector*rate= new BaudSelector;
  8601. layout->addRow(tr("Baud:"),rate);
  8602. connect(rate,SIGNAL(currentIndexChanged(QString)),
  8603. this,SLOT(updateBaudRate(QString)));
  8604. ParitySelector*parity= new ParitySelector;
  8605. layout->addRow(tr("Parity:"),parity);
  8606. connect(parity,SIGNAL(currentIndexChanged(QString)),
  8607. this,SLOT(updateParity(QString)));
  8608. FlowSelector*flow= new FlowSelector;
  8609. layout->addRow(tr("Flow Control:"),flow);
  8610. connect(flow,SIGNAL(currentIndexChanged(QString)),
  8611. this,SLOT(updateFlowControl(QString)));
  8612. StopSelector*stop= new StopSelector;
  8613. layout->addRow(tr("Stop Bits:"),stop);
  8614. connect(stop,SIGNAL(currentIndexChanged(QString)),
  8615. this,SLOT(updateStopBits(QString)));
  8616. /*658:*/
  8617. #line 15201 "./typica.w"
  8618. QDomElement referenceElement=
  8619. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8620. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8621. QDomElement node;
  8622. /*:658*/
  8623. #line 16062 "./typica.w"
  8624. for(int i= 0;i<configData.size();i++)
  8625. {
  8626. node= configData.at(i).toElement();
  8627. if(node.attribute("name")=="port")
  8628. {
  8629. int j= port->findText(node.attribute("value"));
  8630. if(j>=0)
  8631. {
  8632. port->setCurrentIndex(j);
  8633. }
  8634. else
  8635. {
  8636. port->insertItem(0,node.attribute("value"));
  8637. port->setCurrentIndex(0);
  8638. }
  8639. }
  8640. else if(node.attribute("name")=="baudrate")
  8641. {
  8642. rate->setCurrentIndex(rate->findText(node.attribute("value")));
  8643. }
  8644. else if(node.attribute("name")=="parity")
  8645. {
  8646. parity->setCurrentIndex(parity->findText(node.attribute("value")));
  8647. }
  8648. else if(node.attribute("name")=="flowcontrol")
  8649. {
  8650. flow->setCurrentIndex(flow->findText(node.attribute("value")));
  8651. }
  8652. else if(node.attribute("name")=="stopbits")
  8653. {
  8654. stop->setCurrentIndex(stop->findText(node.attribute("value")));
  8655. }
  8656. }
  8657. updatePort(port->currentText());
  8658. updateBaudRate(rate->currentText());
  8659. updateParity(parity->currentText());
  8660. updateFlowControl(flow->currentText());
  8661. updateStopBits(stop->currentText());
  8662. setLayout(layout);
  8663. }
  8664. void ModbusRtuPortConfWidget::updatePort(const QString&newPort)
  8665. {
  8666. updateAttribute("port",newPort);
  8667. }
  8668. void ModbusRtuPortConfWidget::updateBaudRate(const QString&newRate)
  8669. {
  8670. updateAttribute("baudrate",newRate);
  8671. }
  8672. void ModbusRtuPortConfWidget::updateParity(const QString&newParity)
  8673. {
  8674. updateAttribute("parity",newParity);
  8675. }
  8676. void ModbusRtuPortConfWidget::updateFlowControl(const QString&newFlow)
  8677. {
  8678. updateAttribute("flowcontrol",newFlow);
  8679. }
  8680. void ModbusRtuPortConfWidget::updateStopBits(const QString&newStopBits)
  8681. {
  8682. updateAttribute("stopbits",newStopBits);
  8683. }
  8684. /*:695*/
  8685. #line 825 "./typica.w"
  8686. /*697:*/
  8687. #line 16185 "./typica.w"
  8688. ModbusRtuDeviceConfWidget::ModbusRtuDeviceConfWidget(DeviceTreeModel*model,
  8689. const QModelIndex&index)
  8690. :BasicDeviceConfigurationWidget(model,index),
  8691. unitSpecificationLayout(new QStackedLayout),
  8692. decimalSpecificationLayout(new QStackedLayout)
  8693. {
  8694. QVBoxLayout*layout= new QVBoxLayout;
  8695. QToolButton*addChannelButton= new QToolButton;
  8696. addChannelButton->setText(tr("Add Channel"));
  8697. NodeInserter*addTemperaturePV= new NodeInserter("Temperature Process Value",
  8698. "Temperature Process Value",
  8699. "modbustemperaturepv");
  8700. NodeInserter*addTemperatureSV= new NodeInserter("Temperature Set Value",
  8701. "Temperature Set Value",
  8702. "modbustemperaturesv");
  8703. connect(addTemperaturePV,SIGNAL(triggered(QString,QString)),
  8704. this,SLOT(insertChildNode(QString,QString)));
  8705. connect(addTemperatureSV,SIGNAL(triggered(QString,QString)),
  8706. this,SLOT(insertChildNode(QString,QString)));
  8707. QMenu*channelMenu= new QMenu;
  8708. channelMenu->addAction(addTemperaturePV);
  8709. channelMenu->addAction(addTemperatureSV);
  8710. addChannelButton->setMenu(channelMenu);
  8711. addChannelButton->setPopupMode(QToolButton::InstantPopup);
  8712. layout->addWidget(addChannelButton);
  8713. QHBoxLayout*stationLayout= new QHBoxLayout;
  8714. QLabel*stationLabel= new QLabel(tr("Station:"));
  8715. QSpinBox*stationNumber= new QSpinBox;
  8716. stationNumber->setMinimum(0);
  8717. stationNumber->setMaximum(255);
  8718. stationLayout->addWidget(stationLabel);
  8719. stationLayout->addWidget(stationNumber);
  8720. layout->addLayout(stationLayout);
  8721. QCheckBox*fixedUnit= new QCheckBox(tr("Fixed Temperature Unit"));
  8722. layout->addWidget(fixedUnit);
  8723. QWidget*fixedUnitPlaceholder= new QWidget(this);
  8724. QHBoxLayout*fixedUnitLayout= new QHBoxLayout;
  8725. QLabel*fixedUnitLabel= new QLabel(tr("Temperature Unit:"));
  8726. QComboBox*fixedUnitSelector= new QComboBox;
  8727. fixedUnitSelector->addItem("Fahrenheit");
  8728. fixedUnitSelector->addItem("Celsius");
  8729. fixedUnitLayout->addWidget(fixedUnitLabel);
  8730. fixedUnitLayout->addWidget(fixedUnitSelector);
  8731. fixedUnitPlaceholder->setLayout(fixedUnitLayout);
  8732. unitSpecificationLayout->addWidget(fixedUnitPlaceholder);
  8733. QWidget*queriedUnitPlaceholder= new QWidget(this);
  8734. QFormLayout*queriedUnitLayout= new QFormLayout;
  8735. ShortHexSpinBox*unitAddress= new ShortHexSpinBox;
  8736. queriedUnitLayout->addRow(tr("Function 0x03 Unit Address:"),unitAddress);
  8737. QSpinBox*valueF= new QSpinBox;
  8738. valueF->setMinimum(0);
  8739. valueF->setMaximum(65535);
  8740. queriedUnitLayout->addRow(tr("Value for Fahrenheit"),valueF);
  8741. QSpinBox*valueC= new QSpinBox;
  8742. valueC->setMinimum(0);
  8743. valueC->setMaximum(65535);
  8744. queriedUnitLayout->addRow(tr("Value for Celsius"),valueC);
  8745. queriedUnitPlaceholder->setLayout(queriedUnitLayout);
  8746. unitSpecificationLayout->addWidget(queriedUnitPlaceholder);
  8747. layout->addLayout(unitSpecificationLayout);
  8748. QCheckBox*fixedPrecision= new QCheckBox(tr("Fixed Precision"));
  8749. layout->addWidget(fixedPrecision);
  8750. QWidget*fixedPrecisionPlaceholder= new QWidget(this);
  8751. QFormLayout*fixedPrecisionLayout= new QFormLayout;
  8752. QSpinBox*fixedPrecisionValue= new QSpinBox;
  8753. fixedPrecisionValue->setMinimum(0);
  8754. fixedPrecisionValue->setMaximum(9);
  8755. fixedPrecisionLayout->addRow("Places after the decimal point:",
  8756. fixedPrecisionValue);
  8757. fixedPrecisionPlaceholder->setLayout(fixedPrecisionLayout);
  8758. decimalSpecificationLayout->addWidget(fixedPrecisionPlaceholder);
  8759. QWidget*queriedPrecisionPlaceholder= new QWidget(this);
  8760. QFormLayout*queriedPrecisionLayout= new QFormLayout;
  8761. ShortHexSpinBox*precisionAddress= new ShortHexSpinBox;
  8762. queriedPrecisionLayout->addRow("Function 0x03 Decimal Position Address:",
  8763. precisionAddress);
  8764. queriedPrecisionPlaceholder->setLayout(queriedPrecisionLayout);
  8765. decimalSpecificationLayout->addWidget(queriedPrecisionPlaceholder);
  8766. layout->addLayout(decimalSpecificationLayout);
  8767. /*658:*/
  8768. #line 15201 "./typica.w"
  8769. QDomElement referenceElement=
  8770. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8771. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8772. QDomElement node;
  8773. /*:658*/
  8774. #line 16265 "./typica.w"
  8775. for(int i= 0;i<configData.size();i++)
  8776. {
  8777. node= configData.at(i).toElement();
  8778. if(node.attribute("name")=="station")
  8779. {
  8780. stationNumber->setValue(node.attribute("value").toInt());
  8781. }
  8782. else if(node.attribute("name")=="fixedunit")
  8783. {
  8784. if(node.attribute("value")=="true")
  8785. {
  8786. fixedUnit->setCheckState(Qt::Checked);
  8787. }
  8788. else if(node.attribute("value")=="false")
  8789. {
  8790. fixedUnit->setCheckState(Qt::Unchecked);
  8791. }
  8792. }
  8793. else if(node.attribute("name")=="fixedprecision")
  8794. {
  8795. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  8796. }
  8797. else if(node.attribute("name")=="unit")
  8798. {
  8799. fixedUnitSelector->setCurrentIndex(fixedUnitSelector->findText(node.attribute("value")));
  8800. }
  8801. else if(node.attribute("name")=="unitaddress")
  8802. {
  8803. unitAddress->setValue(node.attribute("value").toInt());
  8804. }
  8805. else if(node.attribute("name")=="fvalue")
  8806. {
  8807. valueF->setValue(node.attribute("value").toInt());
  8808. }
  8809. else if(node.attribute("name")=="cvalue")
  8810. {
  8811. valueC->setValue(node.attribute("value").toInt());
  8812. }
  8813. else if(node.attribute("name")=="precisionaddress")
  8814. {
  8815. precisionAddress->setValue(node.attribute("value").toInt());
  8816. }
  8817. else if(node.attribute("name")=="precision")
  8818. {
  8819. fixedPrecisionValue->setValue(node.attribute("value").toInt());
  8820. }
  8821. }
  8822. updateStationNumber(stationNumber->value());
  8823. updateFixedUnit(fixedUnit->isChecked());
  8824. updateFixedDecimal(fixedPrecision->isChecked());
  8825. updateUnit(fixedUnitSelector->currentText());
  8826. updateUnitAddress(unitAddress->value());
  8827. updateValueF(valueF->value());
  8828. updateValueC(valueC->value());
  8829. updatePrecisionAddress(precisionAddress->value());
  8830. updatePrecisionValue(fixedPrecisionValue->value());
  8831. connect(stationNumber,SIGNAL(valueChanged(int)),
  8832. this,SLOT(updateStationNumber(int)));
  8833. connect(fixedUnitSelector,SIGNAL(currentIndexChanged(QString)),
  8834. this,SLOT(updateUnit(QString)));
  8835. connect(unitAddress,SIGNAL(valueChanged(int)),
  8836. this,SLOT(updateUnitAddress(int)));
  8837. connect(valueF,SIGNAL(valueChanged(int)),
  8838. this,SLOT(updateValueF(int)));
  8839. connect(valueC,SIGNAL(valueChanged(int)),
  8840. this,SLOT(updateValueC(int)));
  8841. connect(fixedUnit,SIGNAL(toggled(bool)),
  8842. this,SLOT(updateFixedUnit(bool)));
  8843. connect(fixedPrecision,SIGNAL(toggled(bool)),
  8844. this,SLOT(updateFixedDecimal(bool)));
  8845. connect(fixedPrecisionValue,SIGNAL(valueChanged(int)),
  8846. this,SLOT(updatePrecisionValue(int)));
  8847. connect(precisionAddress,SIGNAL(valueChanged(int)),
  8848. this,SLOT(updatePrecisionAddress(int)));
  8849. setLayout(layout);
  8850. }
  8851. void ModbusRtuDeviceConfWidget::updateStationNumber(int newStation)
  8852. {
  8853. updateAttribute("station",QString("%1").arg(newStation));
  8854. }
  8855. void ModbusRtuDeviceConfWidget::updateFixedUnit(bool newFixed)
  8856. {
  8857. if(newFixed)
  8858. {
  8859. unitSpecificationLayout->setCurrentIndex(0);
  8860. updateAttribute("fixedunit","true");
  8861. }
  8862. else
  8863. {
  8864. unitSpecificationLayout->setCurrentIndex(1);
  8865. updateAttribute("fixedunit","false");
  8866. }
  8867. }
  8868. void ModbusRtuDeviceConfWidget::updateFixedDecimal(bool newFixed)
  8869. {
  8870. if(newFixed)
  8871. {
  8872. decimalSpecificationLayout->setCurrentIndex(0);
  8873. updateAttribute("fixedprecision","true");
  8874. }
  8875. else
  8876. {
  8877. decimalSpecificationLayout->setCurrentIndex(1);
  8878. updateAttribute("fixedprecision","false");
  8879. }
  8880. }
  8881. void ModbusRtuDeviceConfWidget::updateUnit(const QString&newUnit)
  8882. {
  8883. updateAttribute("unit",newUnit);
  8884. }
  8885. void ModbusRtuDeviceConfWidget::updateUnitAddress(int newAddress)
  8886. {
  8887. updateAttribute("unitaddress",QString("%1").arg(newAddress));
  8888. }
  8889. void ModbusRtuDeviceConfWidget::updateValueF(int newValue)
  8890. {
  8891. updateAttribute("fvalue",QString("%1").arg(newValue));
  8892. }
  8893. void ModbusRtuDeviceConfWidget::updateValueC(int newValue)
  8894. {
  8895. updateAttribute("cvalue",QString("%1").arg(newValue));
  8896. }
  8897. void ModbusRtuDeviceConfWidget::updatePrecisionAddress(int newAddress)
  8898. {
  8899. updateAttribute("precisionaddress",QString("%1").arg(newAddress));
  8900. }
  8901. void ModbusRtuDeviceConfWidget::updatePrecisionValue(int newValue)
  8902. {
  8903. updateAttribute("precision",QString("%1").arg(newValue));
  8904. }
  8905. /*:697*/
  8906. #line 826 "./typica.w"
  8907. /*699:*/
  8908. #line 16428 "./typica.w"
  8909. ModbusRtuDeviceTPvConfWidget::ModbusRtuDeviceTPvConfWidget(DeviceTreeModel*model,
  8910. const QModelIndex&index)
  8911. :BasicDeviceConfigurationWidget(model,index)
  8912. {
  8913. QFormLayout*layout= new QFormLayout;
  8914. ShortHexSpinBox*address= new ShortHexSpinBox;
  8915. layout->addRow(tr("Function 0x04 Process Value Address"),address);
  8916. /*658:*/
  8917. #line 15201 "./typica.w"
  8918. QDomElement referenceElement=
  8919. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8920. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8921. QDomElement node;
  8922. /*:658*/
  8923. #line 16436 "./typica.w"
  8924. for(int i= 0;i<configData.size();i++)
  8925. {
  8926. node= configData.at(i).toElement();
  8927. if(node.attribute("name")=="address")
  8928. {
  8929. address->setValue(node.attribute("value").toInt());
  8930. break;
  8931. }
  8932. }
  8933. updateAddress(address->value());
  8934. connect(address,SIGNAL(valueChanged(int)),this,SLOT(updateAddress(int)));
  8935. setLayout(layout);
  8936. }
  8937. void ModbusRtuDeviceTPvConfWidget::updateAddress(int newAddress)
  8938. {
  8939. updateAttribute("address",QString("%1").arg(newAddress));
  8940. }
  8941. /*:699*/
  8942. #line 827 "./typica.w"
  8943. /*701:*/
  8944. #line 16484 "./typica.w"
  8945. ModbusRtuDeviceTSvConfWidget::ModbusRtuDeviceTSvConfWidget(DeviceTreeModel*model,
  8946. const QModelIndex&index)
  8947. :BasicDeviceConfigurationWidget(model,index),boundsLayout(new QStackedLayout)
  8948. {
  8949. QVBoxLayout*layout= new QVBoxLayout;
  8950. QFormLayout*addressLayout= new QFormLayout;
  8951. ShortHexSpinBox*readAddress= new ShortHexSpinBox;
  8952. ShortHexSpinBox*writeAddress= new ShortHexSpinBox;
  8953. addressLayout->addRow(tr("Function 0x04 Read Set Value Address:"),readAddress);
  8954. addressLayout->addRow(tr("Function 0x06 Write Set Value Address:"),writeAddress);
  8955. layout->addLayout(addressLayout);
  8956. QCheckBox*fixedRange= new QCheckBox(tr("Fixed Set Value Range"));
  8957. layout->addWidget(fixedRange);
  8958. QWidget*queriedRangePlaceholder= new QWidget(this);
  8959. QFormLayout*queriedRangeLayout= new QFormLayout;
  8960. ShortHexSpinBox*lowerAddress= new ShortHexSpinBox;
  8961. ShortHexSpinBox*upperAddress= new ShortHexSpinBox;
  8962. queriedRangeLayout->addRow(tr("Function 0x03 Minimum Set Value Address"),
  8963. lowerAddress);
  8964. queriedRangeLayout->addRow(tr("Function 0x03 Maximum Set Value Address"),
  8965. upperAddress);
  8966. queriedRangePlaceholder->setLayout(queriedRangeLayout);
  8967. boundsLayout->addWidget(queriedRangePlaceholder);
  8968. QWidget*fixedRangePlaceholder= new QWidget(this);
  8969. QFormLayout*fixedRangeLayout= new QFormLayout;
  8970. QLineEdit*fixedLower= new QLineEdit;
  8971. QLineEdit*fixedUpper= new QLineEdit;
  8972. fixedRangeLayout->addRow(tr("Minimum Set Value:"),fixedLower);
  8973. fixedRangeLayout->addRow(tr("Maximum Set Value:"),fixedUpper);
  8974. fixedRangePlaceholder->setLayout(fixedRangeLayout);
  8975. boundsLayout->addWidget(fixedRangePlaceholder);
  8976. layout->addLayout(boundsLayout);
  8977. /*658:*/
  8978. #line 15201 "./typica.w"
  8979. QDomElement referenceElement=
  8980. model->referenceElement(model->data(index,Qt::UserRole).toString());
  8981. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  8982. QDomElement node;
  8983. /*:658*/
  8984. #line 16517 "./typica.w"
  8985. for(int i= 0;i<configData.size();i++)
  8986. {
  8987. node= configData.at(i).toElement();
  8988. if(node.attribute("name")=="readaddress")
  8989. {
  8990. readAddress->setValue(node.attribute("value").toInt());
  8991. }
  8992. else if(node.attribute("name")=="writeaddress")
  8993. {
  8994. writeAddress->setValue(node.attribute("value").toInt());
  8995. }
  8996. else if(node.attribute("name")=="fixedrange")
  8997. {
  8998. if(node.attribute("value")=="true")
  8999. {
  9000. fixedRange->setCheckState(Qt::Checked);
  9001. }
  9002. else if(node.attribute("value")=="false")
  9003. {
  9004. fixedRange->setCheckState(Qt::Unchecked);
  9005. }
  9006. }
  9007. else if(node.attribute("name")=="fixedlower")
  9008. {
  9009. fixedLower->setText(node.attribute("value"));
  9010. }
  9011. else if(node.attribute("name")=="fixedupper")
  9012. {
  9013. fixedUpper->setText(node.attribute("value"));
  9014. }
  9015. else if(node.attribute("name")=="loweraddress")
  9016. {
  9017. lowerAddress->setValue(node.attribute("value").toInt());
  9018. }
  9019. else if(node.attribute("name")=="upperaddress")
  9020. {
  9021. upperAddress->setValue(node.attribute("value").toInt());
  9022. }
  9023. }
  9024. updateReadAddress(readAddress->value());
  9025. updateWriteAddress(writeAddress->value());
  9026. updateFixedRange(fixedRange->isChecked());
  9027. updateLower(fixedLower->text());
  9028. updateUpper(fixedUpper->text());
  9029. updateLowerAddress(lowerAddress->value());
  9030. updateUpperAddress(upperAddress->value());
  9031. connect(readAddress,SIGNAL(valueChanged(int)),
  9032. this,SLOT(updateReadAddress(int)));
  9033. connect(writeAddress,SIGNAL(valueChanged(int)),
  9034. this,SLOT(updateWriteAddress(int)));
  9035. connect(fixedRange,SIGNAL(toggled(bool)),this,SLOT(updateFixedRange(bool)));
  9036. connect(fixedLower,SIGNAL(textChanged(QString)),
  9037. this,SLOT(updateLower(QString)));
  9038. connect(fixedUpper,SIGNAL(textChanged(QString)),
  9039. this,SLOT(updateUpper(QString)));
  9040. connect(lowerAddress,SIGNAL(valueChanged(int)),
  9041. this,SLOT(updateLowerAddress(int)));
  9042. connect(upperAddress,SIGNAL(valueChanged(int)),
  9043. this,SLOT(updateUpperAddress(int)));
  9044. setLayout(layout);
  9045. }
  9046. void ModbusRtuDeviceTSvConfWidget::updateReadAddress(int newAddress)
  9047. {
  9048. updateAttribute("readaddress",QString("%1").arg(newAddress));
  9049. }
  9050. void ModbusRtuDeviceTSvConfWidget::updateWriteAddress(int newAddress)
  9051. {
  9052. updateAttribute("writeaddress",QString("%1").arg(newAddress));
  9053. }
  9054. void ModbusRtuDeviceTSvConfWidget::updateFixedRange(bool fixed)
  9055. {
  9056. if(fixed)
  9057. {
  9058. updateAttribute("fixedrange","true");
  9059. boundsLayout->setCurrentIndex(1);
  9060. }
  9061. else
  9062. {
  9063. updateAttribute("fixedrange","false");
  9064. boundsLayout->setCurrentIndex(0);
  9065. }
  9066. }
  9067. void ModbusRtuDeviceTSvConfWidget::updateLower(const QString&lower)
  9068. {
  9069. updateAttribute("fixedlower",lower);
  9070. }
  9071. void ModbusRtuDeviceTSvConfWidget::updateUpper(const QString&upper)
  9072. {
  9073. updateAttribute("fixedupper",upper);
  9074. }
  9075. void ModbusRtuDeviceTSvConfWidget::updateLowerAddress(int newAddress)
  9076. {
  9077. updateAttribute("loweraddress",QString("%1").arg(newAddress));
  9078. }
  9079. void ModbusRtuDeviceTSvConfWidget::updateUpperAddress(int newAddress)
  9080. {
  9081. updateAttribute("upperaddress",QString("%1").arg(newAddress));
  9082. }
  9083. /*:701*/
  9084. #line 828 "./typica.w"
  9085. /*657:*/
  9086. #line 15131 "./typica.w"
  9087. RoasterConfWidget::RoasterConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  9088. :BasicDeviceConfigurationWidget(model,index)
  9089. {
  9090. QVBoxLayout*layout= new QVBoxLayout;
  9091. QPushButton*addDeviceButton= new QPushButton(tr("Add Device"));
  9092. QMenu*deviceMenu= new QMenu;
  9093. NodeInserter*insertAction;
  9094. foreach(insertAction,AppInstance->topLevelNodeInserters)
  9095. {
  9096. connect(insertAction,SIGNAL(triggered(QString,QString)),
  9097. this,SLOT(insertChildNode(QString,QString)));
  9098. deviceMenu->addAction(insertAction);
  9099. }
  9100. addDeviceButton->setMenu(deviceMenu);
  9101. layout->addWidget(addDeviceButton);
  9102. QPushButton*addAnnotationControlButton= new QPushButton(tr("Add Annotation Control"));
  9103. QMenu*annotationMenu= new QMenu;
  9104. NodeInserter*basicButtonInserter= new NodeInserter(tr("Annotation Button"),tr("Annotation Button"),"annotationbutton");
  9105. NodeInserter*countingButtonInserter= new NodeInserter(tr("Counting Button"),tr("Counting Button"),"reconfigurablebutton");
  9106. NodeInserter*spinBoxInserter= new NodeInserter(tr("Numeric Entry"),tr("Numeric Entry"),"annotationspinbox");
  9107. annotationMenu->addAction(basicButtonInserter);
  9108. annotationMenu->addAction(countingButtonInserter);
  9109. annotationMenu->addAction(spinBoxInserter);
  9110. connect(basicButtonInserter,SIGNAL(triggered(QString,QString)),
  9111. this,SLOT(insertChildNode(QString,QString)));
  9112. connect(countingButtonInserter,SIGNAL(triggered(QString,QString)),
  9113. this,SLOT(insertChildNode(QString,QString)));
  9114. connect(spinBoxInserter,SIGNAL(triggered(QString,QString)),
  9115. this,SLOT(insertChildNode(QString,QString)));
  9116. addAnnotationControlButton->setMenu(annotationMenu);
  9117. layout->addWidget(addAnnotationControlButton);
  9118. QPushButton*advancedButton= new QPushButton(tr("Advanced Features"));
  9119. QMenu*advancedMenu= new QMenu;
  9120. NodeInserter*linearsplineinserter= new NodeInserter(tr("Linear Spline Interpolated Series"),tr("Linear Spline Interpolated Series"),"linearspline");
  9121. advancedMenu->addAction(linearsplineinserter);
  9122. NodeInserter*translationinserter= new NodeInserter(tr("Profile Translation"),tr("Profile Translation"),"translation");
  9123. advancedMenu->addAction(translationinserter);
  9124. connect(linearsplineinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  9125. connect(translationinserter,SIGNAL(triggered(QString,QString)),this,SLOT(insertChildNode(QString,QString)));
  9126. advancedButton->setMenu(advancedMenu);
  9127. layout->addWidget(advancedButton);
  9128. QHBoxLayout*idLayout= new QHBoxLayout;
  9129. QLabel*idLabel= new QLabel(tr("Machine ID for database:"));
  9130. idLayout->addWidget(idLabel);
  9131. QSpinBox*id= new QSpinBox;
  9132. idLayout->addWidget(id);
  9133. layout->addLayout(idLayout);
  9134. /*658:*/
  9135. #line 15201 "./typica.w"
  9136. QDomElement referenceElement=
  9137. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9138. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9139. QDomElement node;
  9140. /*:658*/
  9141. #line 15179 "./typica.w"
  9142. for(int i= 0;i<configData.size();i++)
  9143. {
  9144. node= configData.at(i).toElement();
  9145. if(node.attribute("name")=="databaseid")
  9146. {
  9147. id->setValue(node.attribute("value").toInt());
  9148. break;
  9149. }
  9150. }
  9151. updateRoasterId(id->value());
  9152. connect(id,SIGNAL(valueChanged(int)),this,SLOT(updateRoasterId(int)));
  9153. setLayout(layout);
  9154. }
  9155. /*:657*//*659:*/
  9156. #line 15211 "./typica.w"
  9157. void RoasterConfWidget::updateRoasterId(int id)
  9158. {
  9159. updateAttribute("databaseid",QString("%1").arg(id));
  9160. }
  9161. /*:659*/
  9162. #line 829 "./typica.w"
  9163. /*705:*/
  9164. #line 16667 "./typica.w"
  9165. AnnotationButtonConfWidget::AnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  9166. :BasicDeviceConfigurationWidget(model,index)
  9167. {
  9168. QFormLayout*layout= new QFormLayout;
  9169. QLineEdit*buttonTextEdit= new QLineEdit;
  9170. QLineEdit*annotationTextEdit= new QLineEdit;
  9171. layout->addRow(tr("Button Text:"),buttonTextEdit);
  9172. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  9173. /*658:*/
  9174. #line 15201 "./typica.w"
  9175. QDomElement referenceElement=
  9176. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9177. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9178. QDomElement node;
  9179. /*:658*/
  9180. #line 16676 "./typica.w"
  9181. for(int i= 0;i<configData.size();i++)
  9182. {
  9183. node= configData.at(i).toElement();
  9184. if(node.attribute("name")=="buttontext")
  9185. {
  9186. buttonTextEdit->setText(node.attribute("value"));
  9187. }
  9188. else if(node.attribute("name")=="annotationtext")
  9189. {
  9190. annotationTextEdit->setText(node.attribute("value"));
  9191. }
  9192. }
  9193. updateButtonText(buttonTextEdit->text());
  9194. updateAnnotationText(annotationTextEdit->text());
  9195. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  9196. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  9197. setLayout(layout);
  9198. }
  9199. /*:705*//*706:*/
  9200. #line 16698 "./typica.w"
  9201. void AnnotationButtonConfWidget::updateButtonText(const QString&text)
  9202. {
  9203. updateAttribute("buttontext",text);
  9204. }
  9205. void AnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  9206. {
  9207. updateAttribute("annotationtext",text);
  9208. }
  9209. /*:706*//*709:*/
  9210. #line 16736 "./typica.w"
  9211. ReconfigurableAnnotationButtonConfWidget::ReconfigurableAnnotationButtonConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  9212. :BasicDeviceConfigurationWidget(model,index)
  9213. {
  9214. QFormLayout*layout= new QFormLayout;
  9215. QLineEdit*buttonTextEdit= new QLineEdit;
  9216. QLineEdit*annotationTextEdit= new QLineEdit;
  9217. layout->addRow(tr("Button Text:"),buttonTextEdit);
  9218. layout->addRow(tr("Annotation Text:"),annotationTextEdit);
  9219. /*658:*/
  9220. #line 15201 "./typica.w"
  9221. QDomElement referenceElement=
  9222. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9223. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9224. QDomElement node;
  9225. /*:658*/
  9226. #line 16745 "./typica.w"
  9227. for(int i= 0;i<configData.size();i++)
  9228. {
  9229. node= configData.at(i).toElement();
  9230. if(node.attribute("name")=="buttontext")
  9231. {
  9232. buttonTextEdit->setText(node.attribute("value"));
  9233. }
  9234. else if(node.attribute("name")=="annotationtext")
  9235. {
  9236. annotationTextEdit->setText(node.attribute("value"));
  9237. }
  9238. }
  9239. updateButtonText(buttonTextEdit->text());
  9240. updateAnnotationText(annotationTextEdit->text());
  9241. connect(buttonTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateButtonText(QString)));
  9242. connect(annotationTextEdit,SIGNAL(textEdited(QString)),this,SLOT(updateAnnotationText(QString)));
  9243. QTextEdit*documentation= new QTextEdit;
  9244. documentation->setHtml(tr("If the <b>Annotation Text</b> contains <tt>%1</tt>, this will be replaced in the annotation with a number that increments each time the button is pressed."));
  9245. documentation->setReadOnly(true);
  9246. layout->addRow("",documentation);
  9247. setLayout(layout);
  9248. }
  9249. void ReconfigurableAnnotationButtonConfWidget::updateButtonText(const QString&text)
  9250. {
  9251. updateAttribute("buttontext",text);
  9252. }
  9253. void ReconfigurableAnnotationButtonConfWidget::updateAnnotationText(const QString&text)
  9254. {
  9255. updateAttribute("annotationtext",text);
  9256. }
  9257. /*:709*/
  9258. #line 830 "./typica.w"
  9259. /*712:*/
  9260. #line 16813 "./typica.w"
  9261. NoteSpinConfWidget::NoteSpinConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  9262. :BasicDeviceConfigurationWidget(model,index)
  9263. {
  9264. QFormLayout*layout= new QFormLayout;
  9265. QLineEdit*labelEdit= new QLineEdit;
  9266. layout->addRow(tr("Control Label: "),labelEdit);
  9267. QLineEdit*minimumEdit= new QLineEdit;
  9268. layout->addRow(tr("Minimum Value: "),minimumEdit);
  9269. QLineEdit*maximumEdit= new QLineEdit;
  9270. layout->addRow(tr("Maximum Value: "),maximumEdit);
  9271. QSpinBox*precisionEdit= new QSpinBox;
  9272. precisionEdit->setMinimum(0);
  9273. precisionEdit->setMaximum(9);
  9274. layout->addRow(tr("Precision"),precisionEdit);
  9275. QLineEdit*pretext= new QLineEdit;
  9276. layout->addRow(tr("Prefix text"),pretext);
  9277. QLineEdit*posttext= new QLineEdit;
  9278. layout->addRow(tr("Suffix text"),posttext);
  9279. /*658:*/
  9280. #line 15201 "./typica.w"
  9281. QDomElement referenceElement=
  9282. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9283. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9284. QDomElement node;
  9285. /*:658*/
  9286. #line 16832 "./typica.w"
  9287. for(int i= 0;i<configData.size();i++)
  9288. {
  9289. node= configData.at(i).toElement();
  9290. if(node.attribute("name")=="label")
  9291. {
  9292. labelEdit->setText(node.attribute("value"));
  9293. }
  9294. else if(node.attribute("name")=="minimum")
  9295. {
  9296. minimumEdit->setText(node.attribute("value"));
  9297. }
  9298. else if(node.attribute("name")=="maximum")
  9299. {
  9300. maximumEdit->setText(node.attribute("value"));
  9301. }
  9302. else if(node.attribute("name")=="precision")
  9303. {
  9304. precisionEdit->setValue(node.attribute("value").toInt());
  9305. }
  9306. else if(node.attribute("name")=="pretext")
  9307. {
  9308. pretext->setText(node.attribute("value"));
  9309. }
  9310. else if(node.attribute("name")=="posttext")
  9311. {
  9312. posttext->setText(node.attribute("value"));
  9313. }
  9314. }
  9315. updateLabel(labelEdit->text());
  9316. updateMinimum(minimumEdit->text());
  9317. updateMaximum(maximumEdit->text());
  9318. updatePrecision(precisionEdit->value());
  9319. updatePretext(pretext->text());
  9320. updatePosttext(posttext->text());
  9321. connect(labelEdit,SIGNAL(textEdited(QString)),this,SLOT(updateLabel(QString)));
  9322. connect(minimumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMinimum(QString)));
  9323. connect(maximumEdit,SIGNAL(textEdited(QString)),this,SLOT(updateMaximum(QString)));
  9324. connect(precisionEdit,SIGNAL(valueChanged(int)),this,SLOT(updatePrecision(int)));
  9325. connect(pretext,SIGNAL(textEdited(QString)),this,SLOT(updatePretext(QString)));
  9326. connect(posttext,SIGNAL(textEdited(QString)),this,SLOT(updatePosttext(QString)));
  9327. setLayout(layout);
  9328. }
  9329. void NoteSpinConfWidget::updateLabel(const QString&text)
  9330. {
  9331. updateAttribute("label",text);
  9332. }
  9333. void NoteSpinConfWidget::updateMinimum(const QString&minimum)
  9334. {
  9335. updateAttribute("minimum",minimum);
  9336. }
  9337. void NoteSpinConfWidget::updateMaximum(const QString&maximum)
  9338. {
  9339. updateAttribute("maximum",maximum);
  9340. }
  9341. void NoteSpinConfWidget::updatePrecision(int precision)
  9342. {
  9343. updateAttribute("precision",QString("%1").arg(precision));
  9344. }
  9345. void NoteSpinConfWidget::updatePretext(const QString&text)
  9346. {
  9347. updateAttribute("pretext",text);
  9348. }
  9349. void NoteSpinConfWidget::updatePosttext(const QString&text)
  9350. {
  9351. updateAttribute("posttext",text);
  9352. }
  9353. /*:712*/
  9354. #line 831 "./typica.w"
  9355. /*270:*/
  9356. #line 6849 "./typica.w"
  9357. LinearCalibrator::LinearCalibrator(QObject*parent):
  9358. QObject(parent),Lo1(0),Lo2(0),Up1(1),Up2(1),sensitivitySetting(0.0),clamp(false)
  9359. {
  9360. }
  9361. /*:270*//*271:*/
  9362. #line 6863 "./typica.w"
  9363. void LinearCalibrator::newMeasurement(Measurement measure)
  9364. {
  9365. double outval= Lo1+(measure.temperature()-Lo2)*(Up1-Lo1)/(Up2-Lo2);
  9366. if(clamp)
  9367. {
  9368. if(outval<Lo1)
  9369. {
  9370. outval= Lo1;
  9371. }
  9372. else if(outval> Up1)
  9373. {
  9374. outval= Up1;
  9375. }
  9376. }
  9377. if(sensitivitySetting>=0.05)
  9378. {
  9379. int temp= qRound(outval/sensitivitySetting);
  9380. outval= temp*sensitivitySetting;
  9381. }
  9382. Measurement adjusted(outval,measure.time(),measure.scale());
  9383. emit measurement(adjusted);
  9384. }
  9385. /*:271*//*272:*/
  9386. #line 6889 "./typica.w"
  9387. double LinearCalibrator::measuredLower()
  9388. {
  9389. return Lo2;
  9390. }
  9391. double LinearCalibrator::measuredUpper()
  9392. {
  9393. return Up2;
  9394. }
  9395. double LinearCalibrator::mappedLower()
  9396. {
  9397. return Lo1;
  9398. }
  9399. double LinearCalibrator::mappedUpper()
  9400. {
  9401. return Up1;
  9402. }
  9403. bool LinearCalibrator::isClosedRange()
  9404. {
  9405. return clamp;
  9406. }
  9407. void LinearCalibrator::setMeasuredLower(double lower)
  9408. {
  9409. Lo2= lower;
  9410. }
  9411. void LinearCalibrator::setMeasuredUpper(double upper)
  9412. {
  9413. Up2= upper;
  9414. }
  9415. void LinearCalibrator::setMappedLower(double lower)
  9416. {
  9417. Lo1= lower;
  9418. }
  9419. void LinearCalibrator::setMappedUpper(double upper)
  9420. {
  9421. Up1= upper;
  9422. }
  9423. void LinearCalibrator::setClosedRange(bool closed)
  9424. {
  9425. clamp= closed;
  9426. }
  9427. void LinearCalibrator::setSensitivity(double sensitivity)
  9428. {
  9429. sensitivitySetting= sensitivity;
  9430. }
  9431. double LinearCalibrator::sensitivity()
  9432. {
  9433. return sensitivitySetting;
  9434. }
  9435. /*:272*/
  9436. #line 832 "./typica.w"
  9437. /*277:*/
  9438. #line 7022 "./typica.w"
  9439. void LinearSplineInterpolator::add_pair(double source,double destination)
  9440. {
  9441. pairs->insert(source,destination);
  9442. make_interpolators();
  9443. }
  9444. void LinearSplineInterpolator::make_interpolators()
  9445. {
  9446. if(pairs->size()> 1)
  9447. {
  9448. while(interpolators->size()> 0)
  9449. {
  9450. LinearCalibrator*removed= interpolators->takeFirst();
  9451. removed->deleteLater();
  9452. }
  9453. QMap<double,double> ::const_iterator i= pairs->constBegin();
  9454. QMap<double,double> ::const_iterator j= i+1;
  9455. while(j!=pairs->constEnd())
  9456. {
  9457. LinearCalibrator*segment= new LinearCalibrator();
  9458. segment->setMeasuredLower(i.key());
  9459. segment->setMappedLower(i.value());
  9460. segment->setMeasuredUpper(j.key());
  9461. segment->setMappedUpper(j.value());
  9462. segment->setClosedRange(false);
  9463. interpolators->append(segment);
  9464. connect(segment,SIGNAL(measurement(Measurement)),this,SIGNAL(newData(Measurement)));
  9465. i++;
  9466. j++;
  9467. }
  9468. }
  9469. }
  9470. LinearSplineInterpolator::LinearSplineInterpolator(QObject*parent):
  9471. QObject(parent),pairs(new QMap<double,double> ),
  9472. interpolators(new QList<LinearCalibrator*> )
  9473. {
  9474. }
  9475. void LinearSplineInterpolator::newMeasurement(Measurement measure)
  9476. {
  9477. QMap<double,double> ::const_iterator i= pairs->constBegin();
  9478. int index= -1;
  9479. while(i!=pairs->constEnd())
  9480. {
  9481. if(measure.temperature()<=i.key())
  9482. {
  9483. break;
  9484. }
  9485. i++;
  9486. index++;
  9487. }
  9488. if(index<0)
  9489. {
  9490. index= 0;
  9491. }
  9492. if(index>=interpolators->size())
  9493. {
  9494. index= interpolators->size()-1;
  9495. }
  9496. if(interpolators->at(index)!=NULL)
  9497. {
  9498. interpolators->at(index)->newMeasurement(measure);
  9499. }
  9500. }
  9501. /*:277*/
  9502. #line 833 "./typica.w"
  9503. /*734:*/
  9504. #line 18114 "./typica.w"
  9505. LinearSplineInterpolationConfWidget::LinearSplineInterpolationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  9506. :BasicDeviceConfigurationWidget(model,index),knotmodel(new SaltModel(2))
  9507. {
  9508. QFormLayout*layout= new QFormLayout;
  9509. QLineEdit*source= new QLineEdit;
  9510. layout->addRow(tr("Source column name:"),source);
  9511. QLineEdit*destination= new QLineEdit;
  9512. layout->addRow(tr("Destination column name:"),destination);
  9513. knotmodel->setHeaderData(0,Qt::Horizontal,"Input");
  9514. knotmodel->setHeaderData(1,Qt::Horizontal,"Output");
  9515. QTableView*mappingTable= new QTableView;
  9516. mappingTable->setModel(knotmodel);
  9517. NumericDelegate*delegate= new NumericDelegate;
  9518. mappingTable->setItemDelegate(delegate);
  9519. layout->addRow(tr("Mapping data:"),mappingTable);
  9520. /*658:*/
  9521. #line 15201 "./typica.w"
  9522. QDomElement referenceElement=
  9523. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9524. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9525. QDomElement node;
  9526. /*:658*/
  9527. #line 18130 "./typica.w"
  9528. for(int i= 0;i<configData.size();i++)
  9529. {
  9530. node= configData.at(i).toElement();
  9531. if(node.attribute("name")=="source")
  9532. {
  9533. source->setText(node.attribute("value"));
  9534. }
  9535. else if(node.attribute("name")=="destination")
  9536. {
  9537. destination->setText(node.attribute("value"));
  9538. }
  9539. else if(node.attribute("name")=="sourcevalues")
  9540. {
  9541. /*735:*/
  9542. #line 18169 "./typica.w"
  9543. QString data= node.attribute("value");
  9544. if(data.length()> 3)
  9545. {
  9546. data.chop(2);
  9547. data= data.remove(0,2);
  9548. }
  9549. QStringList itemList= data.split(",");
  9550. /*:735*/
  9551. #line 18144 "./typica.w"
  9552. int column= 0;
  9553. /*736:*/
  9554. #line 18181 "./typica.w"
  9555. for(int i= 0;i<itemList.size();i++)
  9556. {
  9557. knotmodel->setData(knotmodel->index(i,column),
  9558. QVariant(itemList.at(i).toDouble()),
  9559. Qt::DisplayRole);
  9560. }
  9561. /*:736*/
  9562. #line 18146 "./typica.w"
  9563. }
  9564. else if(node.attribute("name")=="destinationvalues")
  9565. {
  9566. /*735:*/
  9567. #line 18169 "./typica.w"
  9568. QString data= node.attribute("value");
  9569. if(data.length()> 3)
  9570. {
  9571. data.chop(2);
  9572. data= data.remove(0,2);
  9573. }
  9574. QStringList itemList= data.split(",");
  9575. /*:735*/
  9576. #line 18151 "./typica.w"
  9577. int column= 1;
  9578. /*736:*/
  9579. #line 18181 "./typica.w"
  9580. for(int i= 0;i<itemList.size();i++)
  9581. {
  9582. knotmodel->setData(knotmodel->index(i,column),
  9583. QVariant(itemList.at(i).toDouble()),
  9584. Qt::DisplayRole);
  9585. }
  9586. /*:736*/
  9587. #line 18153 "./typica.w"
  9588. }
  9589. }
  9590. updateSourceColumn(source->text());
  9591. updateDestinationColumn(destination->text());
  9592. updateKnots();
  9593. connect(source,SIGNAL(textEdited(QString)),this,SLOT(updateSourceColumn(QString)));
  9594. connect(destination,SIGNAL(textEdited(QString)),this,SLOT(updateDestinationColumn(QString)));
  9595. connect(knotmodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateKnots()));
  9596. setLayout(layout);
  9597. }
  9598. /*:734*//*737:*/
  9599. #line 18192 "./typica.w"
  9600. void LinearSplineInterpolationConfWidget::updateKnots()
  9601. {
  9602. updateAttribute("sourcevalues",knotmodel->arrayLiteral(0,Qt::DisplayRole));
  9603. updateAttribute("destinationvalues",knotmodel->arrayLiteral(1,Qt::DisplayRole));
  9604. }
  9605. void LinearSplineInterpolationConfWidget::updateSourceColumn(const QString&source)
  9606. {
  9607. updateAttribute("source",source);
  9608. }
  9609. void LinearSplineInterpolationConfWidget::updateDestinationColumn(const QString&dest)
  9610. {
  9611. updateAttribute("destination",dest);
  9612. }
  9613. /*:737*/
  9614. #line 834 "./typica.w"
  9615. /*740:*/
  9616. #line 18235 "./typica.w"
  9617. TranslationConfWidget::TranslationConfWidget(DeviceTreeModel*model,const QModelIndex&index)
  9618. :BasicDeviceConfigurationWidget(model,index),
  9619. temperatureValue(new QDoubleSpinBox),unitSelector(new QComboBox)
  9620. {
  9621. unitSelector->addItem("Fahrenheit");
  9622. unitSelector->addItem("Celsius");
  9623. temperatureValue->setMinimum(0);
  9624. temperatureValue->setMaximum(1000);
  9625. QFormLayout*layout= new QFormLayout;
  9626. QLineEdit*column= new QLineEdit;
  9627. layout->addRow(tr("Column to match:"),column);
  9628. layout->addRow(tr("Unit:"),unitSelector);
  9629. layout->addRow(tr("Value:"),temperatureValue);
  9630. /*658:*/
  9631. #line 15201 "./typica.w"
  9632. QDomElement referenceElement=
  9633. model->referenceElement(model->data(index,Qt::UserRole).toString());
  9634. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  9635. QDomElement node;
  9636. /*:658*/
  9637. #line 18249 "./typica.w"
  9638. for(int i= 0;i<configData.size();i++)
  9639. {
  9640. node= configData.at(i).toElement();
  9641. if(node.attribute("name")=="column")
  9642. {
  9643. column->setText(node.attribute("value"));
  9644. }
  9645. else if(node.attribute("name")=="unit")
  9646. {
  9647. unitSelector->setCurrentIndex(unitSelector->findText(node.attribute("value")));
  9648. }
  9649. else if(node.attribute("name")=="value")
  9650. {
  9651. temperatureValue->setValue(node.attribute("value").toDouble());
  9652. }
  9653. }
  9654. updateMatchingColumn(column->text());
  9655. updateTemperature();
  9656. connect(column,SIGNAL(textEdited(QString)),this,SLOT(updateMatchingColumn(QString)));
  9657. connect(unitSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateTemperature()));
  9658. connect(temperatureValue,SIGNAL(valueChanged(double)),this,SLOT(updateTemperature()));
  9659. setLayout(layout);
  9660. }
  9661. /*:740*//*741:*/
  9662. #line 18278 "./typica.w"
  9663. void TranslationConfWidget::updateTemperature()
  9664. {
  9665. updateAttribute("unit",unitSelector->currentText());
  9666. updateAttribute("value",QString("%1").arg(temperatureValue->value()));
  9667. if(unitSelector->currentText()=="Fahrenheit")
  9668. {
  9669. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()));
  9670. }
  9671. else
  9672. {
  9673. updateAttribute("FValue",QString("%1").arg(temperatureValue->value()*9/5+32));
  9674. }
  9675. }
  9676. void TranslationConfWidget::updateMatchingColumn(const QString&column)
  9677. {
  9678. updateAttribute("column",column);
  9679. }
  9680. /*:741*/
  9681. #line 835 "./typica.w"
  9682. /*:17*/
  9683. #line 763 "./typica.w"
  9684. /*21:*/
  9685. #line 895 "./typica.w"
  9686. template<class TYPE> TYPE getself(QScriptContext*context)
  9687. {
  9688. TYPE self= qobject_cast<TYPE> (context->thisObject().toQObject());
  9689. return self;
  9690. }
  9691. template<> QTime getself(QScriptContext*context)
  9692. {
  9693. QTime self= context->thisObject().toVariant().toTime();
  9694. return self;
  9695. }
  9696. template<> SqlQueryConnection*getself(QScriptContext*context)
  9697. {
  9698. SqlQueryConnection*self=
  9699. (SqlQueryConnection*)qscriptvalue_cast<void*> (context->thisObject());
  9700. return self;
  9701. }
  9702. template<> QXmlQuery*getself(QScriptContext*context)
  9703. {
  9704. QXmlQuery*self=
  9705. (QXmlQuery*)qscriptvalue_cast<void*> (context->thisObject());
  9706. return self;
  9707. }
  9708. template<> QXmlStreamWriter*getself(QScriptContext*context)
  9709. {
  9710. QXmlStreamWriter*self=
  9711. (QXmlStreamWriter*)qscriptvalue_cast<void*> (context->thisObject());
  9712. return self;
  9713. }
  9714. template<> QXmlStreamReader*getself(QScriptContext*context)
  9715. {
  9716. QXmlStreamReader*self=
  9717. (QXmlStreamReader*)qscriptvalue_cast<void*> (context->thisObject());
  9718. return self;
  9719. }
  9720. /*:21*//*22:*/
  9721. #line 940 "./typica.w"
  9722. template<class TYPE> TYPE argument(int arg,QScriptContext*context)
  9723. {
  9724. TYPE argument= qobject_cast<TYPE> (context->argument(arg).toQObject());
  9725. return argument;
  9726. }
  9727. template<> QString argument(int arg,QScriptContext*context)
  9728. {
  9729. return context->argument(arg).toString();
  9730. }
  9731. template<> QVariant argument(int arg,QScriptContext*context)
  9732. {
  9733. return context->argument(arg).toVariant();
  9734. }
  9735. template<> int argument(int arg,QScriptContext*context)
  9736. {
  9737. return context->argument(arg).toInt32();
  9738. }
  9739. template<> SqlQueryConnection*argument(int arg,QScriptContext*context)
  9740. {
  9741. return(SqlQueryConnection*)
  9742. qscriptvalue_cast<void*> (context->argument(arg));
  9743. }
  9744. template<> QModelIndex argument(int arg,QScriptContext*context)
  9745. {
  9746. return qscriptvalue_cast<QModelIndex> (context->argument(arg));
  9747. }
  9748. /*:22*//*26:*/
  9749. #line 1017 "./typica.w"
  9750. void setQObjectProperties(QScriptValue,QScriptEngine*)
  9751. {
  9752. }
  9753. /*:26*//*28:*/
  9754. #line 1031 "./typica.w"
  9755. void setQPaintDeviceProperties(QScriptValue,QScriptEngine*)
  9756. {
  9757. }
  9758. void setQLayoutItemProperties(QScriptValue,QScriptEngine*)
  9759. {
  9760. }
  9761. /*:28*//*31:*/
  9762. #line 1070 "./typica.w"
  9763. QScriptValue constructQWidget(QScriptContext*,QScriptEngine*engine)
  9764. {
  9765. QScriptValue object= engine->newQObject(new QWidget);
  9766. setQWidgetProperties(object,engine);
  9767. return object;
  9768. }
  9769. void setQWidgetProperties(QScriptValue value,QScriptEngine*engine)
  9770. {
  9771. setQObjectProperties(value,engine);
  9772. setQPaintDeviceProperties(value,engine);
  9773. value.setProperty("setLayout",engine->newFunction(QWidget_setLayout));
  9774. value.setProperty("activateWindow",
  9775. engine->newFunction(QWidget_activateWindow));
  9776. }
  9777. /*:31*//*32:*/
  9778. #line 1092 "./typica.w"
  9779. QScriptValue QWidget_setLayout(QScriptContext*context,QScriptEngine*)
  9780. {
  9781. if(context->argumentCount()==1)
  9782. {
  9783. QWidget*self= getself<QWidget*> (context);
  9784. QLayout*layout= argument<QLayout*> (0,context);
  9785. if(layout)
  9786. {
  9787. self->setLayout(layout);
  9788. }
  9789. else
  9790. {
  9791. context->throwError("Incorrect argument type passed to "
  9792. "QWidget::setLayout(). This method requires "
  9793. "a QLayout.");
  9794. }
  9795. }
  9796. else
  9797. {
  9798. context->throwError("Incorrect number of arguments passed to "
  9799. "QWidget::setLayout(). This method takes one "
  9800. "QLayout as an argument.");
  9801. }
  9802. return QScriptValue();
  9803. }
  9804. QScriptValue QWidget_activateWindow(QScriptContext*context,
  9805. QScriptEngine*)
  9806. {
  9807. QWidget*self= getself<QWidget*> (context);
  9808. self->activateWindow();
  9809. return QScriptValue();
  9810. }
  9811. /*:32*//*34:*/
  9812. #line 1166 "./typica.w"
  9813. ScriptQMainWindow::ScriptQMainWindow():QMainWindow(NULL)
  9814. {
  9815. }
  9816. void ScriptQMainWindow::saveSizeAndPosition(const QString&key)
  9817. {
  9818. QSettings settings;
  9819. settings.beginGroup(key);
  9820. settings.setValue("pos",pos());
  9821. settings.setValue("size",size());
  9822. settings.endGroup();
  9823. }
  9824. void ScriptQMainWindow::restoreSizeAndPosition(const QString&key)
  9825. {
  9826. QSettings settings;
  9827. settings.beginGroup(key);
  9828. if(settings.contains("size"))
  9829. {
  9830. resize(settings.value("size").toSize());
  9831. }
  9832. if(settings.contains("pos"))
  9833. {
  9834. move(settings.value("pos").toPoint());
  9835. }
  9836. settings.endGroup();
  9837. }
  9838. void ScriptQMainWindow::displayStatus(const QString&message)
  9839. {
  9840. statusBar()->showMessage(message);
  9841. }
  9842. void ScriptQMainWindow::showEvent(QShowEvent*event)
  9843. {
  9844. if(!event->spontaneous())
  9845. {
  9846. /*36:*/
  9847. #line 1240 "./typica.w"
  9848. QSettings settings;
  9849. restoreGeometry(settings.value(QString("geometries/%1").arg(objectName())).
  9850. toByteArray());
  9851. /*:36*/
  9852. #line 1205 "./typica.w"
  9853. event->accept();
  9854. }
  9855. else
  9856. {
  9857. event->ignore();
  9858. }
  9859. }
  9860. void ScriptQMainWindow::show()
  9861. {
  9862. QMainWindow::show();
  9863. }
  9864. void ScriptQMainWindow::closeEvent(QCloseEvent*event)
  9865. {
  9866. emit aboutToClose();
  9867. /*35:*/
  9868. #line 1234 "./typica.w"
  9869. QSettings settings;
  9870. settings.setValue(QString("geometries/%1").arg(objectName()),saveGeometry());
  9871. /*:35*/
  9872. #line 1222 "./typica.w"
  9873. event->accept();
  9874. }
  9875. /*:34*//*39:*/
  9876. #line 1268 "./typica.w"
  9877. QScriptValue constructQMainWindow(QScriptContext*,QScriptEngine*engine)
  9878. {
  9879. QScriptValue object= engine->newQObject(new ScriptQMainWindow);
  9880. setQMainWindowProperties(object,engine);
  9881. return object;
  9882. }
  9883. void setQMainWindowProperties(QScriptValue value,QScriptEngine*engine)
  9884. {
  9885. setQWidgetProperties(value,engine);
  9886. value.setProperty("setCentralWidget",
  9887. engine->newFunction(QMainWindow_setCentralWidget));
  9888. value.setProperty("menuBar",engine->newFunction(QMainWindow_menuBar));
  9889. }
  9890. /*:39*//*40:*/
  9891. #line 1290 "./typica.w"
  9892. QScriptValue QMainWindow_setCentralWidget(QScriptContext*context,
  9893. QScriptEngine*)
  9894. {
  9895. if(context->argumentCount()==1)
  9896. {
  9897. QMainWindow*self= getself<QMainWindow*> (context);
  9898. QWidget*widget= argument<QWidget*> (0,context);
  9899. if(widget)
  9900. {
  9901. self->setCentralWidget(widget);
  9902. }
  9903. else
  9904. {
  9905. context->throwError("Incorrect argument type passed to "
  9906. "QMainWindow::setCentralWidget(). This "
  9907. "method requires a QWidget.");
  9908. }
  9909. }
  9910. else
  9911. {
  9912. context->throwError("Incorrect number of arguments passed to "
  9913. "QMainWindow::setCentralWidget(). This method "
  9914. "takes one QWidget as an argument.");
  9915. }
  9916. return QScriptValue();
  9917. }
  9918. /*:40*//*41:*/
  9919. #line 1324 "./typica.w"
  9920. QScriptValue QMainWindow_menuBar(QScriptContext*context,QScriptEngine*engine)
  9921. {
  9922. QScriptValue object;
  9923. if(context->argumentCount()==0)
  9924. {
  9925. QMainWindow*self= getself<QMainWindow*> (context);
  9926. QMenuBar*bar= self->menuBar();
  9927. object= engine->newQObject(bar);
  9928. setQMenuBarProperties(object,engine);
  9929. }
  9930. else
  9931. {
  9932. context->throwError("Incorrect number of arguments passed to "
  9933. "QMainWindow::menuBar(). This method takes no "
  9934. "arguments.");
  9935. }
  9936. return object;
  9937. }
  9938. /*:41*//*43:*/
  9939. #line 1354 "./typica.w"
  9940. void setQMenuBarProperties(QScriptValue value,QScriptEngine*engine)
  9941. {
  9942. setQWidgetProperties(value,engine);
  9943. value.setProperty("addMenu",engine->newFunction(QMenuBar_addMenu));
  9944. }
  9945. /*:43*//*44:*/
  9946. #line 1369 "./typica.w"
  9947. QScriptValue QMenuBar_addMenu(QScriptContext*context,QScriptEngine*engine)
  9948. {
  9949. QScriptValue object;
  9950. if(context->argumentCount()==1)
  9951. {
  9952. QMenuBar*self= getself<QMenuBar*> (context);
  9953. QString title= argument<QString> (0,context);
  9954. object= engine->newQObject(self->addMenu(title));
  9955. setQMenuProperties(object,engine);
  9956. }
  9957. else
  9958. {
  9959. context->throwError("Incorrect number of arguments passed to "
  9960. "QMenuBar::addMenu(). This method takes one "
  9961. "string as an argument.");
  9962. }
  9963. return object;
  9964. }
  9965. /*:44*//*46:*/
  9966. #line 1399 "./typica.w"
  9967. void setQMenuProperties(QScriptValue value,QScriptEngine*engine)
  9968. {
  9969. setQWidgetProperties(value,engine);
  9970. value.setProperty("addAction",engine->newFunction(QMenu_addAction));
  9971. value.setProperty("addSeparator",engine->newFunction(QMenu_addSeparator));
  9972. }
  9973. /*:46*//*47:*/
  9974. #line 1409 "./typica.w"
  9975. QScriptValue QMenu_addAction(QScriptContext*context,QScriptEngine*)
  9976. {
  9977. if(context->argumentCount()==1)
  9978. {
  9979. QMenu*self= getself<QMenu*> (context);
  9980. QAction*action= argument<QAction*> (0,context);
  9981. if(action)
  9982. {
  9983. self->addAction(action);
  9984. }
  9985. else
  9986. {
  9987. context->throwError("Incorrect argument type passed to "
  9988. "QMenu::addAction(). This method requires a "
  9989. "QAction.");
  9990. }
  9991. }
  9992. else
  9993. {
  9994. context->throwError("Incorrect number of arguments passed to "
  9995. "QMenu::addAction(). This method takes one "
  9996. "QAction as an argument.");
  9997. }
  9998. return QScriptValue();
  9999. }
  10000. QScriptValue QMenu_addSeparator(QScriptContext*context,QScriptEngine*)
  10001. {
  10002. if(context->argumentCount()==0)
  10003. {
  10004. QMenu*self= getself<QMenu*> (context);
  10005. self->addSeparator();
  10006. }
  10007. else
  10008. {
  10009. context->throwError("Incorrect number of arguments passed to "
  10010. "QMenu::addSeparator(). This method takes no "
  10011. "arguments.");
  10012. }
  10013. return QScriptValue();
  10014. }
  10015. /*:47*//*50:*/
  10016. #line 1471 "./typica.w"
  10017. QScriptValue constructQFrame(QScriptContext*,QScriptEngine*engine)
  10018. {
  10019. QScriptValue object= engine->newQObject(new QFrame);
  10020. setQFrameProperties(object,engine);
  10021. return object;
  10022. }
  10023. void setQFrameProperties(QScriptValue value,QScriptEngine*engine)
  10024. {
  10025. setQWidgetProperties(value,engine);
  10026. }
  10027. /*:50*//*53:*/
  10028. #line 1505 "./typica.w"
  10029. QScriptValue constructQLabel(QScriptContext*context,QScriptEngine*engine)
  10030. {
  10031. QString text;
  10032. if(context->argumentCount()==1)
  10033. {
  10034. text= argument<QString> (0,context);
  10035. }
  10036. QScriptValue object= engine->newQObject(new QLabel(text));
  10037. setQLabelProperties(object,engine);
  10038. return object;
  10039. }
  10040. void setQLabelProperties(QScriptValue value,QScriptEngine*engine)
  10041. {
  10042. setQFrameProperties(value,engine);
  10043. }
  10044. /*:53*//*56:*/
  10045. #line 1551 "./typica.w"
  10046. QScriptValue constructQSplitter(QScriptContext*,QScriptEngine*engine)
  10047. {
  10048. QScriptValue object= engine->newQObject(new QSplitter);
  10049. setQSplitterProperties(object,engine);
  10050. return object;
  10051. }
  10052. void setQSplitterProperties(QScriptValue value,QScriptEngine*engine)
  10053. {
  10054. setQFrameProperties(value,engine);
  10055. value.setProperty("addWidget",engine->newFunction(QSplitter_addWidget));
  10056. value.setProperty("saveState",engine->newFunction(QSplitter_saveState));
  10057. value.setProperty("restoreState",
  10058. engine->newFunction(QSplitter_restoreState));
  10059. }
  10060. /*:56*//*57:*/
  10061. #line 1571 "./typica.w"
  10062. QScriptValue QSplitter_addWidget(QScriptContext*context,QScriptEngine*)
  10063. {
  10064. if(context->argumentCount()==1)
  10065. {
  10066. QSplitter*self= getself<QSplitter*> (context);
  10067. QWidget*widget= argument<QWidget*> (0,context);
  10068. if(widget)
  10069. {
  10070. self->addWidget(widget);
  10071. }
  10072. else
  10073. {
  10074. context->throwError("Incorrect argument type passed to "
  10075. "QSplitter::addWidget(). This method "
  10076. "requires a QWidget.");
  10077. }
  10078. }
  10079. else
  10080. {
  10081. context->throwError("Incorrect number of arguments passed to "
  10082. "QSplitter::addWidget(). This method takes one "
  10083. "QWidget as an argument.");
  10084. }
  10085. return QScriptValue();
  10086. }
  10087. /*:57*//*58:*/
  10088. #line 1604 "./typica.w"
  10089. QScriptValue QSplitter_saveState(QScriptContext*context,QScriptEngine*)
  10090. {
  10091. if(context->argumentCount()==1)
  10092. {
  10093. QSplitter*self= getself<QSplitter*> (context);
  10094. QString key= argument<QString> (0,context);
  10095. QSettings settings;
  10096. settings.setValue(key,self->saveState());
  10097. }
  10098. else
  10099. {
  10100. context->throwError("Incorrect number of arguments passed to "
  10101. "QSplitter::saveState(). This method takes one "
  10102. "string as an argument.");
  10103. }
  10104. return QScriptValue();
  10105. }
  10106. QScriptValue QSplitter_restoreState(QScriptContext*context,QScriptEngine*)
  10107. {
  10108. if(context->argumentCount()==1)
  10109. {
  10110. QSplitter*self= getself<QSplitter*> (context);
  10111. QString key= argument<QString> (0,context);
  10112. QSettings settings;
  10113. self->restoreState(settings.value(key).toByteArray());
  10114. }
  10115. else
  10116. {
  10117. context->throwError("Incorrect number of arguments passed to "
  10118. "QSplitter::restoreState(). This method takes "
  10119. "one string as an argument.");
  10120. }
  10121. return QScriptValue();
  10122. }
  10123. /*:58*//*60:*/
  10124. #line 1657 "./typica.w"
  10125. void setQLayoutProperties(QScriptValue value,QScriptEngine*engine)
  10126. {
  10127. setQLayoutItemProperties(value,engine);
  10128. value.setProperty("addWidget",engine->newFunction(QLayout_addWidget));
  10129. }
  10130. QScriptValue QLayout_addWidget(QScriptContext*context,QScriptEngine*)
  10131. {
  10132. if(context->argumentCount()==1)
  10133. {
  10134. QLayout*self= getself<QLayout*> (context);
  10135. QWidget*widget= argument<QWidget*> (0,context);
  10136. if(widget)
  10137. {
  10138. self->addWidget(widget);
  10139. }
  10140. else
  10141. {
  10142. context->throwError("Incorrect argument type passed to "
  10143. "QLayout::addWidget(). This method requires "
  10144. "a QWidget.");
  10145. }
  10146. }
  10147. else
  10148. {
  10149. context->throwError("Incorrect number of arguments passed to "
  10150. "QLayout::addWidget(). This method takes one "
  10151. "QWidget as an argument.");
  10152. }
  10153. return QScriptValue();
  10154. }
  10155. /*:60*//*63:*/
  10156. #line 1724 "./typica.w"
  10157. QScriptValue constructQBoxLayout(QScriptContext*,QScriptEngine*engine)
  10158. {
  10159. QScriptValue object=
  10160. engine->newQObject(new QBoxLayout(QBoxLayout::LeftToRight));
  10161. setQBoxLayoutProperties(object,engine);
  10162. return object;
  10163. }
  10164. void setQBoxLayoutProperties(QScriptValue value,QScriptEngine*engine)
  10165. {
  10166. setQLayoutProperties(value,engine);
  10167. value.setProperty("addLayout",engine->newFunction(QBoxLayout_addLayout));
  10168. value.setProperty("addWidget",engine->newFunction(QBoxLayout_addWidget));
  10169. }
  10170. QScriptValue QBoxLayout_addLayout(QScriptContext*context,QScriptEngine*)
  10171. {
  10172. if(context->argumentCount()> 0&&context->argumentCount()<3)
  10173. {
  10174. QBoxLayout*self= getself<QBoxLayout*> (context);
  10175. QLayout*layout= argument<QLayout*> (0,context);
  10176. int stretch= 0;
  10177. if(context->argumentCount()==2)
  10178. {
  10179. stretch= argument<int> (1,context);
  10180. }
  10181. if(layout)
  10182. {
  10183. self->addLayout(layout,stretch);
  10184. }
  10185. else
  10186. {
  10187. context->throwError("Incorrect argument type passed to "
  10188. "QLayout::addLayout(). This method requires "
  10189. "a QLayout.");
  10190. }
  10191. }
  10192. else
  10193. {
  10194. context->throwError("Incorrect number of arguments passed to "
  10195. "QLayout::addLayout(). This method takes one "
  10196. "QLayout as an argument and optionally one integer.");
  10197. }
  10198. return QScriptValue();
  10199. }
  10200. /*:63*//*64:*/
  10201. #line 1775 "./typica.w"
  10202. QScriptValue QBoxLayout_addWidget(QScriptContext*context,QScriptEngine*)
  10203. {
  10204. if(context->argumentCount()> 0&&context->argumentCount()<4)
  10205. {
  10206. QBoxLayout*self= getself<QBoxLayout*> (context);
  10207. QWidget*widget= argument<QWidget*> (0,context);
  10208. int stretch= 0;
  10209. Qt::Alignment alignment= 0;
  10210. if(context->argumentCount()> 1)
  10211. {
  10212. stretch= argument<int> (1,context);
  10213. }
  10214. if(context->argumentCount()> 2)
  10215. {
  10216. alignment= (Qt::Alignment)(argument<int> (2,context));
  10217. }
  10218. if(widget)
  10219. {
  10220. self->addWidget(widget,stretch,alignment);
  10221. }
  10222. else
  10223. {
  10224. context->throwError("Incorrect argument type passed to "
  10225. "QBoxLayout::addWidget(). This method requires "
  10226. "a QWidget.");
  10227. }
  10228. }
  10229. else
  10230. {
  10231. context->throwError("Incorrect number of arguments passed to "
  10232. "QBoxLayout::addWidget(). This method takes one "
  10233. "QWidget and optionally up to two integers as "
  10234. "arguments.");
  10235. }
  10236. return QScriptValue();
  10237. }
  10238. /*:64*//*67:*/
  10239. #line 1839 "./typica.w"
  10240. QScriptValue constructQAction(QScriptContext*,QScriptEngine*engine)
  10241. {
  10242. QScriptValue object= engine->newQObject(new QAction(NULL));
  10243. setQActionProperties(object,engine);
  10244. return object;
  10245. }
  10246. void setQActionProperties(QScriptValue value,QScriptEngine*engine)
  10247. {
  10248. setQObjectProperties(value,engine);
  10249. value.setProperty("setShortcut",engine->newFunction(QAction_setShortcut));
  10250. }
  10251. QScriptValue QAction_setShortcut(QScriptContext*context,QScriptEngine*)
  10252. {
  10253. if(context->argumentCount()==1)
  10254. {
  10255. QAction*self= getself<QAction*> (context);
  10256. self->setShortcut(argument<QString> (0,context));
  10257. }
  10258. else
  10259. {
  10260. context->throwError("Incorrect number of arguments passed to "
  10261. "QAction::setShortcut(). This method takes one "
  10262. "string as an argument.");
  10263. }
  10264. return QScriptValue();
  10265. }
  10266. /*:67*//*70:*/
  10267. #line 1897 "./typica.w"
  10268. QScriptValue QFileDialog_getOpenFileName(QScriptContext*context,
  10269. QScriptEngine*engine)
  10270. {
  10271. QScriptValue retval;
  10272. if(context->argumentCount()==3)
  10273. {
  10274. QWidget*widget= argument<QWidget*> (0,context);
  10275. if(widget)
  10276. {
  10277. QString caption= argument<QString> (1,context);
  10278. QString dir= argument<QString> (2,context);
  10279. retval= QScriptValue(engine,
  10280. QFileDialog::getOpenFileName(widget,caption,
  10281. dir,"",0,0));
  10282. setQFileDialogProperties(retval,engine);
  10283. }
  10284. else
  10285. {
  10286. context->throwError("Incorrect argument type passed to "
  10287. "QFileDialog::getOpenFileName(). The first "
  10288. "argument to this method must be a QWidget.");
  10289. }
  10290. }
  10291. else
  10292. {
  10293. context->throwError("Incorrect number of arguments passed to "
  10294. "QFileDialog::getOpenFileName(). This method "
  10295. "takes one QWidget followed by two strings for a "
  10296. "total of three arguments.");
  10297. }
  10298. return retval;
  10299. }
  10300. /*:70*//*71:*/
  10301. #line 1933 "./typica.w"
  10302. QScriptValue QFileDialog_getSaveFileName(QScriptContext*context,
  10303. QScriptEngine*engine)
  10304. {
  10305. QScriptValue retval;
  10306. if(context->argumentCount()==3)
  10307. {
  10308. QWidget*widget= argument<QWidget*> (0,context);
  10309. if(widget)
  10310. {
  10311. QString caption= argument<QString> (1,context);
  10312. QString dir= argument<QString> (2,context);
  10313. retval= QScriptValue(engine,
  10314. QFileDialog::getSaveFileName(widget,caption,
  10315. dir,"",0,0));
  10316. setQFileDialogProperties(retval,engine);
  10317. }
  10318. else
  10319. {
  10320. context->throwError("Incorrect argument type passed to "
  10321. "QFileDialog::getSaveFileName(). The first "
  10322. "argument to this method must be a QWidget.");
  10323. }
  10324. }
  10325. else
  10326. {
  10327. context->throwError("Incorrect number of arguments passed to "
  10328. "QFileDialog::getSaveFileName(). This method "
  10329. "takes one QWidget followed by two strings for a "
  10330. "total of three arguments.");
  10331. }
  10332. return retval;
  10333. }
  10334. /*:71*//*72:*/
  10335. #line 1970 "./typica.w"
  10336. void setQFileDialogProperties(QScriptValue value,QScriptEngine*engine)
  10337. {
  10338. setQDialogProperties(value,engine);
  10339. }
  10340. void setQDialogProperties(QScriptValue value,QScriptEngine*engine)
  10341. {
  10342. setQWidgetProperties(value,engine);
  10343. }
  10344. /*:72*//*75:*/
  10345. #line 2005 "./typica.w"
  10346. QScriptValue constructQFile(QScriptContext*context,QScriptEngine*engine)
  10347. {
  10348. QScriptValue object=
  10349. engine->newQObject(new QFile(argument<QString> (0,context)));
  10350. setQFileProperties(object,engine);
  10351. return object;
  10352. }
  10353. /*:75*//*76:*/
  10354. #line 2016 "./typica.w"
  10355. void setQFileProperties(QScriptValue value,QScriptEngine*engine)
  10356. {
  10357. setQIODeviceProperties(value,engine);
  10358. value.setProperty("remove",engine->newFunction(QFile_remove));
  10359. }
  10360. QScriptValue QFile_remove(QScriptContext*context,QScriptEngine*engine)
  10361. {
  10362. QFile*self= getself<QFile*> (context);
  10363. bool retval= self->remove();
  10364. return QScriptValue(engine,retval);
  10365. }
  10366. /*:76*//*77:*/
  10367. #line 2038 "./typica.w"
  10368. void setQIODeviceProperties(QScriptValue value,QScriptEngine*engine)
  10369. {
  10370. setQObjectProperties(value,engine);
  10371. value.setProperty("open",engine->newFunction(QIODevice_open));
  10372. value.setProperty("close",engine->newFunction(QIODevice_close));
  10373. value.setProperty("readToString",
  10374. engine->newFunction(QIODevice_readToString));
  10375. }
  10376. /*:77*//*78:*/
  10377. #line 2053 "./typica.w"
  10378. QScriptValue QIODevice_open(QScriptContext*context,QScriptEngine*)
  10379. {
  10380. QIODevice*self= getself<QIODevice*> (context);
  10381. if(context->argumentCount()==1)
  10382. {
  10383. switch(argument<int> (0,context))
  10384. {
  10385. case 1:
  10386. self->open(QIODevice::ReadOnly);
  10387. break;
  10388. case 2:
  10389. self->open(QIODevice::WriteOnly);
  10390. break;
  10391. case 3:
  10392. self->open(QIODevice::ReadWrite);
  10393. break;
  10394. default:
  10395. break;
  10396. }
  10397. }
  10398. else
  10399. {
  10400. self->open(QIODevice::ReadWrite);
  10401. }
  10402. return QScriptValue();
  10403. }
  10404. QScriptValue QIODevice_close(QScriptContext*context,QScriptEngine*)
  10405. {
  10406. QIODevice*self= getself<QIODevice*> (context);
  10407. self->close();
  10408. return QScriptValue();
  10409. }
  10410. /*:78*//*79:*/
  10411. #line 2092 "./typica.w"
  10412. QScriptValue QIODevice_readToString(QScriptContext*context,QScriptEngine*)
  10413. {
  10414. QIODevice*self= getself<QIODevice*> (context);
  10415. self->reset();
  10416. return QScriptValue(QString(self->readAll()));
  10417. }
  10418. /*:79*//*82:*/
  10419. #line 2122 "./typica.w"
  10420. QScriptValue constructQBuffer(QScriptContext*context,QScriptEngine*engine)
  10421. {
  10422. QByteArray*array= new QByteArray(argument<QString> (0,context).toAscii());
  10423. QScriptValue object= engine->newQObject(new QBuffer(array));
  10424. setQBufferProperties(object,engine);
  10425. return object;
  10426. }
  10427. void setQBufferProperties(QScriptValue value,QScriptEngine*engine)
  10428. {
  10429. setQIODeviceProperties(value,engine);
  10430. value.setProperty("setData",engine->newFunction(QBuffer_setData));
  10431. }
  10432. QScriptValue QBuffer_setData(QScriptContext*context,QScriptEngine*)
  10433. {
  10434. QBuffer*self= getself<QBuffer*> (context);
  10435. self->setData(argument<QString> (0,context).toAscii());
  10436. return QScriptValue();
  10437. }
  10438. /*:82*//*85:*/
  10439. #line 2170 "./typica.w"
  10440. QScriptValue constructXQuery(QScriptContext*,QScriptEngine*engine)
  10441. {
  10442. QScriptValue object= engine->toScriptValue<void*> (new QXmlQuery);
  10443. setXQueryProperties(object,engine);
  10444. return object;
  10445. }
  10446. void setXQueryProperties(QScriptValue value,QScriptEngine*engine)
  10447. {
  10448. value.setProperty("bind",engine->newFunction(XQuery_bind));
  10449. value.setProperty("exec",engine->newFunction(XQuery_exec));
  10450. value.setProperty("setQuery",engine->newFunction(XQuery_setQuery));
  10451. }
  10452. /*:85*//*86:*/
  10453. #line 2188 "./typica.w"
  10454. QScriptValue XQuery_bind(QScriptContext*context,QScriptEngine*)
  10455. {
  10456. QXmlQuery*self= getself<QXmlQuery*> (context);
  10457. QIODevice*buffer= argument<QIODevice*> (1,context);
  10458. self->bindVariable(argument<QString> (0,context),buffer);
  10459. return QScriptValue();
  10460. }
  10461. /*:86*//*87:*/
  10462. #line 2199 "./typica.w"
  10463. QScriptValue XQuery_setQuery(QScriptContext*context,QScriptEngine*)
  10464. {
  10465. QXmlQuery*self= getself<QXmlQuery*> (context);
  10466. self->setQuery(argument<QString> (0,context));
  10467. return QScriptValue();
  10468. }
  10469. /*:87*//*88:*/
  10470. #line 2209 "./typica.w"
  10471. QScriptValue XQuery_exec(QScriptContext*context,QScriptEngine*)
  10472. {
  10473. QXmlQuery*self= getself<QXmlQuery*> (context);
  10474. QString result;
  10475. self->evaluateTo(&result);
  10476. return QScriptValue(result);
  10477. }
  10478. /*:88*//*91:*/
  10479. #line 2264 "./typica.w"
  10480. QScriptValue constructXmlWriter(QScriptContext*context,QScriptEngine*engine)
  10481. {
  10482. QXmlStreamWriter*retval;
  10483. if(context->argumentCount()==1)
  10484. {
  10485. retval= new QXmlStreamWriter(argument<QIODevice*> (0,context));
  10486. }
  10487. else
  10488. {
  10489. retval= new QXmlStreamWriter;
  10490. }
  10491. QScriptValue object= engine->toScriptValue<void*> (retval);
  10492. setXmlWriterProperties(object,engine);
  10493. return object;
  10494. }
  10495. void setXmlWriterProperties(QScriptValue value,QScriptEngine*engine)
  10496. {
  10497. value.setProperty("setDevice",engine->newFunction(XmlWriter_setDevice));
  10498. value.setProperty("writeAttribute",
  10499. engine->newFunction(XmlWriter_writeAttribute));
  10500. value.setProperty("writeCDATA",engine->newFunction(XmlWriter_writeCDATA));
  10501. value.setProperty("writeCharacters",
  10502. engine->newFunction(XmlWriter_writeCharacters));
  10503. value.setProperty("writeDTD",engine->newFunction(XmlWriter_writeDTD));
  10504. value.setProperty("writeEmptyElement",
  10505. engine->newFunction(XmlWriter_writeEmptyElement));
  10506. value.setProperty("writeEndDocument",
  10507. engine->newFunction(XmlWriter_writeEndDocument));
  10508. value.setProperty("writeEndElement",
  10509. engine->newFunction(XmlWriter_writeEndElement));
  10510. value.setProperty("writeEntityReference",
  10511. engine->newFunction(XmlWriter_writeEntityReference));
  10512. value.setProperty("writeProcessingInstruction",
  10513. engine->newFunction(XmlWriter_writeProcessingInstruction));
  10514. value.setProperty("writeStartDocument",
  10515. engine->newFunction(XmlWriter_writeStartDocument));
  10516. value.setProperty("writeStartElement",
  10517. engine->newFunction(XmlWriter_writeStartElement));
  10518. value.setProperty("writeTextElement",
  10519. engine->newFunction(XmlWriter_writeTextElement));
  10520. }
  10521. /*:91*//*92:*/
  10522. #line 2311 "./typica.w"
  10523. QScriptValue XmlWriter_setDevice(QScriptContext*context,QScriptEngine*)
  10524. {
  10525. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10526. QIODevice*device= argument<QIODevice*> (0,context);
  10527. self->setDevice(device);
  10528. return QScriptValue();
  10529. }
  10530. /*:92*//*93:*/
  10531. #line 2325 "./typica.w"
  10532. QScriptValue XmlWriter_writeStartDocument(QScriptContext*context,
  10533. QScriptEngine*)
  10534. {
  10535. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10536. self->writeStartDocument(argument<QString> (0,context));
  10537. return QScriptValue();
  10538. }
  10539. QScriptValue XmlWriter_writeEndDocument(QScriptContext*context,
  10540. QScriptEngine*)
  10541. {
  10542. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10543. self->writeEndDocument();
  10544. return QScriptValue();
  10545. }
  10546. /*:93*//*94:*/
  10547. #line 2344 "./typica.w"
  10548. QScriptValue XmlWriter_writeDTD(QScriptContext*context,QScriptEngine*)
  10549. {
  10550. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10551. self->writeDTD(argument<QString> (0,context));
  10552. return QScriptValue();
  10553. }
  10554. /*:94*//*95:*/
  10555. #line 2355 "./typica.w"
  10556. QScriptValue XmlWriter_writeStartElement(QScriptContext*context,
  10557. QScriptEngine*)
  10558. {
  10559. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10560. self->writeStartElement(argument<QString> (0,context));
  10561. return QScriptValue();
  10562. }
  10563. QScriptValue XmlWriter_writeAttribute(QScriptContext*context,QScriptEngine*)
  10564. {
  10565. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10566. self->writeAttribute(argument<QString> (0,context),
  10567. argument<QString> (1,context));
  10568. return QScriptValue();
  10569. }
  10570. QScriptValue XmlWriter_writeCharacters(QScriptContext*context,QScriptEngine*)
  10571. {
  10572. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10573. self->writeCharacters(argument<QString> (0,context));
  10574. return QScriptValue();
  10575. }
  10576. QScriptValue XmlWriter_writeEndElement(QScriptContext*context,QScriptEngine*)
  10577. {
  10578. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10579. self->writeEndElement();
  10580. return QScriptValue();
  10581. }
  10582. /*:95*//*96:*/
  10583. #line 2391 "./typica.w"
  10584. QScriptValue XmlWriter_writeEmptyElement(QScriptContext*context,
  10585. QScriptEngine*)
  10586. {
  10587. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10588. self->writeEmptyElement(argument<QString> (0,context));
  10589. return QScriptValue();
  10590. }
  10591. QScriptValue XmlWriter_writeTextElement(QScriptContext*context,
  10592. QScriptEngine*)
  10593. {
  10594. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10595. self->writeTextElement(argument<QString> (0,context),
  10596. argument<QString> (1,context));
  10597. return QScriptValue();
  10598. }
  10599. /*:96*//*97:*/
  10600. #line 2412 "./typica.w"
  10601. QScriptValue XmlWriter_writeCDATA(QScriptContext*context,QScriptEngine*)
  10602. {
  10603. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10604. self->writeCDATA(argument<QString> (0,context));
  10605. return QScriptValue();
  10606. }
  10607. QScriptValue XmlWriter_writeEntityReference(QScriptContext*context,
  10608. QScriptEngine*)
  10609. {
  10610. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10611. self->writeEntityReference(argument<QString> (0,context));
  10612. return QScriptValue();
  10613. }
  10614. QScriptValue XmlWriter_writeProcessingInstruction(QScriptContext*context,
  10615. QScriptEngine*)
  10616. {
  10617. QXmlStreamWriter*self= getself<QXmlStreamWriter*> (context);
  10618. self->writeProcessingInstruction(argument<QString> (0,context),
  10619. argument<QString> (1,context));
  10620. return QScriptValue();
  10621. }
  10622. /*:97*//*100:*/
  10623. #line 2471 "./typica.w"
  10624. QScriptValue constructXmlReader(QScriptContext*context,QScriptEngine*engine)
  10625. {
  10626. QXmlStreamReader*retval=
  10627. new QXmlStreamReader(argument<QIODevice*> (0,context));
  10628. QScriptValue object= engine->toScriptValue<void*> (retval);
  10629. setXmlReaderProperties(object,engine);
  10630. return object;
  10631. }
  10632. void setXmlReaderProperties(QScriptValue value,QScriptEngine*engine)
  10633. {
  10634. value.setProperty("atEnd",engine->newFunction(XmlReader_atEnd));
  10635. value.setProperty("attribute",engine->newFunction(XmlReader_attribute));
  10636. value.setProperty("hasAttribute",
  10637. engine->newFunction(XmlReader_hasAttribute));
  10638. value.setProperty("isDTD",engine->newFunction(XmlReader_isDTD));
  10639. value.setProperty("isStartElement",
  10640. engine->newFunction(XmlReader_isStartElement));
  10641. value.setProperty("name",engine->newFunction(XmlReader_name));
  10642. value.setProperty("readElementText",
  10643. engine->newFunction(XmlReader_readElementText));
  10644. value.setProperty("readNext",
  10645. engine->newFunction(XmlReader_readNext));
  10646. value.setProperty("text",engine->newFunction(XmlReader_text));
  10647. }
  10648. /*:100*//*101:*/
  10649. #line 2501 "./typica.w"
  10650. QScriptValue XmlReader_attribute(QScriptContext*context,QScriptEngine*)
  10651. {
  10652. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  10653. QString retval=
  10654. self->attributes().value(argument<QString> (0,context)).toString();
  10655. return QScriptValue(retval);
  10656. }
  10657. QScriptValue XmlReader_hasAttribute(QScriptContext*context,QScriptEngine*)
  10658. {
  10659. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  10660. bool retval=
  10661. self->attributes().hasAttribute(argument<QString> (0,context));
  10662. return QScriptValue(retval);
  10663. }
  10664. /*:101*//*102:*/
  10665. #line 2521 "./typica.w"
  10666. QScriptValue XmlReader_atEnd(QScriptContext*context,QScriptEngine*)
  10667. {
  10668. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  10669. return QScriptValue(self->atEnd());
  10670. }
  10671. QScriptValue XmlReader_isDTD(QScriptContext*context,QScriptEngine*)
  10672. {
  10673. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  10674. return QScriptValue(self->isDTD());
  10675. }
  10676. QScriptValue XmlReader_isStartElement(QScriptContext*context,QScriptEngine*)
  10677. {
  10678. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  10679. return QScriptValue(self->isStartElement());
  10680. }
  10681. /*:102*//*103:*/
  10682. #line 2542 "./typica.w"
  10683. QScriptValue XmlReader_readNext(QScriptContext*context,QScriptEngine*)
  10684. {
  10685. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  10686. self->readNext();
  10687. return QScriptValue();
  10688. }
  10689. /*:103*//*104:*/
  10690. #line 2552 "./typica.w"
  10691. QScriptValue XmlReader_name(QScriptContext*context,QScriptEngine*)
  10692. {
  10693. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  10694. return QScriptValue(self->name().toString());
  10695. }
  10696. QScriptValue XmlReader_readElementText(QScriptContext*context,QScriptEngine*)
  10697. {
  10698. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  10699. return QScriptValue(self->readElementText());
  10700. }
  10701. QScriptValue XmlReader_text(QScriptContext*context,QScriptEngine*)
  10702. {
  10703. QXmlStreamReader*self= getself<QXmlStreamReader*> (context);
  10704. return QScriptValue(self->text().toString());
  10705. }
  10706. /*:104*//*107:*/
  10707. #line 2594 "./typica.w"
  10708. void setQSettingsProperties(QScriptValue value,QScriptEngine*engine)
  10709. {
  10710. setQObjectProperties(value,engine);
  10711. value.setProperty("value",engine->newFunction(QSettings_value));
  10712. value.setProperty("setValue",engine->newFunction(QSettings_setValue));
  10713. }
  10714. /*:107*//*108:*/
  10715. #line 2606 "./typica.w"
  10716. QScriptValue QSettings_value(QScriptContext*context,QScriptEngine*engine)
  10717. {
  10718. QScriptValue object;
  10719. if(context->argumentCount()==1||context->argumentCount()==2)
  10720. {
  10721. QSettings settings;
  10722. QString key= argument<QString> (0,context);
  10723. QVariant value;
  10724. QVariant retval;
  10725. if(context->argumentCount()> 1)
  10726. {
  10727. value= argument<QVariant> (1,context);
  10728. retval= settings.value(key,value);
  10729. }
  10730. else
  10731. {
  10732. retval= settings.value(key);
  10733. }
  10734. object= engine->newVariant(retval);
  10735. }
  10736. else
  10737. {
  10738. context->throwError("Incorrect number of arguments passed to "
  10739. "QSettings::value(). This method takes one "
  10740. "string and one optional variant type.");
  10741. }
  10742. return object;
  10743. }
  10744. QScriptValue QSettings_setValue(QScriptContext*context,QScriptEngine*)
  10745. {
  10746. if(context->argumentCount()==2)
  10747. {
  10748. QSettings settings;
  10749. QString key= argument<QString> (0,context);
  10750. QVariant value= argument<QVariant> (1,context);
  10751. settings.setValue(key,value);
  10752. }
  10753. else
  10754. {
  10755. context->throwError("Incorrect number of arguments passed to "
  10756. "QSettings::setValue(). This method takes one "
  10757. "string and one variant type for a total of two "
  10758. "arguments.");
  10759. }
  10760. return QScriptValue();
  10761. }
  10762. /*:108*//*111:*/
  10763. #line 2675 "./typica.w"
  10764. QScriptValue constructQLCDNumber(QScriptContext*,QScriptEngine*engine)
  10765. {
  10766. QScriptValue object= engine->newQObject(new QLCDNumber());
  10767. setQLCDNumberProperties(object,engine);
  10768. return object;
  10769. }
  10770. void setQLCDNumberProperties(QScriptValue value,QScriptEngine*engine)
  10771. {
  10772. setQFrameProperties(value,engine);
  10773. }
  10774. /*:111*//*114:*/
  10775. #line 2733 "./typica.w"
  10776. QScriptValue constructQTime(QScriptContext*context,
  10777. QScriptEngine*engine)
  10778. {
  10779. QScriptValue object;
  10780. if(context->argumentCount()==0||
  10781. (context->argumentCount()>=2&&context->argumentCount()<=4))
  10782. {
  10783. int arg1= 0;
  10784. int arg2= 0;
  10785. int arg3= 0;
  10786. int arg4= 0;
  10787. switch(context->argumentCount())
  10788. {
  10789. case 4:
  10790. arg4= argument<int> (3,context);
  10791. case 3:
  10792. arg3= argument<int> (2,context);
  10793. case 2:
  10794. arg2= argument<int> (1,context);
  10795. arg1= argument<int> (0,context);
  10796. default:
  10797. break;
  10798. }
  10799. if(context->argumentCount())
  10800. {
  10801. object= engine->toScriptValue<QTime> (QTime(arg1,arg2,arg3,
  10802. arg4));
  10803. }
  10804. else
  10805. {
  10806. object= engine->toScriptValue<QTime> (QTime());
  10807. }
  10808. setQTimeProperties(object,engine);
  10809. }
  10810. else
  10811. {
  10812. context->throwError("Incorrect number of arguments passed to "
  10813. "QTime::QTime(). This method takes zero, two, "
  10814. "three, or four integer arguments.");
  10815. }
  10816. return object;
  10817. }
  10818. /*:114*//*115:*/
  10819. #line 2781 "./typica.w"
  10820. void setQTimeProperties(QScriptValue value,QScriptEngine*engine)
  10821. {
  10822. value.setProperty("addMSecs",engine->newFunction(QTime_addMSecs));
  10823. value.setProperty("addSecs",engine->newFunction(QTime_addSecs));
  10824. value.setProperty("elapsed",engine->newFunction(QTime_elapsed));
  10825. value.setProperty("hour",engine->newFunction(QTime_hour));
  10826. value.setProperty("isNull",engine->newFunction(QTime_isNull));
  10827. value.setProperty("isValid",engine->newFunction(QTime_isValid));
  10828. value.setProperty("minute",engine->newFunction(QTime_minute));
  10829. value.setProperty("msec",engine->newFunction(QTime_msec));
  10830. value.setProperty("msecsTo",engine->newFunction(QTime_msecsTo));
  10831. value.setProperty("restart",engine->newFunction(QTime_restart));
  10832. value.setProperty("second",engine->newFunction(QTime_second));
  10833. value.setProperty("secsTo",engine->newFunction(QTime_secsTo));
  10834. value.setProperty("setHMS",engine->newFunction(QTime_setHMS));
  10835. value.setProperty("start",engine->newFunction(QTime_start));
  10836. value.setProperty("toString",engine->newFunction(QTime_toString));
  10837. value.setProperty("currentTime",engine->newFunction(QTime_currentTime));
  10838. value.setProperty("fromString",engine->newFunction(QTime_fromString));
  10839. value.setProperty("valueOf",engine->newFunction(QTime_valueOf));
  10840. }
  10841. /*:115*//*116:*/
  10842. #line 2810 "./typica.w"
  10843. QScriptValue QTime_valueOf(QScriptContext*context,QScriptEngine*)
  10844. {
  10845. QTime self= getself<QTime> (context);
  10846. int retval= (self.hour()*60*60*1000)+(self.minute()*60*1000)+
  10847. (self.second()*1000)+self.msec();
  10848. return QScriptValue(retval);
  10849. }
  10850. /*:116*//*117:*/
  10851. #line 2824 "./typica.w"
  10852. QScriptValue QTime_addMSecs(QScriptContext*context,QScriptEngine*engine)
  10853. {
  10854. QTime time;
  10855. QScriptValue retval;
  10856. if(context->argumentCount()==1)
  10857. {
  10858. QTime self= getself<QTime> (context);
  10859. time= self.addMSecs(argument<int> (0,context));
  10860. retval= engine->toScriptValue<QTime> (time);
  10861. setQTimeProperties(retval,engine);
  10862. }
  10863. else
  10864. {
  10865. context->throwError("Incorrect number of arguments passed to "
  10866. "QTime::addMSecs(). This method takes one "
  10867. "integer as an argument.");
  10868. }
  10869. return retval;
  10870. }
  10871. QScriptValue QTime_addSecs(QScriptContext*context,QScriptEngine*engine)
  10872. {
  10873. QTime time;
  10874. QScriptValue retval;
  10875. if(context->argumentCount()==1)
  10876. {
  10877. QTime self= getself<QTime> (context);
  10878. time= self.addSecs(argument<int> (0,context));
  10879. retval= engine->toScriptValue<QTime> (time);
  10880. setQTimeProperties(retval,engine);
  10881. }
  10882. else
  10883. {
  10884. context->throwError("Incorrect number of arguments passed to "
  10885. "QTime::addSecs(). This method takes one "
  10886. "integer as an argument.");
  10887. }
  10888. return retval;
  10889. }
  10890. /*:117*//*118:*/
  10891. #line 2867 "./typica.w"
  10892. QScriptValue QTime_elapsed(QScriptContext*context,QScriptEngine*engine)
  10893. {
  10894. QScriptValue retval;
  10895. if(context->argumentCount()==0)
  10896. {
  10897. QTime self= getself<QTime> (context);
  10898. retval= QScriptValue(engine,self.elapsed());
  10899. }
  10900. else
  10901. {
  10902. context->throwError("Incorrect number of arguments passed to "
  10903. "QTime::elapsed(). This method takes no "
  10904. "arguments.");
  10905. }
  10906. return retval;
  10907. }
  10908. /*:118*//*119:*/
  10909. #line 2888 "./typica.w"
  10910. QScriptValue QTime_hour(QScriptContext*context,QScriptEngine*engine)
  10911. {
  10912. QScriptValue retval;
  10913. if(context->argumentCount()==0)
  10914. {
  10915. QTime self= getself<QTime> (context);
  10916. retval= QScriptValue(engine,self.hour());
  10917. }
  10918. else
  10919. {
  10920. context->throwError("Incorrect number of arguments passed to "
  10921. "QTime::hour(). This method takes no "
  10922. "arguments.");
  10923. }
  10924. return retval;
  10925. }
  10926. /*:119*//*120:*/
  10927. #line 2908 "./typica.w"
  10928. QScriptValue QTime_minute(QScriptContext*context,QScriptEngine*engine)
  10929. {
  10930. QScriptValue retval;
  10931. if(context->argumentCount()==0)
  10932. {
  10933. QTime self= getself<QTime> (context);
  10934. retval= QScriptValue(engine,self.minute());
  10935. }
  10936. else
  10937. {
  10938. context->throwError("Incorrect number of arguments passed to "
  10939. "QTime::minute(). This method takes no "
  10940. "arguments.");
  10941. }
  10942. return retval;
  10943. }
  10944. QScriptValue QTime_second(QScriptContext*context,QScriptEngine*engine)
  10945. {
  10946. QScriptValue retval;
  10947. if(context->argumentCount()==0)
  10948. {
  10949. QTime self= getself<QTime> (context);
  10950. retval= QScriptValue(engine,self.second());
  10951. }
  10952. else
  10953. {
  10954. context->throwError("Incorrect number of arguments passed to "
  10955. "QTime::second(). This method takes no "
  10956. "arguments.");
  10957. }
  10958. return retval;
  10959. }
  10960. QScriptValue QTime_msec(QScriptContext*context,QScriptEngine*engine)
  10961. {
  10962. QScriptValue retval;
  10963. if(context->argumentCount()==0)
  10964. {
  10965. QTime self= getself<QTime> (context);
  10966. retval= QScriptValue(engine,self.msec());
  10967. }
  10968. else
  10969. {
  10970. context->throwError("Incorrect number of arguments passed to "
  10971. "QTime::msec(). This method takes no "
  10972. "arguments.");
  10973. }
  10974. return retval;
  10975. }
  10976. /*:120*//*121:*/
  10977. #line 2964 "./typica.w"
  10978. QScriptValue QTime_isNull(QScriptContext*context,QScriptEngine*engine)
  10979. {
  10980. QScriptValue retval;
  10981. if(context->argumentCount()==0)
  10982. {
  10983. QTime self= getself<QTime> (context);
  10984. retval= QScriptValue(engine,self.isNull());
  10985. }
  10986. else
  10987. {
  10988. context->throwError("Incorrect number of arguments passed to "
  10989. "QTime::isNull(). This method takes no "
  10990. "arguments.");
  10991. }
  10992. return retval;
  10993. }
  10994. QScriptValue QTime_isValid(QScriptContext*context,QScriptEngine*engine)
  10995. {
  10996. QScriptValue retval;
  10997. if(context->argumentCount()==0)
  10998. {
  10999. QTime self= getself<QTime> (context);
  11000. retval= QScriptValue(engine,self.isValid());
  11001. }
  11002. else
  11003. {
  11004. context->throwError("Incorrect number of arguments passed to "
  11005. "QTime::isValid(). This method takes no "
  11006. "arguments.");
  11007. }
  11008. return retval;
  11009. }
  11010. /*:121*//*122:*/
  11011. #line 3002 "./typica.w"
  11012. QScriptValue QTime_msecsTo(QScriptContext*context,QScriptEngine*engine)
  11013. {
  11014. QScriptValue retval;
  11015. if(context->argumentCount()==1)
  11016. {
  11017. QTime self= getself<QTime> (context);
  11018. QTime arg= argument<QVariant> (0,context).toTime();
  11019. retval= QScriptValue(engine,self.msecsTo(arg));
  11020. }
  11021. else
  11022. {
  11023. context->throwError("Incorrect number of arguments passed to "
  11024. "QTime::msecsTo(). This method takes one QTime.");
  11025. }
  11026. return retval;
  11027. }
  11028. QScriptValue QTime_secsTo(QScriptContext*context,QScriptEngine*engine)
  11029. {
  11030. QScriptValue retval;
  11031. if(context->argumentCount()==1)
  11032. {
  11033. QTime self= getself<QTime> (context);
  11034. QTime arg= argument<QVariant> (0,context).toTime();
  11035. retval= QScriptValue(engine,self.secsTo(arg));
  11036. }
  11037. else
  11038. {
  11039. context->throwError("Incorrect number of arguments passed to "
  11040. "QTime::secsTo(). This method takes one QTime.");
  11041. }
  11042. return retval;
  11043. }
  11044. /*:122*//*123:*/
  11045. #line 3041 "./typica.w"
  11046. QScriptValue QTime_restart(QScriptContext*context,QScriptEngine*engine)
  11047. {
  11048. QScriptValue retval;
  11049. if(context->argumentCount()==0)
  11050. {
  11051. QTime self= getself<QTime> (context);
  11052. retval= QScriptValue(engine,self.restart());
  11053. }
  11054. else
  11055. {
  11056. context->throwError("Incorrect number of arguments passed to "
  11057. "QTime::restart(). This method takes no "
  11058. "arguments.");
  11059. }
  11060. return retval;
  11061. }
  11062. QScriptValue QTime_start(QScriptContext*context,QScriptEngine*)
  11063. {
  11064. if(context->argumentCount()==0)
  11065. {
  11066. QTime self= getself<QTime> (context);
  11067. self.start();
  11068. }
  11069. else
  11070. {
  11071. context->throwError("Incorrect number of arguments passed to "
  11072. "QTime::start(). This method takes no arguments.");
  11073. }
  11074. return QScriptValue();
  11075. }
  11076. /*:123*//*124:*/
  11077. #line 3077 "./typica.w"
  11078. QScriptValue QTime_setHMS(QScriptContext*context,QScriptEngine*engine)
  11079. {
  11080. QScriptValue retval;
  11081. if(context->argumentCount()==3||context->argumentCount()==4)
  11082. {
  11083. QTime self= getself<QTime> (context);
  11084. int arg1= 0;
  11085. int arg2= 0;
  11086. int arg3= 0;
  11087. int arg4= 0;
  11088. switch(context->argumentCount())
  11089. {
  11090. case 4:
  11091. arg4= argument<int> (3,context);
  11092. case 3:
  11093. arg3= argument<int> (2,context);
  11094. arg2= argument<int> (1,context);
  11095. arg1= argument<int> (0,context);
  11096. default:
  11097. break;
  11098. }
  11099. retval= QScriptValue(engine,self.setHMS(arg1,arg2,arg3,arg4));
  11100. }
  11101. else
  11102. {
  11103. context->throwError("Incorrect number of arguments passed to "
  11104. "QTime::setHMS(). This method takes three or "
  11105. "four integer arguments.");
  11106. }
  11107. return retval;
  11108. }
  11109. /*:124*//*125:*/
  11110. #line 3113 "./typica.w"
  11111. QScriptValue QTime_toString(QScriptContext*context,QScriptEngine*engine)
  11112. {
  11113. QScriptValue retval;
  11114. if(context->argumentCount()==1)
  11115. {
  11116. QTime self= getself<QTime> (context);
  11117. retval= QScriptValue(engine,self.toString(argument<QString> (0,context)));
  11118. }
  11119. else
  11120. {
  11121. context->throwError("Incorrect number of arguments passed to "
  11122. "QTime::toString(). This method takes one QString "
  11123. "as an argument.");
  11124. }
  11125. return retval;
  11126. }
  11127. /*:125*//*126:*/
  11128. #line 3134 "./typica.w"
  11129. QScriptValue QTime_currentTime(QScriptContext*,QScriptEngine*engine)
  11130. {
  11131. QScriptValue object;
  11132. object= engine->toScriptValue<QTime> (QTime::currentTime());
  11133. setQTimeProperties(object,engine);
  11134. return object;
  11135. }
  11136. QScriptValue QTime_fromString(QScriptContext*context,QScriptEngine*engine)
  11137. {
  11138. QScriptValue object;
  11139. if(context->argumentCount()==2)
  11140. {
  11141. QString time= argument<QString> (0,context);
  11142. QString format= argument<QString> (1,context);
  11143. object= engine->toScriptValue<QTime> (QTime::fromString(time,format));
  11144. setQTimeProperties(object,engine);
  11145. }
  11146. else
  11147. {
  11148. context->throwError("Incorrect number of arguments passed to "
  11149. "QTime::fromString(). This method takes two "
  11150. "string arguments.");
  11151. }
  11152. return object;
  11153. }
  11154. /*:126*//*128:*/
  11155. #line 3174 "./typica.w"
  11156. void setQAbstractScrollAreaProperties(QScriptValue value,QScriptEngine*engine)
  11157. {
  11158. setQFrameProperties(value,engine);
  11159. }
  11160. /*:128*//*130:*/
  11161. #line 3188 "./typica.w"
  11162. void setQAbstractItemViewProperties(QScriptValue value,QScriptEngine*engine)
  11163. {
  11164. setQAbstractScrollAreaProperties(value,engine);
  11165. }
  11166. /*:130*//*132:*/
  11167. #line 3202 "./typica.w"
  11168. void setQGraphicsViewProperties(QScriptValue value,QScriptEngine*engine)
  11169. {
  11170. setQAbstractScrollAreaProperties(value,engine);
  11171. }
  11172. void setQTableViewProperties(QScriptValue value,QScriptEngine*engine)
  11173. {
  11174. setQAbstractItemViewProperties(value,engine);
  11175. }
  11176. /*:132*//*135:*/
  11177. #line 3235 "./typica.w"
  11178. QScriptValue constructQPushButton(QScriptContext*,QScriptEngine*engine)
  11179. {
  11180. QScriptValue object= engine->newQObject(new QPushButton());
  11181. setQPushButtonProperties(object,engine);
  11182. return object;
  11183. }
  11184. void setQPushButtonProperties(QScriptValue value,QScriptEngine*engine)
  11185. {
  11186. setQAbstractButtonProperties(value,engine);
  11187. }
  11188. void setQAbstractButtonProperties(QScriptValue value,QScriptEngine*engine)
  11189. {
  11190. setQWidgetProperties(value,engine);
  11191. }
  11192. /*:135*//*142:*/
  11193. #line 3347 "./typica.w"
  11194. QScriptValue constructQSqlQuery(QScriptContext*,QScriptEngine*engine)
  11195. {
  11196. QScriptValue object=
  11197. engine->toScriptValue<void*> (new SqlQueryConnection());
  11198. setQSqlQueryProperties(object,engine);
  11199. return object;
  11200. }
  11201. /*:142*//*143:*/
  11202. #line 3359 "./typica.w"
  11203. void setQSqlQueryProperties(QScriptValue value,QScriptEngine*engine)
  11204. {
  11205. value.setProperty("bind",engine->newFunction(QSqlQuery_bind));
  11206. value.setProperty("bindFileData",
  11207. engine->newFunction(QSqlQuery_bindFileData));
  11208. value.setProperty("bindDeviceData",
  11209. engine->newFunction(QSqlQuery_bindDeviceData));
  11210. value.setProperty("exec",engine->newFunction(QSqlQuery_exec));
  11211. value.setProperty("executedQuery",engine->newFunction(QSqlQuery_executedQuery));
  11212. value.setProperty("invalidate",engine->newFunction(QSqlQuery_invalidate));
  11213. value.setProperty("next",engine->newFunction(QSqlQuery_next));
  11214. value.setProperty("prepare",engine->newFunction(QSqlQuery_prepare));
  11215. value.setProperty("value",engine->newFunction(QSqlQuery_value));
  11216. }
  11217. /*:143*//*144:*/
  11218. #line 3377 "./typica.w"
  11219. QScriptValue QSqlQuery_exec(QScriptContext*context,QScriptEngine*engine)
  11220. {
  11221. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  11222. QScriptValue retval;
  11223. if(context->argumentCount()==1)
  11224. {
  11225. retval= QScriptValue(engine,
  11226. query->exec(argument<QString> (0,context)));
  11227. }
  11228. else
  11229. {
  11230. retval= QScriptValue(engine,query->exec());
  11231. }
  11232. if(query->lastError().isValid())
  11233. {
  11234. qDebug()<<query->lastQuery();
  11235. qDebug()<<query->lastError().text();
  11236. }
  11237. return retval;
  11238. }
  11239. QScriptValue QSqlQuery_executedQuery(QScriptContext*context,QScriptEngine*)
  11240. {
  11241. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  11242. return QScriptValue(query->lastQuery());
  11243. }
  11244. QScriptValue QSqlQuery_next(QScriptContext*context,QScriptEngine*engine)
  11245. {
  11246. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  11247. return QScriptValue(engine,query->next());
  11248. }
  11249. QScriptValue QSqlQuery_value(QScriptContext*context,QScriptEngine*engine)
  11250. {
  11251. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  11252. return QScriptValue(engine,
  11253. query->value(argument<int> (0,context)).toString());
  11254. }
  11255. /*:144*//*145:*/
  11256. #line 3421 "./typica.w"
  11257. QScriptValue QSqlQuery_prepare(QScriptContext*context,QScriptEngine*engine)
  11258. {
  11259. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  11260. return QScriptValue(engine,query->prepare(argument<QString> (0,context)));
  11261. }
  11262. QScriptValue QSqlQuery_bind(QScriptContext*context,QScriptEngine*)
  11263. {
  11264. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  11265. query->bindValue(argument<QString> (0,context),
  11266. argument<QVariant> (1,context));
  11267. return QScriptValue();
  11268. }
  11269. QScriptValue QSqlQuery_bindFileData(QScriptContext*context,
  11270. QScriptEngine*)
  11271. {
  11272. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  11273. QString placeholder= argument<QString> (0,context);
  11274. QString filename= argument<QString> (1,context);
  11275. QFile file(filename);
  11276. QByteArray data;
  11277. if(file.open(QIODevice::ReadOnly))
  11278. {
  11279. data= file.readAll();
  11280. file.close();
  11281. }
  11282. query->bindValue(placeholder,data);
  11283. return QScriptValue();
  11284. }
  11285. QScriptValue QSqlQuery_bindDeviceData(QScriptContext*context,
  11286. QScriptEngine*)
  11287. {
  11288. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  11289. QString placeholder= argument<QString> (0,context);
  11290. QIODevice*device= argument<QIODevice*> (1,context);
  11291. device->reset();
  11292. QByteArray data;
  11293. data= device->readAll();
  11294. query->bindValue(placeholder,data);
  11295. return QScriptValue();
  11296. }
  11297. /*:145*//*146:*/
  11298. #line 3473 "./typica.w"
  11299. QScriptValue QSqlQuery_invalidate(QScriptContext*context,QScriptEngine*)
  11300. {
  11301. SqlQueryConnection*query= getself<SqlQueryConnection*> (context);
  11302. delete query;
  11303. return QScriptValue::UndefinedValue;
  11304. }
  11305. /*:146*//*149:*/
  11306. #line 3514 "./typica.w"
  11307. QScriptValue baseName(QScriptContext*context,QScriptEngine*engine)
  11308. {
  11309. QFileInfo info(argument<QString> (0,context));
  11310. QScriptValue retval(engine,info.baseName());
  11311. return retval;
  11312. }
  11313. QScriptValue dir(QScriptContext*context,QScriptEngine*engine)
  11314. {
  11315. QFileInfo info(argument<QString> (0,context));
  11316. QDir dir= info.dir();
  11317. QScriptValue retval(engine,dir.path());
  11318. return retval;
  11319. }
  11320. /*:149*//*150:*/
  11321. #line 3533 "./typica.w"
  11322. QScriptValue sqlToArray(QScriptContext*context,QScriptEngine*engine)
  11323. {
  11324. QString source= argument<QString> (0,context);
  11325. source.remove(0,1);
  11326. source.chop(1);
  11327. QStringList elements= source.split(",");
  11328. QString element;
  11329. QScriptValue dest= engine->newArray(elements.size());
  11330. int i= 0;
  11331. foreach(element,elements)
  11332. {
  11333. if(element.startsWith("\"")&&element.endsWith("\""))
  11334. {
  11335. element.chop(1);
  11336. element= element.remove(0,1);
  11337. }
  11338. dest.setProperty(i,QScriptValue(engine,element));
  11339. i++;
  11340. }
  11341. return dest;
  11342. }
  11343. /*:150*//*151:*/
  11344. #line 3559 "./typica.w"
  11345. QScriptValue setFont(QScriptContext*context,QScriptEngine*)
  11346. {
  11347. QString font= argument<QString> (0,context);
  11348. QString classname;
  11349. if(context->argumentCount()> 1)
  11350. {
  11351. classname= argument<QString> (1,context);
  11352. QApplication::setFont(QFont(font),classname.toLatin1().constData());
  11353. }
  11354. else
  11355. {
  11356. QApplication::setFont(QFont(font));
  11357. }
  11358. return QScriptValue();
  11359. }
  11360. /*:151*//*152:*/
  11361. #line 3579 "./typica.w"
  11362. QScriptValue annotationFromRecord(QScriptContext*context,QScriptEngine*)
  11363. {
  11364. SqlQueryConnection query;
  11365. QString q= "SELECT file FROM files WHERE id = :file";
  11366. query.prepare(q);
  11367. query.bindValue(":file",argument<int> (0,context));
  11368. query.exec();
  11369. query.next();
  11370. QByteArray array= query.value(0).toByteArray();
  11371. QBuffer buffer(&array);
  11372. buffer.open(QIODevice::ReadOnly);
  11373. QXmlQuery xquery;
  11374. xquery.bindVariable("profile",&buffer);
  11375. QString xq;
  11376. xq= "for $b in doc($profile) //tuple where exists($b/annotation) return $b";
  11377. xquery.setQuery(xq);
  11378. QString result;
  11379. xquery.evaluateTo(&result);
  11380. return QScriptValue(result);
  11381. }
  11382. /*:152*//*153:*/
  11383. #line 3605 "./typica.w"
  11384. QScriptValue setTabOrder(QScriptContext*context,QScriptEngine*)
  11385. {
  11386. QWidget::setTabOrder(argument<QWidget*> (0,context),
  11387. argument<QWidget*> (1,context));
  11388. return QScriptValue();
  11389. }
  11390. /*:153*//*160:*/
  11391. #line 3844 "./typica.w"
  11392. QScriptValue createWindow(QScriptContext*context,QScriptEngine*engine)
  11393. {
  11394. QString targetID= argument<QString> (0,context);
  11395. QDomNode element;
  11396. QScriptValue object;
  11397. /*161:*/
  11398. #line 3865 "./typica.w"
  11399. QDomNodeList windows=
  11400. AppInstance->configuration()->documentElement().elementsByTagName("window");
  11401. QDomNode nullNode;
  11402. int i= 0;
  11403. element= nullNode;
  11404. while(i<windows.count())
  11405. {
  11406. element= windows.at(i);
  11407. QDomNamedNodeMap attributes= element.attributes();
  11408. if(attributes.contains("id"))
  11409. {
  11410. if(attributes.namedItem("id").toAttr().value()==targetID)
  11411. {
  11412. break;
  11413. }
  11414. }
  11415. element= nullNode;
  11416. i++;
  11417. }
  11418. /*:161*/
  11419. #line 3850 "./typica.w"
  11420. if(!element.isNull())
  11421. {
  11422. /*162:*/
  11423. #line 3897 "./typica.w"
  11424. ScriptQMainWindow*window= new ScriptQMainWindow;
  11425. window->setObjectName(targetID);
  11426. object= engine->newQObject(window);
  11427. setQMainWindowProperties(object,engine);
  11428. QWidget*central= new(QWidget);
  11429. central->setParent(window);
  11430. central->setObjectName("centralWidget");
  11431. window->setCentralWidget(central);
  11432. if(element.hasChildNodes())
  11433. {
  11434. /*163:*/
  11435. #line 3932 "./typica.w"
  11436. QStack<QWidget*> widgetStack;
  11437. QStack<QLayout*> layoutStack;
  11438. QString windowScript;
  11439. widgetStack.push(central);
  11440. QDomNodeList windowChildren= element.childNodes();
  11441. int i= 0;
  11442. while(i<windowChildren.count())
  11443. {
  11444. QDomNode current;
  11445. QDomElement element;
  11446. current= windowChildren.at(i);
  11447. if(current.isElement())
  11448. {
  11449. element= current.toElement();
  11450. if(element.tagName()=="program")
  11451. {
  11452. windowScript.append(element.text());
  11453. }
  11454. else if(element.tagName()=="layout")
  11455. {
  11456. addLayoutToWidget(element,&widgetStack,&layoutStack);
  11457. }
  11458. else if(element.tagName()=="menu")
  11459. {
  11460. /*164:*/
  11461. #line 3979 "./typica.w"
  11462. QMenuBar*bar= window->menuBar();
  11463. bar->setParent(window);
  11464. bar->setObjectName("menuBar");
  11465. if(element.hasAttribute("name"))
  11466. {
  11467. QMenu*menu= bar->addMenu(element.attribute("name"));
  11468. menu->setParent(bar);
  11469. if(element.hasAttribute("type"))
  11470. {
  11471. if(element.attribute("type")=="reports")
  11472. {
  11473. if(element.hasAttribute("src"))
  11474. {
  11475. /*548:*/
  11476. #line 12787 "./typica.w"
  11477. QSettings settings;
  11478. QDir directory(QString("%1/%2").arg(settings.value("config").toString()).
  11479. arg(element.attribute("src")));
  11480. directory.setFilter(QDir::Files);
  11481. directory.setSorting(QDir::Name);
  11482. QStringList nameFilter;
  11483. nameFilter<<"*.xml";
  11484. directory.setNameFilters(nameFilter);
  11485. QFileInfoList reportFiles= directory.entryInfoList();
  11486. for(int i= 0;i<reportFiles.size();i++)
  11487. {
  11488. QFileInfo reportFile= reportFiles.at(i);
  11489. /*552:*/
  11490. #line 12864 "./typica.w"
  11491. QString path= reportFile.absoluteFilePath();
  11492. QFile file(path);
  11493. if(file.open(QIODevice::ReadOnly))
  11494. {
  11495. QDomDocument document;
  11496. document.setContent(&file,true);
  11497. QDomElement root= document.documentElement();
  11498. QDomNode titleNode= root.elementsByTagName("reporttitle").at(0);
  11499. if(!titleNode.isNull())
  11500. {
  11501. QDomElement titleElement= titleNode.toElement();
  11502. QString title= titleElement.text();
  11503. if(!title.isEmpty())
  11504. {
  11505. QStringList hierarchy= title.split(":->");
  11506. QMenu*insertionPoint= menu;
  11507. /*553:*/
  11508. #line 12891 "./typica.w"
  11509. for(int j= 0;j<hierarchy.size()-1;j++)
  11510. {
  11511. QObjectList menuList= insertionPoint->children();
  11512. bool menuFound= false;
  11513. for(int k= 0;k<menuList.size();k++)
  11514. {
  11515. QMenu*currentItem= qobject_cast<QMenu*> (menuList.at(k));
  11516. if(currentItem)
  11517. {
  11518. if(currentItem->title()==hierarchy.at(j))
  11519. {
  11520. menuFound= true;
  11521. insertionPoint= currentItem;
  11522. break;
  11523. }
  11524. }
  11525. }
  11526. if(!menuFound)
  11527. {
  11528. insertionPoint= insertionPoint->addMenu(hierarchy.at(j));
  11529. }
  11530. }
  11531. /*:553*/
  11532. #line 12881 "./typica.w"
  11533. ReportAction*action= new ReportAction(path,hierarchy.last());
  11534. insertionPoint->addAction(action);
  11535. }
  11536. }
  11537. }
  11538. /*:552*/
  11539. #line 12800 "./typica.w"
  11540. }
  11541. /*:548*/
  11542. #line 3993 "./typica.w"
  11543. }
  11544. }
  11545. }
  11546. if(element.hasChildNodes())
  11547. {
  11548. /*165:*/
  11549. #line 4006 "./typica.w"
  11550. QDomNodeList menuItems= element.childNodes();
  11551. int j= 0;
  11552. while(j<menuItems.count())
  11553. {
  11554. QDomNode item= menuItems.at(j);
  11555. if(item.isElement())
  11556. {
  11557. QDomElement itemElement= item.toElement();
  11558. if(itemElement.tagName()=="item")
  11559. {
  11560. QAction*itemAction= new QAction(itemElement.text(),menu);
  11561. if(itemElement.hasAttribute("id"))
  11562. {
  11563. itemAction->setObjectName(itemElement.attribute("id"));
  11564. }
  11565. if(itemElement.hasAttribute("shortcut"))
  11566. {
  11567. itemAction->setShortcut(itemElement.attribute("shortcut"));
  11568. }
  11569. menu->addAction(itemAction);
  11570. }
  11571. else if(itemElement.tagName()=="separator")
  11572. {
  11573. menu->addSeparator();
  11574. }
  11575. }
  11576. j++;
  11577. }
  11578. #line 1 "./helpmenu.w"
  11579. /*:165*/
  11580. #line 3999 "./typica.w"
  11581. }
  11582. }
  11583. /*:164*/
  11584. #line 3957 "./typica.w"
  11585. }
  11586. }
  11587. i++;
  11588. }
  11589. QScriptValue oldThis= context->thisObject();
  11590. context->setThisObject(object);
  11591. QScriptValue result= engine->evaluate(windowScript);
  11592. /*157:*/
  11593. #line 3746 "./typica.w"
  11594. if(engine->hasUncaughtException())
  11595. {
  11596. int line= engine->uncaughtExceptionLineNumber();
  11597. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  11598. result.toString();
  11599. QString trace;
  11600. foreach(trace,engine->uncaughtExceptionBacktrace())
  11601. {
  11602. qDebug()<<trace;
  11603. }
  11604. }
  11605. /*:157*/
  11606. #line 3965 "./typica.w"
  11607. context->setThisObject(oldThis);
  11608. /*:163*/
  11609. #line 3908 "./typica.w"
  11610. }
  11611. /*166:*/
  11612. #line 9 "./helpmenu.w"
  11613. HelpMenu*helpMenu= new HelpMenu();
  11614. window->menuBar()->addMenu(helpMenu);
  11615. /*:166*/
  11616. #line 3910 "./typica.w"
  11617. window->show();
  11618. /*:162*/
  11619. #line 3853 "./typica.w"
  11620. }
  11621. return object;
  11622. }
  11623. /*:160*//*171:*/
  11624. #line 4048 "./typica.w"
  11625. void addLayoutToWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  11626. QStack<QLayout*> *layoutStack)
  11627. {
  11628. if(element.hasAttribute("type"))
  11629. {
  11630. /*172:*/
  11631. #line 4069 "./typica.w"
  11632. QLayout*layout;
  11633. QString layoutType= element.attribute("type");
  11634. if(layoutType=="horizontal")
  11635. {
  11636. layout= new QHBoxLayout;
  11637. layoutStack->push(layout);
  11638. populateBoxLayout(element,widgetStack,layoutStack);
  11639. }
  11640. else if(layoutType=="vertical")
  11641. {
  11642. layout= new QVBoxLayout;
  11643. layoutStack->push(layout);
  11644. populateBoxLayout(element,widgetStack,layoutStack);
  11645. }
  11646. else if(layoutType=="grid")
  11647. {
  11648. layout= new QGridLayout;
  11649. layoutStack->push(layout);
  11650. populateGridLayout(element,widgetStack,layoutStack);
  11651. }
  11652. else if(layoutType=="stack")
  11653. {
  11654. layout= new QStackedLayout;
  11655. layoutStack->push(layout);
  11656. populateStackedLayout(element,widgetStack,layoutStack);
  11657. }
  11658. if(element.hasAttribute("id"))
  11659. {
  11660. layout->setObjectName(element.attribute("id"));
  11661. }
  11662. /*:172*/
  11663. #line 4054 "./typica.w"
  11664. QWidget*widget= widgetStack->top();
  11665. if(layout)
  11666. {
  11667. widget->setLayout(layout);
  11668. }
  11669. layoutStack->pop();
  11670. }
  11671. }
  11672. /*:171*//*173:*/
  11673. #line 4107 "./typica.w"
  11674. void populateStackedLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  11675. QStack<QLayout*> *layoutStack)
  11676. {
  11677. QDomNodeList children= element.childNodes();
  11678. QStackedLayout*layout= qobject_cast<QStackedLayout*> (layoutStack->top());
  11679. for(int i= 0;i<children.count();i++)
  11680. {
  11681. QDomNode current;
  11682. QDomElement currentElement;
  11683. current= children.at(i);
  11684. if(current.isElement())
  11685. {
  11686. currentElement= current.toElement();
  11687. if(currentElement.tagName()=="page")
  11688. {
  11689. QWidget*widget= new QWidget;
  11690. layout->addWidget(widget);
  11691. widgetStack->push(widget);
  11692. populateWidget(currentElement,widgetStack,layoutStack);
  11693. widgetStack->pop();
  11694. }
  11695. }
  11696. }
  11697. }
  11698. /*:173*//*174:*/
  11699. #line 4139 "./typica.w"
  11700. void populateGridLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  11701. QStack<QLayout*> *layoutStack)
  11702. {
  11703. QDomNodeList children= element.childNodes();
  11704. int row= -1;
  11705. QGridLayout*layout= qobject_cast<QGridLayout*> (layoutStack->top());
  11706. for(int i= 0;i<children.count();i++)
  11707. {
  11708. QDomNode current;
  11709. QDomElement currentElement;
  11710. current= children.at(i);
  11711. if(current.isElement())
  11712. {
  11713. currentElement= current.toElement();
  11714. if(currentElement.tagName()=="row")
  11715. {
  11716. row++;
  11717. if(currentElement.hasAttribute("height"))
  11718. {
  11719. layout->setRowMinimumHeight(row,
  11720. currentElement.attribute("height").toInt());
  11721. }
  11722. if(currentElement.hasAttribute("stretch"))
  11723. {
  11724. layout->setRowStretch(row,
  11725. currentElement.attribute("stretch").toInt());
  11726. }
  11727. /*175:*/
  11728. #line 4195 "./typica.w"
  11729. int column= -1;
  11730. QDomNodeList rowChildren= currentElement.childNodes();
  11731. for(int j= 0;j<rowChildren.count();j++)
  11732. {
  11733. QDomNode columnNode;
  11734. QDomElement columnElement;
  11735. columnNode= rowChildren.at(j);
  11736. if(columnNode.isElement())
  11737. {
  11738. columnElement= columnNode.toElement();
  11739. if(columnElement.tagName()=="column")
  11740. {
  11741. column++;
  11742. if(columnElement.hasAttribute("column"))
  11743. {
  11744. column= columnElement.attribute("column").toInt();
  11745. }
  11746. if(columnElement.hasAttribute("width"))
  11747. {
  11748. layout->setColumnMinimumWidth(column,
  11749. columnElement.attribute("width").toInt());
  11750. }
  11751. if(columnElement.hasAttribute("stretch"))
  11752. {
  11753. layout->setColumnStretch(column,
  11754. columnElement.attribute("stretch").toInt());
  11755. }
  11756. int hspan= 1;
  11757. int vspan= 1;
  11758. if(columnElement.hasAttribute("rowspan"))
  11759. {
  11760. vspan= columnElement.attribute("rowspan").toInt();
  11761. }
  11762. if(columnElement.hasAttribute("colspan"))
  11763. {
  11764. hspan= columnElement.attribute("colspan").toInt();
  11765. }
  11766. QHBoxLayout*cell= new QHBoxLayout;
  11767. layout->addLayout(cell,row,column,vspan,hspan);
  11768. layoutStack->push(cell);
  11769. populateBoxLayout(columnElement,widgetStack,layoutStack);
  11770. layoutStack->pop();
  11771. }
  11772. }
  11773. }
  11774. /*:175*/
  11775. #line 4167 "./typica.w"
  11776. }
  11777. }
  11778. }
  11779. }
  11780. /*:174*//*176:*/
  11781. #line 4245 "./typica.w"
  11782. void populateBoxLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  11783. QStack<QLayout*> *layoutStack)
  11784. {
  11785. QDomNodeList children= element.childNodes();
  11786. for(int i= 0;i<children.count();i++)
  11787. {
  11788. QDomNode current;
  11789. QDomElement currentElement;
  11790. current= children.at(i);
  11791. if(current.isElement())
  11792. {
  11793. currentElement= current.toElement();
  11794. if(currentElement.tagName()=="button")
  11795. {
  11796. addButtonToLayout(currentElement,widgetStack,layoutStack);
  11797. }
  11798. else if(currentElement.tagName()=="calendar")
  11799. {
  11800. addCalendarToLayout(currentElement,widgetStack,layoutStack);
  11801. }
  11802. else if(currentElement.tagName()=="decoration")
  11803. {
  11804. addDecorationToLayout(currentElement,widgetStack,
  11805. layoutStack);
  11806. }
  11807. else if(currentElement.tagName()=="layout")
  11808. {
  11809. addLayoutToLayout(currentElement,widgetStack,layoutStack);
  11810. }
  11811. else if(currentElement.tagName()=="splitter")
  11812. {
  11813. addSplitterToLayout(currentElement,widgetStack,layoutStack);
  11814. }
  11815. else if(currentElement.tagName()=="label")
  11816. {
  11817. QBoxLayout*layout=
  11818. qobject_cast<QBoxLayout*> (layoutStack->top());
  11819. QLabel*label= new QLabel(currentElement.text());
  11820. layout->addWidget(label);
  11821. }
  11822. else if(currentElement.tagName()=="lcdtemperature")
  11823. {
  11824. addTemperatureDisplayToLayout(currentElement,widgetStack,
  11825. layoutStack);
  11826. }
  11827. else if(currentElement.tagName()=="lcdtimer")
  11828. {
  11829. addTimerDisplayToLayout(currentElement,widgetStack,
  11830. layoutStack);
  11831. }
  11832. else if(currentElement.tagName()=="line")
  11833. {
  11834. addLineToLayout(currentElement,widgetStack,layoutStack);
  11835. }
  11836. else if(currentElement.tagName()=="report")
  11837. {
  11838. addReportToLayout(currentElement,widgetStack,layoutStack);
  11839. }
  11840. else if(currentElement.tagName()=="sqldrop")
  11841. {
  11842. addSqlDropToLayout(currentElement,widgetStack,layoutStack);
  11843. }
  11844. else if(currentElement.tagName()=="sqltablearray")
  11845. {
  11846. addSaltToLayout(currentElement,widgetStack,layoutStack);
  11847. }
  11848. else if(currentElement.tagName()=="sqlview")
  11849. {
  11850. addSqlQueryViewToLayout(currentElement,widgetStack,
  11851. layoutStack);
  11852. }
  11853. else if(currentElement.tagName()=="textarea")
  11854. {
  11855. addTextToLayout(currentElement,widgetStack,layoutStack);
  11856. }
  11857. else if(currentElement.tagName()=="spinbox")
  11858. {
  11859. addSpinBoxToLayout(currentElement,widgetStack,layoutStack);
  11860. }
  11861. else if(currentElement.tagName()=="formarray")
  11862. {
  11863. addFormArrayToLayout(currentElement,widgetStack,layoutStack);
  11864. }
  11865. else if(currentElement.tagName()=="hscale")
  11866. {
  11867. addScaleControlToLayout(currentElement,widgetStack,
  11868. layoutStack);
  11869. }
  11870. else if(currentElement.tagName()=="vscale")
  11871. {
  11872. addIntensityControlToLayout(currentElement,widgetStack,
  11873. layoutStack);
  11874. }
  11875. else if(currentElement.tagName()=="webview")
  11876. {
  11877. addWebViewToLayout(currentElement,widgetStack,layoutStack);
  11878. }
  11879. else if(currentElement.tagName()=="stretch")
  11880. {
  11881. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  11882. layout->addStretch();
  11883. }
  11884. }
  11885. }
  11886. }
  11887. /*:176*//*177:*/
  11888. #line 4355 "./typica.w"
  11889. void addLayoutToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  11890. QStack<QLayout*> *layoutStack)
  11891. {
  11892. QLayout*targetLayout= layoutStack->pop();
  11893. QBoxLayout*boxLayout= qobject_cast<QBoxLayout*> (targetLayout);
  11894. if(element.hasAttribute("type"))
  11895. {
  11896. /*172:*/
  11897. #line 4069 "./typica.w"
  11898. QLayout*layout;
  11899. QString layoutType= element.attribute("type");
  11900. if(layoutType=="horizontal")
  11901. {
  11902. layout= new QHBoxLayout;
  11903. layoutStack->push(layout);
  11904. populateBoxLayout(element,widgetStack,layoutStack);
  11905. }
  11906. else if(layoutType=="vertical")
  11907. {
  11908. layout= new QVBoxLayout;
  11909. layoutStack->push(layout);
  11910. populateBoxLayout(element,widgetStack,layoutStack);
  11911. }
  11912. else if(layoutType=="grid")
  11913. {
  11914. layout= new QGridLayout;
  11915. layoutStack->push(layout);
  11916. populateGridLayout(element,widgetStack,layoutStack);
  11917. }
  11918. else if(layoutType=="stack")
  11919. {
  11920. layout= new QStackedLayout;
  11921. layoutStack->push(layout);
  11922. populateStackedLayout(element,widgetStack,layoutStack);
  11923. }
  11924. if(element.hasAttribute("id"))
  11925. {
  11926. layout->setObjectName(element.attribute("id"));
  11927. }
  11928. /*:172*/
  11929. #line 4363 "./typica.w"
  11930. boxLayout->addLayout(layout);
  11931. layoutStack->pop();
  11932. }
  11933. layoutStack->push(targetLayout);
  11934. }
  11935. /*:177*//*178:*/
  11936. #line 4374 "./typica.w"
  11937. void addSplitterToLayout(QDomElement element,QStack<QWidget*> *widgetStack,
  11938. QStack<QLayout*> *layoutStack)
  11939. {
  11940. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  11941. QSplitter*splitter= new(QSplitter);
  11942. layout->addWidget(splitter);
  11943. /*179:*/
  11944. #line 4387 "./typica.w"
  11945. QString orientation= element.attribute("type");
  11946. if(orientation=="horizontal")
  11947. {
  11948. splitter->setOrientation(Qt::Horizontal);
  11949. }
  11950. else if(orientation=="vertical")
  11951. {
  11952. splitter->setOrientation(Qt::Vertical);
  11953. }
  11954. QString id= element.attribute("id");
  11955. if(!id.isEmpty())
  11956. {
  11957. splitter->setObjectName(id);
  11958. }
  11959. if(element.hasChildNodes())
  11960. {
  11961. widgetStack->push(splitter);
  11962. populateSplitter(element,widgetStack,layoutStack);
  11963. widgetStack->pop();
  11964. }
  11965. /*:179*/
  11966. #line 4381 "./typica.w"
  11967. }
  11968. /*:178*//*180:*/
  11969. #line 4413 "./typica.w"
  11970. void populateSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  11971. QStack<QLayout*> *layoutStack)
  11972. {
  11973. QDomNodeList children= element.childNodes();
  11974. for(int i= 0;i<children.count();i++)
  11975. {
  11976. QDomNode current;
  11977. QDomElement currentElement;
  11978. current= children.at(i);
  11979. if(current.isElement())
  11980. {
  11981. currentElement= current.toElement();
  11982. if(currentElement.tagName()=="decoration")
  11983. {
  11984. addDecorationToSplitter(currentElement,widgetStack,
  11985. layoutStack);
  11986. }
  11987. else if(currentElement.tagName()=="graph")
  11988. {
  11989. addGraphToSplitter(currentElement,widgetStack,layoutStack);
  11990. }
  11991. else if(currentElement.tagName()=="splitter")
  11992. {
  11993. addSplitterToSplitter(currentElement,widgetStack,layoutStack);
  11994. }
  11995. else if(currentElement.tagName()=="lcdtemperature")
  11996. {
  11997. addTemperatureDisplayToSplitter(currentElement,widgetStack,
  11998. layoutStack);
  11999. }
  12000. else if(currentElement.tagName()=="lcdtimer")
  12001. {
  12002. addTimerDisplayToSplitter(currentElement,widgetStack,
  12003. layoutStack);
  12004. }
  12005. else if(currentElement.tagName()=="measurementtable")
  12006. {
  12007. addZoomLogToSplitter(currentElement,widgetStack,layoutStack);
  12008. }
  12009. else if(currentElement.tagName()=="widget")
  12010. {
  12011. addWidgetToSplitter(currentElement,widgetStack,layoutStack);
  12012. }
  12013. }
  12014. }
  12015. }
  12016. /*:180*//*181:*/
  12017. #line 4463 "./typica.w"
  12018. void addSplitterToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  12019. QStack<QLayout*> *layoutStack)
  12020. {
  12021. QSplitter*parent= qobject_cast<QSplitter*> (widgetStack->top());
  12022. QSplitter*splitter= new(QSplitter);
  12023. splitter->setParent(parent);
  12024. parent->addWidget(splitter);
  12025. /*179:*/
  12026. #line 4387 "./typica.w"
  12027. QString orientation= element.attribute("type");
  12028. if(orientation=="horizontal")
  12029. {
  12030. splitter->setOrientation(Qt::Horizontal);
  12031. }
  12032. else if(orientation=="vertical")
  12033. {
  12034. splitter->setOrientation(Qt::Vertical);
  12035. }
  12036. QString id= element.attribute("id");
  12037. if(!id.isEmpty())
  12038. {
  12039. splitter->setObjectName(id);
  12040. }
  12041. if(element.hasChildNodes())
  12042. {
  12043. widgetStack->push(splitter);
  12044. populateSplitter(element,widgetStack,layoutStack);
  12045. widgetStack->pop();
  12046. }
  12047. /*:179*/
  12048. #line 4471 "./typica.w"
  12049. }
  12050. /*:181*//*182:*/
  12051. #line 4480 "./typica.w"
  12052. void addTemperatureDisplayToSplitter(QDomElement element,
  12053. QStack<QWidget*> *widgetStack,
  12054. QStack<QLayout*> *)
  12055. {
  12056. TemperatureDisplay*display= new(TemperatureDisplay);
  12057. if(element.hasAttribute("id"))
  12058. {
  12059. display->setObjectName(element.attribute("id"));
  12060. }
  12061. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  12062. splitter->addWidget(display);
  12063. }
  12064. void addTemperatureDisplayToLayout(QDomElement element,
  12065. QStack<QWidget*> *,
  12066. QStack<QLayout*> *layoutStack)
  12067. {
  12068. TemperatureDisplay*display= new(TemperatureDisplay);
  12069. if(element.hasAttribute("id"))
  12070. {
  12071. display->setObjectName(element.attribute("id"));
  12072. }
  12073. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  12074. layout->addWidget(display);
  12075. }
  12076. /*:182*//*183:*/
  12077. #line 4511 "./typica.w"
  12078. void addTimerDisplayToSplitter(QDomElement element,
  12079. QStack<QWidget*> *widgetStack,
  12080. QStack<QLayout*> *)
  12081. {
  12082. TimerDisplay*display= new(TimerDisplay);
  12083. if(element.hasAttribute("id"))
  12084. {
  12085. display->setObjectName(element.attribute("id"));
  12086. }
  12087. if(element.hasAttribute("format"))
  12088. {
  12089. display->setDisplayFormat(element.attribute("format"));
  12090. }
  12091. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  12092. splitter->addWidget(display);
  12093. }
  12094. void addTimerDisplayToLayout(QDomElement element,
  12095. QStack<QWidget*> *,
  12096. QStack<QLayout*> *layoutStack)
  12097. {
  12098. TimerDisplay*display= new(TimerDisplay);
  12099. if(element.hasAttribute("id"))
  12100. {
  12101. display->setObjectName(element.attribute("id"));
  12102. }
  12103. if(element.hasAttribute("format"))
  12104. {
  12105. display->setDisplayFormat(element.attribute("format"));
  12106. }
  12107. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  12108. layout->addWidget(display);
  12109. }
  12110. /*:183*//*184:*/
  12111. #line 4549 "./typica.w"
  12112. void addDecorationToLayout(QDomElement element,QStack<QWidget*> *,
  12113. QStack<QLayout*> *layoutStack)
  12114. {
  12115. /*185:*/
  12116. #line 4570 "./typica.w"
  12117. QString labelText= element.attribute("name");
  12118. Qt::Orientations orientation= Qt::Horizontal;
  12119. if(element.hasAttribute("type"))
  12120. {
  12121. if(element.attribute("type")=="horizontal")
  12122. {
  12123. orientation= Qt::Horizontal;
  12124. }
  12125. else if(element.attribute("type")=="vertical")
  12126. {
  12127. orientation= Qt::Vertical;
  12128. }
  12129. }
  12130. /*186:*/
  12131. #line 4595 "./typica.w"
  12132. QWidget*theWidget= NULL;
  12133. QDomNodeList children= element.childNodes();
  12134. for(int i= 0;i<children.count();i++)
  12135. {
  12136. QDomNode item= children.at(i);
  12137. if(item.isElement())
  12138. {
  12139. QDomElement itemElement= item.toElement();
  12140. if(itemElement.tagName()=="lcdtemperature")
  12141. {
  12142. TemperatureDisplay*display= new TemperatureDisplay;
  12143. if(itemElement.hasAttribute("id"))
  12144. {
  12145. display->setObjectName(itemElement.attribute("id"));
  12146. }
  12147. theWidget= display;
  12148. }
  12149. else if(itemElement.tagName()=="lcdtimer")
  12150. {
  12151. TimerDisplay*display= new TimerDisplay;
  12152. if(itemElement.hasAttribute("id"))
  12153. {
  12154. display->setObjectName(itemElement.attribute("id"));
  12155. }
  12156. if(itemElement.hasAttribute("format"))
  12157. {
  12158. display->setDisplayFormat(itemElement.attribute("format"));
  12159. }
  12160. theWidget= display;
  12161. }
  12162. }
  12163. }
  12164. /*:186*/
  12165. #line 4584 "./typica.w"
  12166. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  12167. orientation);
  12168. if(element.hasAttribute("id"))
  12169. {
  12170. decoration->setObjectName(element.attribute("id"));
  12171. }
  12172. /*:185*/
  12173. #line 4553 "./typica.w"
  12174. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  12175. layout->addWidget(decoration);
  12176. }
  12177. void addDecorationToSplitter(QDomElement element,
  12178. QStack<QWidget*> *widgetStack,
  12179. QStack<QLayout*> *)
  12180. {
  12181. /*185:*/
  12182. #line 4570 "./typica.w"
  12183. QString labelText= element.attribute("name");
  12184. Qt::Orientations orientation= Qt::Horizontal;
  12185. if(element.hasAttribute("type"))
  12186. {
  12187. if(element.attribute("type")=="horizontal")
  12188. {
  12189. orientation= Qt::Horizontal;
  12190. }
  12191. else if(element.attribute("type")=="vertical")
  12192. {
  12193. orientation= Qt::Vertical;
  12194. }
  12195. }
  12196. /*186:*/
  12197. #line 4595 "./typica.w"
  12198. QWidget*theWidget= NULL;
  12199. QDomNodeList children= element.childNodes();
  12200. for(int i= 0;i<children.count();i++)
  12201. {
  12202. QDomNode item= children.at(i);
  12203. if(item.isElement())
  12204. {
  12205. QDomElement itemElement= item.toElement();
  12206. if(itemElement.tagName()=="lcdtemperature")
  12207. {
  12208. TemperatureDisplay*display= new TemperatureDisplay;
  12209. if(itemElement.hasAttribute("id"))
  12210. {
  12211. display->setObjectName(itemElement.attribute("id"));
  12212. }
  12213. theWidget= display;
  12214. }
  12215. else if(itemElement.tagName()=="lcdtimer")
  12216. {
  12217. TimerDisplay*display= new TimerDisplay;
  12218. if(itemElement.hasAttribute("id"))
  12219. {
  12220. display->setObjectName(itemElement.attribute("id"));
  12221. }
  12222. if(itemElement.hasAttribute("format"))
  12223. {
  12224. display->setDisplayFormat(itemElement.attribute("format"));
  12225. }
  12226. theWidget= display;
  12227. }
  12228. }
  12229. }
  12230. /*:186*/
  12231. #line 4584 "./typica.w"
  12232. WidgetDecorator*decoration= new WidgetDecorator(theWidget,labelText,
  12233. orientation);
  12234. if(element.hasAttribute("id"))
  12235. {
  12236. decoration->setObjectName(element.attribute("id"));
  12237. }
  12238. /*:185*/
  12239. #line 4562 "./typica.w"
  12240. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  12241. splitter->addWidget(decoration);
  12242. }
  12243. /*:184*//*187:*/
  12244. #line 4634 "./typica.w"
  12245. void addWidgetToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  12246. QStack<QLayout*> *layoutStack)
  12247. {
  12248. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  12249. QWidget*widget= new QWidget;
  12250. if(element.hasAttribute("id"))
  12251. {
  12252. widget->setObjectName(element.attribute("id"));
  12253. }
  12254. splitter->addWidget(widget);
  12255. if(element.hasChildNodes())
  12256. {
  12257. widgetStack->push(widget);
  12258. populateWidget(element,widgetStack,layoutStack);
  12259. widgetStack->pop();
  12260. }
  12261. }
  12262. void populateWidget(QDomElement element,QStack<QWidget*> *widgetStack,
  12263. QStack<QLayout*> *layoutStack)
  12264. {
  12265. QDomNodeList children= element.childNodes();
  12266. for(int i= 0;i<children.count();i++)
  12267. {
  12268. QDomNode current;
  12269. QDomElement currentElement;
  12270. current= children.at(i);
  12271. if(current.isElement())
  12272. {
  12273. currentElement= current.toElement();
  12274. if(currentElement.tagName()=="layout")
  12275. {
  12276. addLayoutToWidget(currentElement,widgetStack,layoutStack);
  12277. }
  12278. }
  12279. }
  12280. }
  12281. /*:187*//*188:*/
  12282. #line 4677 "./typica.w"
  12283. void addButtonToLayout(QDomElement element,QStack<QWidget*> *,
  12284. QStack<QLayout*> *layoutStack)
  12285. {
  12286. QAbstractButton*button= NULL;
  12287. QString text= element.attribute("name");
  12288. if(element.hasAttribute("type"))
  12289. {
  12290. QString type= element.attribute("type");
  12291. if(type=="annotation")
  12292. {
  12293. AnnotationButton*abutton= new AnnotationButton(text);
  12294. if(element.hasAttribute("annotation"))
  12295. {
  12296. abutton->setAnnotation(element.attribute("annotation"));
  12297. }
  12298. if(element.hasAttribute("series"))
  12299. {
  12300. abutton->setTemperatureColumn(element.attribute("series").
  12301. toInt());
  12302. }
  12303. if(element.hasAttribute("column"))
  12304. {
  12305. abutton->setAnnotationColumn(element.attribute("column").
  12306. toInt());
  12307. }
  12308. button= abutton;
  12309. }
  12310. else if(type=="check")
  12311. {
  12312. button= new QCheckBox(text);
  12313. }
  12314. else if(type=="push")
  12315. {
  12316. button= new QPushButton(text);
  12317. }
  12318. }
  12319. if(element.hasAttribute("id"))
  12320. {
  12321. button->setObjectName(element.attribute("id"));
  12322. }
  12323. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  12324. layout->addWidget(button);
  12325. }
  12326. /*:188*//*189:*/
  12327. #line 4729 "./typica.w"
  12328. void addSpinBoxToLayout(QDomElement element,QStack<QWidget*> *,
  12329. QStack<QLayout*> *layoutStack)
  12330. {
  12331. AnnotationSpinBox*box= new AnnotationSpinBox("","",NULL);
  12332. if(element.hasAttribute("pretext"))
  12333. {
  12334. box->setPretext(element.attribute("pretext"));
  12335. }
  12336. if(element.hasAttribute("posttext"))
  12337. {
  12338. box->setPosttext(element.attribute("posttext"));
  12339. }
  12340. if(element.hasAttribute("series"))
  12341. {
  12342. box->setTemperatureColumn(element.attribute("series").toInt());
  12343. }
  12344. if(element.hasAttribute("column"))
  12345. {
  12346. box->setAnnotationColumn(element.attribute("column").toInt());
  12347. }
  12348. if(element.hasAttribute("min"))
  12349. {
  12350. box->setMinimum(element.attribute("min").toDouble());
  12351. }
  12352. if(element.hasAttribute("max"))
  12353. {
  12354. box->setMaximum(element.attribute("max").toDouble());
  12355. }
  12356. if(element.hasAttribute("decimals"))
  12357. {
  12358. box->setDecimals(element.attribute("decimals").toInt());
  12359. }
  12360. if(element.hasAttribute("step"))
  12361. {
  12362. box->setSingleStep(element.attribute("step").toDouble());
  12363. }
  12364. if(element.hasAttribute("id"))
  12365. {
  12366. box->setObjectName(element.attribute("id"));
  12367. }
  12368. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  12369. layout->addWidget(box);
  12370. }
  12371. /*:189*//*190:*/
  12372. #line 4785 "./typica.w"
  12373. void addZoomLogToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  12374. QStack<QLayout*> *)
  12375. {
  12376. ZoomLog*widget= new ZoomLog;
  12377. if(!widget)
  12378. {
  12379. qDebug()<<"Error constructing widget!";
  12380. }
  12381. if(element.hasAttribute("id"))
  12382. {
  12383. widget->setObjectName(element.attribute("id"));
  12384. }
  12385. if(element.hasChildNodes())
  12386. {
  12387. QDomNodeList children= element.childNodes();
  12388. int column= 0;
  12389. for(int i= 0;i<children.count();i++)
  12390. {
  12391. QDomNode current;
  12392. QDomElement currentElement;
  12393. current= children.at(i);
  12394. if(current.isElement())
  12395. {
  12396. currentElement= current.toElement();
  12397. if(currentElement.tagName()=="column")
  12398. {
  12399. QString text= currentElement.text();
  12400. widget->setHeaderData(column,text);
  12401. column++;
  12402. }
  12403. }
  12404. }
  12405. }
  12406. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  12407. if(splitter)
  12408. {
  12409. splitter->addWidget(widget);
  12410. }
  12411. else
  12412. {
  12413. qDebug()<<"Splitter not found at top of widget stack!";
  12414. }
  12415. }
  12416. /*:190*//*191:*/
  12417. #line 4833 "./typica.w"
  12418. void addGraphToSplitter(QDomElement element,QStack<QWidget*> *widgetStack,
  12419. QStack<QLayout*> *)
  12420. {
  12421. GraphView*view= new GraphView;
  12422. if(element.hasAttribute("id"))
  12423. {
  12424. view->setObjectName(element.attribute("id"));
  12425. }
  12426. QSplitter*splitter= qobject_cast<QSplitter*> (widgetStack->top());
  12427. splitter->addWidget(view);
  12428. }
  12429. /*:191*//*192:*/
  12430. #line 4850 "./typica.w"
  12431. void addSqlDropToLayout(QDomElement element,QStack<QWidget*> *,
  12432. QStack<QLayout*> *layoutStack)
  12433. {
  12434. SqlComboBox*box= new SqlComboBox();
  12435. if(element.hasAttribute("data"))
  12436. {
  12437. box->setDataColumn(element.attribute("data").toInt());
  12438. }
  12439. if(element.hasAttribute("display"))
  12440. {
  12441. box->setDisplayColumn(element.attribute("display").toInt());
  12442. }
  12443. if(element.hasAttribute("showdata"))
  12444. {
  12445. if(element.attribute("showdata")=="true")
  12446. {
  12447. box->showData(true);
  12448. }
  12449. }
  12450. if(element.hasAttribute("editable"))
  12451. {
  12452. if(element.attribute("editable")=="true")
  12453. {
  12454. box->setEditable(true);
  12455. }
  12456. }
  12457. if(element.hasChildNodes())
  12458. {
  12459. QDomNodeList children= element.childNodes();
  12460. for(int i= 0;i<children.count();i++)
  12461. {
  12462. QDomNode current;
  12463. QDomElement currentElement;
  12464. current= children.at(i);
  12465. if(current.isElement())
  12466. {
  12467. currentElement= current.toElement();
  12468. if(currentElement.tagName()=="null")
  12469. {
  12470. box->addNullOption();
  12471. }
  12472. else if(currentElement.tagName()=="query")
  12473. {
  12474. box->addSqlOptions(currentElement.text());
  12475. }
  12476. }
  12477. }
  12478. }
  12479. if(element.hasAttribute("id"))
  12480. {
  12481. box->setObjectName(element.attribute("id"));
  12482. }
  12483. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  12484. layout->addWidget(box);
  12485. }
  12486. /*:192*//*193:*/
  12487. #line 4929 "./typica.w"
  12488. void addSaltToLayout(QDomElement element,QStack<QWidget*> *,
  12489. QStack<QLayout*> *layoutStack)
  12490. {
  12491. QTableView*view= new QTableView;
  12492. view->setProperty("tabletype",QVariant(QString("SaltTable")));
  12493. SaltModel*model= new SaltModel(element.childNodes().count());
  12494. if(element.hasAttribute("id"))
  12495. {
  12496. view->setObjectName(element.attribute("id"));
  12497. }
  12498. if(element.hasChildNodes())
  12499. {
  12500. QDomNodeList children= element.childNodes();
  12501. int currentColumn= 0;
  12502. for(int i= 0;i<children.count();i++)
  12503. {
  12504. QDomNode current;
  12505. QDomElement currentElement;
  12506. current= children.at(i);
  12507. if(current.isElement())
  12508. {
  12509. currentElement= current.toElement();
  12510. if(currentElement.tagName()=="column")
  12511. {
  12512. if(currentElement.hasAttribute("name"))
  12513. {
  12514. model->setHeaderData(currentColumn,Qt::Horizontal,
  12515. currentElement.attribute("name"));
  12516. }
  12517. if(currentElement.hasAttribute("delegate"))
  12518. {
  12519. /*194:*/
  12520. #line 4977 "./typica.w"
  12521. if(currentElement.attribute("delegate")=="sql")
  12522. {
  12523. /*195:*/
  12524. #line 4993 "./typica.w"
  12525. SqlComboBoxDelegate*delegate= new SqlComboBoxDelegate;
  12526. SqlComboBox*widget= new SqlComboBox();
  12527. if(currentElement.hasAttribute("null"))
  12528. {
  12529. if(currentElement.attribute("null")=="true")
  12530. {
  12531. widget->addNullOption();
  12532. }
  12533. }
  12534. if(currentElement.hasAttribute("showdata"))
  12535. {
  12536. if(currentElement.attribute("showdata")=="true")
  12537. {
  12538. widget->showData(true);
  12539. }
  12540. }
  12541. if(currentElement.hasAttribute("data"))
  12542. {
  12543. widget->setDataColumn(currentElement.attribute("data").toInt());
  12544. }
  12545. if(currentElement.hasAttribute("display"))
  12546. {
  12547. widget->setDisplayColumn(currentElement.attribute("display").toInt());
  12548. }
  12549. widget->addSqlOptions(currentElement.text());
  12550. delegate->setWidget(widget);
  12551. view->setItemDelegateForColumn(currentColumn,delegate);
  12552. /*:195*/
  12553. #line 4980 "./typica.w"
  12554. }
  12555. else if(currentElement.attribute("delegate")=="numeric")
  12556. {
  12557. /*196:*/
  12558. #line 5026 "./typica.w"
  12559. NumericDelegate*delegate= new NumericDelegate;
  12560. view->setItemDelegateForColumn(currentColumn,delegate);
  12561. /*:196*/
  12562. #line 4984 "./typica.w"
  12563. }
  12564. /*:194*/
  12565. #line 4961 "./typica.w"
  12566. }
  12567. currentColumn++;
  12568. }
  12569. }
  12570. }
  12571. }
  12572. view->setModel(model);
  12573. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  12574. layout->addWidget(view);
  12575. }
  12576. /*:193*//*203:*/
  12577. #line 5136 "./typica.w"
  12578. void addLineToLayout(QDomElement element,QStack<QWidget*> *,
  12579. QStack<QLayout*> *layoutStack)
  12580. {
  12581. QLineEdit*widget= new QLineEdit(element.text());
  12582. if(element.hasAttribute("id"))
  12583. {
  12584. widget->setObjectName(element.attribute("id"));
  12585. }
  12586. if(element.hasAttribute("writable"))
  12587. {
  12588. if(element.attribute("writable")=="false")
  12589. {
  12590. widget->setReadOnly(true);
  12591. }
  12592. }
  12593. if(element.hasAttribute("validator"))
  12594. {
  12595. if(element.attribute("validator")=="numeric")
  12596. {
  12597. widget->setValidator(new QDoubleValidator(NULL));
  12598. }
  12599. else if(element.attribute("validator")=="integer")
  12600. {
  12601. widget->setValidator(new QIntValidator(NULL));
  12602. }
  12603. else if(element.attribute("validator")=="expression"&&
  12604. element.hasAttribute("expression"))
  12605. {
  12606. widget->setValidator(new QRegExpValidator(
  12607. QRegExp(element.attribute("expression")),
  12608. NULL));
  12609. }
  12610. }
  12611. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  12612. layout->addWidget(widget);
  12613. }
  12614. /*:203*//*204:*/
  12615. #line 5177 "./typica.w"
  12616. void addTextToLayout(QDomElement element,QStack<QWidget*> *,
  12617. QStack<QLayout*> *layoutStack)
  12618. {
  12619. QTextEdit*widget= new QTextEdit;
  12620. if(element.hasAttribute("id"))
  12621. {
  12622. widget->setObjectName(element.attribute("id"));
  12623. }
  12624. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  12625. layout->addWidget(widget);
  12626. }
  12627. /*:204*//*205:*/
  12628. #line 5194 "./typica.w"
  12629. void addSqlQueryViewToLayout(QDomElement element,
  12630. QStack<QWidget*> *,
  12631. QStack<QLayout*> *layoutStack)
  12632. {
  12633. SqlQueryView*view= new SqlQueryView;
  12634. if(element.hasAttribute("id"))
  12635. {
  12636. view->setObjectName(element.attribute("id"));
  12637. }
  12638. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  12639. layout->addWidget(view);
  12640. }
  12641. /*:205*//*206:*/
  12642. #line 5211 "./typica.w"
  12643. void addCalendarToLayout(QDomElement element,QStack<QWidget*> *,
  12644. QStack<QLayout*> *layoutStack)
  12645. {
  12646. QDateEdit*widget= new QDateEdit;
  12647. widget->setCalendarPopup(true);
  12648. if(element.hasAttribute("id"))
  12649. {
  12650. widget->setObjectName(element.attribute("id"));
  12651. }
  12652. widget->setDate(QDate::currentDate());
  12653. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  12654. layout->addWidget(widget);
  12655. }
  12656. /*:206*//*207:*/
  12657. #line 5229 "./typica.w"
  12658. void setQDateEditProperties(QScriptValue value,QScriptEngine*engine)
  12659. {
  12660. setQDateTimeEditProperties(value,engine);
  12661. }
  12662. void setQDateTimeEditProperties(QScriptValue value,QScriptEngine*engine)
  12663. {
  12664. setQAbstractSpinBoxProperties(value,engine);
  12665. value.setProperty("setDate",engine->newFunction(QDateTimeEdit_setDate));
  12666. value.setProperty("day",engine->newFunction(QDateTimeEdit_day));
  12667. value.setProperty("month",engine->newFunction(QDateTimeEdit_month));
  12668. value.setProperty("year",engine->newFunction(QDateTimeEdit_year));
  12669. }
  12670. /*:207*//*208:*/
  12671. #line 5249 "./typica.w"
  12672. QScriptValue QDateTimeEdit_setDate(QScriptContext*context,QScriptEngine*)
  12673. {
  12674. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  12675. if(context->argumentCount()==3)
  12676. {
  12677. self->setDate(QDate(argument<int> (0,context),
  12678. argument<int> (1,context),
  12679. argument<int> (2,context)));
  12680. }
  12681. else
  12682. {
  12683. context->throwError("Incorrect number of arguments passed to "
  12684. "QDateTimeEdit::setDate(). This method takes three integer arguments "
  12685. "specifying the year, month, and day.");
  12686. }
  12687. return QScriptValue();
  12688. }
  12689. QScriptValue QDateTimeEdit_day(QScriptContext*context,QScriptEngine*)
  12690. {
  12691. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  12692. return QScriptValue(self->date().day());
  12693. }
  12694. QScriptValue QDateTimeEdit_month(QScriptContext*context,QScriptEngine*)
  12695. {
  12696. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  12697. return QScriptValue(self->date().month());
  12698. }
  12699. QScriptValue QDateTimeEdit_year(QScriptContext*context,QScriptEngine*)
  12700. {
  12701. QDateTimeEdit*self= getself<QDateTimeEdit*> (context);
  12702. return QScriptValue(self->date().year());
  12703. }
  12704. /*:208*//*212:*/
  12705. #line 5316 "./typica.w"
  12706. QScriptValue findChildObject(QScriptContext*context,QScriptEngine*engine)
  12707. {
  12708. QObject*parent= argument<QObject*> (0,context);
  12709. QString name= argument<QString> (1,context);
  12710. QObject*object= parent->findChild<QObject*> (name);
  12711. QScriptValue value;
  12712. if(object)
  12713. {
  12714. value= engine->newQObject(object);
  12715. QString className= object->metaObject()->className();
  12716. /*213:*/
  12717. #line 5334 "./typica.w"
  12718. if(className=="TemperatureDisplay")
  12719. {
  12720. setTemperatureDisplayProperties(value,engine);
  12721. }
  12722. else if(className=="TimerDisplay")
  12723. {
  12724. setTimerDisplayProperties(value,engine);
  12725. }
  12726. else if(className=="QAction")
  12727. {
  12728. setQActionProperties(value,engine);
  12729. }
  12730. else if(className=="QBoxLayout")
  12731. {
  12732. setQBoxLayoutProperties(value,engine);
  12733. }
  12734. else if(className=="QDateEdit")
  12735. {
  12736. setQDateEditProperties(value,engine);
  12737. }
  12738. else if(className=="QFrame")
  12739. {
  12740. setQFrameProperties(value,engine);
  12741. }
  12742. else if(className=="QHBoxLayout")
  12743. {
  12744. setQBoxLayoutProperties(value,engine);
  12745. }
  12746. else if(className=="QLCDNumber")
  12747. {
  12748. setQLCDNumberProperties(value,engine);
  12749. }
  12750. else if(className=="QMenu")
  12751. {
  12752. setQMenuProperties(value,engine);
  12753. }
  12754. else if(className=="QMenuBar")
  12755. {
  12756. setQMenuBarProperties(value,engine);
  12757. }
  12758. else if(className=="QPushButton")
  12759. {
  12760. setQPushButtonProperties(value,engine);
  12761. }
  12762. else if(className=="QSplitter")
  12763. {
  12764. setQSplitterProperties(value,engine);
  12765. }
  12766. else if(className=="QTableView")
  12767. {
  12768. if(object->property("tabletype").isValid())
  12769. {
  12770. if(object->property("tabletype").toString()=="SaltTable")
  12771. {
  12772. setSaltTableProperties(value,engine);
  12773. }
  12774. }
  12775. }
  12776. else if(className=="QVBoxLayout")
  12777. {
  12778. setQBoxLayoutProperties(value,engine);
  12779. }
  12780. else if(className=="QWidget")
  12781. {
  12782. setQWidgetProperties(value,engine);
  12783. }
  12784. else if(className=="ScriptQMainWindow")
  12785. {
  12786. setQMainWindowProperties(value,engine);
  12787. }
  12788. else if(className=="SqlComboBox")
  12789. {
  12790. setSqlComboBoxProperties(value,engine);
  12791. }
  12792. else if(className=="SqlQueryView")
  12793. {
  12794. setSqlQueryViewProperties(value,engine);
  12795. }
  12796. else if(className=="ZoomLog")
  12797. {
  12798. setZoomLogProperties(value,engine);
  12799. }
  12800. else if(className=="QTextEdit")
  12801. {
  12802. setQTextEditProperties(value,engine);
  12803. }
  12804. else if(className=="QWebView")
  12805. {
  12806. setQWebViewProperties(value,engine);
  12807. }
  12808. /*:213*/
  12809. #line 5327 "./typica.w"
  12810. }
  12811. return value;
  12812. }
  12813. /*:212*//*215:*/
  12814. #line 5452 "./typica.w"
  12815. QScriptValue SaltTable_columnSum(QScriptContext*context,QScriptEngine*engine)
  12816. {
  12817. QTableView*self= getself<QTableView*> (context);
  12818. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  12819. QString datum;
  12820. double total= 0.0;
  12821. int column= argument<int> (0,context);
  12822. int role= argument<int> (1,context);
  12823. for(int i= 0;i<model->rowCount();i++)
  12824. {
  12825. datum= model->data(model->index(i,column),role).toString();
  12826. if(!datum.isEmpty())
  12827. {
  12828. total+= datum.toDouble();
  12829. }
  12830. }
  12831. return QScriptValue(engine,total);
  12832. }
  12833. /*:215*//*216:*/
  12834. #line 5476 "./typica.w"
  12835. QScriptValue SaltTable_columnArray(QScriptContext*context,
  12836. QScriptEngine*engine)
  12837. {
  12838. QTableView*self= getself<QTableView*> (context);
  12839. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  12840. int column= argument<int> (0,context);
  12841. int role= argument<int> (1,context);
  12842. QString literal= model->arrayLiteral(column,role);
  12843. return QScriptValue(engine,literal);
  12844. }
  12845. QScriptValue SaltTable_quotedColumnArray(QScriptContext*context,
  12846. QScriptEngine*engine)
  12847. {
  12848. QTableView*self= getself<QTableView*> (context);
  12849. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  12850. int column= argument<int> (0,context);
  12851. int role= argument<int> (1,context);
  12852. QString literal= model->quotedArrayLiteral(column,role);
  12853. return QScriptValue(engine,literal);
  12854. }
  12855. QScriptValue SaltTable_bindableColumnArray(QScriptContext*context,
  12856. QScriptEngine*engine)
  12857. {
  12858. QTableView*self= getself<QTableView*> (context);
  12859. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  12860. int column= argument<int> (0,context);
  12861. int role= argument<int> (1,context);
  12862. QString literal= model->arrayLiteral(column,role);
  12863. literal.chop(1);
  12864. literal= literal.remove(0,1);
  12865. return QScriptValue(engine,literal);
  12866. }
  12867. QScriptValue SaltTable_bindableQuotedColumnArray(QScriptContext*context,
  12868. QScriptEngine*engine)
  12869. {
  12870. QTableView*self= getself<QTableView*> (context);
  12871. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  12872. int column= argument<int> (0,context);
  12873. int role= argument<int> (1,context);
  12874. QString literal= model->quotedArrayLiteral(column,role);
  12875. literal.chop(1);
  12876. literal= literal.remove(0,1);
  12877. return QScriptValue(engine,literal);
  12878. }
  12879. /*:216*//*217:*/
  12880. #line 5528 "./typica.w"
  12881. QScriptValue SaltTable_model(QScriptContext*context,QScriptEngine*engine)
  12882. {
  12883. QTableView*self= getself<QTableView*> (context);
  12884. QScriptValue value= engine->newQObject(self->model());
  12885. return value;
  12886. }
  12887. /*:217*//*218:*/
  12888. #line 5542 "./typica.w"
  12889. QScriptValue SaltTable_setData(QScriptContext*context,QScriptEngine*)
  12890. {
  12891. QTableView*self= getself<QTableView*> (context);
  12892. int row= argument<int> (0,context);
  12893. int column= argument<int> (1,context);
  12894. QVariant value= argument<QVariant> (2,context);
  12895. int role= argument<int> (3,context);
  12896. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  12897. QModelIndex cell= model->index(row,column);
  12898. model->setData(cell,value,role);
  12899. self->update(cell);
  12900. return QScriptValue();
  12901. }
  12902. /*:218*//*219:*/
  12903. #line 5560 "./typica.w"
  12904. QScriptValue SaltTable_data(QScriptContext*context,QScriptEngine*engine)
  12905. {
  12906. QTableView*self= getself<QTableView*> (context);
  12907. int row= argument<int> (0,context);
  12908. int column= argument<int> (1,context);
  12909. int role= argument<int> (2,context);
  12910. SaltModel*model= qobject_cast<SaltModel*> (self->model());
  12911. QModelIndex cell= model->index(row,column);
  12912. QVariant value= model->data(cell,role);
  12913. QScriptValue retval= engine->newVariant(value);
  12914. retval.setProperty("value",QScriptValue(value.toString()));
  12915. return retval;
  12916. }
  12917. /*:219*//*220:*/
  12918. #line 5578 "./typica.w"
  12919. void setSaltTableProperties(QScriptValue value,QScriptEngine*engine)
  12920. {
  12921. setQWidgetProperties(value,engine);
  12922. value.setProperty("columnArray",
  12923. engine->newFunction(SaltTable_columnArray));
  12924. value.setProperty("quotedColumnArray",
  12925. engine->newFunction(SaltTable_quotedColumnArray));
  12926. value.setProperty("bindableColumnArray",
  12927. engine->newFunction(SaltTable_bindableColumnArray));
  12928. value.setProperty("bindableQuotedColumnArray",
  12929. engine->newFunction(SaltTable_bindableQuotedColumnArray));
  12930. value.setProperty("columnSum",engine->newFunction(SaltTable_columnSum));
  12931. value.setProperty("data",engine->newFunction(SaltTable_data));
  12932. value.setProperty("model",engine->newFunction(SaltTable_model));
  12933. value.setProperty("setData",engine->newFunction(SaltTable_setData));
  12934. }
  12935. /*:220*//*222:*/
  12936. #line 5611 "./typica.w"
  12937. void setSqlComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  12938. {
  12939. setQComboBoxProperties(value,engine);
  12940. }
  12941. void setQComboBoxProperties(QScriptValue value,QScriptEngine*engine)
  12942. {
  12943. setQWidgetProperties(value,engine);
  12944. value.setProperty("currentData",
  12945. engine->newFunction(QComboBox_currentData));
  12946. value.setProperty("addItem",engine->newFunction(QComboBox_addItem));
  12947. value.setProperty("setModel",engine->newFunction(QComboBox_setModel));
  12948. value.setProperty("findText",engine->newFunction(QComboBox_findText));
  12949. }
  12950. QScriptValue QComboBox_currentData(QScriptContext*context,
  12951. QScriptEngine*engine)
  12952. {
  12953. QComboBox*self= getself<QComboBox*> (context);
  12954. return QScriptValue(engine,
  12955. self->itemData(self->currentIndex()).toString());
  12956. }
  12957. QScriptValue QComboBox_addItem(QScriptContext*context,QScriptEngine*)
  12958. {
  12959. QComboBox*self= getself<QComboBox*> (context);
  12960. self->addItem(argument<QString> (0,context));
  12961. return QScriptValue();
  12962. }
  12963. QScriptValue QComboBox_setModel(QScriptContext*context,QScriptEngine*)
  12964. {
  12965. QComboBox*self= getself<QComboBox*> (context);
  12966. self->setModel(argument<QAbstractItemModel*> (0,context));
  12967. return QScriptValue();
  12968. }
  12969. QScriptValue QComboBox_findText(QScriptContext*context,QScriptEngine*engine)
  12970. {
  12971. QComboBox*self= getself<QComboBox*> (context);
  12972. return QScriptValue(engine,self->findText(argument<QString> (0,context)));
  12973. }
  12974. #line 1 "./abouttypica.w"
  12975. /*:222*//*255:*/
  12976. #line 6495 "./typica.w"
  12977. QScriptValue constructDAQ(QScriptContext*context,QScriptEngine*engine)
  12978. {
  12979. QScriptValue object;
  12980. if(context->argumentCount()==1)
  12981. {
  12982. object= engine->newQObject(new DAQ(argument<QString> (0,context)),
  12983. QScriptEngine::ScriptOwnership);
  12984. setDAQProperties(object,engine);
  12985. }
  12986. else if(context->argumentCount()==2)
  12987. {
  12988. object= engine->newQObject(new DAQ(argument<QString> (0,context),
  12989. argument<QString> (1,context)),
  12990. QScriptEngine::ScriptOwnership);
  12991. setDAQProperties(object,engine);
  12992. }
  12993. else
  12994. {
  12995. context->throwError("Incorrect number of arguments passed to DAQ"
  12996. "constructor. The DAQ constructor takes one"
  12997. "string as an argument specifying a device name."
  12998. "Example: Dev1");
  12999. }
  13000. return object;
  13001. }
  13002. /*:255*//*256:*/
  13003. #line 6525 "./typica.w"
  13004. void setDAQProperties(QScriptValue value,QScriptEngine*engine)
  13005. {
  13006. setQObjectProperties(value,engine);
  13007. value.setProperty("newChannel",engine->newFunction(DAQ_newChannel));
  13008. }
  13009. /*:256*//*257:*/
  13010. #line 6535 "./typica.w"
  13011. QScriptValue DAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  13012. {
  13013. DAQ*self= getself<DAQ*> (context);
  13014. QScriptValue object;
  13015. if(self)
  13016. {
  13017. object=
  13018. engine->newQObject(self->newChannel(argument<int> (0,context),
  13019. argument<int> (1,context)));
  13020. setChannelProperties(object,engine);
  13021. }
  13022. return object;
  13023. }
  13024. /*:257*//*264:*/
  13025. #line 6691 "./typica.w"
  13026. QScriptValue constructFakeDAQ(QScriptContext*context,
  13027. QScriptEngine*engine)
  13028. {
  13029. QScriptValue object;
  13030. if(context->argumentCount()==1)
  13031. {
  13032. object=
  13033. engine->newQObject(new FakeDAQ(argument<QString> (0,context)),
  13034. QScriptEngine::ScriptOwnership);
  13035. setFakeDAQProperties(object,engine);
  13036. }
  13037. else
  13038. {
  13039. context->throwError("Incorrect number of arguments passed to DAQ"
  13040. "constructor. The DAQ constructor takes one"
  13041. "string as an argument specifying a device name."
  13042. "Example: Dev1");
  13043. }
  13044. return object;
  13045. }
  13046. void setFakeDAQProperties(QScriptValue value,QScriptEngine*engine)
  13047. {
  13048. setQObjectProperties(value,engine);
  13049. value.setProperty("newChannel",engine->newFunction(FakeDAQ_newChannel));
  13050. }
  13051. QScriptValue FakeDAQ_newChannel(QScriptContext*context,QScriptEngine*engine)
  13052. {
  13053. FakeDAQ*self= getself<FakeDAQ*> (context);
  13054. QScriptValue object;
  13055. if(self)
  13056. {
  13057. object=
  13058. engine->newQObject(self->newChannel(argument<int> (0,context),
  13059. argument<int> (1,context)));
  13060. setChannelProperties(object,engine);
  13061. }
  13062. return object;
  13063. }
  13064. /*:264*//*268:*/
  13065. #line 6782 "./typica.w"
  13066. void setChannelProperties(QScriptValue value,QScriptEngine*engine)
  13067. {
  13068. setQObjectProperties(value,engine);
  13069. }
  13070. /*:268*//*275:*/
  13071. #line 6968 "./typica.w"
  13072. QScriptValue constructLinearCalibrator(QScriptContext*,QScriptEngine*engine)
  13073. {
  13074. QScriptValue object= engine->newQObject(new LinearCalibrator(NULL));
  13075. setLinearCalibratorProperties(object,engine);
  13076. return object;
  13077. }
  13078. void setLinearCalibratorProperties(QScriptValue value,QScriptEngine*engine)
  13079. {
  13080. setQObjectProperties(value,engine);
  13081. }
  13082. /*:275*//*280:*/
  13083. #line 7105 "./typica.w"
  13084. QScriptValue constructLinearSplineInterpolator(QScriptContext*,QScriptEngine*engine)
  13085. {
  13086. QScriptValue object= engine->newQObject(new LinearSplineInterpolator(NULL));
  13087. setLinearSplineInterpolatorProperties(object,engine);
  13088. return object;
  13089. }
  13090. void setLinearSplineInterpolatorProperties(QScriptValue value,QScriptEngine*engine)
  13091. {
  13092. setQObjectProperties(value,engine);
  13093. }
  13094. /*:280*//*289:*/
  13095. #line 7289 "./typica.w"
  13096. QScriptValue constructTemperatureDisplay(QScriptContext*,
  13097. QScriptEngine*engine)
  13098. {
  13099. QScriptValue object= engine->newQObject(new TemperatureDisplay);
  13100. setTemperatureDisplayProperties(object,engine);
  13101. return object;
  13102. }
  13103. void setTemperatureDisplayProperties(QScriptValue value,QScriptEngine*engine)
  13104. {
  13105. setQLCDNumberProperties(value,engine);
  13106. }
  13107. /*:289*//*296:*/
  13108. #line 7430 "./typica.w"
  13109. QScriptValue constructMeasurementTimeOffset(QScriptContext*,
  13110. QScriptEngine*engine)
  13111. {
  13112. QScriptValue object=
  13113. engine->newQObject(new MeasurementTimeOffset(QTime::currentTime()));
  13114. setMeasurementTimeOffsetProperties(object,engine);
  13115. return object;
  13116. }
  13117. void setMeasurementTimeOffsetProperties(QScriptValue value,
  13118. QScriptEngine*engine)
  13119. {
  13120. setQObjectProperties(value,engine);
  13121. }
  13122. /*:296*//*301:*/
  13123. #line 7539 "./typica.w"
  13124. QScriptValue constructThresholdDetector(QScriptContext*,QScriptEngine*engine)
  13125. {
  13126. QScriptValue object= engine->newQObject(new ThresholdDetector(300));
  13127. return object;
  13128. }
  13129. void setThresholdDetectorProperties(QScriptValue value,QScriptEngine*engine)
  13130. {
  13131. setQObjectProperties(value,engine);
  13132. }
  13133. /*:301*//*306:*/
  13134. #line 7635 "./typica.w"
  13135. QScriptValue constructZeroEmitter(QScriptContext*context,
  13136. QScriptEngine*engine)
  13137. {
  13138. QScriptValue object=
  13139. engine->newQObject(new ZeroEmitter(argument<int> (0,context)));
  13140. setZeroEmitterProperties(object,engine);
  13141. return object;
  13142. }
  13143. void setZeroEmitterProperties(QScriptValue value,QScriptEngine*engine)
  13144. {
  13145. setQObjectProperties(value,engine);
  13146. }
  13147. /*:306*//*311:*/
  13148. #line 7715 "./typica.w"
  13149. QScriptValue constructMeasurementAdapter(QScriptContext*context,
  13150. QScriptEngine*engine)
  13151. {
  13152. QScriptValue object=
  13153. engine->newQObject(new MeasurementAdapter(argument<int> (0,context)));
  13154. setMeasurementAdapterProperties(object,engine);
  13155. return object;
  13156. }
  13157. void setMeasurementAdapterProperties(QScriptValue value,QScriptEngine*engine)
  13158. {
  13159. setQObjectProperties(value,engine);
  13160. }
  13161. /*:311*//*326:*/
  13162. #line 8063 "./typica.w"
  13163. QScriptValue constructGraphView(QScriptContext*,QScriptEngine*engine)
  13164. {
  13165. QScriptValue object= engine->newQObject(new GraphView);
  13166. setGraphViewProperties(object,engine);
  13167. return object;
  13168. }
  13169. void setGraphViewProperties(QScriptValue value,QScriptEngine*engine)
  13170. {
  13171. setQGraphicsViewProperties(value,engine);
  13172. }
  13173. /*:326*//*349:*/
  13174. #line 8667 "./typica.w"
  13175. QScriptValue constructZoomLog(QScriptContext*,QScriptEngine*engine)
  13176. {
  13177. QScriptValue object= engine->newQObject(new ZoomLog);
  13178. setZoomLogProperties(object,engine);
  13179. return object;
  13180. }
  13181. void setZoomLogProperties(QScriptValue value,QScriptEngine*engine)
  13182. {
  13183. setQTableViewProperties(value,engine);
  13184. value.setProperty("saveXML",engine->newFunction(ZoomLog_saveXML));
  13185. value.setProperty("saveCSV",engine->newFunction(ZoomLog_saveCSV));
  13186. value.setProperty("saveState",engine->newFunction(ZoomLog_saveState));
  13187. value.setProperty("restoreState",
  13188. engine->newFunction(ZoomLog_restoreState));
  13189. value.setProperty("lastTime",engine->newFunction(ZoomLog_lastTime));
  13190. value.setProperty("saveTemporary",
  13191. engine->newFunction(ZoomLog_saveTemporary));
  13192. }
  13193. /*:349*//*350:*/
  13194. #line 8693 "./typica.w"
  13195. QScriptValue ZoomLog_saveXML(QScriptContext*context,QScriptEngine*engine)
  13196. {
  13197. ZoomLog*self= getself<ZoomLog*> (context);
  13198. bool retval= self->saveXML(argument<QIODevice*> (0,context));
  13199. return QScriptValue(engine,retval);
  13200. }
  13201. QScriptValue ZoomLog_saveCSV(QScriptContext*context,QScriptEngine*engine)
  13202. {
  13203. ZoomLog*self= getself<ZoomLog*> (context);
  13204. bool retval= self->saveCSV(argument<QIODevice*> (0,context));
  13205. return QScriptValue(engine,retval);
  13206. }
  13207. QScriptValue ZoomLog_saveTemporary(QScriptContext*context,
  13208. QScriptEngine*engine)
  13209. {
  13210. ZoomLog*self= getself<ZoomLog*> (context);
  13211. QString filename= QDir::tempPath();
  13212. filename.append("/");
  13213. filename.append(QUuid::createUuid().toString());
  13214. filename.append(".xml");
  13215. QFile*file= new QFile(filename);
  13216. self->saveXML(file);
  13217. file->close();
  13218. delete file;
  13219. return QScriptValue(engine,filename);
  13220. }
  13221. /*:350*//*351:*/
  13222. #line 8741 "./typica.w"
  13223. QScriptValue ZoomLog_saveState(QScriptContext*context,QScriptEngine*)
  13224. {
  13225. ZoomLog*self= getself<ZoomLog*> (context);
  13226. QString key= argument<QString> (0,context);
  13227. int columns= argument<int> (1,context);
  13228. QSettings settings;
  13229. for(int i= 0;i<columns;i++)
  13230. {
  13231. if(self->columnWidth(i))
  13232. {
  13233. settings.beginGroup(key);
  13234. settings.setValue(QString("%1").arg(i),self->columnWidth(i));
  13235. settings.endGroup();
  13236. }
  13237. }
  13238. return QScriptValue();
  13239. }
  13240. QScriptValue ZoomLog_restoreState(QScriptContext*context,QScriptEngine*)
  13241. {
  13242. ZoomLog*self= getself<ZoomLog*> (context);
  13243. QString key= argument<QString> (0,context);
  13244. int columns= argument<int> (1,context);
  13245. QSettings settings;
  13246. for(int i= 0;i<columns;i++)
  13247. {
  13248. settings.beginGroup(key);
  13249. self->setColumnWidth(i,
  13250. settings.value(QString("%1").arg(i),80).toInt());
  13251. if(settings.value(QString("%1").arg(i),80).toInt()==0)
  13252. {
  13253. self->setColumnWidth(i,80);
  13254. }
  13255. settings.endGroup();
  13256. }
  13257. return QScriptValue();
  13258. }
  13259. QScriptValue ZoomLog_lastTime(QScriptContext*context,QScriptEngine*engine)
  13260. {
  13261. ZoomLog*self= getself<ZoomLog*> (context);
  13262. return QScriptValue(engine,self->lastTime(argument<int> (0,context)));
  13263. }
  13264. /*:351*//*386:*/
  13265. #line 9585 "./typica.w"
  13266. QScriptValue constructAnnotationButton(QScriptContext*context,
  13267. QScriptEngine*engine)
  13268. {
  13269. QScriptValue object=
  13270. engine->newQObject(new AnnotationButton(argument<QString> (0,context)));
  13271. setAnnotationButtonProperties(object,engine);
  13272. return object;
  13273. }
  13274. void setAnnotationButtonProperties(QScriptValue value,QScriptEngine*engine)
  13275. {
  13276. setQPushButtonProperties(value,engine);
  13277. }
  13278. /*:386*//*394:*/
  13279. #line 9728 "./typica.w"
  13280. QScriptValue constructAnnotationSpinBox(QScriptContext*context,
  13281. QScriptEngine*engine)
  13282. {
  13283. QScriptValue object= engine->newQObject(new AnnotationSpinBox(
  13284. argument<QString> (0,context),argument<QString> (1,context)));
  13285. setAnnotationSpinBoxProperties(object,engine);
  13286. return object;
  13287. }
  13288. void setAnnotationSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  13289. {
  13290. setQDoubleSpinBoxProperties(value,engine);
  13291. }
  13292. void setQDoubleSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  13293. {
  13294. setQAbstractSpinBoxProperties(value,engine);
  13295. }
  13296. void setQAbstractSpinBoxProperties(QScriptValue value,QScriptEngine*engine)
  13297. {
  13298. setQWidgetProperties(value,engine);
  13299. }
  13300. /*:394*//*415:*/
  13301. #line 10147 "./typica.w"
  13302. QScriptValue constructTimerDisplay(QScriptContext*,QScriptEngine*engine)
  13303. {
  13304. QScriptValue object= engine->newQObject(new TimerDisplay);
  13305. setTimerDisplayProperties(object,engine);
  13306. return object;
  13307. }
  13308. void setTimerDisplayProperties(QScriptValue value,QScriptEngine*engine)
  13309. {
  13310. setQLCDNumberProperties(value,engine);
  13311. }
  13312. /*:415*//*442:*/
  13313. #line 10642 "./typica.w"
  13314. QScriptValue constructWidgetDecorator(QScriptContext*context,
  13315. QScriptEngine*engine)
  13316. {
  13317. QWidget*widget= argument<QWidget*> (0,context);
  13318. QString text= argument<QString> (1,context);
  13319. Qt::Orientations orientation;
  13320. switch(argument<int> (2,context))
  13321. {
  13322. case 2:
  13323. orientation= Qt::Vertical;
  13324. break;
  13325. default:
  13326. orientation= Qt::Horizontal;
  13327. break;
  13328. }
  13329. QScriptValue object=
  13330. engine->newQObject(new WidgetDecorator(widget,text,orientation));
  13331. setWidgetDecoratorProperties(object,engine);
  13332. return object;
  13333. }
  13334. void setWidgetDecoratorProperties(QScriptValue value,QScriptEngine*engine)
  13335. {
  13336. setQWidgetProperties(value,engine);
  13337. }
  13338. /*:442*//*455:*/
  13339. #line 10923 "./typica.w"
  13340. QScriptValue constructLogEditWindow(QScriptContext*,QScriptEngine*engine)
  13341. {
  13342. QScriptValue object= engine->newQObject(new LogEditWindow);
  13343. return object;
  13344. }
  13345. /*:455*//*474:*/
  13346. #line 11397 "./typica.w"
  13347. QScriptValue constructXMLInput(QScriptContext*context,QScriptEngine*engine)
  13348. {
  13349. QIODevice*device= argument<QIODevice*> (0,context);
  13350. QScriptValue object= engine->newQObject(new XMLInput(&*device,
  13351. argument<int> (1,context)));
  13352. object.setProperty("input",engine->newFunction(XMLInput_input));
  13353. return object;
  13354. }
  13355. QScriptValue XMLInput_input(QScriptContext*context,QScriptEngine*)
  13356. {
  13357. XMLInput*self= getself<XMLInput*> (context);
  13358. self->input();
  13359. return QScriptValue();
  13360. }
  13361. /*:474*//*481:*/
  13362. #line 11565 "./typica.w"
  13363. QScriptValue constructWebView(QScriptContext*,QScriptEngine*engine)
  13364. {
  13365. QScriptValue object= engine->newQObject(new QWebView());
  13366. setQWebViewProperties(object,engine);
  13367. return object;
  13368. }
  13369. void setQWebViewProperties(QScriptValue value,QScriptEngine*engine)
  13370. {
  13371. setQWidgetProperties(value,engine);
  13372. value.setProperty("load",engine->newFunction(WebView_load));
  13373. value.setProperty("print",engine->newFunction(WebView_print));
  13374. value.setProperty("setHtml",engine->newFunction(WebView_setHtml));
  13375. value.setProperty("setContent",engine->newFunction(WebView_setContent));
  13376. value.setProperty("saveXml",engine->newFunction(WebView_saveXml));
  13377. }
  13378. /*:481*//*482:*/
  13379. #line 11586 "./typica.w"
  13380. QScriptValue WebView_load(QScriptContext*context,QScriptEngine*)
  13381. {
  13382. QWebView*self= getself<QWebView*> (context);
  13383. QString file= argument<QString> (0,context);
  13384. self->load(QUrl(file));
  13385. return QScriptValue();
  13386. }
  13387. /*:482*//*483:*/
  13388. #line 11599 "./typica.w"
  13389. QScriptValue WebView_print(QScriptContext*context,QScriptEngine*)
  13390. {
  13391. QWebView*self= getself<QWebView*> (context);
  13392. QPrinter*printer= new QPrinter(QPrinter::HighResolution);
  13393. QPrintDialog printDialog(printer,NULL);
  13394. if(printDialog.exec()==QDialog::Accepted)
  13395. {
  13396. self->print(printer);
  13397. }
  13398. return QScriptValue();
  13399. }
  13400. /*:483*//*484:*/
  13401. #line 11615 "./typica.w"
  13402. QScriptValue WebView_setHtml(QScriptContext*context,QScriptEngine*)
  13403. {
  13404. QWebView*self= getself<QWebView*> (context);
  13405. QString content= argument<QString> (0,context);
  13406. self->setHtml(content);
  13407. return QScriptValue();
  13408. }
  13409. /*:484*//*485:*/
  13410. #line 11628 "./typica.w"
  13411. QScriptValue WebView_setContent(QScriptContext*context,QScriptEngine*)
  13412. {
  13413. QWebView*self= getself<QWebView*> (context);
  13414. QIODevice*device= argument<QIODevice*> (0,context);
  13415. device->reset();
  13416. QByteArray content= device->readAll();
  13417. self->setContent(content,"application/xhtml+xml");
  13418. return QScriptValue();
  13419. }
  13420. /*:485*//*486:*/
  13421. #line 11642 "./typica.w"
  13422. QScriptValue WebView_saveXml(QScriptContext*context,QScriptEngine*)
  13423. {
  13424. QWebView*self= getself<QWebView*> (context);
  13425. return QScriptValue(self->page()->currentFrame()->documentElement().toOuterXml());
  13426. }
  13427. /*:486*//*487:*/
  13428. #line 11652 "./typica.w"
  13429. void addWebViewToLayout(QDomElement element,QStack<QWidget*> *,
  13430. QStack<QLayout*> *layoutStack)
  13431. {
  13432. QWebView*view= new QWebView;
  13433. if(element.hasAttribute("id"))
  13434. {
  13435. view->setObjectName(element.attribute("id"));
  13436. }
  13437. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  13438. layout->addWidget(view);
  13439. }
  13440. /*:487*//*546:*/
  13441. #line 12713 "./typica.w"
  13442. QScriptValue constructSqlQueryView(QScriptContext*,QScriptEngine*engine)
  13443. {
  13444. QScriptValue object= engine->newQObject(new SqlQueryView);
  13445. setSqlQueryViewProperties(object,engine);
  13446. return object;
  13447. }
  13448. void setSqlQueryViewProperties(QScriptValue value,QScriptEngine*engine)
  13449. {
  13450. setQTableViewProperties(value,engine);
  13451. value.setProperty("setHeaderData",
  13452. engine->newFunction(SqlQueryView_setHeaderData));
  13453. value.setProperty("setQuery",engine->newFunction(SqlQueryView_setQuery));
  13454. }
  13455. /*:546*//*547:*/
  13456. #line 12731 "./typica.w"
  13457. QScriptValue SqlQueryView_setQuery(QScriptContext*context,QScriptEngine*)
  13458. {
  13459. SqlQueryView*self= getself<SqlQueryView*> (context);
  13460. QString query= argument<QString> (0,context);
  13461. self->setQuery(query);
  13462. self->reset();
  13463. return QScriptValue();
  13464. }
  13465. QScriptValue SqlQueryView_setHeaderData(QScriptContext*context,
  13466. QScriptEngine*)
  13467. {
  13468. SqlQueryView*self= getself<SqlQueryView*> (context);
  13469. int section= argument<int> (0,context);
  13470. QString data= argument<QString> (1,context);
  13471. self->setHeaderData(section,Qt::Horizontal,data,Qt::DisplayRole);
  13472. return QScriptValue();
  13473. }
  13474. /*:547*//*555:*/
  13475. #line 12930 "./typica.w"
  13476. void addReportToLayout(QDomElement element,QStack<QWidget*> *,
  13477. QStack<QLayout*> *layoutStack)
  13478. {
  13479. QTextEdit*widget= new QTextEdit;
  13480. if(element.hasAttribute("id"))
  13481. {
  13482. widget->setObjectName(element.attribute("id"));
  13483. }
  13484. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  13485. layout->addWidget(widget);
  13486. QTextDocument*document= new QTextDocument;
  13487. QFont defaultFont;
  13488. defaultFont.setPointSize(11);
  13489. document->setDefaultFont(defaultFont);
  13490. QTextCursor cursor(document);
  13491. /*556:*/
  13492. #line 12953 "./typica.w"
  13493. QDomNodeList children= element.childNodes();
  13494. for(int i= 0;i<children.count();i++)
  13495. {
  13496. QDomNode current;
  13497. QDomElement currentElement;
  13498. current= children.at(i);
  13499. if(current.isElement())
  13500. {
  13501. currentElement= current.toElement();
  13502. /*557:*/
  13503. #line 12970 "./typica.w"
  13504. if(currentElement.tagName()=="style")
  13505. {
  13506. document->setDefaultStyleSheet(currentElement.text());
  13507. }
  13508. /*:557*//*558:*/
  13509. #line 12981 "./typica.w"
  13510. if(currentElement.tagName()=="html")
  13511. {
  13512. cursor.insertHtml(currentElement.text());
  13513. }
  13514. /*:558*//*559:*/
  13515. #line 12991 "./typica.w"
  13516. if(currentElement.tagName()=="text")
  13517. {
  13518. cursor.insertText(currentElement.text());
  13519. }
  13520. /*:559*//*560:*/
  13521. #line 13001 "./typica.w"
  13522. if(currentElement.tagName()=="table")
  13523. {
  13524. QTextFrame*frame= cursor.insertFrame(QTextFrameFormat());
  13525. ReportTable*table= new ReportTable(frame,currentElement);
  13526. table->setParent(widget);
  13527. if(currentElement.hasAttribute("id"))
  13528. {
  13529. table->setObjectName(currentElement.attribute("id"));
  13530. }
  13531. }
  13532. /*:560*/
  13533. #line 12963 "./typica.w"
  13534. }
  13535. }
  13536. /*:556*/
  13537. #line 12946 "./typica.w"
  13538. widget->setDocument(document);
  13539. }
  13540. /*:555*//*571:*/
  13541. #line 13213 "./typica.w"
  13542. QScriptValue QTextEdit_print(QScriptContext*context,QScriptEngine*)
  13543. {
  13544. QTextEdit*self= getself<QTextEdit*> (context);
  13545. QTextDocument*document= self->document();
  13546. QPrinter printer;
  13547. QPrintDialog printwindow(&printer,self);
  13548. if(printwindow.exec()!=QDialog::Accepted)
  13549. {
  13550. return QScriptValue();
  13551. }
  13552. document->print(&printer);
  13553. return QScriptValue();
  13554. }
  13555. /*:571*//*572:*/
  13556. #line 13231 "./typica.w"
  13557. void setQTextEditProperties(QScriptValue value,QScriptEngine*engine)
  13558. {
  13559. setQAbstractScrollAreaProperties(value,engine);
  13560. value.setProperty("print",engine->newFunction(QTextEdit_print));
  13561. }
  13562. /*:572*//*581:*/
  13563. #line 13409 "./typica.w"
  13564. void addFormArrayToLayout(QDomElement element,QStack<QWidget*> *,
  13565. QStack<QLayout*> *layoutStack)
  13566. {
  13567. FormArray*widget= new FormArray(element);
  13568. if(element.hasAttribute("id"))
  13569. {
  13570. widget->setObjectName(element.attribute("id"));
  13571. }
  13572. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  13573. layout->addWidget(widget);
  13574. }
  13575. /*:581*//*602:*/
  13576. #line 13996 "./typica.w"
  13577. void addScaleControlToLayout(QDomElement element,QStack<QWidget*> *,
  13578. QStack<QLayout*> *layoutStack)
  13579. {
  13580. ScaleControl*scale= new ScaleControl;
  13581. if(element.hasAttribute("id"))
  13582. {
  13583. scale->setObjectName(element.attribute("id"));
  13584. }
  13585. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  13586. layout->addWidget(scale);
  13587. }
  13588. void addIntensityControlToLayout(QDomElement element,QStack<QWidget*> *,
  13589. QStack<QLayout*> *layoutStack)
  13590. {
  13591. IntensityControl*scale= new IntensityControl;
  13592. if(element.hasAttribute("id"))
  13593. {
  13594. scale->setObjectName(element.attribute("id"));
  13595. }
  13596. QBoxLayout*layout= qobject_cast<QBoxLayout*> (layoutStack->top());
  13597. layout->addWidget(scale);
  13598. }
  13599. /*:602*//*628:*/
  13600. #line 14586 "./typica.w"
  13601. QScriptValue constructDeviceTreeModel(QScriptContext*,QScriptEngine*engine)
  13602. {
  13603. QScriptValue object= engine->newQObject(new DeviceTreeModel);
  13604. setDeviceTreeModelProperties(object,engine);
  13605. return object;
  13606. }
  13607. /*:628*//*630:*/
  13608. #line 14609 "./typica.w"
  13609. void setDeviceTreeModelProperties(QScriptValue value,QScriptEngine*engine)
  13610. {
  13611. setQAbstractItemModelProperties(value,engine);
  13612. value.setProperty("referenceElement",
  13613. engine->newFunction(DeviceTreeModel_referenceElement));
  13614. }
  13615. void setQAbstractItemModelProperties(QScriptValue value,QScriptEngine*engine)
  13616. {
  13617. setQObjectProperties(value,engine);
  13618. value.setProperty("data",engine->newFunction(QAbstractItemModel_data));
  13619. value.setProperty("index",engine->newFunction(QAbstractItemModel_index));
  13620. value.setProperty("rowCount",engine->newFunction(QAbstractItemModel_rowCount));
  13621. value.setProperty("hasChildren",engine->newFunction(QAbstractItemModel_hasChildren));
  13622. }
  13623. /*:630*//*631:*/
  13624. #line 14636 "./typica.w"
  13625. QScriptValue DeviceTreeModel_referenceElement(QScriptContext*context,
  13626. QScriptEngine*engine)
  13627. {
  13628. DeviceTreeModel*model= getself<DeviceTreeModel*> (context);
  13629. QDomElement referenceElement= model->referenceElement(argument<QString> (0,context));
  13630. QDomNodeList configData= referenceElement.elementsByTagName("attribute");
  13631. QDomElement node;
  13632. QVariantMap retval;
  13633. retval.insert("driver",referenceElement.attribute("driver"));
  13634. for(int i= 0;i<configData.size();i++)
  13635. {
  13636. node= configData.at(i).toElement();
  13637. retval.insert(node.attribute("name"),node.attribute("value"));
  13638. }
  13639. return engine->toScriptValue(retval);
  13640. }
  13641. QScriptValue QAbstractItemModel_data(QScriptContext*context,QScriptEngine*engine)
  13642. {
  13643. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  13644. QModelIndex index= argument<QModelIndex> (0,context);
  13645. int role= argument<int> (1,context);
  13646. return engine->toScriptValue(model->data(index,role));
  13647. }
  13648. QScriptValue QAbstractItemModel_index(QScriptContext*context,QScriptEngine*engine)
  13649. {
  13650. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  13651. int row= 0;
  13652. int column= 0;
  13653. QModelIndex index;
  13654. if(context->argumentCount()> 1)
  13655. {
  13656. row= argument<int> (0,context);
  13657. column= argument<int> (1,context);
  13658. }
  13659. if(context->argumentCount()> 2)
  13660. {
  13661. index= argument<QModelIndex> (2,context);
  13662. }
  13663. QModelIndex retval= model->index(row,column,index);
  13664. return engine->toScriptValue(retval);
  13665. }
  13666. QScriptValue QAbstractItemModel_rowCount(QScriptContext*context,
  13667. QScriptEngine*)
  13668. {
  13669. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  13670. QModelIndex index;
  13671. if(context->argumentCount()==1)
  13672. {
  13673. index= argument<QModelIndex> (0,context);
  13674. }
  13675. return QScriptValue(model->rowCount(index));
  13676. }
  13677. QScriptValue QAbstractItemModel_hasChildren(QScriptContext*context,
  13678. QScriptEngine*engine)
  13679. {
  13680. QAbstractItemModel*model= getself<QAbstractItemModel*> (context);
  13681. QModelIndex index;
  13682. if(context->argumentCount()==1)
  13683. {
  13684. index= argument<QModelIndex> (0,context);
  13685. }
  13686. return QScriptValue(engine,model->hasChildren(index));
  13687. }
  13688. /*:631*//*634:*/
  13689. #line 14720 "./typica.w"
  13690. QScriptValue QModelIndex_toScriptValue(QScriptEngine*engine,const QModelIndex&index)
  13691. {
  13692. QVariant var;
  13693. var.setValue(index);
  13694. QScriptValue object= engine->newVariant(var);
  13695. return object;
  13696. }
  13697. void QModelIndex_fromScriptValue(const QScriptValue&value,QModelIndex&index)
  13698. {
  13699. index= value.toVariant().value<QModelIndex> ();
  13700. }
  13701. /*:634*//*650:*/
  13702. #line 15008 "./typica.w"
  13703. QScriptValue constructDeviceConfigurationWindow(QScriptContext*,
  13704. QScriptEngine*engine)
  13705. {
  13706. QScriptValue object= engine->newQObject(new DeviceConfigurationWindow);
  13707. return object;
  13708. }
  13709. /*:650*//*726:*/
  13710. #line 17513 "./typica.w"
  13711. QScriptValue constructModbusRTUDevice(QScriptContext*context,QScriptEngine*engine)
  13712. {
  13713. QScriptValue object;
  13714. if(context->argumentCount()==2)
  13715. {
  13716. object= engine->newQObject(new ModbusRTUDevice(argument<DeviceTreeModel*> (0,context),
  13717. argument<QModelIndex> (1,context)),
  13718. QScriptEngine::ScriptOwnership);
  13719. setModbusRTUDeviceProperties(object,engine);
  13720. }
  13721. else
  13722. {
  13723. context->throwError("Incorrect number of arguments passed to "
  13724. "ModbusRTUDevice constructor. This takes the configuration model "
  13725. "and an index.");
  13726. }
  13727. return object;
  13728. }
  13729. /*:726*//*727:*/
  13730. #line 17535 "./typica.w"
  13731. QScriptValue ModbusRTUDevice_pVChannel(QScriptContext*context,QScriptEngine*engine)
  13732. {
  13733. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  13734. QScriptValue object;
  13735. if(self)
  13736. {
  13737. if(self->channels.size()> 0)
  13738. {
  13739. object= engine->newQObject(self->channels.at(0));
  13740. setChannelProperties(object,engine);
  13741. }
  13742. }
  13743. return object;
  13744. }
  13745. QScriptValue ModbusRTUDevice_sVChannel(QScriptContext*context,QScriptEngine*engine)
  13746. {
  13747. ModbusRTUDevice*self= getself<ModbusRTUDevice*> (context);
  13748. QScriptValue object;
  13749. if(self)
  13750. {
  13751. if(self->channels.size()> 1)
  13752. {
  13753. object= engine->newQObject(self->channels.at(1));
  13754. setChannelProperties(object,engine);
  13755. }
  13756. }
  13757. return object;
  13758. }
  13759. /*:727*//*728:*/
  13760. #line 17568 "./typica.w"
  13761. void setModbusRTUDeviceProperties(QScriptValue value,QScriptEngine*engine)
  13762. {
  13763. setQObjectProperties(value,engine);
  13764. value.setProperty("pVChannel",engine->newFunction(ModbusRTUDevice_pVChannel));
  13765. value.setProperty("sVChannel",engine->newFunction(ModbusRTUDevice_sVChannel));
  13766. }
  13767. /*:728*/
  13768. #line 764 "./typica.w"
  13769. /*525:*/
  13770. #line 12364 "./typica.w"
  13771. int main(int argc,char**argv)
  13772. {
  13773. int*c= &argc;
  13774. Application app(*c,argv);
  13775. /*526:*/
  13776. #line 12390 "./typica.w"
  13777. QStringList themeSearchPath= QIcon::themeSearchPaths();
  13778. themeSearchPath.append(":/resources/icons/tango");
  13779. QIcon::setThemeSearchPaths(themeSearchPath);
  13780. QIcon::setThemeName(":/resources/icons/tango");
  13781. app.setWindowIcon(QIcon(":/resources/icons/appicons/logo.svg"));
  13782. /*:526*/
  13783. #line 12369 "./typica.w"
  13784. /*527:*/
  13785. #line 12400 "./typica.w"
  13786. QFile entypo(":/resources/fonts/entypo.ttf");
  13787. entypo.open(QIODevice::ReadOnly);
  13788. QFontDatabase::addApplicationFontFromData(entypo.readAll());
  13789. entypo.close();
  13790. /*:527*/
  13791. #line 12370 "./typica.w"
  13792. QSettings settings;
  13793. /*660:*/
  13794. #line 15220 "./typica.w"
  13795. app.registerDeviceConfigurationWidget("roaster",RoasterConfWidget::staticMetaObject);
  13796. /*:660*//*670:*/
  13797. #line 15448 "./typica.w"
  13798. app.registerDeviceConfigurationWidget("nidaqmxbase",
  13799. NiDaqMxBaseDriverConfWidget::staticMetaObject);
  13800. app.registerDeviceConfigurationWidget("nidaqmxbase9211series",
  13801. NiDaqMxBase9211ConfWidget::staticMetaObject);
  13802. app.registerDeviceConfigurationWidget("ni9211seriestc",
  13803. Ni9211TcConfWidget::staticMetaObject);
  13804. /*:670*//*678:*/
  13805. #line 15665 "./typica.w"
  13806. app.registerDeviceConfigurationWidget("nidaqmx",NiDaqMxDriverConfWidget::staticMetaObject);
  13807. app.registerDeviceConfigurationWidget("nidaqmx9211series",NiDaqMx9211ConfWidget::staticMetaObject);
  13808. app.registerDeviceConfigurationWidget("nidaqmxtc01",NiDaqMxTc01ConfWidget::staticMetaObject);
  13809. /*:678*//*702:*/
  13810. #line 16626 "./typica.w"
  13811. app.registerDeviceConfigurationWidget("modbusrtuport",ModbusRtuPortConfWidget::staticMetaObject);
  13812. app.registerDeviceConfigurationWidget("modbusrtudevice",ModbusRtuDeviceConfWidget::staticMetaObject);
  13813. app.registerDeviceConfigurationWidget("modbustemperaturepv",ModbusRtuDeviceTPvConfWidget::staticMetaObject);
  13814. app.registerDeviceConfigurationWidget("modbustemperaturesv",ModbusRtuDeviceTSvConfWidget::staticMetaObject);
  13815. /*:702*//*707:*/
  13816. #line 16711 "./typica.w"
  13817. app.registerDeviceConfigurationWidget("annotationbutton",AnnotationButtonConfWidget::staticMetaObject);
  13818. /*:707*//*710:*/
  13819. #line 16781 "./typica.w"
  13820. app.registerDeviceConfigurationWidget("reconfigurablebutton",ReconfigurableAnnotationButtonConfWidget::staticMetaObject);
  13821. /*:710*//*713:*/
  13822. #line 16908 "./typica.w"
  13823. app.registerDeviceConfigurationWidget("annotationspinbox",NoteSpinConfWidget::staticMetaObject);
  13824. /*:713*//*731:*/
  13825. #line 18081 "./typica.w"
  13826. app.registerDeviceConfigurationWidget("modbusrtu",ModbusConfigurator::staticMetaObject);
  13827. /*:731*//*738:*/
  13828. #line 18211 "./typica.w"
  13829. app.registerDeviceConfigurationWidget("linearspline",LinearSplineInterpolationConfWidget::staticMetaObject);
  13830. /*:738*//*742:*/
  13831. #line 18300 "./typica.w"
  13832. app.registerDeviceConfigurationWidget("translation",TranslationConfWidget::staticMetaObject);
  13833. /*:742*/
  13834. #line 12374 "./typica.w"
  13835. /*528:*/
  13836. #line 12412 "./typica.w"
  13837. if(settings.value("database/exists","false").toString()=="true")
  13838. {
  13839. /*533:*/
  13840. #line 12532 "./typica.w"
  13841. QSqlDatabase database=
  13842. QSqlDatabase::addDatabase(settings.value("database/driver").toString());
  13843. database.setHostName(settings.value("database/hostname").toString());
  13844. database.setDatabaseName(settings.value("database/dbname").toString());
  13845. database.setUserName(settings.value("database/user").toString());
  13846. database.setPassword(settings.value("database/password").toString());
  13847. if(!database.open())
  13848. {
  13849. settings.setValue("database/exists","false");
  13850. }
  13851. /*:533*/
  13852. #line 12415 "./typica.w"
  13853. }
  13854. if(settings.value("database/exists","false").toString()=="false")
  13855. {
  13856. /*532:*/
  13857. #line 12523 "./typica.w"
  13858. SqlConnectionSetup dialog;
  13859. dialog.exec();
  13860. /*:532*/
  13861. #line 12419 "./typica.w"
  13862. }
  13863. /*:528*/
  13864. #line 12375 "./typica.w"
  13865. /*154:*/
  13866. #line 3639 "./typica.w"
  13867. QStringList arguments= QCoreApplication::arguments();
  13868. int position= arguments.indexOf("-c");
  13869. QString filename= QString();
  13870. if(position!=-1)
  13871. {
  13872. if(arguments.size()>=position+1)
  13873. {
  13874. filename= arguments.at(position+1);
  13875. }
  13876. }
  13877. if(filename.isEmpty())
  13878. {
  13879. filename= QFileDialog::getOpenFileName(NULL,"Open Configuration File",
  13880. settings.value("config","").toString());
  13881. }
  13882. QDir directory;
  13883. if(!filename.isEmpty())
  13884. {
  13885. QFile file(filename);
  13886. QFileInfo info(filename);
  13887. directory= info.dir();
  13888. settings.setValue("config",directory.path());
  13889. if(file.open(QIODevice::ReadOnly))
  13890. {
  13891. app.configuration()->setContent(&file,true);
  13892. }
  13893. }
  13894. /*155:*/
  13895. #line 3673 "./typica.w"
  13896. QDomElement root= app.configuration()->documentElement();
  13897. QDomNodeList children= root.childNodes();
  13898. QString replacementDoc;
  13899. QDomDocument includedDoc;
  13900. QDomDocumentFragment fragment;
  13901. for(int i= 0;i<children.size();i++)
  13902. {
  13903. QDomNode currentNode= children.at(i);
  13904. QDomElement currentElement;
  13905. if(currentNode.nodeName()=="include")
  13906. {
  13907. currentElement= currentNode.toElement();
  13908. if(currentElement.hasAttribute("src"))
  13909. {
  13910. replacementDoc= directory.path();
  13911. replacementDoc.append('/');
  13912. replacementDoc.append(currentElement.attribute("src"));
  13913. QFile doc(replacementDoc);
  13914. if(doc.open(QIODevice::ReadOnly))
  13915. {
  13916. includedDoc.setContent(&doc,true);
  13917. fragment= includedDoc.createDocumentFragment();
  13918. fragment.appendChild(includedDoc.documentElement());
  13919. root.replaceChild(fragment,currentNode);
  13920. doc.close();
  13921. }
  13922. }
  13923. }
  13924. }
  13925. /*:155*/
  13926. #line 3667 "./typica.w"
  13927. /*:154*/
  13928. #line 12376 "./typica.w"
  13929. /*20:*/
  13930. #line 883 "./typica.w"
  13931. QScriptEngine*engine= new QScriptEngine;
  13932. QScriptValue constructor;
  13933. QScriptValue value;
  13934. /*:20*//*30:*/
  13935. #line 1059 "./typica.w"
  13936. constructor= engine->newFunction(constructQWidget);
  13937. value= engine->newQMetaObject(&QWidget::staticMetaObject,constructor);
  13938. engine->globalObject().setProperty("QWidget",value);
  13939. /*:30*//*38:*/
  13940. #line 1259 "./typica.w"
  13941. constructor= engine->newFunction(constructQMainWindow);
  13942. value= engine->newQMetaObject(&ScriptQMainWindow::staticMetaObject,
  13943. constructor);
  13944. engine->globalObject().setProperty("QMainWindow",value);
  13945. /*:38*//*49:*/
  13946. #line 1464 "./typica.w"
  13947. constructor= engine->newFunction(constructQFrame);
  13948. value= engine->newQMetaObject(&QFrame::staticMetaObject,constructor);
  13949. engine->globalObject().setProperty("QFrame",value);
  13950. /*:49*//*52:*/
  13951. #line 1497 "./typica.w"
  13952. constructor= engine->newFunction(constructQLabel);
  13953. value= engine->newQMetaObject(&QLabel::staticMetaObject,constructor);
  13954. engine->globalObject().setProperty("QLabel",value);
  13955. /*:52*//*55:*/
  13956. #line 1544 "./typica.w"
  13957. constructor= engine->newFunction(constructQSplitter);
  13958. value= engine->newQMetaObject(&QSplitter::staticMetaObject,constructor);
  13959. engine->globalObject().setProperty("QSplitter",value);
  13960. /*:55*//*62:*/
  13961. #line 1715 "./typica.w"
  13962. constructor= engine->newFunction(constructQBoxLayout);
  13963. value= engine->newQMetaObject(&QBoxLayout::staticMetaObject,constructor);
  13964. engine->globalObject().setProperty("QBoxLayout",value);
  13965. /*:62*//*66:*/
  13966. #line 1827 "./typica.w"
  13967. constructor= engine->newFunction(constructQAction);
  13968. value= engine->newQMetaObject(&QAction::staticMetaObject,constructor);
  13969. engine->globalObject().setProperty("QAction",value);
  13970. /*:66*//*69:*/
  13971. #line 1886 "./typica.w"
  13972. value= engine->newQMetaObject(&QFileDialog::staticMetaObject);
  13973. value.setProperty("getOpenFileName",
  13974. engine->newFunction(QFileDialog_getOpenFileName));
  13975. value.setProperty("getSaveFileName",
  13976. engine->newFunction(QFileDialog_getSaveFileName));
  13977. engine->globalObject().setProperty("QFileDialog",value);
  13978. /*:69*//*74:*/
  13979. #line 1998 "./typica.w"
  13980. constructor= engine->newFunction(constructQFile);
  13981. value= engine->newQMetaObject(&QFile::staticMetaObject,constructor);
  13982. engine->globalObject().setProperty("QFile",value);
  13983. /*:74*//*81:*/
  13984. #line 2115 "./typica.w"
  13985. constructor= engine->newFunction(constructQBuffer);
  13986. value= engine->newQMetaObject(&QBuffer::staticMetaObject,constructor);
  13987. engine->globalObject().setProperty("QBuffer",value);
  13988. /*:81*//*84:*/
  13989. #line 2163 "./typica.w"
  13990. constructor= engine->newFunction(constructXQuery);
  13991. engine->globalObject().setProperty("XQuery",constructor);
  13992. /*:84*//*90:*/
  13993. #line 2257 "./typica.w"
  13994. constructor= engine->newFunction(constructXmlWriter);
  13995. engine->globalObject().setProperty("XmlWriter",constructor);
  13996. /*:90*//*99:*/
  13997. #line 2463 "./typica.w"
  13998. constructor= engine->newFunction(constructXmlReader);
  13999. engine->globalObject().setProperty("XmlReader",constructor);
  14000. /*:99*//*106:*/
  14001. #line 2587 "./typica.w"
  14002. value= engine->newQObject(&settings);
  14003. setQSettingsProperties(value,engine);
  14004. engine->globalObject().setProperty("QSettings",value);
  14005. /*:106*//*110:*/
  14006. #line 2668 "./typica.w"
  14007. constructor= engine->newFunction(constructQLCDNumber);
  14008. value= engine->newQMetaObject(&QLCDNumber::staticMetaObject,constructor);
  14009. engine->globalObject().setProperty("QLCDNumber",value);
  14010. /*:110*//*113:*/
  14011. #line 2724 "./typica.w"
  14012. constructor= engine->newFunction(constructQTime);
  14013. engine->globalObject().setProperty("QTime",constructor);
  14014. /*:113*//*134:*/
  14015. #line 3228 "./typica.w"
  14016. constructor= engine->newFunction(constructQPushButton);
  14017. value= engine->newQMetaObject(&QPushButton::staticMetaObject,constructor);
  14018. engine->globalObject().setProperty("QPushButton",value);
  14019. /*:134*//*141:*/
  14020. #line 3339 "./typica.w"
  14021. constructor= engine->newFunction(constructQSqlQuery);
  14022. engine->globalObject().setProperty("QSqlQuery",constructor);
  14023. /*:141*//*148:*/
  14024. #line 3500 "./typica.w"
  14025. engine->globalObject().setProperty("baseName",engine->newFunction(baseName));
  14026. engine->globalObject().setProperty("dir",engine->newFunction(dir));
  14027. engine->globalObject().setProperty("sqlToArray",
  14028. engine->newFunction(sqlToArray));
  14029. engine->globalObject().setProperty("setFont",engine->newFunction(setFont));
  14030. engine->globalObject().setProperty("annotationFromRecord",
  14031. engine->newFunction(annotationFromRecord));
  14032. engine->globalObject().setProperty("setTabOrder",engine->newFunction(setTabOrder));
  14033. /*:148*//*159:*/
  14034. #line 3836 "./typica.w"
  14035. engine->globalObject().setProperty("createWindow",
  14036. engine->newFunction(createWindow));
  14037. /*:159*//*211:*/
  14038. #line 5308 "./typica.w"
  14039. engine->globalObject().setProperty("findChildObject",
  14040. engine->newFunction(findChildObject));
  14041. /*:211*//*254:*/
  14042. #line 6485 "./typica.w"
  14043. constructor= engine->newFunction(constructDAQ);
  14044. value= engine->newQMetaObject(&DAQ::staticMetaObject,constructor);
  14045. engine->globalObject().setProperty("DAQ",value);
  14046. /*:254*//*263:*/
  14047. #line 6683 "./typica.w"
  14048. constructor= engine->newFunction(constructFakeDAQ);
  14049. value= engine->newQMetaObject(&FakeDAQ::staticMetaObject,constructor);
  14050. engine->globalObject().setProperty("FakeDAQ",value);
  14051. /*:263*//*274:*/
  14052. #line 6960 "./typica.w"
  14053. constructor= engine->newFunction(constructLinearCalibrator);
  14054. value= engine->newQMetaObject(&LinearCalibrator::staticMetaObject,
  14055. constructor);
  14056. engine->globalObject().setProperty("LinearCalibrator",value);
  14057. /*:274*//*279:*/
  14058. #line 7098 "./typica.w"
  14059. constructor= engine->newFunction(constructLinearSplineInterpolator);
  14060. value= engine->newQMetaObject(&LinearSplineInterpolator::staticMetaObject,constructor);
  14061. engine->globalObject().setProperty("LinearSplineInterpolator",value);
  14062. /*:279*//*288:*/
  14063. #line 7281 "./typica.w"
  14064. constructor= engine->newFunction(constructTemperatureDisplay);
  14065. value= engine->newQMetaObject(&TemperatureDisplay::staticMetaObject,
  14066. constructor);
  14067. engine->globalObject().setProperty("TemperatureDisplay",value);
  14068. /*:288*//*295:*/
  14069. #line 7419 "./typica.w"
  14070. constructor= engine->newFunction(constructMeasurementTimeOffset);
  14071. value= engine->newQMetaObject(&MeasurementTimeOffset::staticMetaObject,
  14072. constructor);
  14073. engine->globalObject().setProperty("MeasurementTimeOffset",value);
  14074. /*:295*//*300:*/
  14075. #line 7530 "./typica.w"
  14076. constructor= engine->newFunction(constructThresholdDetector);
  14077. value= engine->newQMetaObject(&ThresholdDetector::staticMetaObject,constructor);
  14078. engine->globalObject().setProperty("ThresholdDetector",value);
  14079. /*:300*//*305:*/
  14080. #line 7628 "./typica.w"
  14081. constructor= engine->newFunction(constructZeroEmitter);
  14082. value= engine->newQMetaObject(&ZeroEmitter::staticMetaObject,constructor);
  14083. engine->globalObject().setProperty("ZeroEmitter",value);
  14084. /*:305*//*310:*/
  14085. #line 7707 "./typica.w"
  14086. constructor= engine->newFunction(constructMeasurementAdapter);
  14087. value= engine->newQMetaObject(&MeasurementAdapter::staticMetaObject,
  14088. constructor);
  14089. engine->globalObject().setProperty("MeasurementAdapter",value);
  14090. /*:310*//*325:*/
  14091. #line 8056 "./typica.w"
  14092. constructor= engine->newFunction(constructGraphView);
  14093. value= engine->newQMetaObject(&GraphView::staticMetaObject,constructor);
  14094. engine->globalObject().setProperty("GraphView",value);
  14095. /*:325*//*348:*/
  14096. #line 8659 "./typica.w"
  14097. constructor= engine->newFunction(constructZoomLog);
  14098. value= engine->newQMetaObject(&ZoomLog::staticMetaObject,constructor);
  14099. engine->globalObject().setProperty("ZoomLog",value);
  14100. /*:348*//*385:*/
  14101. #line 9577 "./typica.w"
  14102. constructor= engine->newFunction(constructAnnotationButton);
  14103. value= engine->newQMetaObject(&AnnotationButton::staticMetaObject,
  14104. constructor);
  14105. engine->globalObject().setProperty("AnnotationButton",value);
  14106. /*:385*//*393:*/
  14107. #line 9719 "./typica.w"
  14108. constructor= engine->newFunction(constructAnnotationSpinBox);
  14109. value= engine->newQMetaObject(&AnnotationSpinBox::staticMetaObject,
  14110. constructor);
  14111. engine->globalObject().setProperty("AnnotationSpinBox",value);
  14112. /*:393*//*414:*/
  14113. #line 10140 "./typica.w"
  14114. constructor= engine->newFunction(constructTimerDisplay);
  14115. value= engine->newQMetaObject(&TimerDisplay::staticMetaObject,constructor);
  14116. engine->globalObject().setProperty("TimerDisplay",value);
  14117. /*:414*//*441:*/
  14118. #line 10634 "./typica.w"
  14119. constructor= engine->newFunction(constructWidgetDecorator);
  14120. value= engine->newQMetaObject(&WidgetDecorator::staticMetaObject,constructor);
  14121. engine->globalObject().setProperty("WidgetDecorator",value);
  14122. /*:441*//*454:*/
  14123. #line 10916 "./typica.w"
  14124. constructor= engine->newFunction(constructLogEditWindow);
  14125. value= engine->newQMetaObject(&LogEditWindow::staticMetaObject,constructor);
  14126. engine->globalObject().setProperty("LogEditWindow",value);
  14127. /*:454*//*473:*/
  14128. #line 11390 "./typica.w"
  14129. constructor= engine->newFunction(constructXMLInput);
  14130. value= engine->newQMetaObject(&XMLInput::staticMetaObject,constructor);
  14131. engine->globalObject().setProperty("XMLInput",value);
  14132. /*:473*//*480:*/
  14133. #line 11557 "./typica.w"
  14134. constructor= engine->newFunction(constructWebView);
  14135. value= engine->newQMetaObject(&QWebView::staticMetaObject,constructor);
  14136. engine->globalObject().setProperty("WebView",value);
  14137. /*:480*//*493:*/
  14138. #line 11749 "./typica.w"
  14139. value= engine->newQObject(AppInstance);
  14140. engine->globalObject().setProperty("Application",value);
  14141. /*:493*//*545:*/
  14142. #line 12705 "./typica.w"
  14143. constructor= engine->newFunction(constructSqlQueryView);
  14144. value= engine->newQMetaObject(&SqlQueryView::staticMetaObject,constructor);
  14145. engine->globalObject().setProperty("SqlQueryView",value);
  14146. /*:545*//*629:*/
  14147. #line 14596 "./typica.w"
  14148. constructor= engine->newFunction(constructDeviceTreeModel);
  14149. value= engine->newQMetaObject(&DeviceTreeModel::staticMetaObject,
  14150. constructor);
  14151. engine->globalObject().setProperty("DeviceTreeModel",value);
  14152. /*:629*//*635:*/
  14153. #line 14736 "./typica.w"
  14154. qScriptRegisterMetaType(engine,QModelIndex_toScriptValue,QModelIndex_fromScriptValue);
  14155. /*:635*//*651:*/
  14156. #line 15018 "./typica.w"
  14157. constructor= engine->newFunction(constructDeviceConfigurationWindow);
  14158. value= engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject,
  14159. constructor);
  14160. engine->globalObject().setProperty("DeviceConfigurationWindow",value);
  14161. /*:651*//*725:*/
  14162. #line 17504 "./typica.w"
  14163. constructor= engine->newFunction(constructModbusRTUDevice);
  14164. value= engine->newQMetaObject(&ModbusRTUDevice::staticMetaObject,constructor);
  14165. engine->globalObject().setProperty("ModbusRTUDevice",value);
  14166. /*:725*/
  14167. #line 12377 "./typica.w"
  14168. app.engine= engine;
  14169. /*156:*/
  14170. #line 3721 "./typica.w"
  14171. QString styleText;
  14172. QString programText;
  14173. QDomElement currentElement;
  14174. for(int i= 0;i<children.size();i++)
  14175. {
  14176. QDomNode currentNode= children.at(i);
  14177. if(currentNode.nodeName()=="style")
  14178. {
  14179. currentElement= currentNode.toElement();
  14180. styleText.append(currentElement.text());
  14181. }
  14182. else if(currentNode.nodeName()=="program")
  14183. {
  14184. currentElement= currentNode.toElement();
  14185. programText.append(currentElement.text());
  14186. }
  14187. }
  14188. app.setStyleSheet(styleText);
  14189. QScriptValue result= engine->evaluate(programText);
  14190. /*157:*/
  14191. #line 3746 "./typica.w"
  14192. if(engine->hasUncaughtException())
  14193. {
  14194. int line= engine->uncaughtExceptionLineNumber();
  14195. qDebug()<<"Uncaught excpetion at line "<<line<<" : "<<
  14196. result.toString();
  14197. QString trace;
  14198. foreach(trace,engine->uncaughtExceptionBacktrace())
  14199. {
  14200. qDebug()<<trace;
  14201. }
  14202. }
  14203. /*:157*/
  14204. #line 3741 "./typica.w"
  14205. /*:156*/
  14206. #line 12379 "./typica.w"
  14207. int retval= app.exec();
  14208. delete engine;
  14209. return retval;
  14210. }
  14211. /*:525*/
  14212. #line 765 "./typica.w"
  14213. #include "moc_typica.cpp"
  14214. /*:16*/