예제 #1
0
void Resource::readView(Common::File *file, ViewDataList &list) {
	list.clear();
	while (file->readByte() == 1) {
		list.push_back(ViewData());
		ViewData &view = list.back();

		view._condition = readConditions(file);
		view._graphicName = readString(file);
		readCloseUps(0, file, view._closeUps);
	}
}
예제 #2
0
파일: viewdata.cpp 프로젝트: OpenMW/openmw
ViewData *ViewDataMap::createOrReuseView()
{
    if (mUnusedViews.size())
    {
        ViewData* vd = mUnusedViews.front();
        mUnusedViews.pop_front();
        return vd;
    }
    else
    {
        mViewVector.push_back(ViewData());
        return &mViewVector.back();
    }
}
예제 #3
0
파일: main.cpp 프로젝트: PaulJing/Sora
void ProcessChannel(ChannelSearchInfo * info)
{
	switch (info->type)
	{
	case CH_LINE_TYPE:
		ViewLine(info->hChannel);
		break;
	case CH_SPECTRUM_TYPE:
		ViewSpectrum(info->hChannel);
		break;
	case CH_DOTS_TYPE:
		ViewDots(info->hChannel);
		break;
	case CH_TEXT_TYPE:
		ViewText(info->hChannel);
		break;
	default:
		ViewData(info->hChannel);
	}	
}
예제 #4
0
파일: sessions.cpp 프로젝트: guek/notepadqq
bool saveSession(DocEngine* docEngine, TopEditorContainer* editorContainer, QString sessionPath, QString cacheDirPath)
{
    const bool cacheModifiedFiles = !cacheDirPath.isEmpty();

    QDir cacheDir;

    // Clear the cache directory by deleting and recreating it.
    if (cacheModifiedFiles) {
        cacheDir = QDir(cacheDirPath);

        bool success = false;

        if (cacheDir.exists())
            success = cacheDir.removeRecursively();

        success |= cacheDir.mkpath(cacheDirPath);

        if(!success)
            return false;
    }

    std::vector<ViewData> viewData;

    //Loop through all tabwidgets and their tabs
    const int tabWidgetsCount = editorContainer->count();
    for (int i = 0; i < tabWidgetsCount; i++) {
        EditorTabWidget *tabWidget = editorContainer->tabWidget(i);
        const int tabCount = tabWidget->count();

        viewData.push_back( ViewData() );
        ViewData& currentViewData = viewData.back();

        for (int j = 0; j < tabCount; j++) {
            Editor* editor = tabWidget->editor(j);
            bool isClean = editor->isClean();
            bool isOrphan = editor->fileName().isEmpty();

            if (isOrphan && !cacheModifiedFiles)
                continue; // Don't save temporary files if we're not caching tabs

            TabData td;

            if (!isClean && cacheModifiedFiles) {
                // Tab is dirty, meaning it needs to be cached.
                QUrl cacheFilePath = PersistentCache::createValidCacheName(cacheDir, tabWidget->tabText(j));

                td.cacheFilePath = cacheFilePath.toLocalFile();

                if (docEngine->saveDocument(tabWidget, j, cacheFilePath, true) != DocEngine::saveFileResult_Saved) {
                    return false;
                }
            } else if (isOrphan) {
                // Since we didn't cache the file and it is an orphan, we won't save it in the session.
                continue;
            }
            // Else tab is an openened unmodified file, we don't have to do anything special.

            td.filePath = !isOrphan ? editor->fileName().toLocalFile() : "";

            // Finally save other misc information about the tab.
            const auto& scrollPos = editor->scrollPosition();
            td.scrollX = scrollPos.first;
            td.scrollY = scrollPos.second;
            td.active = tabWidget->currentEditor() == editor;
            td.language = editor->language();

            // If we're caching and there's a file opened in the tab we want to inform the
            // user whether the file's contents have changed since Nqq was last opened.
            // For this we save and later compare the modification date.
            if (!isOrphan && cacheModifiedFiles) {
                // As a special case, if the file has *already* changed we set the modification
                // time to 1 so we always trigger the warning.
                if (editor->fileOnDiskChanged())
                    td.lastModified = 1;
                else
                    td.lastModified = QFileInfo(td.filePath).lastModified().toMSecsSinceEpoch();
            }

            currentViewData.tabs.push_back( td );

        } // end for
    } // end for

    // Write all information to a session file
    QFile file(sessionPath);
    file.open(QIODevice::WriteOnly);

    if (!file.isOpen())
        return false;

    SessionWriter sessionWriter(file);

    for (const auto& view : viewData)
        sessionWriter.addViewData(view);

    return true;
}