Esempio n. 1
0
bool CWizDatabase::CreateDocumentAndInit(const CString& strHtml, \
        const CString& strHtmlUrl, \
        int nFlags, \
        const CString& strTitle, \
        const CString& strName, \
        const CString& strLocation, \
        const CString& strURL, \
        WIZDOCUMENTDATA& data)
{
    bool bRet = false;
    try
    {
        BeginUpdate();

        data.strKbGUID = kbGUID();
        bRet = CreateDocument(strTitle, strName, strLocation, strHtmlUrl, data);
        if (bRet)
        {
            bRet = UpdateDocumentData(data, strHtml, strURL, nFlags);

            Q_EMIT documentCreated(data);
        }
    }
    catch (...)
    {

    }

    EndUpdate();

    return bRet;
}
Esempio n. 2
0
KTextEditor::Document *KateGlobal::createDocument ( QObject *parent )
{
  KateDocument *doc = new KateDocument (false, false, false, 0, parent);

  emit documentCreated (this, doc);

  return doc;
}
Esempio n. 3
0
KateViewManager::KateViewManager(QWidget *parentW, KateMainWindow *parent)
    : QSplitter(parentW)
    , m_mainWindow(parent)
    , m_blockViewCreationAndActivation(false)
    , m_activeViewRunning(false)
    , m_minAge(0)
    , m_guiMergedView(nullptr)
{
    // while init
    m_init = true;

    // important, set them up, as we use them in other methodes
    setupActions();

    // resize mode
    setOpaqueResize(style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, this));

    KateViewSpace *vs = new KateViewSpace(this, 0);
    addWidget(vs);

    vs->setActive(true);
    m_viewSpaceList.append(vs);

    connect(this, SIGNAL(viewChanged(KTextEditor::View*)), this, SLOT(slotViewChanged()));

    connect(KateApp::self()->documentManager(), SIGNAL(documentCreatedViewManager(KTextEditor::Document*)), this, SLOT(documentCreated(KTextEditor::Document*)));

    /**
     * before document is really deleted: cleanup all views!
     */
    connect(KateApp::self()->documentManager(), SIGNAL(documentWillBeDeleted(KTextEditor::Document*))
        , this, SLOT(documentWillBeDeleted(KTextEditor::Document*)));

    /**
     * handle document deletion transactions
     * disable view creation in between
     * afterwards ensure we have views ;)
     */
    connect(KateApp::self()->documentManager(), SIGNAL(aboutToDeleteDocuments(const QList<KTextEditor::Document *> &))
        , this, SLOT(aboutToDeleteDocuments(const QList<KTextEditor::Document *> &)));
    connect(KateApp::self()->documentManager(), SIGNAL(documentsDeleted(const QList<KTextEditor::Document *> &))
        , this, SLOT(documentsDeleted(const QList<KTextEditor::Document *> &)));

    // register all already existing documents
    m_blockViewCreationAndActivation = true;

    const QList<KTextEditor::Document *> &docs = KateApp::self()->documentManager()->documentList();
    foreach(KTextEditor::Document * doc, docs) {
        documentCreated(doc);
    }
Esempio n. 4
0
bool CWizIndexBase::CreateDocumentEx(const WIZDOCUMENTDATA& dataNew)
{
    qDebug() << "create document, title: " << dataNew.strTitle;

    Q_ASSERT(dataNew.strKbGUID == m_strKbGUID);

    WIZDOCUMENTDATA data = dataNew;

    // try to fill the fields not allowed empty
    if (data.strTitle.isEmpty()) {
        TOLOG1("Document Title is empty: %1, Try to rename to the \"New note\"", data.strGUID);
        data.strTitle = "New note";
    }

    if (data.strLocation.isEmpty()) {
        TOLOG1("Document Location is empty: %1, Try to relocation to the /My Notes/", data.strTitle);
        data.strLocation = "/My Notes/";
    }

    CString strFormat = FormatInsertSQLFormat(TABLE_NAME_WIZ_DOCUMENT, FIELD_LIST_WIZ_DOCUMENT, PARAM_LIST_WIZ_DOCUMENT);

    CString strSQL;
    strSQL.Format(strFormat,
        STR2SQL(data.strGUID).utf16(),
        STR2SQL(data.strTitle).utf16(),
        STR2SQL(data.strLocation).utf16(),
        STR2SQL(data.strName).utf16(),
        STR2SQL(data.strSEO).utf16(),
        STR2SQL(data.strURL).utf16(),
        STR2SQL(data.strAuthor).utf16(),
        STR2SQL(data.strKeywords).utf16(),
        STR2SQL(data.strType).utf16(),
        STR2SQL(data.strOwner).utf16(),
        STR2SQL(data.strFileType).utf16(),
        STR2SQL(data.strStyleGUID).utf16(),

        TIME2SQL(data.tCreated).utf16(),
        TIME2SQL(data.tModified).utf16(),
        TIME2SQL(data.tAccessed).utf16(),

        data.nIconIndex,
        data.nSync,
        data.nProtected,
        data.nReadCount,
        data.nAttachmentCount,
        data.nIndexed,

        TIME2SQL(data.tInfoModified).utf16(),
        STR2SQL(data.strInfoMD5).utf16(),
        TIME2SQL(data.tDataModified).utf16(),
        STR2SQL(data.strDataMD5).utf16(),
        TIME2SQL(data.tParamModified).utf16(),
        STR2SQL(data.strParamMD5).utf16(),
        WizInt64ToStr(data.nVersion).utf16()
    );

    if (!ExecSQL(strSQL))
        return false;

    if (!m_bUpdating) {
        emit documentCreated(data);
    }

    return true;
}