Ejemplo n.º 1
0
QVariantMap jsBridge::loadNote(QString guid) {

    LOG_INFO(guid);

    QVariantMap noteJson;
    noteJson["ok"] = false;

    Note *n = Note::fromGUID(guid);
    if (n == NULL)
        return noteJson;

    noteJson["content"] = n->getContent();
    noteJson["guid"] = guid;
    noteJson["title"] = n->getTitle();
    noteJson["active"] = n->getActive();
    noteJson["updated"] = n->getUpdated().toMSecsSinceEpoch();
    noteJson["contentHash"] = n->getContentHash();

    QVariantMap conflict = n->conflict();
    if (!conflict.isEmpty()) {
        noteJson["hasConflict"] = true;
        noteJson["conflict"] = conflict;
    } else
        noteJson["hasConflict"] = false;

    delete n;

    noteJson["ok"] = true;
    return noteJson;
}
Ejemplo n.º 2
0
void MainWindow::writeJsonObject(QJsonObject &json, Note note)
{
    json["DateStart"] = note.getDateStart().toString();
    json["DateEnd"]   = note.getDateEnd().toString();
    json["TimeStart"] = note.getTimeStart().toString();
    json["TimeEnd"]   = note.getTimeEnd().toString();
    json["Title"]     = note.getTitle();
    json["Text"]      = note.getText();
}
Ejemplo n.º 3
0
Note Note::operator =(Note &other)
{
    this->setTime(other.getTime());
    this->setMode(other.getMode()) ;
    this->setTitle(other.getTitle()) ;
    this->setDetails(other.getDetails()) ;
    this->setTrayDisplay(other.getTrayDisplay()) ;
    this->setWindowDisplay(other.getWindowDisplay()) ;
	this->setSound(other.isSound());

    return *this ;
}
Ejemplo n.º 4
0
void MainWindow::on_twTaskField_itemDoubleClicked(QTableWidgetItem *item)
{
    Dialog *dialog = new Dialog(this);
    Note note;
    if(dialog->exec() == QDialog::Accepted)
    {
        note.setTitle(dialog->getTitle());
        note.setText(dialog->getText());
        note.setDateStart(selDate_);
        note.setDateEnd(selDate_);
        note.setTimeStart(QTime::fromString(item->text()));
        note.setTimeEnd(QTime::fromString(item->text()));

        qDebug() << note.getTitle();
        qDebug() << note.getText();
        qDebug() << note.getDateStart();
        qDebug() << note.getDateEnd();
        qDebug() << note.getTimeStart();
        qDebug() << note.getTimeEnd();

        ui->twTaskField->setItem(item->row(), 1, new QTableWidgetItem(dialog->getTitle()
                                                                      +" "
                                                                      +dialog->getText()));
        //и записываем в контейнер:
        if(TimeLine_.size() != 0)
        {
            QLinkedList<Note>::iterator it;
            int i = 0;
            if(isSelDatePresented())
            {
                for(it = TimeLine_.begin(); it != TimeLine_.end(); ++it)
                {
                    if(it->getDateStart() == note.getDateStart())
                    {
                        TimeLine_.insert(it, note);
                        break;
                    }
                    i++;
                }
            }
            else
                TimeLine_.push_back(note);
        }
        else
            TimeLine_.append(note);
    }
    saveFileJson(); //<--- temp
}
Ejemplo n.º 5
0
//----- собственно, работа с json: -----
void MainWindow::readJsonObject(const QJsonObject json, Note &note)
{
    note.setDateStart(QDate::fromString(json["DateStart"].toString()));
    note.setDateEnd(QDate::fromString(json["DateEnd"].toString()));
    note.setTimeStart(QTime::fromString(json["TimeStart"].toString()));
    note.setTimeEnd(QTime::fromString(json["TimeEnd"].toString()));
    note.setTitle(json["Title"].toString());
    note.setText(json["Text"].toString());
//    item.Priority
//    item.Reminder
//    item.Color
//    item.Mask

    qDebug() << note.getTitle();
    qDebug() << note.getText();
    qDebug() << note.getDateStart();
    qDebug() << note.getDateEnd();
    qDebug() << note.getTimeStart();
    qDebug() << note.getTimeEnd();
}
Ejemplo n.º 6
0
void MainWindow::deleteNote(QString note) {

    if (note.isEmpty())
        note = getCurrentNoteGuid();

    if (note.isEmpty())
        return;

    Note *n = Note::fromGUID(note);

    if (n == NULL)
        return;

    QMessageBox msgBox(this);
    msgBox.setText("Are you sure you want to delete this Note?");
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    msgBox.setDefaultButton(QMessageBox::No);
    msgBox.setIcon(QMessageBox::Warning);
    msgBox.setWindowTitle(n->getTitle());
    msgBox.exec();

    if(msgBox.result() != QMessageBox::Yes)
        return;

    saveSelectionState();

    Note::NoteUpdates updates;
    updates[Note::T_ACTIVE] = false;
    updates[Note::T_DELETED] = QDateTime::currentDateTime().toMSecsSinceEpoch();
    n->update(updates);

    delete n;
    ui->notebooks->reload();
    ui->tags->reload();
    loadSelectionState();

    searchIndex->dropNoteIndex(note);
}