Changeset 2 for trunk/orca/qt/qorca.cpp

Show
Ignore:
Timestamp:
01/25/06 14:55:17 (3 years ago)
Author:
krobillard
Message:

orca - Fixed read on Windows.
qt - Added append-text native.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/qt/qorca.cpp

    r1 r2  
    99#include <QTabWidget> 
    1010#include <QMessageBox> 
     11#include <QTextCursor> 
    1112#include "qorca.h" 
    1213#include "cbparse.h" 
     
    791792#define REF_RF_SAVE    a1+1 
    792793#define REF_RF_DIR     a1+2 
     794#define REF_RF_INIT    a1+3 
     795#define REF_RF_PATH    a1+4 
    793796 
    794797static void requestFileNative( OValue* a1 ) 
    795798{ 
    796799    QString fn; 
     800    QString dir; 
    797801    OString* str; 
    798802    const char* cp; 
    799803 
     804    if( orRefineSet( REF_RF_INIT ) ) 
     805    { 
     806        OValue* ref = REF_RF_PATH; 
     807        str = orSTRING( ref ); 
     808        orCTermStr( str ); 
     809        dir = orStrChars( str, ref ); 
     810    } 
     811    else 
     812    { 
     813        dir = qEnv.filePath; 
     814    } 
     815 
    800816    str = orSTRING(a1); 
    801     cp = str->charArray + a1->series.index; 
     817    orCTermStr( str ); 
     818    cp = orStrChars( str, a1 ); 
    802819 
    803820    if( orRefineSet( REF_RF_DIR ) ) 
    804821    { 
    805         fn = QFileDialog::getExistingDirectory(0, QString(cp), qEnv.filePath); 
     822        fn = QFileDialog::getExistingDirectory(0, QString(cp), dir ); 
    806823    } 
    807824    else if( orRefineSet( REF_RF_SAVE ) ) 
    808825    { 
    809         fn = QFileDialog::getSaveFileName( 0, QString(cp), qEnv.filePath ); 
     826        fn = QFileDialog::getSaveFileName( 0, QString(cp), dir ); 
    810827    } 
    811828    else 
    812829    { 
    813         fn = QFileDialog::getOpenFileName( 0, QString(cp), qEnv.filePath ); 
     830        fn = QFileDialog::getOpenFileName( 0, QString(cp), dir ); 
    814831    } 
    815832 
     
    967984 
    968985 
     986static void appendTextNative( OValue* a1 ) 
     987{ 
     988    WIDPool::REC* rec = qEnv.pool.record( a1->integer ); 
     989    if( rec ) 
     990    { 
     991        const OValue* a2 = a1 + 1; 
     992 
     993        switch( rec->type ) 
     994        { 
     995            case WT_LineEdit: 
     996            { 
     997                QString cur; 
     998                QString txt; 
     999                valueToQString( a2, txt ); 
     1000                cur = ((QLineEdit*) rec->widget)->text(); 
     1001                cur.append( txt ); 
     1002                ((QLineEdit*) rec->widget)->setText( cur ); 
     1003            } 
     1004                break; 
     1005 
     1006            case WT_TextEdit: 
     1007            { 
     1008                QString txt; 
     1009                QTextCursor cursor; 
     1010 
     1011                valueToQString( a2, txt ); 
     1012 
     1013                QTextEdit* edit = (QTextEdit*) rec->widget; 
     1014 
     1015                cursor = edit->textCursor(); 
     1016                cursor.movePosition( QTextCursor::End ); 
     1017                cursor.insertText( txt ); 
     1018 
     1019                //edit->insertPlainText( txt ); 
     1020                //edit->append( txt );  // Adds linefeed before text. 
     1021            } 
     1022                break; 
     1023 
     1024            default: 
     1025                break; 
     1026        } 
     1027    } 
     1028} 
     1029 
     1030 
    9691031static void messageNative( OValue* a1 ) 
    9701032{ 
     
    10171079  "dialog: native [layout [block!]]\n" 
    10181080  "widget: native [layout [block!]]\n" 
    1019   "request-file: native [title [string!] /save /dir]\n" 
     1081  "request-file: native [title [string!] /save /dir /init path]\n" 
    10201082  "enable:   native [wid [integer!]]\n" 
    10211083  "disable:  native [wid [integer!]]\n" 
    10221084  "widget-value: native [wid [integer!]]\n" 
    10231085  "set-widget-value: native [wid [integer!] val]\n" 
     1086  "append-text: native [wid [integer!] val]\n" 
    10241087  "watch-dir: native [dir [string! file!] handler [block!]]\n" 
    10251088  "message: native [title [string!] msg [string!] /warn]\n" 
     
    10871150    orNative( (void*) widgetValueNative,    "widget-value" ); 
    10881151    orNative( (void*) setWidgetValueNative, "set-widget-value" ); 
     1152    orNative( (void*) appendTextNative,     "append-text" ); 
    10891153    orNative( (void*) messageNative,        "message" ); 
    10901154#ifdef DIR_WATCHER