コード例 #1
0
void CloudImageProvider::loadfinished(QNetworkReply *reply)
{
    qWarning()<<"Download finished*******";

    QByteArray Data = reply->readAll();
//    qWarning() << "data="<<xmlData.left(200);
                QImage image;
                image.loadFromData(Data);

                QString key = toKey( reply->url().toString());
//                qWarning()<<key<<" <- "<<reply->url().toString();
                cache[key] = image;

//                qWarning()<<"pre image save:"+workDir+"imgcache/"+key+".jpg";
                image.save(workDir+"imgcache/"+key+".jpg");
//                qWarning()<<"post image save";




//    reply->manager()->deleteLater();
    reply->deleteLater();

    emit cacheUpdated();
}
コード例 #2
0
ファイル: loader.cpp プロジェクト: Blei/clay
static ModulePtr loadModuleByName(DottedNamePtr name, vector<string> *sourceFiles, bool verbose) {
    string key = toKey(name);

    llvm::StringMap<ModulePtr>::iterator i = globalModules.find(key);
    if (i != globalModules.end())
        return i->second;

    ModulePtr module;

    if (key == "__primitives__") {
        module = makePrimitivesModule();
    } else if (key == "__operators__") {
        module = makeOperatorsModule();
    } else if (key == "__intrinsics__") {
        module = makeIntrinsicsModule();
    }
    else {
        PathString path = locateModule(name);
        if (verbose) {
            llvm::errs() << "loading module " << name->join() << " from " << path << "\n";
        }
        module = parse(key, loadFile(path, sourceFiles));
    }

    globalModules[key] = module;
    loadDependents(module, sourceFiles, verbose);
    installGlobals(module);

    return module;
}
コード例 #3
0
// CACHE MODULE
QImage CloudImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize)
{
    Q_UNUSED(size)
    Q_UNUSED(requestedSize)

    qWarning()<<"id"<<id;
//    qWarning()<<id<<"   auth_token="<<CloudWindow::getValueFor("auth_token")<<" size="<<requestedSize;
//    QByteArray _ba = "api_key=7118206e08fed2c5ec8c0f2db61bbbdc09ab2dfa&auth_token=" +
//            Cloud::getValueFor("auth_token").toUtf8();

    QString _id = id;
    _id.remove(QChar('#'));

    QNetworkRequest req("http://"+_id);
    qWarning()<<req.url();
//    req.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
    QString key = toKey( req.url().toString());

    if (cache.contains(key))
        return cache[key];

qWarning()<<"YES!!1:"<<req.url();
    cache[key] = QImage();

    QNetworkAccessManager *_mgr = new QNetworkAccessManager;
    connect(_mgr,SIGNAL(finished(QNetworkReply*)),this,SLOT(loadfinished(QNetworkReply*)));

    QNetworkReply *_reply = _mgr->get(req);
    Q_UNUSED(_reply)
//    qWarning()<<_reply;
qWarning()<<"YES!!2";
    return QImage();
}
コード例 #4
0
ファイル: loader.cpp プロジェクト: kssreeram/clay-old
static ModulePtr loadModuleByName(DottedNamePtr name, vector<string> *sourceFiles) {
    string key = toKey(name);

    map<string, ModulePtr>::iterator i = globalModules.find(key);
    if (i != globalModules.end())
        return i->second;

    ModulePtr module;

    if (key == "__primitives__") {
        module = makePrimitivesModule();
    } else if (key == "__operators__") {
        module = makeOperatorsModule();
    }
    else {
        string path = locateModule(name);
        module = parse(key, loadFile(path, sourceFiles));
    }

    globalModules[key] = module;
    loadDependents(module, sourceFiles);
    installGlobals(module);

    return module;
}
コード例 #5
0
ファイル: loader.cpp プロジェクト: kssreeram/clay-old
static void initModule(ModulePtr m) {
    if (m->initialized) return;
    m->initialized = true;
    vector<ImportPtr>::iterator ii, iend;
    for (ii = m->imports.begin(), iend = m->imports.end(); ii != iend; ++ii)
        initModule((*ii)->module);

    if (m->declaration != NULL) {
        if (m->moduleName == "")
            m->moduleName = toKey(m->declaration->name);
        else if (m->moduleName != toKey(m->declaration->name))
            error(m->declaration,
                "module imported by name " + m->moduleName
                + " but declared with name " + toKey(m->declaration->name)
            );
    } else if (m->moduleName == "")
        m->moduleName = "__main__";

    verifyAttributes(m);

    const vector<TopLevelItemPtr> &items = m->topLevelItems;
    vector<TopLevelItemPtr>::const_iterator ti, tend;
    for (ti = items.begin(), tend = items.end(); ti != tend; ++ti) {
        Object *obj = ti->ptr();
        switch (obj->objKind) {
        case OVERLOAD :
            initOverload((Overload *)obj);
            break;
        case INSTANCE :
            initVariantInstance((Instance *)obj);
            break;
        }
    }

    if (llvmDIBuilder != NULL) {
        llvm::DIFile file = m->location == NULL
            ? llvm::DIFile(NULL)
            : m->location->source->getDebugInfo();
        m->debugInfo = (llvm::MDNode*)llvmDIBuilder->createNameSpace(
            llvm::DICompileUnit(llvmDIBuilder->getCU()), // scope
            m->moduleName, // name
            file, // file
            1 // line
            );
    }
}
コード例 #6
0
void CloudImageProvider::clearCache(QString s) {
    qWarning()<<"CloudImageProvider::clearCache:"<<s;
    QString key = toKey(s);
    cache.remove(key);

    QString fn =workDir+"imgcache/"+key+".jpg";
    qWarning()<<fn;
    QFile file(fn);
    if (file.remove()) qWarning()<<"removed";
}
コード例 #7
0
ファイル: shorty.cpp プロジェクト: nim901/Shorty
void Shorty::keyPressEventHandler(QEvent *event){
    qDebug(shorty_Main()) << "A key was pressed. we are now at location" << getLocation() << "and looking for"
                          << data->getCommandAt(getLocation());
    if (data->getCommandAt(getLocation()) == "Ctrl" && ((QKeyEvent*)event)->modifiers() && Qt::ControlModifier) {
        //if key is Ctrl
        qDebug(shorty_Main()) << "Ctrl was pressed. our location is" << getLocation() << "and now it'll be"
                              << getLocation()+1;
        paint(getLocation());
        setLocation(getLocation()+1);
    }
    else if (data->getCommandAt(getLocation()) == "Alt" && ((QKeyEvent*)event)->modifiers() && Qt::AltModifier) {
        //if key is Alt
        qDebug(shorty_Main()) << "Alt was pressed. our location is" << getLocation() << "and now it'll be"
                              << getLocation()+1;
        paint(getLocation());
        setLocation(getLocation()+1);
    }//shift
    else if (data->getCommandAt(getLocation()) == "Enter" &&
             (((QKeyEvent*)event)->key() == Qt::Key_Enter || ((QKeyEvent*)event)->key() == Qt::Key_Return)) {
        //if key is Enter
        qDebug(shorty_Main()) << "Enter was pressed. our location is" << getLocation() << "and now it'll be"
                              << getLocation()+1;
        paint(getLocation());
        setLocation(getLocation()+1);
    }
    else if (data->getCommandAt(getLocation()) == "ESC" && (((QKeyEvent*)event)->key() == Qt::Key_Escape)) {
        //if key is esc
        qDebug(shorty_Main()) << "Enter was pressed. our location is" << getLocation() << "and now it'll be"
                              << getLocation()+1;
        paint(getLocation());
        setLocation(getLocation()+1);
    }
    else { // key is not
        pressedKeys += ((QKeyEvent*)event)->key();
        qDebug(shorty_Main()) << ((QKeyEvent*)event)->key() << "was pressed. our location is" << getLocation()
                              << "and and the key that we are looking for is" << data->getCommandAt(getLocation());
        if ( pressedKeys.contains(toKey(data->getCommandAt(getLocation())))) {
            qDebug(shorty_Main()) << "We got a match. our location is" << getLocation() << "and now it'll be"
                                  << getLocation()+1;
            paint(getLocation());
            setLocation(getLocation()+1);
        }
        else {
            qDebug(shorty_Main()) << "No match for this key. turning on errorFlag";
            setLocation(getLocation()-1);
            errorPaint(getLocation());
            errorFlag = !errorFlag;
        }
    }
    if (getLocation() == keyList.count()) { //full match
        qDebug(shorty_Main()) << "Location is" << getLocation() << "Total count is" <<
                                 keyList.count() << "all keys for this shortcut are matched";
        load();
    }
}
コード例 #8
0
ファイル: loader.cpp プロジェクト: kssreeram/clay-old
static string locateModule(DottedNamePtr name) {
    string path, relativePath;

    relativePath = toRelativePath1(name);
    if (locateFile(relativePath, path))
        return path;

    relativePath = toRelativePath2(name);
    if (locateFile(relativePath, path))
        return path;

    error(name, "module not found: " + toKey(name));
    return "";
}
コード例 #9
0
ファイル: loader.cpp プロジェクト: Blei/clay
static PathString locateModule(DottedNamePtr name) {
    PathString path;

    PathString relativePath1 = toRelativePath1(name);
    if (locateFile(relativePath1, path))
        return path;

    PathString relativePath2 = toRelativePath2(name);
    if (locateFile(relativePath2, path))
        return path;

    string s;
    llvm::raw_string_ostream ss(s);

    ss << "module not found: " + toKey(name) << "\n";

    ss << "tried relative paths:\n";
    ss << "    " << relativePath1 << "\n";
    ss << "    " << relativePath2 << "\n";

    ss << "with suffixes:\n";
    for (vector<llvm::SmallString<32> >::const_iterator entry = moduleSuffixes.begin();
            entry != moduleSuffixes.end(); ++entry)
    {
        ss << "    " << *entry << "\n";
    }

    ss << "in search path:\n";
    for (vector<PathString>::const_iterator entry = searchPath.begin();
            entry != searchPath.end(); ++entry)
    {
        ss << "    " << *entry << "\n";
    }

    ss.flush();

    error(name, s);
    llvm_unreachable("module not found");
}
コード例 #10
0
// XXX currently you can not add the same adjacency (i.e. you can't have multiple
// XXX stream converters registering to handle the same from-to combination. It's
// XXX not programatically prohibited, it's just that results are un-predictable
// XXX right now.
nsresult
nsStreamConverterService::AddAdjacency(const char *aContractID) {
    nsresult rv;
    // first parse out the FROM and TO MIME-types.

    nsAutoCString fromStr, toStr;
    rv = ParseFromTo(aContractID, fromStr, toStr);
    if (NS_FAILED(rv)) return rv;

    // Each MIME-type is a vertex in the graph, so first lets make sure
    // each MIME-type is represented as a key in our hashtable.

    nsCStringKey fromKey(fromStr);
    SCTableData *fromEdges = (SCTableData*)mAdjacencyList->Get(&fromKey);
    if (!fromEdges) {
        // There is no fromStr vertex, create one.

        nsCStringKey *newFromKey = new nsCStringKey(ToNewCString(fromStr), fromStr.Length(), nsCStringKey::OWN);
        if (!newFromKey) return NS_ERROR_OUT_OF_MEMORY;

        SCTableData *data = new SCTableData(newFromKey);
        if (!data) {
            delete newFromKey;
            return NS_ERROR_OUT_OF_MEMORY;
        }

        nsCOMArray<nsIAtom>* edgeArray = new nsCOMArray<nsIAtom>;
        if (!edgeArray) {
            delete newFromKey;
            data->key = nullptr;
            delete data;
            return NS_ERROR_OUT_OF_MEMORY;
        }
        data->data.edges = edgeArray;

        mAdjacencyList->Put(newFromKey, data);
        fromEdges = data;
    }

    nsCStringKey toKey(toStr);
    if (!mAdjacencyList->Get(&toKey)) {
        // There is no toStr vertex, create one.
        nsCStringKey *newToKey = new nsCStringKey(ToNewCString(toStr), toStr.Length(), nsCStringKey::OWN);
        if (!newToKey) return NS_ERROR_OUT_OF_MEMORY;

        SCTableData *data = new SCTableData(newToKey);
        if (!data) {
            delete newToKey;
            return NS_ERROR_OUT_OF_MEMORY;
        }

        nsCOMArray<nsIAtom>* edgeArray = new nsCOMArray<nsIAtom>;
        if (!edgeArray) {
            delete newToKey;
            data->key = nullptr;
            delete data;
            return NS_ERROR_OUT_OF_MEMORY;
        }
        data->data.edges = edgeArray;
        mAdjacencyList->Put(newToKey, data);
    }
    
    // Now we know the FROM and TO types are represented as keys in the hashtable.
    // Let's "connect" the verticies, making an edge.

    nsCOMPtr<nsIAtom> vertex = do_GetAtom(toStr); 
    if (!vertex) return NS_ERROR_OUT_OF_MEMORY;

    NS_ASSERTION(fromEdges, "something wrong in adjacency list construction");
    if (!fromEdges)
        return NS_ERROR_FAILURE;

    nsCOMArray<nsIAtom> *adjacencyList = fromEdges->data.edges;
    return adjacencyList->AppendObject(vertex) ? NS_OK : NS_ERROR_FAILURE;
}
コード例 #11
0
ファイル: loader.cpp プロジェクト: Blei/clay
static void initModule(ModulePtr m, llvm::ArrayRef<string>  importChain) {
    if (m->initState == Module::DONE) return;

    if (m->declaration != NULL) {
        if (m->moduleName == "")
            m->moduleName = toKey(m->declaration->name);
        else if (m->moduleName != toKey(m->declaration->name))
            error(m->declaration,
                "module imported by name " + m->moduleName
                + " but declared with name " + toKey(m->declaration->name)
            );
    } else if (m->moduleName == "")
        m->moduleName = "__main__";


    if (m->initState == Module::RUNNING && !importChain.empty()) {
        // allow prelude to import self
        if (importChain.back() == m->moduleName) {
            return;
        }
    }

    vector<string> importChainNext = importChain;
    importChainNext.push_back(m->moduleName);

    if (m->initState == Module::RUNNING) {
        circularImportsError(importChainNext);
    }

    m->initState = Module::RUNNING;

    vector<ImportPtr>::iterator ii, iend;
    for (ii = m->imports.begin(), iend = m->imports.end(); ii != iend; ++ii)
        initModule((*ii)->module, importChainNext);

    m->initState = Module::DONE;

    verifyAttributes(m);

    llvm::ArrayRef<TopLevelItemPtr> items = m->topLevelItems;
    TopLevelItemPtr const *ti, *tend;
    for (ti = items.begin(), tend = items.end(); ti != tend; ++ti) {
        Object *obj = ti->ptr();
        switch (obj->objKind) {
        case OVERLOAD :
            initOverload((Overload *)obj);
            break;
        case INSTANCE_DECL :
            initVariantInstance((InstanceDecl *)obj);
            break;
        case STATIC_ASSERT_TOP_LEVEL:
            checkStaticAssert((StaticAssertTopLevel *)obj);
            break;
        default:
            break;
        }
    }

    if (llvmDIBuilder != NULL) {
        llvm::DIFile file = m->location.ok()
            ? m->location.source->getDebugInfo()
            : llvm::DIFile(NULL);
        m->debugInfo = (llvm::MDNode*)llvmDIBuilder->createNameSpace(
            llvm::DICompileUnit(llvmDIBuilder->getCU()), // scope
            m->moduleName, // name
            file, // file
            1 // line
            );
    }
}