Exemple #1
0
// Save the current editor content to the current folder/file.
void TextEditor::saveCurrentContent(int saveMode)
{
    bool fileIsWritable;

    //qDebug() << "DBG> save"<<currentFile<<"to currentFolder:"<<currentFolder;

    QUrl url(newFolder+"/"+newFile);
    QString localFile = url.toLocalFile();
    QFile file(localFile);
    fileIsWritable = file.open(QIODevice::WriteOnly | QIODevice::Text);

    if ( fileIsWritable ) {
        QTextStream stream( &file );
        stream<<currentContent;
        file.close();
        currentFolder = newFolder;
        currentFile = newFile;
        if(saveMode==SAVE)
            emit saveCompleted();
        else {
            recentFiles->readRecentFiles();
            recentFiles->addFile(currentFolder+"|"+currentFile);
            emit saveAsCompleted(currentFolder,currentFile);
        }
    } else {
        emit saveFailed(newFile,file.errorString());
    }
}
Exemple #2
0
void QuickTaskCreator::saveAll(){
    QuickTaskTask *task;
    //task = static_cast<QuickTaskTask>(this->taskWidgets.at(x));
    if(this->taskWidgets.count())
        task=this->taskWidgets.takeFirst();
    else return;
    if(task){
        connect(task,SIGNAL(saveCompleted()),this,SLOT(saveAll()));
        task->save();
    }

}
Exemple #3
0
void TaskEditor::save(){


    this->updateStore();

    if(this->store["id"].asString()==""){
        this->store["command"]="addTask";
    }else{
        this->store["command"]="editTask";
    }
    ServerCommand *command = new ServerCommand(this->store,0);
    connect(command, SIGNAL(saveComplete(Json::Value)), command, SLOT(deleteLater()));
    command->send();
    connect(command, SIGNAL(saveComplete(Json::Value)), this, SLOT(saveCompleted(Json::Value)));
    qDebug()<<"saved.";
}
Exemple #4
0
TextEditor::TextEditor(QObject *qml, RecentFiles *recentfiles, QObject *parent) :
    QObject(parent)
{

    currentFolder = "file:///home/user";
    newFolder = currentFolder;
    //currentFolder = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
    //qDebug() << currentFolder;
    currentFile = tr(UNTITLED);
    currentContent = "";
    recentFiles = recentfiles;

    // connect QML signals to TextEditor slots
    connect(qml, SIGNAL(menuOpenClicked(QString)),
             this, SLOT(menuOpenClicked(QString)));
    connect(qml, SIGNAL(toolSaveClicked(QString)),
             this, SLOT(toolSaveClicked(QString)));
    connect(qml, SIGNAL(toolRecentClicked()),
             this, SLOT(toolRecentClicked()));
    connect(qml, SIGNAL(menuSaveAsClicked()),
             this, SLOT(menuSaveAsClicked()));
    connect(qml, SIGNAL(saveAsRequested(QString,QString)),
             this, SLOT(saveAsRequested(QString,QString)));
    connect(qml, SIGNAL(newFolderChanged(QString)),
             this, SLOT(newFolderChanged(QString)));
    connect(qml, SIGNAL(fileOpenRequested(QString)),
             this, SLOT(fileOpenRequested(QString)));
    connect(qml, SIGNAL(saveAsConfirmed(QString)),
             this, SLOT(saveAsConfirmed(QString)));
    connect(qml, SIGNAL(newOrOpenConfirmed(QString)),
             this, SLOT(newOrOpenConfirmed(QString)));
    connect(qml, SIGNAL(openRecentConfirmed()),
             this, SLOT(openRecentConfirmed()));
    connect(qml, SIGNAL(menuQuitClicked(QString)),
             this, SLOT(menuQuitClicked(QString)));
    connect(qml, SIGNAL(saveBeforeClosed(QString)),
             this, SLOT(saveBeforeClosed(QString)));
    connect(qml, SIGNAL(menuNewClicked(QString)),
             this, SLOT(menuNewClicked(QString)));
    connect(qml, SIGNAL(recentFileClicked(QString,QString,QString)),
             this, SLOT(recentFileClicked(QString,QString,QString)));

    // connect TextEditor signals to QML signals
    connect(this, SIGNAL(browseRequested(QString,bool)),
               qml, SLOT(browseRequested(QString,bool)));
    connect(this, SIGNAL(recentRequested()),
               qml, SLOT(recentRequested()));
    connect(this, SIGNAL(openCompleted(QString,QString,QString)),
               qml, SLOT(openCompleted(QString,QString,QString)));
    connect(this, SIGNAL(openFailed(QString,QString)),
               qml, SLOT(openFailed(QString,QString)));
    connect(this, SIGNAL(saveCompleted()),
               qml, SLOT(saveCompleted()));
    connect(this, SIGNAL(saveFailed(QString,QString)),
               qml, SLOT(saveFailed(QString,QString)));
    connect(this, SIGNAL(saveAsCompleted(QString,QString)),
               qml, SLOT(saveAsCompleted(QString,QString)));
    connect(this, SIGNAL(saveAsToBeConfirmed(QString)),
               qml, SLOT(saveAsToBeConfirmed(QString)));
    connect(this, SIGNAL(newOrOpenToBeConfirmed(QString,QString)),
               qml, SLOT(newOrOpenToBeConfirmed(QString,QString)));
    connect(this, SIGNAL(openRecentToBeConfirmed(QString)),
               qml, SLOT(openRecentToBeConfirmed(QString)));
    connect(this, SIGNAL(appCloseToBeConfirmed(QString)),
               qml, SLOT(appCloseToBeConfirmed(QString)));
    connect(this, SIGNAL(appToBeClosed()),
               qml, SLOT(appToBeClosed()));
    connect(this, SIGNAL(editorCleared(QString,QString)),
               qml, SLOT(editorCleared(QString,QString)));
}