Пример #1
0
void XbelReader::readFolder(BookmarkNode *parent)
{
    Q_ASSERT(isStartElement() && name() == QLatin1String("folder"));

    BookmarkNode *folder = new BookmarkNode(BookmarkNode::Folder, parent);
    folder->expanded = (attributes().value(QLatin1String("folded")) == QLatin1String("no"));

    while (!atEnd()) {
        readNext();

        if (isEndElement())
            break;

        if (isStartElement()) {
            if (name() == QLatin1String("title"))
                readTitle(folder);
            else if (name() == QLatin1String("desc"))
                readDescription(folder);
            else if (name() == QLatin1String("folder"))
                readFolder(folder);
            else if (name() == QLatin1String("bookmark"))
                readBookmarkNode(folder);
            else if (name() == QLatin1String("separator"))
                readSeparator(folder);
            else
                skipUnknownElement();
        }
    }
}
Пример #2
0
void XbelReader::readFolder(QTreeWidgetItem *item)
{
    Q_ASSERT(isStartElement() && name() == "folder");

    QTreeWidgetItem *folder = createChildItem(item);
    bool folded = (attributes().value("folded") != "no");
    treeWidget->setItemExpanded(folder, !folded);

    while (!atEnd()) {
        readNext();

        if (isEndElement())
            break;

        if (isStartElement()) {
            if (name() == "title")
                readTitle(folder);
            else if (name() == "folder")
                readFolder(folder);
            else if (name() == "bookmark")
                readBookmark(folder);
            else if (name() == "separator")
                readSeparator(folder);
            else
                readUnknownElement();
        }
    }
}
Пример #3
0
void DirAnalyzer::getFiles(path folder_path, vector<File> & files)
{
	vector<path> files_to_read = readFolder(folder_path);	

	for (vector<path> ::const_iterator it (files_to_read.begin()); it != files_to_read.end(); ++it)
	{	
		path p=*it;
		try
		{
			if (is_regular_file(p))        // is p a regular file?   
			{
				File new_file(p);
				/*File new_file;
				new_file.setName(p.filename());
				new_file.setPath(p.string());
				new_file.setSize(file_size(p));*/
				files.push_back(new_file);
			}

			else if (is_directory(p))      // is p a directory?
			{
			getFiles(p, files);
			}	
		}
	
		catch (const filesystem_error& ex)
		{
			cout << ex.what() << '\n';
			exit(1);
		}
	}
}
Пример #4
0
Folder::Ptr Folder::addFolder(std::fstream &file, BSAULong fileNamesLength, BSAULong &endPos)
{
  Folder::Ptr temp = readFolder(file, fileNamesLength, endPos);
  addFolderInt(temp);

  return temp;
}
Пример #5
0
// Set show hidden status.
void FolderModel::setShowHidden(const bool showHidden)
{
    if(m_showHidden == showHidden)
        return;

    m_showHidden = showHidden;
    readFolder();
    emit showHiddenChanged(m_showHidden);
}
Пример #6
0
// Set folder.
void FolderModel::setFolder(const QString folder)
{
    if(folder.isEmpty() || m_folder == folder)
        return;

    // Read folder.
    m_folder = folder;
    readFolder();

    emit folderChanged(m_folder);
}
Пример #7
0
//! [3]
void XbelReader::readXBEL()
{
    Q_ASSERT(xml.isStartElement() && xml.name() == "xbel");

    while (xml.readNextStartElement()) {
        if (xml.name() == "folder")
            readFolder(0);
        else if (xml.name() == "bookmark")
            readBookmark(0);
        else if (xml.name() == "separator")
            readSeparator(0);
        else
            xml.skipCurrentElement();
    }
}
Пример #8
0
void XbelReader::readXBEL(BookmarkNode *parent)
{
    Q_ASSERT(isStartElement() && name() == QLatin1String("xbel"));

    while (readNextStartElement()) {
        if (name() == QLatin1String("folder"))
            readFolder(parent);
        else if (name() == QLatin1String("bookmark"))
            readBookmarkNode(parent);
        else if (name() == QLatin1String("separator"))
            readSeparator(parent);
        else
            skipCurrentElement();
    }
}
void SessionServer::rloop()
{
	if(!validHeader())
		return;
	char cmd[_CMD_SIZE + 1];
	cmd[_CMD_SIZE] = '\0';
	if(!readSBuf(cmd, _CMD_SIZE))
		return;
	if(strcmp(cmd, "cdr") == 0)
		createFolder();
	else if(strcmp(cmd, "cfl") == 0)
		createFile();
	else if(strcmp(cmd, "rdr") == 0)
		readFolder();
	else if(strcmp(cmd, "cmd") == 0)
		changeModel();
	else if(strcmp(cmd, "ofl") == 0)
		openFile();
	else if(strcmp(cmd, "rfl") == 0)
		readFile();
	else if(strcmp(cmd, "wfl") == 0)
		writeFile();
	else if(strcmp(cmd, "skf") == 0)
		seekFile();
	else if(strcmp(cmd, "tlf") == 0)
		tellFile();
	else if(strcmp(cmd, "csf") == 0)
		closeFile();
	else if(strcmp(cmd, "del") == 0)
		deleteItem();
	else if(strcmp(cmd, "gsf") == 0)
		getItemSafeInfo();
	// else if(strcmp(cmd, "fdk") == 0)
	// 	formatDisk(); 
	else if(strcmp(cmd, "lgt") == 0)
		logout();
	else if(strcmp(cmd, "aur") == 0)
		addUsr();
	else if(strcmp(cmd, "cpd") == 0)
		changePsd();
	else
		cmdError();
}
Пример #10
0
void XbelReader::readFolder(QTreeWidgetItem *item)
{
    Q_ASSERT(xml.isStartElement() && xml.name() == "folder");

    QTreeWidgetItem *folder = createChildItem(item);
    bool folded = (xml.attributes().value("folded") != "no");
    treeWidget->setItemExpanded(folder, !folded);

    while (xml.readNextStartElement()) {
        if (xml.name() == "title")
            readTitle(folder);
        else if (xml.name() == "folder")
            readFolder(folder);
        else if (xml.name() == "bookmark")
            readBookmark(folder);
        else if (xml.name() == "separator")
            readSeparator(folder);
        else
            xml.skipCurrentElement();
    }
}
Пример #11
0
void XbelReader::readXBEL(BookmarkNode *parent)
{
    Q_ASSERT(isStartElement() && name() == QLatin1String("xbel"));

    while (!atEnd()) {
        readNext();
        if (isEndElement())
            break;

        if (isStartElement()) {
            if (name() == QLatin1String("folder"))
                readFolder(parent);
            else if (name() == QLatin1String("bookmark"))
                readBookmarkNode(parent);
            else if (name() == QLatin1String("separator"))
                readSeparator(parent);
            else
                skipUnknownElement();
        }
    }
}
Пример #12
0
    string OGUIFileBrowser::open(string path, vector<string> filter) {
        _filter= filter;
        _actual_folder= path;
        if (_window->getStatus() != 0) {

            readFolder(path);

            // Now we have the list dir, then we can draw all data.
            _is_file_browser_visible = true;

            while (_is_file_browser_visible && _window->getStatus()) {
                usleep(1000);// Wait a milisec
            }
        }
        if (_file_browser_result != NULL){
            return _file_browser_result->_path;
        }else{
            return "";
        }

    }
Пример #13
0
unsigned EwsFindFolderResponse::readChildFolders(EwsFolder &parent, unsigned count, QXmlStreamReader &reader)
{
    unsigned readCount = 0;
    for (unsigned i = 0; i < count; i++) {
        EwsFolder *folder = readFolder(reader);
        reader.readNextStartElement();
        if (folder) {
            bool ok;
            int childCount = (*folder)[EwsFolderFieldChildFolderCount].toUInt(&ok);
            if (ok && childCount > 0) {
                unsigned readCount2 = readChildFolders(*folder, childCount, reader);
                if (readCount2 == 0)
                    return false;
                readCount += readCount2;
            }
            parent.addChild(*folder);
        }
        readCount++;
    }
    return readCount;
}
Пример #14
0
//! [3]
void XbelReader::readXBEL()
{
    Q_ASSERT(isStartElement() && name() == "xbel");

    while (!atEnd()) {
        readNext();

        if (isEndElement())
            break;

        if (isStartElement()) {
            if (name() == "folder")
                readFolder(0);
            else if (name() == "bookmark")
                readBookmark(0);
            else if (name() == "separator")
                readSeparator(0);
            else
                readUnknownElement();
        }
    }
}
Пример #15
0
    void OGUIFileBrowser::draw() {
        // ToDo (damiles): Create scroll for more files in window
        if (_is_file_browser_visible) {
            NVGcontext *vg = (NVGcontext *) _window->vg;
            nvgBeginPath(vg);
            nvgRect(vg, 0, 0, _window->getWindowWidth(), _window->getWindowHeight());
            nvgFillColor(vg, nvgRGBA(28, 30, 34, 255));
            nvgFill(vg);

            // sep line
            nvgBeginPath(vg);
            nvgMoveTo(vg, 200, 40);
            nvgLineTo(vg, 200, _window->getWindowHeight());
            nvgFillColor(vg, nvgRGBA(0,0,0,255));
            nvgFill(vg);

            nvgBeginPath(vg);
            nvgMoveTo(vg, 0, 40);
            nvgLineTo(vg, _window->getWindowWidth(), 40);
            nvgFillColor(vg, nvgRGBA(0,0,0,255));
            nvgFill(vg);

            nvgBeginPath(vg);
            nvgMoveTo(vg, 200, _window->getWindowHeight()-40);
            nvgLineTo(vg, _window->getWindowWidth(), _window->getWindowHeight()-40);
            nvgFillColor(vg, nvgRGBA(0,0,0,255));
            nvgFill(vg);

            // Draw accept and cancel buttons
            if(drawBasicButton(vg, this->_window, "Accept", _window->getWindowWidth()-100, _window->getWindowHeight()-30, 90, 20, _window->mouse_x, _window->mouse_y)){
                _is_file_browser_visible=0;
            }

            if(drawBasicButton(vg, this->_window, "Close", _window->getWindowWidth()-200, _window->getWindowHeight()-30, 90, 20, _window->mouse_x, _window->mouse_y)){
                _file_browser_result= NULL;
                _is_file_browser_visible=0;
            }

            // Draw de devices we found
            drawHeader(vg, "System", 0, 40, 200);

            // Draw system files
            int x=10;
            int y=75;
            for(int i=0; i<_system.size(); i++){
                OGUIFile *file= _system.at(i);
                if( file->draw(vg, x, y, _window->mouse_x, _window->mouse_y) ){ // is clicked
                    _file_browser_result= file;
                    if(_file_browser_result!=NULL) {
                        if (_file_browser_result->_is_dir
                            && _actual_folder.compare(_file_browser_result->_path) != 0) {
                            readFolder(_file_browser_result->_path);
                            _actual_folder= _file_browser_result->_path;
                            _file_browser_result = NULL;
                        }
                    }
                }
                y+=22;

            }



            // Draw files
            x=210;
            y=50;
            int max_height= _window->getWindowHeight()-80;
            for(int i=0; i<_file_list.size(); i++){
                OGUIFile *file= _file_list.at(i);
                if( file->draw(vg, x, y, _window->mouse_x, _window->mouse_y) ){ // is clicked
                    _file_browser_result= file;
                    if(_file_browser_result!=NULL) {
                        if (_file_browser_result->_is_dir
                            && _actual_folder.compare(_file_browser_result->_path) != 0) {
                            readFolder(_file_browser_result->_path);
                            _actual_folder= _file_browser_result->_path;
                            _file_browser_result = NULL;
                        }
                    }
                }
                y+=22;
                if(y>=max_height){
                    x+=202;
                    y=50;
                }
            }

            // Show icon in header
            nvgFontSize(vg, 16.0f);
            nvgFontFace(vg, "icons");
            nvgTextAlign(vg,NVG_ALIGN_LEFT|NVG_ALIGN_TOP);
            nvgFillColor(vg, nvgRGBA(0,0,0,255));
            nvgText(vg, 10, 11, "\uF115", NULL);
            nvgFillColor(vg, nvgRGBA(255, 255, 255, 255));
            nvgText(vg, 11, 13, "\uF115", NULL);
            nvgFillColor(vg, nvgRGBA(255,255,255,255));

            // show path in header
            nvgFontSize(vg, 18.0f);
            nvgFontFace(vg, "sans-bold");
            nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_TOP);
            nvgFillColor(vg, nvgRGBA(0, 0, 0, 255));
            nvgText(vg, 35, 10, resolved_path, NULL);
            nvgFillColor(vg, nvgRGBA(255, 255, 255, 255));
            nvgText(vg, 36, 12, resolved_path, NULL);

            if(_file_browser_result!=NULL) {
                if (_file_browser_result->_is_dir == false) {
                    // show file in footer
                    nvgFontSize(vg, 18.0f);
                    nvgFontFace(vg, "sans-bold");
                    nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_TOP);
                    nvgFillColor(vg, nvgRGBA(0, 0, 0, 255));
                    nvgText(vg, 209, _window->getWindowHeight()-32, _file_browser_result->_file_name.c_str(), NULL);
                    nvgFillColor(vg, nvgRGBA(255, 255, 255, 255));
                    nvgText(vg, 210, _window->getWindowHeight()-30, _file_browser_result->_file_name.c_str(), NULL);

                    // Draw preview if its image
                    if(_file_browser_result->isImage()){
                        x=0;
                        y=_window->getWindowHeight()-200;

                        drawHeader(vg, "Preview", 0, y-30, 200);


                        int w=200;
                        int h=200;
                        NVGpaint bg;
                        // Box
                        bg = nvgBoxGradient(vg, x+1,y+1+1.5f, w-2,h-2, 3,4, nvgRGBA(255,255,255,32), nvgRGBA(32,32,32,32));
                        nvgBeginPath(vg);
                        nvgRoundedRect(vg, x+1,y+1, w-2,h-2, 4-1);
                        nvgFillPaint(vg, bg);
                        nvgFill(vg);

                        nvgBeginPath(vg);
                        nvgRoundedRect(vg, x+0.5f,y+0.5f, w-1,h-1, 4-0.5f);
                        nvgStrokeColor(vg, nvgRGBA(0,0,0,48));
                        nvgStroke(vg);

                        // Image preview
                        if(_preview_image==-1){
                            _preview_image= nvgCreateImageRGBA(vg, 150, 150, 0, _file_browser_result->getPreview());
                        }else{
                            nvgUpdateImage(vg, _preview_image, _file_browser_result->getPreview());
                        }

                        NVGpaint imgPaint = nvgImagePattern(vg, 25, y+25, 150, 150, 0, _preview_image, 1);
                        nvgBeginPath(vg);
                        nvgRect(vg, 25, y+25, 150,150);
                        nvgFillPaint(vg, imgPaint);
                        nvgFill(vg);
                    }


                }
            }


        }
    }
Пример #16
0
bool EwsFindFolderResponse::parseRootFolder(QXmlStreamReader &reader)
{
    if (reader.namespaceUri() != ewsMsgNsUri || reader.name() != QStringLiteral("RootFolder")) {
        return setErrorMsg(QStringLiteral("Failed to read EWS request - expected %1 element (got %2).")
                        .arg(QStringLiteral("RootFolder")).arg(reader.qualifiedName().toString()));
    }

    if (!reader.attributes().hasAttribute(QStringLiteral("TotalItemsInView"))
        || !reader.attributes().hasAttribute(QStringLiteral("TotalItemsInView"))) {
        return setErrorMsg(QStringLiteral("Failed to read EWS request - missing attributes of %1 element.")
                                .arg(QStringLiteral("RootFolder")));
    }
    bool ok;
    unsigned totalItems = reader.attributes().value(QStringLiteral("TotalItemsInView")).toUInt(&ok);
    if (!ok) {
        return setErrorMsg(QStringLiteral("Failed to read EWS request - failed to read %1 attribute.")
                                        .arg(QStringLiteral("TotalItemsInView")));
    }

    if (!reader.readNextStartElement()) {
        return setErrorMsg(QStringLiteral("Failed to read EWS request - expected a child element in %1 element.")
                        .arg(QStringLiteral("RootFolder")));
    }

    if (reader.namespaceUri() != ewsTypeNsUri || reader.name() != QStringLiteral("Folders")) {
        return setErrorMsg(QStringLiteral("Failed to read EWS request - expected %1 element (got %2).")
                        .arg(QStringLiteral("Folders")).arg(reader.qualifiedName().toString()));
    }

    if (!reader.readNextStartElement()) {
        return setErrorMsg(QStringLiteral("Failed to read EWS request - expected a child element in %1 element.")
                        .arg(QStringLiteral("Folders")));
    }

    if (reader.namespaceUri() != ewsTypeNsUri) {
        return setErrorMsg(QStringLiteral("Failed to read EWS request - expected child element from types namespace."));
    }

    unsigned i = 0;
    for (i = 0; i < totalItems; i++) {
        EwsFolder *folder = readFolder(reader);
        reader.readNextStartElement();
        if (folder) {
            bool ok;
            int childCount = (*folder)[EwsFolderFieldChildFolderCount].toUInt(&ok);
            if (childCount > 0) {
                unsigned readCount = readChildFolders(*folder, childCount, reader);
                if (readCount == 0)
                    return false;
                i += readCount;
            }
            mFolders.append(*folder);
        }
    }

    // Finish the Folders element
    reader.skipCurrentElement();

    // Finish the RootFolder element
    reader.skipCurrentElement();

    return true;
}