Exemplo n.º 1
0
Document::~Document()
{
	m_scene_model->removeAllScenes();

	clearIndex();
	emit removeCacheFile(g_cache_path + m_cache_filename);
}
Exemplo n.º 2
0
void Indexer::buildIndex()
{
	if (path == "") return; // Path must be set
	
	clearIndex();
	
	// Index all files in path
	QDir dir(path);
	QFileInfoList list = dir.entryInfoList();
	emit startedIndexing(list.size());
	for (int i = 0; i < list.size(); i++) {
		QFileInfo fileInfo = list.at(i);
		if (!fileInfo.isFile()) continue;
		if (fileInfo.suffix().toLower() != "jpg") continue;
		
		//qDebug() << "Indexing "<<fileInfo.fileName();
		emit indexingFile(fileInfo.fileName());
		FeatureVector fv;
		fv=getFV(fileInfo.filePath());
		putInIndex(fileInfo.fileName(), fv);
	}
	
	// Initialize whatever datastructures need to be initialized after putting in index
	indexPostInit();
	
	// Serialize index to an index file
	writeIndex();
	pathIndexed = true;
	emit finishedIndexing();
}
Exemplo n.º 3
0
bool Document::saveAs()
{
	// Request new filename
	QString filename = getSaveFileName(tr("Save File As"));
	if (filename.isEmpty()) {
		return false;
	}
	if (m_filename == filename) {
		return save();
	}

	// Save file as new name
	if (QFile::exists(filename) && (DocumentWatcher::instance()->isWatching(filename) || !QFile::remove(filename))) {
		QMessageBox::critical(window(), tr("Sorry"), tr("Unable to overwrite '%1'.").arg(QDir::toNativeSeparators(filename)));
		return false;
	}

	QByteArray encoding;
	std::swap(m_filename, filename);
	std::swap(m_encoding, encoding);
	if (!save()) {
		std::swap(m_filename, filename);
		std::swap(m_encoding, encoding);
		return false;
	}

	clearIndex();
	updateSaveLocation();
	m_text->setReadOnly(false);
	m_text->document()->setModified(false);
	emit changedName();
	return true;
}
Exemplo n.º 4
0
bool Document::saveAs()
{
	QString selected;
	QString filename = QFileDialog::getSaveFileName(window(), tr("Save File As"), m_filename, fileFilter(m_filename), &selected);
	if (!filename.isEmpty()) {
		filename = fileNameWithExtension(filename, selected);
		if (QFile::exists(filename) && !QFile::remove(filename)) {
			QMessageBox::critical(window(), tr("Sorry"), tr("Unable to overwrite '%1'.").arg(filename));
			return false;
		}
		qSwap(m_filename, filename);
		if (!save()) {
			m_filename = filename;
			return false;
		}
		clearIndex();
		updateSaveLocation();
		m_text->setReadOnly(false);
		m_text->document()->setModified(false);
		emit changedName();
		return true;
	} else {
		return false;
	}
}
Exemplo n.º 5
0
Document::~Document()
{
	m_scene_model->removeAllScenes();

	DocumentWatcher::instance()->removeWatch(this);
	clearIndex();
}
Exemplo n.º 6
0
void FileFilterIndex::resetIndex()
{
	clearAllFilters();
	clearIndex(genreIndexAllKeys);
	clearIndex(playersIndexAllKeys);
	clearIndex(pubDevIndexAllKeys);
	clearIndex(ratingsIndexAllKeys);
	clearIndex(favoritesIndexAllKeys);
	clearIndex(hiddenIndexAllKeys);
	clearIndex(kidGameIndexAllKeys);
}
Exemplo n.º 7
0
void CBuffer_Delete(CBuffer* cb)
{
    assert(cb);

    lock(cb, true);

    clearText(cb, false);
    clearWriteBuffer(cb);
    clearIndex(cb);
    clearUsedNodes(cb);

    lock(cb, false);
    Sys_DestroyMutex(cb->mutex);
    cb->mutex = 0;
    free(cb);
}
Exemplo n.º 8
0
void Document::setRichText(bool rich_text)
{
	// Get new file name
	m_old_states[m_text->document()->availableUndoSteps()] = qMakePair(m_filename, m_rich_text);
	if (!m_filename.isEmpty()) {
		QString filename = m_filename;
		int suffix_index = filename.lastIndexOf(QChar('.'));
		int file_index = filename.lastIndexOf(QChar('/'));
		if (suffix_index > file_index) {
			filename.chop(filename.length() - suffix_index);
		}
                filename.append(rich_text ? ".proseup" : ".txt");
		QString selected;
		m_filename = QFileDialog::getSaveFileName(window(), tr("Save File As"), filename, fileFilter(filename), &selected);
		if (!m_filename.isEmpty()) {
			m_filename = fileNameWithExtension(m_filename, selected);
			clearIndex();
		} else {
			findIndex();
		}
	}

	// Set file type
	m_rich_text = rich_text;
	m_text->setAcceptRichText(m_rich_text);

	// Always remove formatting to have something to undo
	QTextCursor cursor(m_text->document());
	cursor.beginEditBlock();
	cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
	cursor.setBlockFormat(QTextBlockFormat());
	cursor.setCharFormat(QTextCharFormat());
        cleanUpDocument();
	cursor.endEditBlock();
	m_old_states[m_text->document()->availableUndoSteps()] = qMakePair(m_filename, m_rich_text);

	// Save file
	if (!m_filename.isEmpty()) {
		save();
		updateState();
		m_text->document()->setModified(false);
	}
	emit changedName();
	emit formattingEnabled(m_rich_text);
}
Exemplo n.º 9
0
// Load existing image index or mark as not indexed
bool Indexer::loadIndex(QString indexFile)
{
	clearIndex();
	pathIndexed = false;

	QFile file(path + QDir::separator() + indexFile);
	if (!file.exists()) return false;
	
	file.open(QIODevice::ReadOnly);
	QDataStream in(&file);
	
	QString indexerId, indexerParams, imageFeaturesId, imageFeaturesParams;
	quint32 magic;
	in >> magic;
	if (magic != MAGIC)
		return false; // Not a ETFImageSearch file
	
	int len = strlen(APP_ID)+1;
	char* applicationId = new char[len];
	in >> applicationId;
	if (strcmp(applicationId, APP_ID) != 0) {
		//qDebug() << "Bad appid: "<<applicationId;
		delete[] applicationId;
		return false; // Not this version of ETFImageSearch
	}
	delete[] applicationId;
	
	// Skip header
	in >> indexerId >> indexerParams >> imageFeaturesId >> imageFeaturesParams;
	
	if (!loadIndexSub(in))
		return false;
	
	file.close();
	
	// Initialize whatever datastructures need to be initialized after putting in index
	indexPostInit();
	
	pathIndexed = true;
	this->indexFile = indexFile;
	return true;
}
Exemplo n.º 10
0
bool side::enter()
{
	if (filesPath.size() < 2 && !(_stricmp(files[indexFile].name, "..")))
		return false;
	else if (!(_stricmp(files[indexFile].name, "..")))  //..
	{
		string tName(filesPath.back());
		filesPath.pop_back();
		makePath();
		if (!fillFiles())
			throw string("Can't read the directory: " + path);
		indexFile = getIndexByNameInCurrent(tName);
		if (indexFile >= side::countFiles)  // не вміщається в першу (значить хз :) десь посерединці поставимо :))
		{
			indexRow = 10;
			upIndexFile = indexFile - 10;
		}
		else // ваміщається в перший комлект
		{
			upIndexFile = 0;
			indexRow = indexFile;
		}
		show();
		writePath();
		return true;
	}
	else if ((_stricmp(files[indexFile].name, "..")) && !(files[indexFile].attrib & _A_SUBDIR))
		return false;
	else   // not .. but folder
	{
		filesPath.emplace_back(files[indexFile].name);
		makePath();
		if (!fillFiles())
			throw string("Can't read the directory: " + path);
		clearIndex();
		show();
		writePath();
		return true;
	}
	
}
Exemplo n.º 11
0
Document::~Document()
{
	clearIndex();
}
Exemplo n.º 12
0
 void clear()
 {
     clearValues();
     clearIndex();;
 }
Exemplo n.º 13
0
Document::~Document()
{
    clearIndex();
    QFile::remove(g_cache_path + m_cache_filename);
}
Exemplo n.º 14
0
void Document::close()
{
	clearIndex();
	deleteLater();
}
Exemplo n.º 15
0
void QSqlExtension::clear()
{
    clearValues();
    clearIndex();
}
Exemplo n.º 16
0
bool KMFolderIndex::readIndex()
{
  qint32 len;
  KMMsgInfo* mi;

  assert(mIndexStream != 0);
  rewind(mIndexStream);

  clearIndex();
  int version;

  setDirty( false );

  if (!readIndexHeader(&version)) return false;

  mUnreadMsgs = 0;
  mTotalMsgs = 0;
  mHeaderOffset = KDE_ftell(mIndexStream);

  clearIndex();
  while (!feof(mIndexStream))
  {
    mi = 0;
    if(version >= 1505) {
      if(!fread(&len, sizeof(len), 1, mIndexStream))
        break;

      if (mIndexSwapByteOrder)
        len = kmail_swap_32(len);

      off_t offs = KDE_ftell(mIndexStream);
      if(KDE_fseek(mIndexStream, len, SEEK_CUR))
        break;
      mi = new KMMsgInfo(folder(), offs, len);
    }
    else
    {
      QByteArray line( MAX_LINE, '\0' );
      fgets(line.data(), MAX_LINE, mIndexStream);
      if (feof(mIndexStream)) break;
      if (*line.data() == '\0') {
        fclose(mIndexStream);
        //kDebug( KMKernel::storageDebug() ) << "fclose(mIndexStream = " << mIndexStream << ")";
        mIndexStream = 0;
        clearIndex();
        return false;
      }
      mi = new KMMsgInfo(folder());
      mi->compat_fromOldIndexString(line, mConvertToUtf8);
    }
    if(!mi)
      break;

    if (mi->status().isDeleted())
    {
      delete mi;  // skip messages that are marked as deleted
      setDirty( true );
      needsCompact = true;  //We have deleted messages - needs to be compacted
      continue;
    }
#ifdef OBSOLETE
    else if (mi->isNew())
    {
      mi->setStatus(KMMsgStatusUnread);
      mi->setDirty(false);
    }
#endif
    if ((mi->status().isNew()) || (mi->status().isUnread()) ||
        (folder() == kmkernel->outboxFolder()))
    {
      ++mUnreadMsgs;
      if (mUnreadMsgs == 0) ++mUnreadMsgs;
    }
    mMsgList.append(mi, false);
  }
  if( version < 1505)
  {
    mConvertToUtf8 = false;
    setDirty( true );
    writeIndex();
  }
  mTotalMsgs = mMsgList.count();
  return true;
}
Exemplo n.º 17
0
PLUGIN_EXPORT void ExecuteBang(void* data, LPCWSTR args)
{
	ChildMeasure* child = (ChildMeasure*)data;
	ParentMeasure* parent = child->parent;

	// !CommandMeasure can only be used on the Parent measure.
	if (!parent || parent->ownerChild != child)
		return;

	// !CommandMeasure Clear
	if (_wcsicmp(args, L"Clear") == 0)
	{
		std::wstring currentData = parent->clipboard->GetIndex(0);

		// Clear contents of the Clipboard
		if (!parent->clipboard->DeleteClipboard())
		{
			RmLog(LOG_ERROR, L"Clipboard.dll: Unable to delete clipboard");
		}
		else
		{
			if (!currentData.empty())
			{
				// Clear index 0 of ALL instances (if equal to current index 0)
				clearIndex(currentData);
			}
		}

		return;
	}
	else
	{
		// Check for commands with args.
		LPCWSTR arg = wcschr(args, L' ');
		if (arg)
		{
			// Skip the space
			++arg;

			// !CommandMeasure ClearIndex n (where n represents an index)
			if (_wcsnicmp(args, L"ClearIndex", 10) == 0)
			{
				int index = _wtoi(arg);
				std::wstring currentData = parent->clipboard->GetIndex(index);

				if (!currentData.empty())
				{
					// Index 0 represents the Windows Clipboard. If deleting this index, other parent measure need to be modified.
					if (index == 0)
					{
						parent->clipboard->ClearClipboard();
						clearIndex(currentData);
					}
					else
					{
						if (!parent->clipboard->DeleteIndex(index))
						{
							std::wstring error = L"Clipboard.dll: Unable to delete index \"";
							error += index;
							error += L'"';
							RmLog(LOG_ERROR, error.c_str());
						}
					}
				}

				return;
			}
			// !CommandMeasure "CopyIndex n" (where n represents an index)
			else if (_wcsnicmp(args, L"CopyIndex", 9) == 0)
			{
				LPCWSTR text = parent->clipboard->GetIndex(_wtoi(arg));

				if (!parent->clipboard->SetClipboard(text))
				{
					RmLog(LOG_ERROR, L"Clipboard.dll: Unable to set clipboard");
				}

				return;
			}
			else
			{
				RmLog(LOG_ERROR, L"Clipboard.dll: Unknown args");
			}
		}
	}

	return;
}
Exemplo n.º 18
0
Document::~Document()
{
    clearIndex();
    emit removeCacheFile(g_cache_path + m_cache_filename);
}