From 90825e2392b2d70e43c7a25b8a3752299a933894 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kjsembed/docs/examples/grepdialog/README | 6 + kjsembed/docs/examples/grepdialog/grepdlg.js | 23 +++ kjsembed/docs/examples/grepdialog/grepdlg.ui | 199 +++++++++++++++++++++++ kjsembed/docs/examples/grepdialog/grepresults.js | 36 ++++ kjsembed/docs/examples/grepdialog/grepresults.ui | 131 +++++++++++++++ kjsembed/docs/examples/grepdialog/guigrep | 6 + 6 files changed, 401 insertions(+) create mode 100644 kjsembed/docs/examples/grepdialog/README create mode 100644 kjsembed/docs/examples/grepdialog/grepdlg.js create mode 100644 kjsembed/docs/examples/grepdialog/grepdlg.ui create mode 100644 kjsembed/docs/examples/grepdialog/grepresults.js create mode 100644 kjsembed/docs/examples/grepdialog/grepresults.ui create mode 100755 kjsembed/docs/examples/grepdialog/guigrep (limited to 'kjsembed/docs/examples/grepdialog') diff --git a/kjsembed/docs/examples/grepdialog/README b/kjsembed/docs/examples/grepdialog/README new file mode 100644 index 00000000..e126113f --- /dev/null +++ b/kjsembed/docs/examples/grepdialog/README @@ -0,0 +1,6 @@ +Illustrates a number of useful facilities: + +- Creating dialogs from .ui files. +- Reading files from stdin and parsing them with JS regexps. +- Displaying formatted text using QML. +- Using shell scripts with kjscmd. diff --git a/kjsembed/docs/examples/grepdialog/grepdlg.js b/kjsembed/docs/examples/grepdialog/grepdlg.js new file mode 100644 index 00000000..2df87d98 --- /dev/null +++ b/kjsembed/docs/examples/grepdialog/grepdlg.js @@ -0,0 +1,23 @@ +// Create and show the dialog +var dlg = Factory.loadui('grepdlg.ui'); +dlg.exec(); + +// Extract the parameters +var search = dlg.child('search_edit').text; +var files = dlg.child('files_edit').text; +var matchcase = dlg.child('case_check').checked; +var shownumbers = dlg.child('shownumbers_check').checked; + +// Build the command line +var options = ''; +if ( !matchcase ) { + options += '-i '; +} +if ( shownumbers ) { + options += '-n '; +} + +cmd = 'grep -H '+options+"'"+search+"' "+files; + +// Print the command line +print( cmd ); diff --git a/kjsembed/docs/examples/grepdialog/grepdlg.ui b/kjsembed/docs/examples/grepdialog/grepdlg.ui new file mode 100644 index 00000000..53a169bd --- /dev/null +++ b/kjsembed/docs/examples/grepdialog/grepdlg.ui @@ -0,0 +1,199 @@ + +GrepDialog + + + GrepDialog + + + + 0 + 0 + 319 + 213 + + + + Grep Dialog + + + true + + + + unnamed + + + 11 + + + 6 + + + + search_edit + + + KJSEmbed + + + + + TextLabel2 + + + &Search for: + + + search_edit + + + + + TextLabel3 + + + In &files: + + + files_edit + + + + + files_edit + + + * + + + + + Spacer5 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + case_check + + + Match &case + + + + + TextLabel3_2 + + + Options: + + + + + TextLabel1 + + + + 12 + 1 + + + + Grep Dialog + + + + + Line1 + + + HLine + + + Sunken + + + Horizontal + + + + + shownumbers_check + + + Show line &numbers + + + true + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + buttonOk + + + &OK + + + true + + + true + + + + + + + + + buttonOk + clicked() + GrepDialog + accept() + + + + diff --git a/kjsembed/docs/examples/grepdialog/grepresults.js b/kjsembed/docs/examples/grepdialog/grepresults.js new file mode 100644 index 00000000..99a698cd --- /dev/null +++ b/kjsembed/docs/examples/grepdialog/grepresults.js @@ -0,0 +1,36 @@ +// Create the dialog +var dlg = Factory.loadui('grepresults.ui'); +var text = dlg.child('results_text'); + +function build_row( file, line, text ) +{ + file = file.replace( /:$/, "" ); + line = line.replace( /:$/, "" ); + return '' + +''+file+'' + +''+line+'' + +''+text+''; +} + +var s = ''; +s += ''; +s += ''; +s += ''; + +var line = readLine(); +while ( line != null ) { + line.replace( /&/g,"&"); + line = line.replace( /"/g,"""); + line = line.replace( / +GrepResults + + + GrepResults + + + + 0 + 0 + 578 + 324 + + + + Grep Results + + + + unnamed + + + + TextLabel1 + + + + 12 + 1 + + + + Grep Results + + + + + Line1 + + + HLine + + + Sunken + + + Horizontal + + + + + results_text + + + Box + + + Plain + + + 1 + + + RichText + + + true + + + false + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + buttonOk + + + &Dismiss + + + true + + + true + + + + + + + + + buttonOk + clicked() + GrepResults + accept() + + + + diff --git a/kjsembed/docs/examples/grepdialog/guigrep b/kjsembed/docs/examples/grepdialog/guigrep new file mode 100755 index 00000000..490e4676 --- /dev/null +++ b/kjsembed/docs/examples/grepdialog/guigrep @@ -0,0 +1,6 @@ +#!/bin/sh + +KJSCMD="`which kjscmd`" +GREP_CMD=`$KJSCMD grepdlg.js` +VIEW_CMD="$KJSCMD grepresults.js" +eval $GREP_CMD | $VIEW_CMD -- cgit v1.2.1
FileLineText