Beispiel #1
0
CString CWizIndexBase::FormatModifiedQuerySQL(const CString& strTableName,
                                              const CString& strFieldList)
{
    return WizFormatString2(_T("select %1 from %2 where WIZ_VERSION = -1"),
                            strFieldList,
                            strTableName);
}
Beispiel #2
0
CString CWizIndexBase::FormatDeleteSQLFormat(const CString& strTableName,
                                             const CString& strKey)
{
    return WizFormatString2(_T("delete from %1 where %2=%s"),
                            strTableName,
                            strKey);
}
Beispiel #3
0
CString CWizIndexBase::FormatQuerySQL(const CString& strTableName,
                                      const CString& strFieldList)
{
    return WizFormatString2(_T("select %1 from %2"),
                            strFieldList,
                            strTableName);
}
void CWizNoteInfoForm::setDocument(const WIZDOCUMENTDATA& data)
{
    Q_ASSERT(!data.strKbGUID.isEmpty());
    m_docKbGuid = data.strKbGUID;
    m_docGuid = data.strGUID;

    CWizDatabase& db = CWizDatabaseManager::instance()->db(data.strKbGUID);
    QString doc = db.GetDocumentFileName(data.strGUID);
    QString sz = ::WizGetFileSizeHumanReadalbe(doc);

    ui->editTitle->setText(data.strTitle);

    // private document
    if (data.strKbGUID == CWizDatabaseManager::instance()->db().kbGUID()) {
        ui->labelNotebook->setText(data.strLocation);

        QString tags = db.GetDocumentTagsText(data.strGUID);
        ui->labelTags->setText(tags);

        ui->editAuthor->setText(data.strAuthor);

    // group document
    } else {
        CWizTagDataArray arrayTag;
        if (!db.GetDocumentTags(data.strGUID, arrayTag)) {
            ui->labelNotebook->clear();
        } else {
            if (arrayTag.size() > 1) {
                TOLOG1("Group document should only have one tag: %1", data.strTitle);
            }

            QString tagText;
            if (arrayTag.size()) {
                tagText = db.getTagTreeText(arrayTag[0].strGUID);
            }

            ui->labelNotebook->setText("/" + db.name() + tagText + "/");
        }

        ui->labelTags->clear();
        ui->editAuthor->setText(data.strAuthor);
    }

    // common fields
    ui->editCreateTime->setText(data.tCreated.toString());
    ui->editUpdateTime->setText(data.tModified.toString());
    ui->editURL->setText(data.strURL);
    ui->labelOpenURL->setText(WizFormatString2("<a href=\"%1\">%2</a>", data.strURL, tr("Open")));
    ui->labelSize->setText(sz);
    ui->checkEncrypted->setChecked(data.nProtected ? true : false);

    bool canEdit = (db.CanEditDocument(data) && !CWizDatabase::IsInDeletedItems(data.strLocation));
    ui->editAuthor->setReadOnly(!canEdit);
    ui->editTitle->setReadOnly(!canEdit);
    ui->editURL->setReadOnly(!canEdit);
    ui->checkEncrypted->setEnabled(canEdit && !db.IsGroup());
}
Beispiel #5
0
void CWizKbSync::startDownloadObjectsData()
{
    m_db->GetAllObjectsNeedToBeDownloaded(m_arrayAllObjectsNeedToBeDownloaded);

    int nTotal = m_arrayAllObjectsNeedToBeDownloaded.size();

    if (m_nDaysDownload == -1) {
        m_arrayAllObjectsNeedToBeDownloaded.clear();
    } else {
        COleDateTime tNow = ::WizGetCurrentTime();
        size_t count = m_arrayAllObjectsNeedToBeDownloaded.size();
        for (intptr_t i = count - 1; i >= 0; i--)
        {
            COleDateTime t = m_arrayAllObjectsNeedToBeDownloaded[i].tTime;
            t = t.addDays(m_nDaysDownload);
            if (t < tNow) {
                m_arrayAllObjectsNeedToBeDownloaded.erase(m_arrayAllObjectsNeedToBeDownloaded.begin() + i);
                continue;
            }

            if (m_arrayAllObjectsNeedToBeDownloaded[i].eObjectType == wizobjectDocumentAttachment) {
                m_arrayAllObjectsNeedToBeDownloaded.erase(m_arrayAllObjectsNeedToBeDownloaded.begin() + i);
                continue;
            }
        }
    }

    int nTotalDownload = m_arrayAllObjectsNeedToBeDownloaded.size();
    if (nTotal) {
        Q_EMIT processLog(WizFormatString2(tr("downloading objects data, total %1 objects need download, actually download: %2"),
                                           QString::number(nTotal),
                                           QString::number(nTotalDownload)));
    }

    Q_EMIT progressChanged(progressAttachmentUploaded);
    downloadNextObjectData();
}
QString formatLabelLink(const QString& linkHref, const QString& text)
{
    return WizFormatString2("<a href=\"%1\" style=\"color:#5990EF;"
                    "text-decoration:none;\">%2</a>", linkHref, text);
}
Beispiel #7
0
QString WizXmlRpcFaultValue::toString() const
{
    return WizFormatString2("Fault error: %1, %2", WizIntToStr(getFaultCode()), getFaultString());
}
Beispiel #8
0
	virtual CString ToString() const { return WizFormatString2(_T("Fault error: %1, %2"), WizIntToStr(GetFaultCode()), GetFaultString()); }
QString CWizXmlRpcFaultValue::ToString() const
{
    return WizFormatString2(_T("Fault error: %1, %2"), WizIntToStr(GetFaultCode()), GetFaultString());
}
bool WizKMCombineDocumentsToHtmlFile(WizDatabaseManager& dbMgr, const CWizDocumentDataArray& arrayDocument, QString splitter, bool addTitle, QString& strResultFileName, CWizDocumentAttachmentDataArray& arrayAttachment, QString& strError)
{
    QString strTempPath = Utils::WizPathResolve::tempPath() + WizGenGUIDLowerCaseLetterOnly() + "/";
    ::WizEnsurePathExists(strTempPath);
    //
    CWizStdStringArray htmls;
    //
    size_t nCount = arrayDocument.size();
    for (size_t i = 0; i < nCount; i++)
    {
        WIZDOCUMENTDATA doc = arrayDocument[i];
        //
        WizDatabase& db = dbMgr.db(doc.strKbGUID);
        if (!db.isDocumentDownloaded(doc.strGUID))
        {
            strError = QObject::tr("Note has not been downloaded");
            return false;
        }
        //
        if (!db.documentToHtmlFile(doc, strTempPath))
        {
            strError = QObject::tr("Failed to get note data");
            return false;
        }
        //
        QString htmlFileName = strTempPath + "index.html";
        if (!QFileInfo::exists(htmlFileName))
        {
            strError = QObject::tr("Failed to get note data");
            return false;
        }
        //
        QString html;
        if (!WizLoadUnicodeTextFromFile(htmlFileName, html))
        {
            strError = QObject::tr("Failed to read note data");
            return false;
        }
        //
        htmls.push_back(html);
        //
        CWizDocumentAttachmentDataArray atts;
        db.getDocumentAttachments(doc.strGUID, atts);
        for (WIZDOCUMENTATTACHMENTDATA att : atts)
        {
            if (!db.isAttachmentDownloaded(att.strGUID))
            {
                strError = QObject::tr("Note attachment %1 has not been downloaded").arg(att.strName);
                return false;
            }
            //
            arrayAttachment.push_back(att);
        }
    }
    //
    CString strAllHTML;
    //
    for (size_t i = 0; i < nCount; i++)
    {
        CString html = htmls[i];
        WIZDOCUMENTDATA doc = arrayDocument[i];
        if (-1 != WizStrStrI_Pos(html, CString(_T("<frameset"))))
        {
            strError = QObject::tr("Cannot combine html because html contains frame set");
            return false;
        }
        //
        CString strTitle = doc.strTitle;
        WizOleDateTime t = doc.tCreated;
        CString strDate = t.toLocalLongDate();
        //
        if (addTitle)
        {
            CString strInfoHtml = WizFormatString2(_T("<h2>%1 (%2)</h2>"), strTitle, strDate);
            ::WizHTMLInsertTextBeforeBody(strInfoHtml, html);
        }
        //
        if (!WizCombineHtmlText(strAllHTML, html))
        {
            strError = QObject::tr("Cannot combine html");
            return false;
        }
        //
        if (i < nCount - 1)
        {
            if (!splitter.isEmpty())
            {
                WizCombineHtmlText(strAllHTML, splitter);
            }
        }
    }
    //
    strResultFileName = strTempPath + "index.html";
    //
    bool ret = ::WizSaveUnicodeTextToUtf8File(strResultFileName, strAllHTML);
    if (!ret)
    {
        strError = QObject::tr("Cannot save note html");
        return false;
    }
    return true;
}