Subversion Repositories svn.mios32

Rev

Rev 1594 | Rev 1726 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1594 Rev 1724
Line 1... Line 1...
1
/* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
1
/* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
2
// $Id: MiosFileBrowser.cpp 1594 2012-12-10 23:43:43Z tk $
2
// $Id: MiosFileBrowser.cpp 1724 2013-03-28 20:23:40Z tk $
3
/*
3
/*
4
 * File browser for MIOS32 applications
4
 * File browser for MIOS32 applications
5
 *
5
 *
6
 * ==========================================================================
6
 * ==========================================================================
7
 *
7
 *
Line 64... Line 64...
64
    int getItemWidth() const
64
    int getItemWidth() const
65
    {
65
    {
66
        return 100;
66
        return 100;
67
    }
67
    }
68
68
69
    const String getUniqueName() const
69
    String getUniqueName() const
70
    {
70
    {
71
        if( fileItem->parentPath.compare(T("/")) == 0 ) {
71
        if( fileItem->parentPath.compare(T("/")) == 0 ) {
72
            return T("/") + fileItem->name;
72
            return T("/") + fileItem->name;
73
        } else {
73
        } else {
74
            if( fileItem->name.compare(T("/")) == 0 )
74
            if( fileItem->name.compare(T("/")) == 0 )
Line 132... Line 132...
132
        TreeViewItem::itemDoubleClicked(e);
132
        TreeViewItem::itemDoubleClicked(e);
133
        if( getOwnerView()->isEnabled() )
133
        if( getOwnerView()->isEnabled() )
134
            browser->treeItemDoubleClicked(this);
134
            browser->treeItemDoubleClicked(this);
135
    }
135
    }
136
136
137
    const String getDragSourceDescription()
137
    var getDragSourceDescription()
138
    {
138
    {
139
        return "MIOS Filebrowser Items";
139
        return "MIOS Filebrowser Items";
140
    }
140
    }
141
141
142
private:
142
private:
Line 312... Line 312...
312
                statusLabel->setText(T("Editing ") + currentReadFileName + T(" in text mode."), true);
312
                statusLabel->setText(T("Editing ") + currentReadFileName + T(" in text mode."), true);
313
            } else if( buttonThatWasClicked == editHexButton && textEditor->isVisible() ) {
313
            } else if( buttonThatWasClicked == editHexButton && textEditor->isVisible() ) {
314
                if( textEditor->isVisible() && !textEditor->isReadOnly() ) {
314
                if( textEditor->isVisible() && !textEditor->isReadOnly() ) {
315
                    // visible & read only mode means, that binary data is edited -> transfer to Hex Editor only in this case!
315
                    // visible & read only mode means, that binary data is edited -> transfer to Hex Editor only in this case!
316
                    String tmpStr(textEditor->getText());
316
                    String tmpStr(textEditor->getText());
317
                    Array<uint8> data((uint8 *)tmpStr.toCString(), tmpStr.length());
317
                    Array<uint8> data((uint8 *)tmpStr.toUTF8().getAddress(), tmpStr.length());
318
                    openHexEditor(data);
318
                    openHexEditor(data);
319
                } else {
319
                } else {
320
                    // otherwise re-use data in hex editor
320
                    // otherwise re-use data in hex editor
321
                    openHexEditor(hexEditor->getBinary());
321
                    openHexEditor(hexEditor->getBinary());
322
                }
322
                }
Line 361... Line 361...
361
                // write back the read file
361
                // write back the read file
362
                uploadBuffer(currentReadFileName, hexEditor->getBinary());
362
                uploadBuffer(currentReadFileName, hexEditor->getBinary());
363
            } else if( textEditor->isVisible() ) {
363
            } else if( textEditor->isVisible() ) {
364
                // write back the read file
364
                // write back the read file
365
                String txt(textEditor->getText());
365
                String txt(textEditor->getText());
366
                Array<uint8> tmp((uint8 *)txt.toCString(), txt.length());
366
                Array<uint8> tmp((uint8 *)txt.toUTF8().getAddress(), txt.length());
367
                uploadBuffer(currentReadFileName, tmp);
367
                uploadBuffer(currentReadFileName, tmp);
368
            }
368
            }
369
        }
369
        }
370
    }
370
    }
371
}
371
}
Line 440... Line 440...
440
    }
440
    }
441
}
441
}
442
442
443
void MiosFileBrowser::enableFileButtons(void)
443
void MiosFileBrowser::enableFileButtons(void)
444
{
444
{
-
 
445
    treeView->setEnabled(true);
-
 
446
445
    updateButton->setEnabled(true);
447
    updateButton->setEnabled(true);
446
    uploadButton->setEnabled(true);
448
    uploadButton->setEnabled(true);
447
    downloadButton->setEnabled(true);
449
    downloadButton->setEnabled(true);
448
    editTextButton->setEnabled(true);
450
    editTextButton->setEnabled(true);
449
    editHexButton->setEnabled(true);
451
    editHexButton->setEnabled(true);
Line 480... Line 482...
480
   
482
   
481
    uint8 *ptr = (uint8 *)&data.getReference(0);
483
    uint8 *ptr = (uint8 *)&data.getReference(0);
482
    for(int i=0; i<data.size(); ++i, ++ptr) {
484
    for(int i=0; i<data.size(); ++i, ++ptr) {
483
        if( *ptr == 0 ) {
485
        if( *ptr == 0 ) {
484
            hasBinaryData = true; // full conversion to string not possible
486
            hasBinaryData = true; // full conversion to string not possible
485
            str += T("\\0"); // show \0 instead
487
            str += "\\0"; // show \0 instead
486
        } else {
488
        } else {
487
            str += (char)*ptr;
489
            str += (const wchar_t)*ptr;
488
        }
490
        }
489
    }
491
    }
490
492
491
    return str;
493
    return str;
492
}
494
}
Line 580... Line 582...
580
        rootItem->setOpen(true);
582
        rootItem->setOpen(true);
581
        treeView->setRootItem(rootItem);
583
        treeView->setRootItem(rootItem);
582
584
583
        if( accessPossible ) {
585
        if( accessPossible ) {
584
            if( currentDirOpenStates ) {
586
            if( currentDirOpenStates ) {
585
                treeView->restoreOpennessState(*currentDirOpenStates);
587
                treeView->restoreOpennessState(*currentDirOpenStates, true);
586
                deleteAndZero(currentDirOpenStates);
588
                deleteAndZero(currentDirOpenStates);
587
            }
589
            }
588
590
589
            uploadButton->setEnabled(true);
591
            uploadButton->setEnabled(true);
590
            createDirButton->setEnabled(true);
592
            createDirButton->setEnabled(true);
Line 623... Line 625...
623
            sendCommand(T("read ") + currentReadFileName);
625
            sendCommand(T("read ") + currentReadFileName);
624
            return true;
626
            return true;
625
        } else {
627
        } else {
626
            // restore default path
628
            // restore default path
627
            String defaultPath(File::getSpecialLocation(File::userHomeDirectory).getFullPathName());
629
            String defaultPath(File::getSpecialLocation(File::userHomeDirectory).getFullPathName());
628
            PropertiesFile *propertiesFile = ApplicationProperties::getInstance()->getCommonSettings(true);
630
            PropertiesFile *propertiesFile = MiosStudioProperties::getInstance()->getCommonSettings(true);
629
            if( propertiesFile ) {
631
            if( propertiesFile ) {
630
                defaultPath = propertiesFile->getValue(T("defaultFilebrowserPath"), defaultPath);
632
                defaultPath = propertiesFile->getValue(T("defaultFilebrowserPath"), defaultPath);
631
            }
633
            }
632
634
633
            String readFileName(currentReadFileName.substring(currentReadFileName.lastIndexOfChar('/')+1));
635
            String readFileName(currentReadFileName.substring(currentReadFileName.lastIndexOfChar('/')+1));
Line 786... Line 788...
786
//==============================================================================
788
//==============================================================================
787
bool MiosFileBrowser::uploadFile(void)
789
bool MiosFileBrowser::uploadFile(void)
788
{
790
{
789
    // restore default path
791
    // restore default path
790
    String defaultPath(File::getSpecialLocation(File::userHomeDirectory).getFullPathName());
792
    String defaultPath(File::getSpecialLocation(File::userHomeDirectory).getFullPathName());
791
    PropertiesFile *propertiesFile = ApplicationProperties::getInstance()->getCommonSettings(true);
793
    PropertiesFile *propertiesFile = MiosStudioProperties::getInstance()->getCommonSettings(true);
792
    if( propertiesFile ) {
794
    if( propertiesFile ) {
793
        defaultPath = propertiesFile->getValue(T("defaultFilebrowserPath"), defaultPath);
795
        defaultPath = propertiesFile->getValue(T("defaultFilebrowserPath"), defaultPath);
794
    }
796
    }
795
    File defaultPathFile(defaultPath);
797
    File defaultPathFile(defaultPath);
796
    FileChooser myChooser(T("Upload File to Core"), defaultPathFile);
798
    FileChooser myChooser(T("Upload File to Core"), defaultPathFile);
Line 1159... Line 1161...
1159
}
1161
}
1160
1162
1161
//==============================================================================
1163
//==============================================================================
1162
void MiosFileBrowser::handleIncomingMidiMessage(const MidiMessage& message, uint8 runningStatus)
1164
void MiosFileBrowser::handleIncomingMidiMessage(const MidiMessage& message, uint8 runningStatus)
1163
{
1165
{
1164
    uint8 *data = message.getRawData();
1166
    uint8 *data = (uint8 *)message.getRawData();
1165
    uint32 size = message.getRawDataSize();
1167
    uint32 size = message.getRawDataSize();
1166
    int messageOffset = 0;
1168
    int messageOffset = 0;
1167
1169
1168
    bool messageReceived = false;
1170
    bool messageReceived = false;
1169
    if( runningStatus == 0xf0 &&
1171
    if( runningStatus == 0xf0 &&