예제 #1
0
void MainWindow::slotSaveHistory() {
    QMap<QString, QStringList> map;
    QStringList text;
    text << "text/plain";
    map.insert(tr("History"), text );
    QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
    if (filename.isEmpty() ) return;

    QFileInfo info(filename);

    DocLnk nf;
    nf.setType("text/plain");
    nf.setFile(filename);
    nf.setName(info.fileName());


    QFile file(filename);
    if ( !file.open(IO_WriteOnly ) ) return;

    QTextStream str(&file );
    if ( currentSession() )
        currentSession()->emulationHandler()->emulation()->streamHistory(&str);

    file.close();
    nf.writeLink();
}
예제 #2
0
void MainWindow::slotSaveLog() {
    if( currentSession()->emulationHandler()->isLogging() ) {
        DocLnk nf;
        QString m_logName = currentSession()->emulationHandler()->logFileName();
        QFileInfo info(m_logName);
        nf.setType("text/plain");
        nf.setFile(m_logName);
        nf.setName(info.fileName());
        nf.writeLink();
        m_recordLog->setText( tr("Start log") );
        m_recordingLog = false;
        currentSession()->emulationHandler()->clearLog();
    }
    else {
        QMap<QString, QStringList> map;
        QStringList text;
        text << "text/plain";
        map.insert(tr("Log"), text );
        Opie::Core::OConfig cfg("opie-console");
        cfg.setGroup("defaults");
        QString startDir = cfg.readEntry("defaultlogdir", QPEApplication::documentDir() );
        QString m_logName = OFileDialog::getSaveFileName(2, startDir, QString::null, map, 0, startDir);
        if (m_logName.isEmpty() )
            return;

        m_recordLog->setText( tr("Stop log") );
        m_recordingLog = true;
        currentSession()->emulationHandler()->startLogging(m_logName);
    }
}
예제 #3
0
void TextEdit::openFile( const QString &f )
{
    odebug << "filename is "+ f << oendl;
    QString filer;
    QFileInfo fi( f);
    if(f.find(".desktop",0,true) != -1 && !openDesktop ) {
        switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) {
        case 0: //desktop
            filer = f;
            break;
        case 1: //linked
            DocLnk sf(f);
            filer = sf.file();
            break;
        };
    }
    else if(fi.baseName().left(1) == "") {
        odebug << "opening dotfile" << oendl;
        currentFileName=f;
        openDotFile(currentFileName);
        return;
    }
    /*
     * The problem is a file where Config(f).isValid() and it does not
     * end with .desktop will be treated as desktop file
     */
    else if (f.find(".desktop",0,true) != -1 ) {
        DocLnk sf(f);
        filer = sf.file();
        if(filer.right(1) == "/")
            filer = f;
    }
    else
        filer = f;

    DocLnk nf;
    nf.setType("text/plain");
    nf.setFile(filer);
    currentFileName=filer;

    nf.setName(fi.baseName());
    openFile(nf);

    odebug << "openFile string "+currentFileName << oendl;

    showEditTools();
    // Show filename in caption
    updateCaption();
    checkEnableDelete();
}
예제 #4
0
void MainWindow::slotSaveScript() {
    if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
        QMap<QString, QStringList> map;
        QStringList text;
        text << "text/plain";
        map.insert(tr("Script"), text );
        QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
        if (!filename.isEmpty()) {
            QFileInfo info(filename);
            if (info.extension(FALSE) != "script")
                filename += ".script";
            DocLnk nf;
            nf.setType("text/plain");
            nf.setFile(filename);
            nf.setName(info.fileName());
            FileManager fm;
            fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
            currentSession()->emulationHandler()->clearScript();
            m_saveScript->setEnabled(false);
            m_recordScript->setEnabled(true);
            populateScripts();
        }
    }
}
예제 #5
0
파일: vmemo.cpp 프로젝트: opieproject/opie
bool VMemo::startRecording()
{
    QString date = TimeString::dateString( QDateTime::currentDateTime(),false,true);
    date.replace(QRegExp("'"),"");
    date.replace(QRegExp(" "),"_");
    date.replace(QRegExp(":"),"-");
    date.replace(QRegExp(","),"");

    if( m_useAlerts ) {
        setupStatusWidget( "vm_"+ date ); // no tr
    }
    else {
        m_statusWidget = 0;
        m_timeLabel = 0;
    }

    Config config( "Vmemo" );
    config.setGroup( "System" );
    QString fileName = config.readEntry("RecLocation", QPEApplication::documentDir() );

    int s;
    s=fileName.find(':');
    if(s)
        fileName=fileName.right(fileName.length()-s-2);
    odebug << "pathname will be "+fileName << oendl;

    if( fileName.left(1).find('/') == -1)
        fileName="/"+fileName;
    if( fileName.right(1).find('/') == -1)
        fileName+="/";

    fileName += "vm_"+ date + ".wav";
    odebug << "filename is " + fileName << oendl;

    if( !m_recorder.setup( fileName, m_fileparams ) ) {
        QMessageBox::critical(0, "vmemo", "Could not start recording", "Abort");
        return false;
    }

    if( m_maxseconds > 0 || m_statusWidget )
        t_timer->start( 1000 );

    // FIXME error checking!
    m_elapsedseconds = 0;
    recording = true;
    repaint();
    m_recorder.record( this );

    QArray<int> cats(1);
    cats[0] = config.readNumEntry("Category", 0);

    QString dlName("vm_");
    dlName += date;
    DocLnk l;
    l.setFile(fileName);
    l.setName(dlName);
    l.setType("audio/x-wav");
    l.setCategories(cats);
    l.writeLink();
    return true;
}
예제 #6
0
/*!
  prompted save */
bool TextEdit::saveAs()
{
    odebug << "saveAsFile " + currentFileName << oendl;

    QString rt = editor->text();
    odebug << currentFileName << oendl;

    QString docname;
    if( currentFileName.isEmpty()
        || currentFileName == tr("Unnamed")
        || currentFileName == tr("Text Editor"))
    {
        odebug << "do silly TT filename thing" << oendl;
        QString pt = rt.simplifyWhiteSpace();
        int i = pt.find( ' ' );
        docname = pt;
        if ( i > 0 )
            docname = pt.left( i );

        while( docname.startsWith( "." ) )
            docname = docname.mid( 1 );
        docname.replace( QRegExp("/"), "_" );
        // Cut the length. Filenames longer than 40 are not helpful
        // and something goes wrong when they get too long.
        if ( docname.length() > 40 ) docname = docname.left(40);

        if ( docname.isEmpty() ) docname = tr("Unnamed");
    }

    QMap<QString, QStringList> map;
    map.insert(tr("All"), QStringList() );
    QStringList text;
    text << "text/*";
    map.insert(tr("Text"), text );
    text << "*";
    map.insert(tr("All"), text );

    QFileInfo cuFi( docname);
    QString filee = cuFi.fileName();
    QString dire = cuFi.dirPath();
    if(dire==".")
        dire = QPEApplication::documentDir();

    QString str;
    if( !featureAutoSave) {
        str = OFileDialog::getSaveFileName( 2, dire, filee, map);
        if(!str.isEmpty() && QFile::exists(str)) {
            switch ( QMessageBox::warning(this,tr("Text Editor"),tr("<p>The selected file already exists. Overwrite it?</p>"),tr("Overwrite"),tr("Cancel"),0,1) ) {
            case 0: //Overwrite
                break;
            case 1: //Cancel
                return false;
                break;
            }
        }
    }
    else
        str = docname;

    if(!str.isEmpty()) {
        QString fileNm=str;

        odebug << "saving filename "+fileNm << oendl;
        QFileInfo fi(fileNm);
        currentFileName=fi.fileName();
        if(doc)
            delete doc;

        DocLnk nf;
        nf.setType("text/plain");
        nf.setFile( fileNm);
        doc = new DocLnk(nf);
        odebug << "Saving file as " << currentFileName << oendl;
        doc->setName( fi.baseName() );

        FileManager fm;
        if ( !fm.saveFile( *doc, rt ) ) {
            QMessageBox::message(tr("Text Edit"),tr("Save Failed"));
            return false;
        }

        if( filePerms ) {
            filePermissions *filePerm;
            filePerm = new filePermissions(this, tr("Permissions"),true, 0,
                                           (const QString &)fileNm);
            QPEApplication::execDialog( filePerm );

            delete  filePerm;
        }
        updateCaption();
        resetEditStatus();
        if(caption().left(1)=="*")
            setCaption(caption().right(caption().length()-1));
        checkEnableDelete();

        return true;
    }
    odebug << "returning false" << oendl;
    return false;
} //end saveAs