/*! Constructor. */ UsbUiSettingModel::UsbUiSettingModel( QObject *parent ) : QAbstractItemModel( parent), mSelectionModel(NULL) { mModelActive = new UsbUiModelActive(); mCurrentMode = currentMode(); initializeModelData(mCurrentMode); bool ret = mSettingsManager.startMonitoring( XQSettingsKey( XQSettingsKey::TargetCentralRepository, KCRUidUsbWatcher.iUid, KUsbWatcherPersonality ) ); myDebug() << ">>> UsbUiSettingModel::startMonitoring value=" << ret; // signal: personality changed in the central repository ret = connect( &mSettingsManager, SIGNAL( valueChanged( const XQSettingsKey&, const QVariant& ) ), this, SLOT( cenrepChanged( const XQSettingsKey&, const QVariant& ) ) ); myDebug() << ">>> UsbUiSettingModel::UsbUiSettingModel connect valueChanged=" << ret; // signal: response from usbwatcher to our attempt to set the personality ret = connect( mModelActive, SIGNAL( requestCompleted( int ) ), this, SLOT( personalitySetCompleted( int ))); myDebug() << ">>> UsbUiSettingModel::UsbUiSettingModel connect requestCompleted=" << ret; }
/*! * emits a signal when the request is completed */ void UsbUiModelActive::emitRequestCompleted( int status ) { myDebug() << ">>> UsbUiModelActive::emitRequestCompleted status: "; myDebug() << status; emit requestCompleted( status ); myDebug() << "<<< UsbUiModelActive::emitRequestCompleted"; }
KoReportItemMaps::KoReportItemMaps(QDomNode & element) { myDebug() << "======" << this; createProperties(); QDomNodeList nl = element.childNodes(); QString n; QDomNode node; m_name->setValue(element.toElement().attribute("report:name")); m_controlSource->setValue(element.toElement().attribute("report:item-data-source")); //m_resizeMode->setValue(element.toElement().attribute("report:resize-mode", "stretch")); Z = element.toElement().attribute("report:z-index").toDouble(); parseReportRect(element.toElement(), &m_pos, &m_size); myDebug() << "====== childgren:"; for (int i = 0; i < nl.count(); i++) { node = nl.item(i); n = node.nodeName(); // if (n == "report:Maps-data") { // // setInlineImageData(node.firstChild().nodeValue().toLatin1()); // } else { kDebug() << "====== while parsing image element encountered unknow element: " << n; // } } m_mapImage = new QImage(m_size.toScene().toSize(), QImage::Format_ARGB32); m_mapImage->fill(QColor(200, 150, 5).rgb()); }
QNetworkRequest inihandlerclass::requestfromini(const QString &inistring) { QFile f; f.setFileName(QApplication::applicationDirPath() + "/network/" + file); if (!f.open(QIODevice::ReadOnly)) { myDebug() << QObject::tr("the file network/wormnet.net is missing!"); } QTextStream ts(&f); while (ts.readLine() != inistring && !ts.atEnd()) ; if (ts.atEnd()) { myDebug() << QObject::tr("The file network/wormnet.net file is corrupt!") << inistring << QObject::tr(" can not be found, but is important."); } QNetworkRequest r; QStringList sl; QString s(ts.readLine()); while (!s.startsWith("[") && !ts.atEnd()) { if(!s.startsWith("//") && s!=""){ sl = s.split(" "); QString s1=sl.takeFirst(); QString s2=sl.join(" "); r.setRawHeader(s1.toAscii(), s2.toAscii()); } s = ts.readLine(); } return r; }
/*! Destructor. */ UsbUiModelActive::~UsbUiModelActive() { myDebug() << ">>> UsbUiModelActive::~UsbUiModelActive"; delete d; iUsbWatcher.Close(); myDebug() << "<<< UsbUiModelActive::~UsbUiModelActive"; }
/*! * Get the translated mode name for the personality friendly name. */ QString UsbUiSettingModel::modeName( QString &friendlyName ) { myDebug() << ">>> UsbUiSettingModel::modeName"; QString textId = TextIdPrefix + friendlyName; QString modeName = hbTrId( textId.toAscii() ); myDebug() << "<<< UsbUiSettingModel::modeName " << modeName; return modeName; }
/*! Constructor. */ UsbUiModelActivePrivate::UsbUiModelActivePrivate( UsbUiModelActive *parent, int priority ) : CActive( (TInt) priority ), q( parent ) { myDebug() << ">>> UsbUiModelActivePrivate::UsbUiModelActivePrivate"; CActiveScheduler::Add( this ); myDebug() << "<<< UsbUiModelActivePrivate::UsbUiModelActivePrivate"; }
/*! Destructor. */ UsbUiSettingModel::~UsbUiSettingModel() { myDebug() << ">>> UsbUiSettingModel::~UsbUiSettingModel"; mSettingsManager.stopMonitoring( XQSettingsKey( XQSettingsKey::TargetCentralRepository, KCRUidUsbWatcher.iUid, KUsbWatcherPersonality ) ); delete mModelActive; myDebug() << "<<< UsbUiSettingModel::~UsbUiSettingModel"; }
/*! Provides notification of changes in selected usb mode */ void UsbUiSettingModel::cenrepChanged( const XQSettingsKey &key, const QVariant &value ) { Q_UNUSED(key); myDebug() << ">>> UsbUiSettingModel::cenrepChanged"; // key is not checked, as we monitor only one key updateSelectionModel(value.toInt()); myDebug() << "<<< UsbUiSettingModel::cenrepChanged"; }
/*! * Get the current USB mode (personality) ID */ int UsbUiSettingModel::currentMode() { myDebug() << ">>> UsbUiSettingModel::CurrentMode"; int currentMode = mSettingsManager.readItemValue( XQSettingsKey( XQSettingsKey::TargetCentralRepository, KCRUidUsbWatcher.iUid, KUsbWatcherPersonality ) ).toInt(); myDebug() << "<<< UsbUiSettingModel::CurrentMode " << currentMode; return currentMode; }
int KoReportItemMaps::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, const QVariant &data, KRScriptHandler *script) { Q_UNUSED(script) myDebug() << this << "data:" << data; QString dataKey = data.toString(); QStringList dataList = dataKey.split(QLatin1Char(';')); //myDebug() << "splited:" << dataList; Marble::MarbleWidget* marble; if(m_marbles.count(dataKey)==0){ //no such marble yet marble = initMarble(); m_marbles.insert(dataKey, marble); connect(marble->model(), SIGNAL(modelChanged()), this, SLOT(requestRedraw())); if(dataList.count()==3){ marble->setCenterLatitude(dataList[0].toDouble()); marble->setCenterLongitude(dataList[1].toDouble()); marble->zoomView(dataList[2].toInt()); } }else{ marble = m_marbles[dataKey]; } marble->render(m_mapImage); OROImage * id = new OROImage(); id->setImage(*m_mapImage); id->setScaled(false); id->setPosition(m_pos.toScene() + offset); id->setSize(m_size.toScene()); OroIds oroIds; if (page) { page->addPrimitive(id); oroIds.pageId = id; myDebug() << "page:id=" <<id; } if (section) { OROImage *i2 = dynamic_cast<OROImage*>(id->clone()); i2->setPosition(m_pos.toPoint()); section->addPrimitive(i2); oroIds.sectionId = i2; myDebug() << "section:id=" << i2; } if (!page) { delete id; oroIds.pageId=0; } oroIds.marbleWidget = marble; m_marbleImgs[marble->model()]=oroIds; return 0; //Item doesn't stretch the section height }
/*! Constructor. */ UsbUiModelActive::UsbUiModelActive( int priority, QObject *parent ) : QObject( parent ) { myDebug() << ">>> UsbUiModelActive::UsbUiModelActive"; d = new UsbUiModelActivePrivate( this, priority ); int err= iUsbWatcher.Connect(); myDebug() << "iUsbWatcher.Connect() returned "; myDebug() << err; myDebug() << "<<< UsbUiModelActive::UsbUiModelActive"; }
void UsbUiSettingModel::setSelectionModel(QItemSelectionModel *selectionModel) { myDebug() << ">>> UsbUiSettingModel::setSelectionModel"; mSelectionModel = selectionModel; connect( mSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection & ) ), this, SLOT( handleSelectionChange( const QItemSelection &, const QItemSelection & ) ) ); updateSelectionModel(mCurrentMode); myDebug() << "<<< UsbUiSettingModel::setSelectionModel return"; }
/*! * it checks the response from usbwatcher to see if the new mode change has been successful * it will go back to the previous personality if it has not been successful */ void UsbUiSettingModel::personalitySetCompleted (int status ) { myDebug() << ">>> UsbUiSettingModel::personalitySetCompleted status= " << status; // status contains Symbian error code from usbwatcher // if the status is KErrNone, we are ready to process the next request if (status != KErrNone) { // changing the personality failed, so we need to set back the previous personality // the value will be read from central repository and also updates mCurrentMode updateSelectionModel(currentMode()); } myDebug() << "<<< UsbUiSettingModel::personalitySetCompleted"; }
void KoReportItemMaps::requestRedraw() { myDebug() << sender(); QImage tmpImg(*m_mapImage); Marble::MarbleModel* marbleModel = dynamic_cast<Marble::MarbleModel*>(sender()); OroIds *oroIds = &m_marbleImgs[marbleModel]; oroIds->marbleWidget->render(&tmpImg); if(oroIds->pageId) oroIds->pageId->setImage(tmpImg); if(oroIds->sectionId) oroIds->sectionId->setImage(tmpImg); myDebug() << "pageId sectionId marbleWidget"; myDebug() << oroIds->pageId << oroIds->sectionId << oroIds->marbleWidget; }
bool UsbUiSettingModel::isPersonalityHidden(RUsb &usbman, TInt personalityId) { myDebug() << ">>> UsbUiSettingModel::isPersonalityHidden from USB Manager"; bool hidden = false; TUint32 property = 0; TInt ret = usbman.GetPersonalityProperty(personalityId, property); if (ret == KErrNone) { myDebug() << "property " << property; if (property & KUsbPersonalityPropertyHidden) { hidden = true; } } myDebug() << "<<< UsbUiSettingModel::isPersonalityHidden " << hidden; return hidden; }
int bridgeList(void *magic, char *line) { EVMod *mod = (EVMod *)magic; HSP_mod_OVS *mdata = (HSP_mod_OVS *)mod->data; // we're looking for the lines that have "name : <bridge-name>" // or specifically the sequence: // name // <whitespace> // : // <whitespace> // <bridge-name> // sscanf with format string "name%*[\t ]:%*[\t ]%s" works, but // assumes that the whitespace is not empty. I don't think we // can necessarily assume that (?) char bridgeName[SFVS_MAX_LINELEN]; if(sscanf(line, "name%*[\t ]:%*[\t ]%s", bridgeName) == 1) { // copy the bridge name char *br = stripQuotes(bridgeName, SFVS_QUOTES); myDebug(1, "bridgeList> %s", br); if(br && (br[0] != '\0')) { setStr(&mdata->bridge, br); // now run a command to check (and possible change) the bridge sFlow setting char *bridge_get_sflow_cmd[] = { SFVS_OVS_CMD, "get", "bridge", br, "sflow", NULL }; char line[SFVS_MAX_LINELEN]; if(myExec(mod, bridge_get_sflow_cmd, bridgeGetSFlow, line, SFVS_MAX_LINELEN, NULL) == NO) return NO; } } return YES; }
//------------------------------------------------------------------------------ QString getTextFromHtmlFile(QString filePath) { QString str = ""; QFile file(filePath); // qDebug() << filePath; file.close(); if (file.exists()) { if (file.open(QIODevice::ReadOnly)) { QTextStream stream(&file); QString encoding = getEncodingFromFile(filePath); stream.setCodec(getCodecOfEncoding(encoding)); str = stream.readAll(); // // qDebug() << "str = " << str; // int body = QString("<body>").length(); // int posBegin = str.indexOf("<body>"); // int posEnd = str.indexOf("</body>"); // str = str.mid(posBegin + body, // posEnd - posBegin - body); file.close(); } else { myDebug() << "Error: not open file(getTextFromHtmlFile):" << filePath; } } return str; }
//------------------------------------------------------------------------------ QString getParamModule(QString filename, QString param) { // translate to hindi QString str = ""; QString line; QString parama = param + " = "; QFile file(filename); if (file.isOpen()) file.close(); if (file.open(QIODevice::ReadOnly)) { QTextStream stream( &file ); do { line = stream.readLine(); if (line.indexOf(parama) >= 0) { str = line.remove(parama); } } while (str.isEmpty() and !line.isNull()); file.close(); } else { myDebug() << "Error: not get param. Param: " << param; } return str; }
int Commentary::loadModuleData(const int moduleID) { myDebug() << moduleID; m_loaded = false; m_module = m_map->module(moduleID); m_moduleID = moduleID; m_moduleType = m_module->moduleType(); if(m_module->m_commentaryModule.isNull()) { m_commentaryModule = m_module->newCommentaryModule(moduleType()); } else { m_commentaryModule = m_module->m_commentaryModule; } if(m_commentaryModule == nullptr) { myWarning() << "invalid module"; return 1; } m_commentaryModule->setSettings(m_settings); if(m_commentaryModule->loadModuleData(m_moduleID, m_module->path()) != 0) { myWarning() << "loading failed"; return 1; } m_versification = m_commentaryModule->versification(); m_loadedModuleID = m_moduleID; m_loaded = true; return 0; }
/*! * Sets the the selected personality through usbwatcher */ void UsbUiModelActive::SetUsbPersonality(int personality) { myDebug() << ">>> UsbUiModelActive::SetUsbPersonality"; myDebug() << "requested personality is "; myDebug() << personality; // Change the personality asynchrously, result checked in RunL() if( IsActive() ) { Cancel(); } myDebug() << "setting new personality"; iUsbWatcher.SetPersonality(RequestStatus(), personality); SetActive(); myDebug() << "<<< UsbUiModelActive::SetUsbPersonality"; }
/** * Emits get to load the selected module. */ void ModuleDockWidget::loadModuleData(QModelIndex index, Actions::OpenLinkModifiers mod) { const int moduleID = index.data(Qt::UserRole + 1).toInt(); if(m_dontLoad == false && moduleID >= 0) { Module *m = m_moduleManager->getModule(moduleID); //const OBVCore::ModuleType type = m->moduleType(); const OBVCore::ModuleClass cl = m->moduleClass(); if(cl == OBVCore::DictionaryModuleClass) { m_actions->get("dict:/" + QString::number(moduleID), mod); } else if(cl == OBVCore::WebPageClass) { m_actions->get("webpage:/" + QString::number(moduleID), mod); } else if(cl == OBVCore::BibleModuleClass) { myDebug() << "bible"; m_moduleID = moduleID; VerseUrl url; VerseUrlRange range; range.setModule(moduleID); range.setBook(VerseUrlRange::LoadFirstBook); range.setChapter(VerseUrlRange::LoadFirstChapter); range.setWholeChapter(); url.addRange(range); m_actions->get(url, mod); } } }
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); connect(ui->logText, SIGNAL(returnPressed()), ui->logButton, SLOT(animateClick())); connect(ui->warningText, SIGNAL(returnPressed()), ui->warningButton, SLOT(animateClick())); connect(ui->criticalText, SIGNAL(returnPressed()), ui->criticalButton, SLOT(animateClick())); connect(ui->logButton, &QPushButton::clicked, [&](){ if (!ui->logText->text().isEmpty()) { myDebug() << ui->logText->text(); } }); connect(ui->warningButton, &QPushButton::clicked, [&](){ if (!ui->warningText->text().isEmpty()) { myWarning() << ui->warningText->text(); } }); connect(ui->criticalButton, &QPushButton::clicked, [&](){ if (!ui->criticalText->text().isEmpty()) { myCritical() << ui->criticalText->text(); } }); }
/*! * This is called when usb selection is changed in the view (selection model). */ void UsbUiSettingModel::handleSelectionChange(const QItemSelection &selected, const QItemSelection &deselected ) { Q_UNUSED( deselected ); myDebug() << ">>> UsbUiSettingModel::handleSelectionChange"; QModelIndexList items = selected.indexes(); if (!items.isEmpty()) { myDebug() << " UsbUiSettingModel::handleSelectionChange item exists"; QModelIndex index = items[0]; int newPersonalityId = mPersonalityIds.at(index.row()); if ( newPersonalityId != mCurrentMode ) { myDebug() << " UsbUiSettingModel::handleSelectionChange setting personality"; mModelActive->SetUsbPersonality(newPersonalityId); } } myDebug() << "<<< UsbUiSettingModel::handleSelectionChange return"; }
// 初始化 void MyApp::init(QApplication &app) { m_strAppPath = app.applicationDirPath() + "/"; #ifdef Q_OS_UNIX if (!m_strAppPath.startsWith("/")) { myDebug("m_strAppPath no start with /" << m_strAppPath) ; m_strAppPath = "/" + m_strAppPath; } #endif m_strDataPath = m_strAppPath + "data/"; m_strLogPath = m_strDataPath + "log"; m_strTestPath = m_strDataPath + "test/"; m_strDownloadPath = m_strAppPath + "download/"; m_strScreenShotPath = m_strDataPath + "screen_shot/"; m_strWavPath = m_strDataPath + "wav_normal/"; m_strRecordPath = m_strDataPath + "record/"; m_strDbPath = m_strDataPath + "database/"; m_strBackupPath = m_strDataPath + "backup/"; m_strConfPath = m_strDataPath + "conf/"; m_strIniFile = m_strConfPath + "config.ini"; // 检查目录 checkDirs(); // 创建配置文件 creatorSettingFile(); // 读取设备编号 m_strDevId = getSettingKeyValue("SysConfig", "DeviceId", "59909200001").toString(); // 数据上传服务器配置 m_strDataServerAddr = getSettingKeyValue("DataServer", "IpAddr", "222.180.250.162").toString(); m_nDataServerPort = getSettingKeyValue("DataServer", "Port", 5100).toInt(); // 系统升级配置 m_strUpServerUrl = getSettingKeyValue("Version", "AppUrl", "http://121.40.121.132:9191/apps/vict_app").toString(); m_strCheckVersion = getSettingKeyValue("Version", "VerUrl", "http://121.40.121.132:9191/vict_version.php").toString(); m_strAppName = getSettingKeyValue("Version", "AppName", "vict_app").toString(); // 音量控制 m_nSysVolume = getSettingKeyValue("SysConfig", "SysVolume", 127).toInt(); m_nRecVolume = getSettingKeyValue("SysConfig", "RecVolume", 85).toInt(); // SMTP m_strSmtpAddr = getSettingKeyValue("Server", "SmtpAddr", "220.181.12.12").toString(); // 读取用户配置 m_strMsgServer = getSettingKeyValue("Server", "MsgServer", "183.230.8.172").toString(); m_nUdpRoomPort = getSettingKeyValue("Server", "UdpRoom", 43434).toInt(); m_nTcpMsgPort = getSettingKeyValue("Server", "MsgProt", 60001).toInt(); m_nTcpFilePort = getSettingKeyValue("Server", "FilePort", 60001).toInt(); m_nUserId = getSettingKeyValue("MsgUser", "Id", 101).toInt(); m_strPwd = getSettingKeyValue("MsgUser", "Passwd", "123").toString(); }
/*! USBIndicator::handleInteraction */ bool USBIndicator::handleInteraction(InteractionType type) { myDebug() << ">>> USBIndicator::handleInteraction"; bool handled = false; TUidType uidtype(KExecutableImageUid, TUid::Uid(0x00), TUid::Uid(KUSBUIUid)); if (type == InteractionActivated) { RProcess usbUiProcess; TInt result = usbUiProcess.Create(KUSBExe(), KNullDesC, uidtype); if (result == KErrNone) { usbUiProcess.Resume(); } usbUiProcess.Close(); handled = true; } myDebug() << "<<< USBIndicator::handleInteraction"; return handled; }
QString UsbUiSettingModel::getFriendlyName(RUsb &usbman, TInt personalityId) { myDebug() << ">>> UsbUiSettingModel::getFriendlyName"; QString friendlyName; HBufC* description = NULL; TInt err = usbman.GetDescription(personalityId, description); if (err == KErrNone) { friendlyName = QString::fromUtf16(description->Ptr(), description->Length()); friendlyName.replace( QChar(' '), QChar('_') ); delete description; } else { myDebug() << " UsbUiSettingModel::getFriendlyName RUsb error " << err; } myDebug() << " UsbUiSettingModel::getFriendlyName friendlyName=" << friendlyName; myDebug() << "<<< UsbUiSettingModel::getFriendlyName"; return friendlyName; }
/*! * updates the selection model * The selection model will signal the view. */ void UsbUiSettingModel::updateSelectionModel(int newPersonality) { myDebug() << ">>> UsbUiSettingModel::updateSelectionModel value=" << newPersonality; mCurrentMode = newPersonality; mSelectionModel->clear(); int row = mPersonalityIds.indexOf(newPersonality); myDebug() << ">>> UsbUiSettingModel::updateSelectionModel row=" << row; // in case of the hidden personality , the selection model is left empty if ( row >= 0 ) { //set selection model for the new selection QModelIndex selectionIndex = index(row, 0, QModelIndex()); QItemSelection selection(selectionIndex, selectionIndex); mSelectionModel->select(selection, QItemSelectionModel::Select); } myDebug() << "<<< UsbUiSettingModel::updateSelectionModel"; }
void UsbUiSettingModel::initializeModelData( int aModeId ) { myDebug() << ">>> UsbUiSettingModel::initializeModelData aModeId=" << aModeId; RUsb usbMan; if ( usbMan.Connect() == KErrNone ) { RArray<TInt> personalityIds; mPersonalityIds.clear(); if ( usbMan.GetPersonalityIds( personalityIds ) == KErrNone ) { for ( int i = 0; i < personalityIds.Count(); i++ ) { myDebug() << ">>> UsbUiSettingModel::initializeModelData personality ID =" << personalityIds[i]; if ( !isPersonalityHidden(usbMan, personalityIds[i]) ) { mPersonalityIds.append( personalityIds[i] ); QString friendlyName = getFriendlyName(usbMan, personalityIds[i]); QStringList displayList; //text-1 mode name displayList.append( modeName( friendlyName ) ); //text-2 description QString textId = TextIdPrefix + friendlyName + DescriptionIdPostfix; displayList.append( hbTrId(textId.toAscii()) ); QMap< int, QVariant > dataRow; dataRow[ Qt::DisplayRole ] = QVariant( displayList ); //icon-1 QString iconName = ModeIconNamePrefix + friendlyName; HbIcon icon(iconName); QList<QVariant> icons; icons << icon; dataRow[ Qt::DecorationRole ] = QVariant( icons ); mSettingsList << dataRow; } } } personalityIds.Close(); usbMan.Close(); } myDebug() << "<<< UsbUiSettingModel::initializeModelData"; }
KoReportItemMaps::~KoReportItemMaps() { myDebug() << "DIE:" << this << m_marbles.count(); delete m_mapImage; delete m_set; QMap<QString, Marble::MarbleWidget*>::iterator i = m_marbles.begin(); while(i != m_marbles.end()){ delete i.value(); i++; } }