Пример #1
0
bool QvernoteStorage::copyNote(Guid noteGuid, Guid toNotebookGuid)
{
	Note note;
	QNote::load(getDB(), noteGuid, note);
	note.notebookGuid = toNotebookGuid;
	return createNote(note);
}
Пример #2
0
/** Gets and Osc, sets up a new NoteKey structure, assigns stuff and adds to the note list */
NoteKey * newPlayNote(uint8_t noteIndex, uint8_t source)
{
	NoteKey * pNewNote;
	Oscillator * pNewOsc;
	pNewOsc = popOsc();
	if(pNewOsc)
	{
		pNewNote = createNote(pNewOsc, noteTable[noteIndex], NOTE_ATTACK);
		pNewOsc->amplitude = 0;
		pNewOsc->enabled = TRUE;
		pNewOsc->phaseCounter = 0;
		pNewOsc->phaseIncrement = noteTable[noteIndex];
		pNewOsc->frequency =  noteTable[noteIndex];
		pNewOsc->noteNumber = noteIndex;
		if((source & NOTE_SRC_MASK) == NOTE_SRC_LAYER)
			pNewOsc->waveForm = synthLayers[source & NOTE_LAYER_MASK].waveType;
		else
			pNewOsc->waveForm = currentSelectedWaveForm;
		pNewOsc->noteId = NOTE_ID(source, noteIndex);
		pNewNote->noteId = NOTE_ID(source, noteIndex);
		addNoteItem(pNewNote);
		pitchBend(currentPitchBend);
		return pNewNote;
	}
	return NULL;
}
Пример #3
0
bool WizNoteManager::createNote(WIZDOCUMENTDATA& data, const QString& strKbGUID,
                                 const QString& strTitle, const QString& strHtml,
                                 const WIZTAGDATA& tag)
{
    QString location = m_dbMgr.db(strKbGUID).getDefaultNoteLocation();
    return createNote(data, strKbGUID, strTitle, strHtml, location, tag);
}
Пример #4
0
void NoteEditTest::shouldEmitNotEmitNoteWhenTextIsEmpty()
{
    MessageViewer::NoteEdit edit;
    KMime::Message::Ptr msg(new KMime::Message);
    edit.setMessage(msg);
    QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("noteedit"));
    QSignalSpy spy(&edit, SIGNAL(createNote(KMime::Message::Ptr,Akonadi::Collection)));
    QTest::keyClick(noteedit, Qt::Key_Enter);
    QCOMPARE(spy.count(), 0);
}
Пример #5
0
void NoteEditTest::shouldNotEmitNoteWhenMessageIsNull()
{
    MessageViewer::NoteEdit edit;
    QString subject = QStringLiteral("Test Note");
    QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("noteedit"));
    noteedit->setText(subject);
    QSignalSpy spy(&edit, SIGNAL(createNote(KMime::Message::Ptr,Akonadi::Collection)));
    QTest::keyClick(noteedit, Qt::Key_Enter);
    QCOMPARE(spy.count(), 0);
}
Пример #6
0
void NoteEditTest::shouldEmitNoteWhenPressEnter()
{
    MessageViewer::NoteEdit edit;
    KMime::Message::Ptr msg(new KMime::Message);
    QString subject = QStringLiteral("Test Note");
    msg->subject(true)->fromUnicodeString(subject, "us-ascii");
    edit.setMessage(msg);
    QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("noteedit"));
    QSignalSpy spy(&edit, SIGNAL(createNote(KMime::Message::Ptr,Akonadi::Collection)));
    QTest::keyClick(noteedit, Qt::Key_Enter);
    QCOMPARE(spy.count(), 1);
}
Пример #7
0
void NoteList::fitSize(int w, int h)
{
    m_viewPortHeight = h;
    int rh = h;
    if(m_notes.size() == 1) {
        if(m_notes[0] == 0)
            createNote(0);
        m_notes[0]->resize(w,h);
    }
    else
        rh = size().height();
    resize(w, rh);
}
Пример #8
0
bool WizNoteManager::createNote(WIZDOCUMENTDATA& data, const QString& strKbGUID,
                                 const QString& strTitle, const QString& strHtml,
                                 const QString& strLocation, const WIZTAGDATA& tag)
{
    if (!createNote(data, strKbGUID, strTitle, strHtml, strLocation))
        return false;

    if (!tag.strGUID.isEmpty())
    {
        WizDocument doc(m_dbMgr.db(strKbGUID), data);
        doc.addTag(tag);
    }

    return true;
}
Пример #9
0
/** Just a function to test if my lists are working correctly */
void listTest()
{
	NoteKey * n1;
	NoteKey * n2;
	NoteKey * n3;
	NoteKey * n4;

	
	n1 = createNote(&Oscillators[0], 0xFF, NOTE_NONE);
	n2 = createNote(&Oscillators[0], 0x33, NOTE_NONE);
	n3 = createNote(&Oscillators[0], 0x84, NOTE_NONE);
	n4 = createNote(&Oscillators[0], 0xF1, NOTE_NONE);
	
	addNoteItem(n1);
	addNoteItem(n3);
	addNoteItem(n2);
	removeNoteItem(n2);
	addNoteItem(n4);
	removeNoteItem(n1);
	removeNoteItem(n3);
	removeNoteItem(n4);
	return;
	
}
Пример #10
0
void NoteEditTest::shouldEmitCorrectCollection()
{
    MessageViewer::NoteEdit edit;
    Akonadi::CollectionComboBox *akonadicombobox = edit.findChild<Akonadi::CollectionComboBox *>(QStringLiteral("akonadicombobox"));
    KMime::Message::Ptr msg(new KMime::Message);
    QString subject = QStringLiteral("Test Note");
    msg->subject(true)->fromUnicodeString(subject, "us-ascii");
    edit.setMessage(msg);
    akonadicombobox->setCurrentIndex(3);
    Akonadi::Collection col = akonadicombobox->currentCollection();
    QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("noteedit"));
    QSignalSpy spy(&edit, SIGNAL(createNote(KMime::Message::Ptr,Akonadi::Collection)));
    QTest::keyClick(noteedit, Qt::Key_Enter);
    QCOMPARE(spy.count(), 1);
    QCOMPARE(spy.at(0).at(1).value<Akonadi::Collection>(), col);
}
Пример #11
0
bool WizNoteManager::createNoteByTemplate(WIZDOCUMENTDATA& data, const WIZTAGDATA& tag, const QString& strZiw)
{
    //通过模板创建笔记时,如果模板文件不存在则创建一篇空笔记
    if (!QFile::exists(strZiw))
    {
        qDebug() << "Template file not exists : " << strZiw;
        return createNote(data, data.strKbGUID, data.strTitle, "<p><br></p>", data.strLocation, tag);
    }

    if (!m_dbMgr.db(data.strKbGUID).createDocumentByTemplate(strZiw, data.strLocation, tag, data))
    {
        qDebug() << "Failed to new document! " << strZiw;
        return false;
    }
    return true;
}
Пример #12
0
void NoteEditTest::shouldNoteHasCorrectSubject()
{
    MessageViewer::NoteEdit edit;
    KMime::Message::Ptr msg(new KMime::Message);
    QString subject = QStringLiteral("Test Note");
    msg->subject(true)->fromUnicodeString(subject, "us-ascii");
    edit.setMessage(msg);
    QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("noteedit"));
    QSignalSpy spy(&edit, SIGNAL(createNote(KMime::Message::Ptr,Akonadi::Collection)));
    QTest::keyClick(noteedit, Qt::Key_Enter);
    QCOMPARE(spy.count(), 1);
    KMime::Message::Ptr notePtr = spy.at(0).at(0).value<KMime::Message::Ptr>();
    QVERIFY((bool)notePtr);
    Akonadi::NoteUtils::NoteMessageWrapper note(notePtr);
    QCOMPARE(note.title(), subject);
}
Пример #13
0
void NoteList::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.fillRect(event->rect(), QBrush(Qt::white));

    QRect redrawRect = event->rect();
    int top = redrawRect.top();
    int btm = redrawRect.bottom();
    int i, n = m_notes.size();
    int h = 0;
    int beginRow = -1, endRow = -1;
    int beginTop = 0;
    int unitHeight;
    for(i=0;i<n;++i) {
        unitHeight = (m_notes[i] == 0)? UNIT_PADDING : m_notes[i]->height();
        h += unitHeight;
        if(beginRow == -1 && h >= top) {
            beginRow = i;
            beginTop = h-unitHeight;
        }
        if(endRow == -1 && h >= btm) {
            endRow = i+1;
            break;
        }
    }
    if(endRow == -1 || endRow >= n)
        endRow = n-1;
    if(beginRow>=0 && endRow-beginRow+1 > 0) {
        for (i = beginRow; i <= endRow; ++i) {
            if(m_notes[i] == 0)
                createNote(i);
            if(m_notes[i]) {
                m_notes[i]->setGeometry(QRect(16, beginTop, width()-16, m_notes[i]->height()));
                beginTop += m_notes[i]->height();
            }
        }
    }
    event->accept();
}
Пример #14
0
bool WizNoteManager::createNote(WIZDOCUMENTDATA& data)
{
    return createNote(data, "", QObject::tr("Untitled"), "<p><br/></p>", "");
}
Пример #15
0
bool WizNoteManager::createNote(WIZDOCUMENTDATA& data, const QString& strKbGUID)
{
    return createNote(data, strKbGUID, QObject::tr("Untitled"), "<p><br/></p>", "");
}
Пример #16
0
bool WizNoteManager::createNote(WIZDOCUMENTDATA& data, const QString& strKbGUID,
                                 const QString& strLocation, const WIZTAGDATA& tag)
{
    return createNote(data, strKbGUID, QObject::tr("Untitled"), "<p><br/></p>", strLocation, tag);
}
Пример #17
0
bool WizNoteManager::createNote(WIZDOCUMENTDATA& data, const QString& strKbGUID,
                                 const QString& strTitle, const QString& strHtml)
{
    return createNote(data, strKbGUID, strTitle, strHtml, "");
}