Ejemplo n.º 1
0
void UBExportDocument::persistsDocument(UBDocumentProxy* pDocumentProxy, QString filename)
{
    UniboardSankoreTransition document;
    QString documentPath(pDocumentProxy->persistencePath());
    document.checkDocumentDirectory(documentPath);

    QuaZip zip(filename);
    zip.setFileNameCodec("UTF-8");
    if(!zip.open(QuaZip::mdCreate))
    {
        qWarning("Export failed. Cause: zip.open(): %d", zip.getZipError());
        return;
    }

    QDir documentDir = QDir(pDocumentProxy->persistencePath());

    QuaZipFile outFile(&zip);
    UBFileSystemUtils::compressDirInZip(documentDir, "", &outFile, true, this);

    if(zip.getZipError() != 0)
    {
        qWarning("Export failed. Cause: zip.close(): %d", zip.getZipError());
    }

    zip.close();

    UBPlatformUtils::setFileType(filename, 0x5542647A /* UBdz */);

}
Ejemplo n.º 2
0
CString AppSetting::relativePath( CString name )
{
	CHAR my_documents[MAX_PATH];
	HRESULT result = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents);
	CString documentPath(my_documents);
	documentPath.AppendFormat("\\%s\\%s.txt", SETTING_NAME, name.GetBuffer());
	return documentPath;
}
Ejemplo n.º 3
0
void UBWebPublisher::persist(UBDocumentProxy* pDocumentProxy)
{
    if (!pDocumentProxy)
        return;

    UniboardSankoreTransition document;
    QString documentPath(pDocumentProxy->persistencePath());
    document.checkDocumentDirectory(documentPath);

    UBDocumentPublisher* publisher = new UBDocumentPublisher(pDocumentProxy, this); // the publisher will self delete when publication finishes
    publisher->publish();

}
Ejemplo n.º 4
0
void AppSetting:: loadApplicationSetting()
{
	CWinApp* pApp = AfxGetApp();

	showNavigation = pApp->GetProfileInt(REGKEY_APP_NAME, REGKEY_SHOW_NAVIGATION, 1) != 0;//0 -> false; 1 -> true

	bShowHelpText = pApp->GetProfileInt(REGKEY_APP_NAME, REGKEY_DISPLAY_TEXT, 1) != 0;
	bShowAxis = pApp->GetProfileInt(REGKEY_APP_NAME, REGKEY_DISPLAY_AXIS, 1) != 0;
	objPath = pApp->GetProfileString(REGKEY_APP_NAME, REGKEY_OBJECT_PATH);
	simulationDataPath = pApp->GetProfileString(REGKEY_APP_NAME, REGKEY_SIM_DATA_PATH);

	CHAR my_documents[MAX_PATH];
	HRESULT result = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents);
	CString documentPath(my_documents);
	documentPath.AppendFormat("\\%s", SETTING_NAME);
	if (GetFileAttributes(documentPath) == INVALID_FILE_ATTRIBUTES)
	{
		CreateDirectory(documentPath,NULL);
	}
}
bool UBExportDocumentSetAdaptor::addDocumentToZip(const QModelIndex &pIndex, UBDocumentTreeModel *model, QuaZip &zip)
{
    static int i = 0;
    i++;

    QModelIndex parentIndex = pIndex;
    if (!parentIndex.isValid()) {
        return false;
    }

    UBDocumentProxy *pDocumentProxy = model->proxyForIndex(parentIndex);
    if (pDocumentProxy) {

//        Q_ASSERT(QFileInfo(pDocumentProxy->persistencePath()).exists());
//        UBForeighnObjectsHandler cleaner;
//        cleaner.cure(pDocumentProxy->persistencePath());

        UniboardSankoreTransition document;
        QString documentPath(pDocumentProxy->persistencePath());
        document.checkDocumentDirectory(documentPath);

        QDir documentDir = QDir(pDocumentProxy->persistencePath());
        QuaZipFile zipFile(&zip);
        UBFileSystemUtils::compressDirInZip(documentDir, QFileInfo(documentPath).fileName() + "/", &zipFile, false);

        if(zip.getZipError() != 0)
        {
            qWarning("Export failed. Cause: zip.close(): %d", zip.getZipError());
        }
    }

    for (int i = 0; i < model->rowCount(parentIndex); ++i) {
        QModelIndex curIndex = model->index(i, 0, parentIndex);
        if (!addDocumentToZip(curIndex, model, zip)) {
            return false;
        }
    }

    return true;
}
Ejemplo n.º 6
0
const QString& EditorTabWidget::currentDocumentPath() {
  return documentPath(currentPageIndex());
}