예제 #1
0
bool addNewFile(string fileName, string address, string owner) {
	if (isSaved(fileName)) throw accessError(SAVED);
	if (!isExisting(address)) throw accessError(NO_FILE);

	string fileDirectory = getFilePath(fileName);
	ifstream fileToCopy(address);

	char c;
	if (mkdir(fileDirectory.c_str())) throw accessError(ERR_CR_DIR);						//error creating directory
	ofstream fileToCreate(fileDirectory + '\\' + fileName);
	while (true) {
		c = fileToCopy.get();
		if (!fileToCopy.eof())
			fileToCreate.put(c);
		else break;
	}

	fileToCopy.close();
	fileToCreate.close();

	createPermFile(fileName, owner);
	createDiffFile(fileName);

	return true;
}
예제 #2
0
void MainWindow::on_actionExit_triggered()
{
    if (!isSaved()) {
        SaveChangesDialog *scd = new SaveChangesDialog(this);
        scd->exec();
        if (tmpProjectName=="") return;
    }
    close();
}
예제 #3
0
void MainWindow::closeEvent(QCloseEvent *event)
{
    emit mainWindowClosed();
    if (!isSaved()) {
        SaveChangesDialog *scd = new SaveChangesDialog(this);
        scd->exec();
        if (tmpProjectName=="") return;
    }
    event->accept();
}
예제 #4
0
void MainWindow::on_centralWidget_destroyed()
{
    if (!isSaved()) {
        SaveChangesDialog *scd = new SaveChangesDialog(this);
        scd->exec();
        if (tmpProjectName=="") return;
    }
    close();

}
예제 #5
0
    /**
     * @brief Project::setSaveStatus
     * @param newStatus
     */
    void Project::setSaveStatus(bool newStatus)
    {
        if (newStatus != m_SaveStatus) {
            m_SaveStatus = newStatus;

            if (isSaved())
                emit saved();
            else
                emit modified();
        }
    }
예제 #6
0
void MainWindow::on_actionClose_project_triggered()
{
    if (!isSaved()) {
        SaveChangesDialog *scd = new SaveChangesDialog(this);
        scd->exec();
        if (tmpProjectName=="") return;
    }
    iconDiagram()->clear();
    projectName="";
    setWindowTitle("Untitled - XRayStudio");
}
예제 #7
0
void MainWindow::on_actionNew_project_triggered()
{
    if (!isSaved()) {
        SaveChangesDialog *scd = new SaveChangesDialog(this);
        scd->exec();
        if (tmpProjectName=="") return;
    }
    ProjectDialog *proj_dialog = new ProjectDialog(this, baseProjectFolder, true);
    proj_dialog->exec();
    if (projectName!="") setWindowTitle(projectName + " - XRayStudio");
    else setWindowTitle("Untitled - XRayStudio");
    //projectDialog->show();
}
예제 #8
0
bool deleteFileWithPermissions(string fileName, string nickname) {
	if (!isSaved(fileName)) throw accessError(NOT_SAVED);
	if (!isOwner(fileName, nickname)) throw accessError(NOT_OWNER);

	string fileDirectory = getFilePath(fileName);
	remove((fileDirectory + '\\' + fileName).c_str());
	string permFileName = fileDirectory + '\\' + fileName + "-perm.dat";
	remove(permFileName.c_str());
	string diffFileName = fileDirectory + '\\' + fileName + "-diff.dat";
	remove(diffFileName.c_str());
	_rmdir(fileDirectory.c_str());
	return true;
}
예제 #9
0
bool addExistingFile(string fileName, string address, string owner) {
	string fileDirectory = getFilePath(fileName);

	if (!isSaved(fileName)) throw accessError(NOT_SAVED);
	if (!isExisting(address)) throw accessError(NO_FILE);
	if (!isAccessable(fileName, owner)) throw accessError(NOT_USER);

	diffTree tree(fileName);

	diffNode* start = tree.getTreePathByID(tree.currentVersion);
	diffNode* finish = tree.getTreePath();

	modernizeFile(fileName, tree.getVersionsPath(start, finish));

	vector<diffString> exf;
	vector<diffString> newf;
	ifstream existingFile(fileDirectory + '\\' + fileName);
	ifstream newFile(address);
	while (!existingFile.eof()) {
		diffString buf;
		buf.text = new char[MAX];
		existingFile.getline(buf.text, MAX);
		buf.length = strlen(buf.text);
		exf.push_back(buf);
	}
	while (!newFile.eof()) {
		diffString buf;
		buf.text = new char[MAX];
		newFile.getline(buf.text, MAX);
		buf.length = strlen(buf.text);
		newf.push_back(buf);
	}
	vector<diffString> difference = diff(exf, newf);
	showChangesVector(difference);
	diffNode* child = new diffNode;
	child->diffLine = difference;
	tree.addNode(finish, child);

	ofstream diffFile(fileDirectory + '\\' + fileName + "-diff.dat");
	diffFile.close();

	tree.printDiffTreeFile(fileName);

	deleteFile(fileName);
	addFile(fileName, address);

	return true;
}
예제 #10
0
void MainWindow::on_actionLoad_project_triggered()
{
    if (!isSaved()) {
        SaveChangesDialog *scd = new SaveChangesDialog(this);
        scd->exec();
        if (tmpProjectName=="") return;
    }
    tmpProjectFolder = projectFolder;
    tmpProjectName = projectName;
    LoadProject(baseProjectFolder);
    projectFolder = tmpProjectFolder;
    projectName = tmpProjectName;
    if (projectName!="") setWindowTitle(projectName + " - XRayStudio");
    else setWindowTitle("Untitled - XRayStudio");

}
예제 #11
0
파일: VarUnit.cpp 프로젝트: SlySven/Mudlet
void VarUnit::buildVarTree(QTreeWidgetItem* p, TVar* var, bool showHidden)
{
    QList<QTreeWidgetItem*> cList;
    QListIterator<TVar*> it(var->getChildren(true));
    while (it.hasNext()) {
        TVar* child = it.next();
        if (showHidden || !isHidden(child)) {
            QStringList s1;
            s1 << child->getName();
            auto pItem = new QTreeWidgetItem(s1);
            pItem->setText(0, child->getName());
            pItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsTristate | Qt::ItemIsUserCheckable);
            pItem->setToolTip(0, "Checked variables will be saved and loaded with your profile.");
            pItem->setCheckState(0, Qt::Unchecked);
            if (isSaved(child)) {
                pItem->setCheckState(0, Qt::Checked);
            }
            if (!shouldSave(child)) { // 6 is lua_tfunction, parent must be saveable as well if not global
                pItem->setFlags(pItem->flags() & ~(Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable));
                pItem->setForeground(0, QBrush(QColor("grey")));
                pItem->setToolTip(0, "");
            }
            pItem->setData(0, Qt::UserRole, child->getValueType());
            QIcon icon;
            switch (child->getValueType()) {
            case 5:
                icon.addPixmap(QPixmap(QStringLiteral(":/icons/table.png")), QIcon::Normal, QIcon::Off);
                break;
            case 6:
                icon.addPixmap(QPixmap(QStringLiteral(":/icons/function.png")), QIcon::Normal, QIcon::Off);
                break;
            default:
                icon.addPixmap(QPixmap(QStringLiteral(":/icons/variable.png")), QIcon::Normal, QIcon::Off);
                break;
            }
            pItem->setIcon(0, icon);
            wVars.insert(pItem, child);
            cList.append(pItem);
            if (child->getValueType() == 5) {
                buildVarTree((QTreeWidgetItem*)pItem, child, showHidden);
            }
        }
    }
    p->addChildren(cList);
}
예제 #12
0
int Mgr::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: cellChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: readFinish((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 2: onCid((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: timecall(); break;
        case 4: debugfn(); break;
        case 5: savescode((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 6: saveLoc((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break;
        case 7: { bool _r = isSaved((*reinterpret_cast< QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 8: overWrite((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break;
        case 9: quit(); break;
        default: ;
        }
        _id -= 10;
    }
    return _id;
}
예제 #13
0
bool QOrmObject::needPrimaryKey()
{
    return (primaryKey().isNull() || primaryKey() == 0) && !isSaved();
}
예제 #14
0
void HGTController::fillDownloadList(bool &usingDiffs)
{
	usingDiffs = false;
	safe_delete(m_vSuperBlockList);
	MCFCore::MCF *webMcf = new MCFCore::MCF();

	try
	{
		webMcf->dlHeaderFromHttp(m_szUrl.c_str());
	}
	catch (gcException &e)
	{
		onErrorEvent(e);
		safe_delete(webMcf);
		return;
	}

	webMcf->sortFileList();

	uint64 mcfOffset = m_pHeader->getSize();
	size_t fsSize = m_rvFileList.size();

	//find the last files offset
	for (size_t x=0; x< fsSize; x++)
	{
		if (!m_rvFileList[x]->isSaved())
			continue;

		if ((m_rvFileList[x]->isComplete() || m_rvFileList[x]->hasStartedDL()) && m_rvFileList[x]->getOffSet() > mcfOffset)
		{
			mcfOffset = m_rvFileList[x]->getOffSet() + m_rvFileList[x]->getCurSize();
		}
	}

	std::deque<Misc::WGTBlock*> vBlockList;
	std::sort(m_rvFileList.begin(), m_rvFileList.end(), SortByOffset);

	for (size_t x=0; x<fsSize; x++)
	{
		//dont download all ready downloaded items
		if (m_rvFileList[x]->isComplete())
			continue;

		//skip files that arnt "saved" in the MCF
		if (!m_rvFileList[x]->isSaved())
			continue;	

		uint32 index = webMcf->findFileIndexByHash(m_rvFileList[x]->getHash());
		auto webFile = webMcf->getFile(index);

		uint64 size = m_rvFileList[x]->getCurSize();
		bool started = m_rvFileList[x]->hasStartedDL();

		if (index == UNKNOWN_ITEM || !webFile || !webFile->isSaved())
		{
			Warning(gcString("File {0} is not in web MCF. Skipping download.\n", m_rvFileList[x]->getName()));

			if (!started)
				m_rvFileList[x]->delFlag(MCFCore::MCFFileI::FLAG_SAVE);

			continue;
		}	


		if (!started)
			m_rvFileList[x]->setOffSet(mcfOffset);


		Misc::WGTBlock* temp = new Misc::WGTBlock;

		temp->fileOffset = m_rvFileList[x]->getOffSet();
		temp->file = m_rvFileList[x];

		if (webFile->hasDiff() && HasAllFlags(m_rvFileList[x]->getFlags(), MCFFileI::FLAG_CANUSEDIFF))
		{
			temp->webOffset = webFile->getDiffOffSet();
			temp->size = webFile->getDiffSize();

			if (!started)
				mcfOffset += webFile->getSize();

			usingDiffs = true;
		}
		else
		{
			m_rvFileList[x]->delFlag(MCFFileI::FLAG_CANUSEDIFF);
			temp->webOffset = webFile->getOffSet();
			temp->size = size;

			if (!started)
				mcfOffset += size;
		}

		vBlockList.push_back(temp);
		m_uiTotal += temp->size;
	}


	std::sort(vBlockList.begin(), vBlockList.end(), &WGTBlockSort);

	while (vBlockList.size() > 0)
	{
		Misc::WGTSuperBlock* sb = new Misc::WGTSuperBlock();
		sb->offset = vBlockList[0]->webOffset;

		do
		{
			Misc::WGTBlock* block = vBlockList.front();
			vBlockList.pop_front();

			sb->size += block->size;
			sb->vBlockList.push_back(block);
		}
		while (vBlockList.size() > 0 && vBlockList[0]->webOffset == (sb->offset + sb->size));

		m_vSuperBlockList.push_back(sb);
	}
}