Example #1
0
bool AsyncFile::asyncRead(qint64 pos)
{
    if (reading)
        return true;

    qint64 bytes = qMin(BUFFER_SIZE, MAX_BUFFER_SIZE - m_readBuffer.size());
    const qint64 offset = pos + m_readBuffer.size();
    bytes = qMin(bytes, size() - offset);
    qDebug() << "asyncRead" << "pos" << pos << "size" << size() << "bytes" << bytes;
    if (bytes <= 0)
        return true;
    Q_ASSERT(offset + bytes <= size());
    overlapped.overlapped.Offset = offset;

    bool ok = ReadFileEx(m_FileHandle,
                         overlapped.buffer,
                         bytes,
//                             &dwBytesRead,
                         &overlapped.overlapped,
                         &readCallback);
    if (!ok) {
        setError(QFileDevice::ReadError, errorMessage(GetLastError()) );
    }
    reading = ok;
    qDebug() << "asyncRead" << "finished" << ok;
    return ok;
}
Example #2
0
void is_analysis_fun::set_trunc_image()
{
    qDebug()<<"set_trun_Image_marker";
    V3DLONG y_offset=sz_img[0];
    V3DLONG z_offset=sz_img[0]*sz_img[1];
    V3DLONG page_size=z_offset*sz_img[2];
    int mid=list_markers->currentRow();//start from zero--marker 1

    int halfwindowsize=param.halfwindowsize;
    //create bounding box
    V3DLONG x,y,z;
    x=LList_out[mid].x;
    y=LList_out[mid].y;
    z=LList_out[mid].z;

    if (x<halfwindowsize) sz[0]=x+halfwindowsize+1;
    else if (x+halfwindowsize>sz_img[0]) sz[0]=sz_img[0]-x+halfwindowsize;
    else sz[0]=2*halfwindowsize+1;

    if (y<halfwindowsize) sz[1]=y+halfwindowsize+1;
    else if (y+halfwindowsize>sz_img[1]) sz[1]=sz_img[1]-y+halfwindowsize;
    else sz[1]=2*halfwindowsize+1;

    if (z<halfwindowsize) sz[2]=z+halfwindowsize+1;
    else if (z+halfwindowsize>sz_img[2]) sz[2]=sz_img[2]-z+halfwindowsize;
    else sz[2]=2*halfwindowsize+1;

    sz[3]=3;

    if (image_trun!=0)
    {
        delete [] image_trun;
        image_trun=0;
    }
    image_trun=new unsigned char[sz[0]*sz[1]*sz[2]*sz[3]];
    memset(image_trun,0,sz[0]*sz[1]*sz[2]*sz[3]);
    qDebug()<<"image_trun allocated"<<sz[0]<<":"<<sz[1]<<":"<<sz[2];
    //Store the area around the marker in image_trun
    x_start=MAX(0,x-halfwindowsize);
    y_start=MAX(0,y-halfwindowsize);
    z_start=MAX(0,z-halfwindowsize);
    x_end=MIN(sz_img[0],x+halfwindowsize+1);
    y_end=MIN(sz_img[1],y+halfwindowsize+1);
    z_end=MIN(sz_img[2],z+halfwindowsize+1);
    qDebug()<<"halfsize:"<<halfwindowsize<<" x,y,z:"<<x<<":"<<y<<":"<<z;
    qDebug()<<"sz0,sz1,sz2:"<<sz[0]<<":"<<sz[1]<<":"<<sz[2];

    for (V3DLONG dx=x_start;dx<x_end;dx++){
        for (V3DLONG dy=y_start;dy<y_end;dy++){
            for (V3DLONG dz=z_start;dz<z_end;dz++){
                V3DLONG pos=xyz2pos(dx,dy,dz,y_offset,z_offset);
                V3DLONG pos1=xyz2pos(dx-x_start,dy-y_start,dz-z_start,sz[0],sz[0]*sz[1]);
                image_trun[pos1]=mask[pos];
                image_trun[pos1+sz[0]*sz[1]*sz[2]]=mask[pos+page_size];
                image_trun[pos1+2*sz[0]*sz[1]*sz[2]]=mask[pos+2*page_size];
            }
        }
    }
    qDebug()<<"finish setting up image";
}
Example #3
0
void parseCommandLine(QCoreApplication &app, CmdLineOptions *opts)
{
    QCommandLineParser parser;

    parser.setApplicationDescription("remove db key at specified path");
    parser.addHelpOption();
    parser.addVersionOption();

    parser.addPositionalArgument("key", QCoreApplication::translate("main", "key"));

    QCommandLineOption debugOption(QStringList() << "d" << "debug",
                                   QCoreApplication::translate("main", "enable debug/verbose logging"));
    parser.addOption(debugOption);

    parser.process(app);

    opts->debuggingEnabled = parser.isSet(debugOption);

    const QStringList posArgs = parser.positionalArguments();
    if (posArgs.size() < 1)
    {
        qCritical("invalid arguments");
        exit(1);
    }

    opts->key = posArgs.at(0);

    DbdLogging::logger()->debugMode =  opts->debuggingEnabled;

    qDebug() << "debugging enabled:" << opts->debuggingEnabled;
    qDebug() << "key:" << opts->key;
}
void qdicomimagewidget::mouseMoveEvent(QMouseEvent* e) {
   e->accept();
   _dcmimage->load_image(_filename.toStdString().c_str());
   QPoint tmp = e->pos();
   QPoint delta = _lastMousePosition - tmp;
   qDebug() << delta.x() << " x " << delta.y() ;
   if (delta.x() != 0) {
      if (delta.x() > 0) 
	 _windowcenter+=5.0;
      else
	 _windowcenter -=5.0;
   }
   if (delta.y() != 0) {
      if (delta.y() > 0) 
	 _windowwidth += 5.0;
      else
	 _windowwidth -= 5.0;
   }
   _lastMousePosition = tmp;
   _dcmimage->get_image()->setWindow(_windowcenter,_windowwidth);
   _dcmimage->get_image()->getOutputData(_qimagebuffer,_qimagesize,8);
   
    if (_qimage != 0)
      delete _qimage;
    _qimage = new QImage(_qimagebuffer, _dcmimage->get_width(), _dcmimage->get_height(), QImage::Format_Indexed8);
    qDebug() << "window  : "<< _windowcenter << " , " << _windowwidth;
   update();
}
Example #5
0
int Database::deleteSymbol (Bars *bd)
{
    if (! getSymbol(bd))
    {
        qDebug() << "Database::deleteSymbol: invalid SYMBOL";
        return 0;
    }

    // drop quote table
    QSqlQuery q(_db);

    QString s = "DROP TABLE " + bd->table();
    q.exec(s);
    if (q.lastError().isValid())
    {
        qDebug() << "Database::deleteSymbol:" + q.lastError().text();
        return 0;
    }

    // remove index records for symbol
    s = "DELETE FROM symbolIndex WHERE name='" + bd->symbol() + "'";
    q.exec(s);
    if (q.lastError().isValid())
    {
        qDebug() << "Database::deleteSymbol:" + q.lastError().text();
        return 0;
    }

    return 1;
}
Example #6
0
UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const
{
    UConverter *conv = 0;
    if (state) {
        if (!state->d) {
            // first time
            state->flags |= QTextCodec::FreeFunction;
            QTextCodecUnalignedPointer::encode(state->state_data, qIcuCodecStateFree);
            UErrorCode error = U_ZERO_ERROR;
            state->d = ucnv_open(m_name, &error);
            ucnv_setSubstChars(static_cast<UConverter *>(state->d),
                               state->flags & QTextCodec::ConvertInvalidToNull ? "\0" : "?", 1, &error);
            if (U_FAILURE(error))
                qDebug() << "getConverter(state) ucnv_open failed" << m_name << u_errorName(error);
        }
        conv = static_cast<UConverter *>(state->d);
    }
    if (!conv) {
        // stateless conversion
        UErrorCode error = U_ZERO_ERROR;
        conv = ucnv_open(m_name, &error);
        ucnv_setSubstChars(conv, "?", 1, &error);
        if (U_FAILURE(error))
            qDebug() << "getConverter(no state) ucnv_open failed" << m_name << u_errorName(error);
    }
    return conv;
}
Example #7
0
RPiServer::RPiServer(QObject *parent) :
    QObject(parent)
{
    m_cfg = Utilities::getConfig ("config.mts");
    qDebug() << m_cfg[IMAGE_INTERVAL].toString ();

    m_server = new TCPServer ();
    m_ip = new ImageProcessor ();
    m_cmdTimer = new QTimer ();
    m_dataPro = new DataProtocol ();
    m_client = new TCPClient (m_cfg[CLIENT_IP].toString ());
    m_cp = new CommandParser ();

    connect(m_server, SIGNAL(sigGotData(QByteArray)), this, SLOT(slotGotData(QByteArray)));
    connect(m_cmdTimer, SIGNAL(timeout()), this, SLOT(slotSendCommand ()));
    //
    // Slots to respond to Command Parser signals
    //
    connect(m_cp, SIGNAL(sigRecvImage()), this, SLOT(slotRecvImage ()));
    connect(m_cp, SIGNAL(sigSendTime()), this, SLOT(slotSendTime ()));
    connect(m_cp, SIGNAL(sigCRCMismatch()), this, SLOT(slotRequestResend ()));
    connect(m_cp, SIGNAL(sigResend()), this, SLOT(slotResend ()));
    connect(m_cp, SIGNAL(sigRecvConfig()), this, SLOT(slotRecvConfg ()));

    qDebug() << "Starting timer...";
    m_cmdTimer->start (10000);
}
Example #8
0
void StandardDialog::showMessageDialog() {
  int ret1 = QMessageBox::question(this, tr("question dialog"),
                                   tr("do you know the HIRG ?"),
                                   QMessageBox::Yes, QMessageBox::No);
  if (ret1 == QMessageBox::Yes) {
    qDebug() << tr("question");
  }

  int ret2 = QMessageBox::information(this, tr("infomation dialog"),
                                      tr("I'm xiaohai."), QMessageBox::Ok);
  if (ret2 == QMessageBox::Ok) {
    qDebug() << tr("infomation dialog.");
  }

  int ret3 = QMessageBox::warning(this, tr("warning dialog"),
                                  tr("don't stop the process in early"),
                                  QMessageBox::Abort);
  if (ret3 == QMessageBox::Abort) {
    qDebug() << tr("warning dialog");
  }

  int ret4 = QMessageBox::critical(this, tr("error dialog"),
                                   tr("find a error..."), QMessageBox::YesAll);
  if (ret4 == QMessageBox::YesAll) {
    qDebug() << tr("error");
  }

  QMessageBox::about(this, tr("about dialog"), tr("This is a Qt program..."));
}
Example #9
0
QString Paths::configDir(const QString &dirName) {
  QString dir;

#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
  dir = QStandardPaths::locate(QStandardPaths::ConfigLocation,
#if defined Q_OS_LINUX || defined Q_OS_MAC
                               VER_COMPANYNAME_STR "/" VER_PRODUCTNAME_STR "/" +
#endif /* LINUX || MAC */
                                   dirName,
                               QStandardPaths::LocateDirectory);
  if (dir.isEmpty()) {
    QString tmp =
        QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
#if defined Q_OS_LINUX || defined Q_OS_MAC
    tmp += "/" VER_COMPANYNAME_STR "/" VER_PRODUCTNAME_STR;
#endif /* LINUX || MAC */
    dir = tmp + "/" + dirName;
    QDir(dir).mkpath(dir);
    qDebug() << "Created new config direcrory:" << dir;
  }
#else
  dir = QStandardPaths::locate(QStandardPaths::AppConfigLocation, dirName,
                               QStandardPaths::LocateDirectory);
  if (dir.isEmpty()) {
    QString tmp =
        QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
    dir = tmp + "/" + dirName;
    QDir(dir).mkpath(dir);
    qDebug() << "Created new config direcrory:" << dir;
  }
#endif /* QT_VERSION < 5.5.0 */

  return dir;
}
Example #10
0
void STab::handleFinishStreamLoading(bool)
{
    qDebug("STab::handleFinishStreamLoading");

    disconnect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(handleFinishStreamLoading(bool)));

    ui->progressBar->setValue(99);

    //
    QSettings* const settings = Settings::getHostsInstance();
    settings->beginGroup(this->currentGroup);
    QString mode = settings->value("mode").toString();
    if (mode == QString("regexps")) {
        QWebFrame *frame = ui->webView->page()->mainFrame();
        QString content = frame->toHtml();

        int size = settings->beginReadArray("rule");
        for (int i = 0; i < size; ++i) {
            settings->setArrayIndex(i);

            QRegExp rx(settings->value("from").toString());
            content.replace(rx, settings->value("to").toString());
        }

        settings->endArray();

        qDebug() << content;

        ui->webView->setContent(content.toUtf8());
    }
    settings->endGroup();

    prepareUi();
}
Example #11
0
void StandardDialog::showInputDialog() {
  bool ok;
  QString string =
      QInputDialog::getText(this, tr("input dialog"), tr("input username: "),
                            QLineEdit::Normal, tr("admin"), &ok);
  if (ok) {
    qDebug() << "string: " << string;
  }

  int value =
      QInputDialog::getInt(this, tr("input integer dialog"), tr("-1000, 1000"),
                           100, -1000, 1000, 10, &ok);
  if (ok) {
    qDebug() << "value: " << value;
  }

  double value2 =
      QInputDialog::getDouble(this, tr("input double dialog"),
                              tr("-1000.0, 1000.0"), 0.00, -1000, 1000, 2, &ok);
  if (ok) {
    qDebug() << "value2: " << value2;
  }

  QStringList items;
  items << tr("item1") << tr("item2");
  QString item =
      QInputDialog::getItem(this, tr("input item dialog"),
                            tr("input the next item"), items, 0, true, &ok);
  if (ok) {
    qDebug() << "item: " << item;
  }
}
Example #12
0
QScriptValue constructQDoubleValidator(QScriptContext *context,
                            QScriptEngine  *engine)
{
  QDoubleValidator *obj = 0;

  if (DEBUG)
  {
    qDebug("constructQDoubleValidator() entered");
    for (int i = 0; i < context->argumentCount(); i++)
      qDebug("context->argument(%d) = %s", i,
             qPrintable(context->argument(i).toString()));
  }

  if (context->argumentCount() >= 4)
    obj = new QDoubleValidator(context->argument(0).toNumber(),
                    context->argument(1).toNumber(),
                    context->argument(2).toInt32(),
                    context->argument(3).toQObject());
  else if (context->argumentCount() == 1)
    obj = new QDoubleValidator(context->argument(0).toQObject());
  else
    context->throwError(QScriptContext::UnknownError,
                        "QDoubleValidator() constructor is not yet supported");

  return engine->toScriptValue(obj);
}
Example #13
0
jint JNI_OnLoad(JavaVM *vm, void *reserved)
{
    qDebug() << "JNI_OnLoad";
    java_vm = vm;
    
    // Get JNI Env for all function calls
    if (vm->GetEnv( (void **) &jenv, JNI_VERSION_1_6) != JNI_OK) {
        qDebug() << "GetEnv failed.";
        return -1;
    }
    
#if 0
    // Find the class calling native function
    jclass NativeUsb = (*env)->FindClass(env, "com/venky/Home");
    if (class_home == NULL) {
        LOG_D ("FindClass failed : No class found.");
        return -1;
}

// Register native method for getUsbPermission
JNINativeMethod nm[1] = {
    { "getPermission", "(Landroid/app/Activity;)I", get_permission}
};

if ((*env)->RegisterNatives(env, NativeUsb, nm , 1)) {
    LOG_D ("RegisterNatives Failed.");
    return -1;
}
#endif
    return JNI_VERSION_1_6;
}
Example #14
0
wxString callActivityMethod_ss(const char *method, wxString parm)
{
    wxString return_string;
    QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative",
                                                                           "activity", "()Landroid/app/Activity;");
    
    if ( !activity.isValid() ){
        qDebug() << "Activity is not valid";
        return return_string;
    }

    //  Need a Java environment to decode the resulting string
    if (java_vm->GetEnv( (void **) &jenv, JNI_VERSION_1_6) != JNI_OK) {
        qDebug() << "GetEnv failed.";
        return _T("jenv Error");
    }
    
    jstring p = (jenv)->NewStringUTF(parm.c_str());
    
    
    //  Call the desired method
    QAndroidJniObject data = activity.callObjectMethod(method, "(Ljava/lang/String;)Ljava/lang/String;", p);
    
    jstring s = data.object<jstring>();
    
    const char *ret_string = (jenv)->GetStringUTFChars(s, NULL);
    return_string = wxString(ret_string, wxConvUTF8);
    
    return return_string;
    
}
Example #15
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QList<QString> list;
    list.append("Nagavavara");
    list.insert(7,"Bangaluru");
    list.insert(1,"Mysore");
    list.insert(2,"Hubli");
    list.insert(3,"Dharawad");
    list.insert(4,"Belgaum");
    list.insert(5,"Gulbarga");
    list.insert(6,"Raichur");

    QListIterator<QString> it(list);
    while(it.hasNext()) {
        QString str = it.next();
        qDebug() << "Valu =" << str;
    }

    QHash<int,QString> myHash;
    myHash.insert(1,"Bangaloru");
    myHash.insert(2,"Mysuru");
    myHash.insert(3,"Hubli");
    myHash.insert(4,"Raichur");
    myHash.insert(5,"Bidar");
    myHash.insert(6,"Bijapur");

    QString valu = myHash.value(1);
    qDebug() << "Key =" << 1 << " Value="<<valu <<endl;

    QList<int> keys = myHash.keys();
    QList<QString> values = myHash.values();

    return a.exec();
}
Example #16
0
QString Paths::configFile(const QString &fileName) {
  QString name;

#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
  name =
      QStandardPaths::locate(QStandardPaths::ConfigLocation,
#if defined Q_OS_LINUX || defined Q_OS_MAC
                             VER_COMPANYNAME_STR "/" VER_PRODUCTNAME_STR "/" +
#endif /* LINUX || MAC */
                                 fileName);
  if (name.isEmpty()) {
    QString dir =
        QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
#if defined Q_OS_LINUX || defined Q_OS_MAC
    dir += "/" VER_COMPANYNAME_STR "/" VER_PRODUCTNAME_STR;
#endif /* LINUX || MAC */
    QDir(dir).mkpath(dir);
    name = dir + "/" + fileName;
    qDebug() << "New config file query:" << name;
  }
#else
  name = QStandardPaths::locate(QStandardPaths::AppConfigLocation, fileName);
  if (name.isEmpty()) {
    QString dir =
        QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
    QDir(dir).mkpath(dir);
    name = dir + "/" + fileName;
    qDebug() << "New config file query:" << name;
  }
#endif /* QT_VERSION < 5.5.0 */

  return name;
}
void SqlQueryDataSource::updateModel()
{
    if (m_databaseName.isEmpty() || m_queryString.isEmpty()) {
        setStatus(Null);
        return;
    }
    if (!m_databaseName.isEmpty()) {
        if (QSqlDatabase::contains(m_databaseName)) {
            m_database = QSqlDatabase::database(m_databaseName);
        } else {
            m_database = QSqlDatabase::addDatabase("QSQLITE", m_databaseName);
            QString databasePath = QDir(m_storageLocation).filePath(m_databaseName + ".db");
            m_database.setDatabaseName(databasePath);
            qDebug() << "database path: " << databasePath;
        }
        if (!m_database.isOpen()) {
            m_database.open();
        }
    }
    if (m_database.isValid() && !m_queryString.isEmpty()) {
        setStatus(Loading);
        m_query = QSqlQuery(m_queryString, m_database);
        m_model->setQuery(m_query);
        m_model->updateRoleNames();
        if (m_query.lastError().isValid()) {
            qDebug() << "Error" << m_query.lastError().text();
            setStatus(Error);
        } else {
            setStatus(Ready);
        }
    }
    emit modelChanged(m_model);
}
Example #18
0
//下面的代码是消息过滤
bool MainWindow::eventFilter(QObject *o, QEvent *e)  //通用的对象指针,通用的事件指针
{

        QKeyEvent *pe=static_cast<QKeyEvent *>(e);

        if(e->type()==QEvent::KeyPress)
        {
            qDebug()<<pe->key();//转化为ASII打印出来
        }

       // return false;  //处理完中断


    if(e->type()==QEvent::KeyPress)
    {
        QKeyEvent *pe=static_cast<QKeyEvent *>(e);

        if(pe->key()==Qt::Key_K &&(Qt::ControlModifier & pe->modifiers()))
        {
            qDebug()<<"control + k";

        }
    }

    return QMainWindow::eventFilter(o,e);  //消息链表
}
Example #19
0
bool QNativeSocketEnginePrivate::nativeListen(int backlog)
{
    if (::listen(socketDescriptor, backlog) == SOCKET_ERROR) {
        int err = WSAGetLastError();
        WS_ERROR_DEBUG(err);
        switch (err) {
        case WSANOTINITIALISED:
            //###
            break;
        case WSAEADDRINUSE:
            setError(QAbstractSocket::AddressInUseError,
                     PortInuseErrorString);
            break;
        default:
            break;
        }

#if defined (QNATIVESOCKETENGINE_DEBUG)
        qDebug("QNativeSocketEnginePrivate::nativeListen(%i) == false (%s)",
               backlog, socketErrorString.toLatin1().constData());
#endif
        return false;
    }

#if defined (QNATIVESOCKETENGINE_DEBUG)
    qDebug("QNativeSocketEnginePrivate::nativeListen(%i) == true", backlog);
#endif

    socketState = QAbstractSocket::ListeningState;
    return true;
}
Example #20
0
void KDEProjectsReaderTest::testsProperParse()
{
    KDEProjectsModel m;
    KDEProjectsReader reader(&m, 0);

    if(reader.hasErrors())
        qDebug() << "errors:" << reader.errors();

    QVERIFY(!reader.hasErrors());

    WAIT_FOR_SIGNAL(&reader,downloadDone());

    for(int i=0; i<m.rowCount(); i++) {
        QStandardItem* item = m.item(i,0);
        qDebug() << ":::::" << item->text() << item->icon() << item->data(KDEProjectsModel::VcsLocationRole);

        QVERIFY(item);
        QVERIFY(!item->text().isEmpty());

        QVariant urls = item->data(KDEProjectsModel::VcsLocationRole);
        QVERIFY(urls.isValid());
        QVERIFY(urls.canConvert(QVariant::Map));
        QVariantMap mapurls=urls.toMap();
        for(QVariantMap::const_iterator it=mapurls.constBegin(), itEnd=mapurls.constEnd(); it!=itEnd; ++it) {
            QVERIFY(!it.key().isEmpty());
            QVERIFY(!it.value().toString().isEmpty());
        }

        QVERIFY(!item->data(KDEProjectsModel::VcsLocationRole).toMap().isEmpty());
    }
}
Example #21
0
void control::event2() {
    setA(false);
    setC(true);
    qDebug() << "Plastic Bottling Size Reached";
    qDebug() << "Molding Bottle";
    QTimer::singleShot(500, this, SLOT(event3()));
}
Example #22
0
QMimeData* BrowseTableModel::mimeData(const QModelIndexList &indexes) const {
    QMimeData *mimeData = new QMimeData();
    QList<QUrl> urls;

    // Ok, so the list of indexes we're given contains separates indexes for
    // each column, so even if only one row is selected, we'll have like 7
    // indexes.  We need to only count each row once:
    QList<int> rows;

    foreach (QModelIndex index, indexes) {
        if (index.isValid()) {
            if (!rows.contains(index.row())) {
                rows.push_back(index.row());
                QUrl url = QUrl::fromLocalFile(getTrackLocation(index));
                if (!url.isValid()) {
                    qDebug() << "ERROR invalid url\n";
                } else {
                    urls.append(url);
                    qDebug() << "Appending URL:" << url;
                }
            }
        }
    }
    mimeData->setUrls(urls);
    return mimeData;
}
Example #23
0
void Scanner::onDownload(QNetworkReply* reply)
{
    qDebug() << "onDownload";
    m_active = false;

    if(reply->error() != QNetworkReply::NoError) {
        qDebug() << reply->errorString();
        return;
    }

    qDebug() << "saving " << reply->url().toString();
    QString random = (QString) qrand();
    QString path = m_path + reply->url().fileName();

    QFile* file = new QFile(path);
    if(file->open(QIODevice::WriteOnly)) {
        file->write(reply->readAll());
    }
    file->flush();
    file->close();
    delete file;
    file = 0;

    if(!downloadQueue.isEmpty())
        BeginDownload();

    return;
}
Example #24
0
void sqldate::testNeiroHistoriDate()
{
    QFile file("test.txt");
    file.open(QIODevice::Append);
    QString str;
    QSqlQuery query = dbOrg->exec("SELECT * FROM histori WHERE (Col1!=\"\"&&winorloss!=\"\");");
    int a(0);
    while(query.next())
    {
        if(query.value(2).toString()!="-1")
        {
            a++;
            str = query.value(2).toString()+query.value(4).toString();
            //file.write(str.toUtf8());
            emit getTestd(str,query.value(0).toString());
            qDebug()<<a;
        }
    }/*
    for(int i(0);i<50;i++)
    {
        query.next();
        if(query.value(2).toString()!="-1")
        {
            a++;
            str = query.value(2).toString()+query.value(4).toString();
            //qDebug()<<query.value(0).toString();
            //file.write(str.toUtf8());
            emit getTestDate(query.value(0).toString());
        }
    }*/
    file.close();
    qDebug()<<a;
}
void MainWindow::showEvent(QShowEvent *)
{
	if (!_device)
	{
		if (!reconnectToDevice())
			return;

		QSettings settings;
		restoreGeometry("main-window", *this);
		restoreState(settings.value("state/main-window").toByteArray());

		qDebug() << "device found, opening session...";
		mtp::SessionPtr session;
		static const int MaxAttempts = 3;
		for(int attempt = 0; attempt < MaxAttempts; ++attempt)
		{
			try
			{
				session = _device->OpenSession(1);
				mtp::msg::DeviceInfo di = session->GetDeviceInfo();
				qDebug() << "device info" << fromUtf8(di.Manufacturer) << " " << fromUtf8(di.Model);
				break;
			}
			catch(const mtp::usb::TimeoutException &ex)
			{
				qDebug() << "timed out getting device info: " << fromUtf8(ex.what()) << ", retrying...";
				if (attempt + 1 == MaxAttempts)
				{
					QMessageBox::critical(this, tr("MTP"), tr("MTP device does not respond"));
					_device.reset();
					return;
				}
			}
			catch(const mtp::usb::DeviceNotFoundException &ex)
			{
				qDebug() << "device disconnected, retrying...";
				if (!reconnectToDevice())
					return;
			}
		}

		_storageModel = new MtpStoragesModel(this);
		while (!_storageModel->update(session))
		{
			int r = QMessageBox::warning(this, tr("No MTP Storages"),
				tr("No MTP storage found, your device might be locked.\nPlease unlock and press Retry to continue or Abort to exit."),
				QMessageBox::Retry | QMessageBox::Abort);
			if (r & QMessageBox::Abort)
			{
				_device.reset();
				return;
			}
		}
		_ui->storageList->setModel(_storageModel);
		_objectModel->setSession(session);
		onStorageChanged(_ui->storageList->currentIndex());
		qDebug() << "session opened, starting";
		_proxyModel->setSourceModel(_objectModel);
	}
}
Example #26
0
void SystemError::db_connection_error(QString err)
{
    //打印错误信息
    qDebug("--------------------------------------------------------------------");
    qDebug()<< "Time:" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
    qDebug()<< "system_error: " << err;
}
Example #27
0
void is_analysis_fun::set_on_dendrite()
{
    qDebug()<<"set on dendrite";
    open_main_win();
    //bool cur_flag=false;
    //cur_flag=check_cur_win();

    //update landmarks color and status
    //color for dendrite blue 85,170,255
    QList<QListWidgetItem*> sel_list=list_markers->selectedItems();
    qDebug()<<"this many selected:"<<sel_list.size();
    edit_box->clear();
    for (int i=0;i<sel_list.size();i++)
    {
        int mid= list_markers->row(sel_list[i]);
//        if (cur_flag)
//        {
//            LList_adj[mid].color.r=85;
//            LList_adj[mid].color.g=170;
//            LList_adj[mid].color.b=255;
//        }
        LList_out[mid].color.r=85;
        LList_out[mid].color.g=170;
        LList_out[mid].color.b=255;
        voxel_groups[mid].on_dendrite=true;
        sel_list[i]->setText("marker " + QString::number(mid+1) + " on dendrite");
        edit_box->appendPlainText("marker: " + QString::number(mid+1) + " are located on dendrite");
    }

    callback->setLandmark(main_win,LList_out);
    callback->pushObjectIn3DWindow(main_win);
//    if (cur_flag)
//        callback->setLandmark(curwin,LList_adj);
//        callback->pushObjectIn3DWindow(curwin);
}
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    StringProvider::loadTemplate();

    ui->setupUi(this);

    initLayout();

    sqlLiteProvider = new SqlLiteProvider();
    connect(sqlLiteProvider, SIGNAL(updateEventLogUI(QList<EventLog>)),
            this, SLOT(sloUpdateEventLogUI(QList<EventLog>)));
    sqlLiteProvider->loadDatabase();

    httpProvider = new HttpProvider();
    connect(httpProvider, SIGNAL(sigHttpFinished(QNetworkReply*)),
            this, SLOT(sloHttpFinished(QNetworkReply*)));

    connect(ui->tableScan, SIGNAL(signalInsertLog(EventLog)),
            this, SLOT(slotInsertLog(EventLog)));

    // Load metascan online key
    QSettings qs(SETTINGS_DOMAIN, SETTINGS_USER);
    QString moKey = qs.value(SETTINGS_MO_KEY).toString();
    StringProvider::METASCAN_ONLINE_KEY = moKey;
    if(moKey.isEmpty()) {
        qDebug() << "moKey = NULLLLL";
        SettingsDialog* dialogSettings = new SettingsDialog(this);
        dialogSettings->setModal(true);
        dialogSettings->show();
    } else {
        qDebug() << "moKey = " << moKey;
    }
}
Example #29
0
void SearchWidget::changeList2(QNetworkReply *reply)
{
    qDebug()<<"danny error type"<<reply->error();

    if(reply->error()== QNetworkReply::NoError)
    {
        lyricList.clear();
        //QString text = reply->readAll();

        QByteArray bytes = reply->readAll();  //获取字节
        QString result(bytes);  //转化为字符串
        qDebug()<<"changeList2 result:"<<result;
        qDebug()<<"changeList2 reply:"<<bytes;
        QTextCodec *codec = QTextCodec::codecForName("utf-8");
        //QString str = "0891683108500145F1240D91685143256178F0000831214281659423044F60597D";
        QString t = result;
        QStringList s;

        for(int i = 0;i < t.length();i += 4) {
        s.append(t.mid(i,4));
        }
        QString t1;

        foreach (const QString &t, s) {
        t1.append(t.toUShort(0,16));
        }
Example #30
0
void GdalAdapter::fromXML(QXmlStreamReader& stream)
{
    theBbox = QRectF();
    theImages.clear();

    while(!stream.atEnd() && !stream.isEndElement()) {
        if (stream.name() == "Images") {
            if (stream.attributes().hasAttribute("projection"))
                theProjection = stream.attributes().value("projection").toString();
            if (stream.attributes().hasAttribute("source"))
                theSourceTag = stream.attributes().value("source").toString();
            stream.readNext();
            while(!stream.atEnd() && !stream.isEndElement()) {
                if (stream.name() == "Image") {
                    QString fn = stream.attributes().value("filename").toString();
                    if (!fn.isEmpty())
                        loadImage(fn);
                    stream.readNext();
                } else if (!stream.isWhitespace()) {
                    qDebug() << "gdalimage: logic error: " << stream.name() << " : " << stream.tokenType() << " (" << stream.lineNumber() << ")";
                    stream.skipCurrentElement();
                }
                stream.readNext();
            }
        } else if (!stream.isWhitespace()) {
            qDebug() << "gdalmain: logic error: " << stream.name() << " : " << stream.tokenType() << " (" << stream.lineNumber() << ")";
            stream.skipCurrentElement();
        }

        stream.readNext();
    }
}