本文整理汇总了C++中QString::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QString::append方法的具体用法?C++ QString::append怎么用?C++ QString::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QString
的用法示例。
在下文中一共展示了QString::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Find
void AliasesFindDialog::Find(){
QString StringFind;
QString StringDomain;
if( lineEdit_Domain->isEnabled() ){
StringDomain.append("%");
StringDomain.append(lineEdit_Domain->text());
StringDomain.append("%");
}else{
StringDomain="%%";
}
StringFind.append("%");
StringFind.append(lineEdit_Find->text());
StringFind.append("%");
TestQuery();
if( db_psql.isOpen() ){
if(tableWidget_Find->isSortingEnabled()){
tableWidget_Find->setSortingEnabled(false);
}
tableWidget_Find->clearContents();
tableWidget_Find->setRowCount(0);
QSqlQuery query( db_psql );
if(comboBox->currentIndex() == 0){
query.prepare("SELECT local_part,domain,recipients FROM aliases_view WHERE local_part ILIKE :find and domain ILIKE :domain");
}else{
query.prepare("SELECT local_part,domain,recipients FROM aliases_view WHERE recipients ILIKE :find and domain ILIKE :domain");
}
query.bindValue(":find", StringFind);
query.bindValue(":domain", StringDomain);
if( !query.exec() ){
QMessageBox::warning(this, tr("Query Error"),
query.lastError().text(),
QMessageBox::Ok);
query.clear();
}else{
for(int i = 0; i < query.size(); i++){
query.next();
tableWidget_Find->setRowCount(i + 1);
__item0 = new QTableWidgetItem();
__item0->setText(query.value(0).toString());
tableWidget_Find->setItem(i, 0, __item0);
__item1 = new QTableWidgetItem();
__item1->setText(query.value(1).toString());
tableWidget_Find->setItem(i, 1, __item1);
__item2 = new QTableWidgetItem();
__item2->setText(query.value(2).toString());
tableWidget_Find->setItem(i, 2, __item2);
}
}
tableWidget_Find->setSortingEnabled(true);
query.clear();
}else{
this->reject();
}
}
示例2: commitChanges
bool QgsVectorLayerEditBuffer::commitChanges( QStringList& commitErrors )
{
QgsVectorDataProvider* provider = L->dataProvider();
commitErrors.clear();
int cap = provider->capabilities();
bool success = true;
// geometry updates attribute updates
// yes no => changeGeometryValues
// no yes => changeAttributeValues
// yes yes => changeFeatures
//
// update geometries
//
if ( !mChangedGeometries.isEmpty() && (( cap & QgsVectorDataProvider::ChangeFeatures ) == 0 || mChangedAttributeValues.isEmpty() ) )
{
if ( provider->changeGeometryValues( mChangedGeometries ) )
{
commitErrors << tr( "SUCCESS: %n geometries were changed.", "changed geometries count", mChangedGeometries.size() );
emit committedGeometriesChanges( L->id(), mChangedGeometries );
mChangedGeometries.clear();
}
else
{
commitErrors << tr( "ERROR: %n geometries not changed.", "not changed geometries count", mChangedGeometries.size() );
success = false;
}
}
QgsFields oldFields = L->fields();
//
// delete attributes
//
bool attributesChanged = false;
if ( !mDeletedAttributeIds.isEmpty() )
{
if (( cap & QgsVectorDataProvider::DeleteAttributes ) && provider->deleteAttributes( mDeletedAttributeIds.toSet() ) )
{
commitErrors << tr( "SUCCESS: %n attribute(s) deleted.", "deleted attributes count", mDeletedAttributeIds.size() );
emit committedAttributesDeleted( L->id(), mDeletedAttributeIds );
mDeletedAttributeIds.clear();
attributesChanged = true;
}
else
{
commitErrors << tr( "ERROR: %n attribute(s) not deleted.", "not deleted attributes count", mDeletedAttributeIds.size() );
#if 0
QString list = "ERROR: Pending attribute deletes:";
Q_FOREACH ( int idx, mDeletedAttributeIds )
{
list.append( ' ' + L->pendingFields().at( idx ).name() );
}
commitErrors << list;
#endif
success = false;
}
}
示例3: while
QTextDocument *MyPrint::print(QSqlQueryModel *model, RowList colHeaders, QString title, QString footer, int groupCols = 0)
{
QString body;
QStringList colls;
body.append("<html><head>"
"<link rel='stylesheet' type='text/css' href='format.css'>"
"</head><body>");
if (title!="")
body.append("<center><H2>" + title + "</H2></center><br>");
body.append("<center><table border='1' class = 'mine'><tr>");
RowList::const_iterator i = colHeaders.constBegin();
while (i != colHeaders.constEnd()) {
colls.append(QString::number(i.key()));
body.append("<th>" + i.value() + "</th>\n");
++i;
}
body.append("</tr>\n");
while (model->canFetchMore())
model->fetchMore();
QMap<int,QString> groupTitles; // заголовки групп groupTitles(номер колонки, название группы)
QMap<int,int> groupCounts; // количество элементов в группе groupCounts(номер колонки, кол-во)
for (int index = 0; index < model->rowCount(); index++)
{
body.append("<tr>\n");
for (int listId = 0; listId < colls.count(); listId++)
{
if(listId < groupCols) // если колонки нужно сгруппировать(если это групируемая колонка)
{
if(groupTitles.value(listId) != model->record(index).value(colls[listId].toInt()).toString())
{
groupTitles[listId] = model->record(index).value(colls[listId].toInt()).toString();
body.append("<td class='grHead' colspan = '"+QString::number(colls.count()-listId)+"'><b>");
body.append(groupTitles[listId]);
body.append("</b></td>\n</tr>\n<tr>\n");
if(listId == groupCols-1)
for(int i=0; i < listId + 1; i++)
body.append("<td>1</td>\n");
else
for(int i=0; i < listId + 1; i++)
body.append("<td></td>\n");
groupCounts[listId] = 1;
}
else
{
groupCounts[listId] = groupCounts[listId] + 1;
body.append("<td>" + QString::number(groupCounts[listId]) + "</td>\n");
}
}
else
{
body.append("<td>");
body.append(model->record(index).value(colls[listId].toInt()).toString());
body.append("</td>\n");
}
}
body.append("</tr>\n");
}
body.append("</table></center>");
if (footer!="")
body.append("<center>" + footer + "</center>");
body.append("</body></html>");
// qDebug()<<body;
QTextDocument *toPrint = new QTextDocument;
// toPrint->addResource(QTextDocument::ImageResource, QUrl( "bg.png" ), QPixmap(":/img/img/institution_icon.png") );
toPrint->addResource(QTextDocument::StyleSheetResource, QUrl( "format.css" ), css->reportCss);
toPrint->setHtml(body);
return toPrint;
}
示例4: QWidget
QT_BEGIN_NAMESPACE
FindWidget::FindWidget(QWidget *parent)
: QWidget(parent)
, appPalette(qApp->palette())
{
TRACE_OBJ
installEventFilter(this);
QHBoxLayout *hboxLayout = new QHBoxLayout(this);
QString resourcePath = QLatin1String(":/qt-project.org/assistant/images/");
#ifndef Q_OS_MAC
hboxLayout->setMargin(0);
hboxLayout->setSpacing(6);
resourcePath.append(QLatin1String("win"));
#else
resourcePath.append(QLatin1String("mac"));
#endif
toolClose = setupToolButton(QLatin1String(""),
resourcePath + QLatin1String("/closetab.png"));
hboxLayout->addWidget(toolClose);
connect(toolClose, SIGNAL(clicked()), SLOT(hide()));
editFind = new QLineEdit(this);
hboxLayout->addWidget(editFind);
editFind->setMinimumSize(QSize(150, 0));
connect(editFind, SIGNAL(textChanged(QString)), this,
SLOT(textChanged(QString)));
connect(editFind, SIGNAL(returnPressed()), this, SIGNAL(findNext()));
connect(editFind, SIGNAL(textChanged(QString)), this, SLOT(updateButtons()));
toolPrevious = setupToolButton(tr("Previous"),
resourcePath + QLatin1String("/previous.png"));
connect(toolPrevious, SIGNAL(clicked()), this, SIGNAL(findPrevious()));
hboxLayout->addWidget(toolPrevious);
toolNext = setupToolButton(tr("Next"),
resourcePath + QLatin1String("/next.png"));
hboxLayout->addWidget(toolNext);
connect(toolNext, SIGNAL(clicked()), this, SIGNAL(findNext()));
checkCase = new QCheckBox(tr("Case Sensitive"), this);
hboxLayout->addWidget(checkCase);
labelWrapped = new QLabel(this);
labelWrapped->setScaledContents(true);
labelWrapped->setTextFormat(Qt::RichText);
labelWrapped->setMinimumSize(QSize(0, 20));
labelWrapped->setMaximumSize(QSize(105, 20));
labelWrapped->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter);
labelWrapped->setText(tr("<img src=\":/qt-project.org/assistant/images/wrap.png\""
"> Search wrapped"));
hboxLayout->addWidget(labelWrapped);
QSpacerItem *spacerItem = new QSpacerItem(20, 20, QSizePolicy::Expanding,
QSizePolicy::Minimum);
hboxLayout->addItem(spacerItem);
setMinimumWidth(minimumSizeHint().width());
labelWrapped->hide();
updateButtons();
}
示例5: readSerial
int SerialThread::readSerial(int timeout)
{
if (!m_logInFile || !m_logInOutFile)
{
if (m_logsEnabled)
{
openLogs();
}
}
qint64 currms = QDateTime::currentMSecsSinceEpoch();
int readlen = m_buffer.size();
QByteArray qbuffer;
if (m_buffer.size() > 10240)
{
//Error here somehow;
Q_ASSERT(m_buffer.size() < 10240);
}
unsigned char buffer[10240];
qbuffer.append(m_buffer);
/*for (int i=0;i<m_buffer.size();i++)
{
buffer[i] = m_buffer[i];
qbuffer.append(m_buffer[i]);
}*/
m_buffer.clear();
//bool inpacket = false;
//bool inescape = false;
QString byteoutofpacket;
while (currms + timeout > QDateTime::currentMSecsSinceEpoch())
{
#ifdef Q_OS_WIN32
if (!ReadFile(m_portHandle,(LPVOID)buffer,1024,(LPDWORD)&readlen,NULL))
{
//Serial error here
qDebug() << "Serial Read error";
}
#else
readlen = read(m_portHandle,buffer,1024);
#endif //Q_OS_WIN32
if (readlen < 0)
{
//Nothing on the port
msleep(10);
}
else
{
if (m_logsEnabled)
{
m_logInFile->write((const char*)buffer,readlen);
m_logInFile->flush();
}
}
if (readlen == 0)
{
msleep(10);
}
for (int i=0;i<readlen;i++)
{
if (buffer[i] == 0xAA)
{
if (m_inpacket)
{
//Start byte in the middle of a packet
//Clear out the buffer and start fresh
m_inescape = false;
if (m_logsEnabled)
{
m_logWriteMutex.lock();
m_logInOutFile->write(QByteArray().append(0xAA));
QByteArray nbuffer(qbuffer);
nbuffer.replace(0xBB,QByteArray().append(0xBB).append(0x44));
nbuffer.replace(0xAA,QByteArray().append(0xBB).append(0x55));
nbuffer.replace(0xCC,QByteArray().append(0xBB).append(0x33));
m_logInOutFile->write((const char*)nbuffer.data(),nbuffer.size());
m_logInOutFile->write(QByteArray().append(0xCC));
m_logInOutFile->flush();
m_logWriteMutex.unlock();
}
qbuffer.clear();
qDebug() << "Buffer error";
m_packetErrorCount++;
}
//qbuffer.append(buffer[i]);
//qDebug() << "Start of packet";
//Start of packet
m_inpacket = true;
}
else if (buffer[i] == 0xCC && m_inpacket)
{
//qDebug() << "End of packet. Size:" << qbuffer.size();
//End of packet
m_inpacket = false;
//qbuffer.append(buffer[i]);
//m_logFile->flush();
//emit parseBuffer(qbuffer);
//New Location of checksum
//.........这里部分代码省略.........
示例6: RunButtonPress
void TicTacToe::RunButtonPress(QPushButton *b)
{
int quad = -1;
if(b == ui->TopLeft_Button)
quad = 0;
if(b == ui->TopMiddle_Button)
quad = 1;
if(b == ui->TopRight_Button)
quad = 2;
if(b == ui->MiddleLeft_Button)
quad = 3;
if(b == ui->MiddleMiddle_Button)
quad = 4;
if(b == ui->MiddleRight_Button)
quad = 5;
if(b == ui->BottomLeft_Button)
quad = 6;
if(b == ui->BottomMiddle_Button)
quad = 7;
if(b == ui->BottomRight_Button)
quad = 8;
if(is_X)
{
is_X = false;
SetButton(&b,"X");
}
else
{
is_X = true;
SetButton(&b,"O");
}
if(quad == 0)
ui->TopLeft_Button = b;
if(quad == 1)
ui->TopMiddle_Button = b;
if(quad == 2)
ui->TopRight_Button = b;
if(quad == 3)
ui->MiddleLeft_Button = b;
if(quad == 4)
ui->MiddleMiddle_Button = b;
if(quad == 5)
ui->MiddleRight_Button = b;
if(quad == 6)
ui->BottomLeft_Button = b;
if(quad == 7)
ui->BottomMiddle_Button = b;
if(quad == 8)
ui->BottomRight_Button = b;
if(hasWinner())
{
QMessageBox::Icon w = QMessageBox::Information;
QString s;
s.append(&winner);
s.append(" has won!");
QMessageBox *winner = new QMessageBox("Winner",s,w,0,DIALOG_OK_BUTTON,0,this,Qt::MSWindowsFixedSizeDialogHint);
winner->show();
connect(winner,SIGNAL(finished(int)),this,SLOT(MBoxClose(int)));
return;
}
if(isFull())
{
QMessageBox::Icon i = QMessageBox::Information;
QMessageBox *b = new QMessageBox("CAT","The Game ended in a tie.",i,0,DIALOG_OK_BUTTON,0,this,Qt::MSWindowsFixedSizeDialogHint);
b->show();
connect(b,SIGNAL(finished(int)),this,SLOT(MBoxClose(int)));
}
}
示例7: release
void ReleaseDialog::release()
{
setTitle("发布版本");
QString pwd = lineedit_pwd->text();
QString name = lineedit_name->text();
if(pwd.isEmpty() || name.isEmpty() || name.size() > 16)
{
QString prompt;
prompt = QString("必须设置加密密码\n填写版本信息。");
if(name.size() > 16)
prompt = QString("版本信息不能超过16个字符。");
QMessageBox box(QMessageBox::Information, "提示", prompt);
box.setStandardButtons(QMessageBox::Ok);
box.setButtonText(QMessageBox::Ok, "确定");
box.exec();
return;
}
////name 最大16个字符
if(!setFilePath())
{
QMessageBox::information(NULL, "提示", "文件路径设置失败!");
return;
}
bar->setHidden(false);
QDateTime start,end;
getDateTime(start, end);
QString jsonfilePath = getReadFilePath(start, end);
this->setCursor(Qt::WaitCursor);
///读JSON下载资源
readJsonFile(jsonfilePath);
///打包
QStringList fileNames = getCurrentDirFiles(releasePath);
QString destPath = QCoreApplication::applicationDirPath();
destPath.append("/ZIP/");
QDir dir(destPath);
if(!dir.exists())
dir.mkpath(destPath);
QString destName = currentDate.toString("yyyy-MM-dd_hh_mm_ss");
destName.append(".zip");
destPath.append(destName);
QFile destFile(destPath);
if(destFile.exists())
{
}
zipFile zf;
QByteArray dest = destPath.toLocal8Bit();
zf = zipOpen(dest.data(), APPEND_STATUS_CREATE);
if (zf == NULL)
{
QMessageBox::information(NULL, "提示", "打开压缩文件失败!");
return;
}
label_title->setText("压缩文件……");
// LOKI_ON_BLOCK_EXIT(zipClose, zf, (const char *)NULL);
for (int i=0; i<fileNames.size(); i++)
{
QString tempStr = fileNames.at(i);
QString path = releasePath;
path.remove("music");
QString temprel = path;
QString deststr = tempStr.remove(temprel);
if (!ZipAddFile(zf, deststr, fileNames.at(i), pwd, true)) //"default_yqc"
{
continue;
}
}
int errclose = zipClose(zf, NULL);
if (errclose != ZIP_OK)
qDebug() << " zipClose ret : " << errclose;
label_title->setText("上传压缩包……");
QFile file(destPath);
qDebug() << " size " << file.size();
if(file.size()/1024/1024 >= 1024)
{
QMessageBox::information(this, "提示", "上传文件大小必须小于1G!");
return;
}
///上传打包文件
// QString url;
// CurlUpload *curlUpload = new CurlUpload();
// bool ok = curlUpload->uploadYQDyun(destName, destPath, url);
// if(!ok)
// {
// url = "";
//.........这里部分代码省略.........
示例8: parseBuffer
void LogLoader::parseBuffer(QByteArray buffer)
{
if (buffer.size() <= 3)
{
qDebug() << "Not long enough to even contain a header!";
return;
}
//Trim off 0xAA and 0xCC from the start and end
buffer = buffer.mid(1);
buffer = buffer.mid(0,buffer.length()-1);
//qDebug() << "Packet:" << QString::number(buffer[1],16) << QString::number(buffer[buffer.length()-2],16);
QByteArray header;
//currPacket.clear();
//Parse the packet here
int headersize = 3;
int iloc = 0;
bool seq = false;
bool len = false;
if (buffer[iloc] & 0x4)
{
//Has header
seq = true;
//qDebug() << "Has seq";
headersize += 1;
}
if (buffer[iloc] & 0x1)
{
//Has length
len = true;
//qDebug() << "Has length";
headersize += 2;
}
header = buffer.mid(0,headersize);
iloc++;
unsigned int payloadid = (unsigned int)buffer[iloc] << 8;
payloadid += (unsigned char)buffer[iloc+1];
//qDebug() << QString::number(payloadid,16);
//qDebug() << QString::number(buffer[iloc-1],16);
//qDebug() << QString::number(buffer[iloc],16);
//qDebug() << QString::number(buffer[iloc+1],16);
//qDebug() << QString::number(buffer[iloc+2],16);
iloc += 2;
//qDebug() << QString::number(payloadid,16);
if (seq)
{
//qDebug() << "Sequence number" << QString::number(currPacket[iloc]);
iloc += 1;
}
QByteArray payload;
if (len)
{
//qDebug() << "Length found, buffer size:" << buffer.length() << "iloc:" << QString::number(iloc);
unsigned int length = buffer[iloc] << 8;
length += buffer[iloc+1];
//qDebug() << "Length:" << length;
iloc += 2;
//curr += length;
payload.append(buffer.mid(iloc,length));
}
else
{
//qDebug() << "Buffer length:" << buffer.length();
//qDebug() << "Attempted cut:" << buffer.length() - iloc;
payload.append(buffer.mid(iloc),(buffer.length()-iloc) -1);
}
//qDebug() << "Payload";
QString output;
for (int i=0;i<payload.size();i++)
{
int num = (unsigned char)payload[i];
output.append(" ").append((num < 0xF) ? "0" : "").append(QString::number(num,16));
}
//qDebug() << output;
output.clear();
//qDebug() << "Header";
for (int i=0;i<header.size();i++)
{
int num = (unsigned char)header[i];
output.append(" ").append((num < 0xF) ? "0" : "").append(QString::number(num,16));
}
//qDebug() << output;
//Last byte of currPacket should be out checksum.
unsigned char sum = 0;
for (int i=0;i<header.size();i++)
{
sum += header[i];
}
for (int i=0;i<payload.size();i++)
{
sum += payload[i];
}
//qDebug() << "Payload sum:" << QString::number(sum);
//qDebug() << "Checksum sum:" << QString::number((unsigned char)currPacket[currPacket.length()-1]);
if (sum != (unsigned char)buffer[buffer.length()-1])
{
qDebug() << "BAD CHECKSUM!";
qDebug() << "header size:" << header.size();
//.........这里部分代码省略.........
示例9: parseUserData
QString parser::parseUserData(QString rawData)
{
cout << "parsing user raw data" << endl;
vector <QString> clearedData;
QString finalData;
int amountFields = sizeof(fieldID) / sizeof(*fieldID);
QStringList strList;
strList = rawData.split("\n", QString::SkipEmptyParts);
foreach (QString str, strList)
{
for (int i = 0; i < amountFields; i++)
{
reGlobal.setPattern("^" + fieldID[i] + "(.*)");
// cout << "pattern: " << re.pattern().toLatin1().data() <<
// "\nstring: " << str.toLatin1().data() << endl;
if (reGlobal.indexIn(str)!= -1)
{
// вставляем идентификатор следующего поля
clearedData.push_back(fieldID[i]);
clearedData.push_back(reGlobal.cap(1));
break;
}
}
}
for (unsigned short int i = 0; i < clearedData.size(); i++)
{
if (clearedData.at(i) == "10#")
finalData.append("<b>Фамилия:</b> " + clearedData.at(++i) + "<br>");
else
if (clearedData.at(i) == "11#")
finalData.append("<b>Имя:</b> " + clearedData.at(++i) + "<br>");
else
if (clearedData.at(i) == "12#")
finalData.append("<b>Отчество:</b> " + clearedData.at(++i) + "<br>");
else
if (clearedData.at(i) == "21#")
finalData.append("<b>Год Рождения:</b> " + clearedData.at(++i) + "<br>");
else
if (clearedData.at(i) == "50#")
finalData.append("<b>Категория:</b> " + clearedData.at(++i) + "<br>");
else
if (clearedData.at(i) == "67#")
finalData.append("<b>Доп. категория:</b> " + clearedData.at(++i) + "<br>");
else
if (clearedData.at(i) == "20#")
finalData.append("<b>Образование:</b> " + clearedData.at(++i) + "<br>");
else
if (clearedData.at(i) == "17#")
finalData.append("<b>Телефон:</b> " + clearedData.at(++i) + "<br>");
else
finalData.append(clearedData.at(i) + "<br>");
}
cout << "end parsing" << endl;
return finalData;
}
示例10: FileType
void
dmz::QtPluginAppUpdater::_slot_download_start () {
if (_updateDialog) {
#if defined (Q_WS_WIN)
const QString FileType ("exe");
#elif defined (Q_WS_MAC)
const QString FileType ("dmg");
#else
const QString FileType ("zip");
#endif
QString appName (_updateVersion.get_name ().get_buffer ());
appName.replace (" ", "-");
const String Major (_updateVersion.get_major ());
const String Minor (_updateVersion.get_minor ());
const String Bug (_updateVersion.get_bug ());
const String Build (_updateVersion.get_build ());
QString fileName;
if (_downloadToTemp) {
fileName = tr ("%1/%2-%3-%4-%5-%6.%7").
arg (QDir::tempPath ()).
arg (appName).
arg (Major.get_buffer ()).
arg (Minor.get_buffer ()).
arg (Bug.get_buffer ()).
arg (Build.get_buffer ()).
arg (FileType);
}
else {
QString defaultFileName = tr ("%1/%2-%3-%4-%5-%6.%7").
arg (QDesktopServices::storageLocation (QDesktopServices::DesktopLocation)).
arg (appName).
arg (Major.get_buffer ()).
arg (Minor.get_buffer ()).
arg (Bug.get_buffer ()).
arg (Build.get_buffer ()).
arg (FileType);
#if defined (Q_WS_MAC)
QString tempPath (defaultFileName);
tempPath.replace (QRegExp (
QDesktopServices::displayName (QDesktopServices::DesktopLocation)),
"Downloads");
QFileInfo fi (tempPath);
if (QFile::exists (fi.absolutePath ())) {
defaultFileName = tempPath;
}
#endif
fileName = get_save_file_name_with_extension (
_mainWindowModule ? _mainWindowModule->get_qt_main_window () : 0,
tr ("Save File"),
QDir::toNativeSeparators (defaultFileName),
tr ("*.%1").arg (FileType),
FileType);
}
if (!fileName.isEmpty ()) {
QString downloadServer (_downloadUrl.get_buffer ());
downloadServer.replace ("{app_name}", appName);
downloadServer.replace ("{major}", Major.get_buffer ());
downloadServer.replace ("{minor}", Minor.get_buffer ());
downloadServer.replace ("{bug}", Bug.get_buffer ());
downloadServer.replace ("{build_number}", Build.get_buffer ());
downloadServer.append (tr (".") + FileType);
QUrl url (downloadServer);
_log.info << "Downloading: " << qPrintable (url.toString ()) << endl;
QNetworkRequest request (url);
_downloadReply = _netManager->get (request);
if (_downloadReply) {
connect (
_downloadReply, SIGNAL (downloadProgress (qint64, qint64)),
this, SLOT (_slot_download_progress (qint64, qint64)));
connect (
_downloadReply, SIGNAL (readyRead ()),
this, SLOT (_slot_download_ready_read ()));
connect (
_downloadReply, SIGNAL (finished ()),
this, SLOT (_slot_download_finished ()));
_downloadFile.setFileName (fileName);
//.........这里部分代码省略.........
示例11: writeXML
void QgsDiagramSettings::writeXML( QDomElement& rendererElem, QDomDocument& doc ) const
{
QDomElement categoryElem = doc.createElement( "DiagramCategory" );
categoryElem.setAttribute( "font", font.toString() );
categoryElem.setAttribute( "backgroundColor", backgroundColor.name() );
categoryElem.setAttribute( "backgroundAlpha", backgroundColor.alpha() );
categoryElem.setAttribute( "width", QString::number( size.width() ) );
categoryElem.setAttribute( "height", QString::number( size.height() ) );
categoryElem.setAttribute( "penColor", penColor.name() );
categoryElem.setAttribute( "penAlpha", penColor.alpha() );
categoryElem.setAttribute( "penWidth", QString::number( penWidth ) );
categoryElem.setAttribute( "minScaleDenominator", QString::number( minScaleDenominator ) );
categoryElem.setAttribute( "maxScaleDenominator", QString::number( maxScaleDenominator ) );
categoryElem.setAttribute( "transparency", QString::number( transparency ) );
// site type (mm vs. map units)
if ( sizeType == MM )
{
categoryElem.setAttribute( "sizeType", "MM" );
}
else
{
categoryElem.setAttribute( "sizeType", "MapUnits" );
}
// label placement method (text diagram)
if ( labelPlacementMethod == Height )
{
categoryElem.setAttribute( "labelPlacementMethod", "Height" );
}
else
{
categoryElem.setAttribute( "labelPlacementMethod", "XHeight" );
}
if ( scaleByArea )
{
categoryElem.setAttribute( "scaleDependency", "Area" );
}
else
{
categoryElem.setAttribute( "scaleDependency", "Diameter" );
}
// orientation (histogram)
switch ( diagramOrientation )
{
case Left:
categoryElem.setAttribute( "diagramOrientation", "Left" );
break;
case Right:
categoryElem.setAttribute( "diagramOrientation", "Right" );
break;
case Down:
categoryElem.setAttribute( "diagramOrientation", "Down" );
break;
case Up:
categoryElem.setAttribute( "diagramOrientation", "Up" );
break;
default:
categoryElem.setAttribute( "diagramOrientation", "Up" );
break;
}
categoryElem.setAttribute( "barWidth", QString::number( barWidth ) );
categoryElem.setAttribute( "minimumSize", QString::number( minimumSize ) );
categoryElem.setAttribute( "angleOffset", QString::number( angleOffset ) );
QString colors;
for ( int i = 0; i < categoryColors.size(); ++i )
{
if ( i > 0 )
{
colors.append( "/" );
}
colors.append( categoryColors.at( i ).name() );
}
categoryElem.setAttribute( "colors", colors );
QString categories;
for ( int i = 0; i < categoryIndices.size(); ++i )
{
if ( i > 0 )
{
categories.append( "/" );
}
categories.append( QString::number( categoryIndices.at( i ) ) );
}
categoryElem.setAttribute( "categories", categories );
rendererElem.appendChild( categoryElem );
}
示例12: generateImage
void ccRasterizeTool::generateImage() const
{
if (!m_grid.isValid())
return;
//default values
double emptyCellsHeight = 0;
double minHeight = m_grid.minHeight;
double maxHeight = m_grid.maxHeight;
//get real values
EmptyCellFillOption fillEmptyCellsStrategy = getFillEmptyCellsStrategyExt( emptyCellsHeight,
minHeight,
maxHeight);
QImage bitmap8(m_grid.width,m_grid.height,QImage::Format_Indexed8);
if (!bitmap8.isNull())
{
// Build a custom palette (gray scale)
QVector<QRgb> palette(256);
{
for (unsigned i = 0; i < 256; i++)
palette[i] = qRgba(i,i,i,255);
}
double maxColorComp = 255.99; //.99 --> to avoid round-off issues later!
if (fillEmptyCellsStrategy == LEAVE_EMPTY)
{
palette[255] = qRgba(255,0,255,0); //magenta/transparent color for empty cells (in place of pure white)
maxColorComp = 254.99;
}
bitmap8.setColorTable(palette);
//bitmap8.fill(255);
unsigned emptyCellColorIndex = 0;
switch (fillEmptyCellsStrategy)
{
case LEAVE_EMPTY:
emptyCellColorIndex = 255; //should be transparent!
break;
case FILL_MINIMUM_HEIGHT:
emptyCellColorIndex = 0;
break;
case FILL_MAXIMUM_HEIGHT:
emptyCellColorIndex = 255;
break;
case FILL_CUSTOM_HEIGHT:
{
double normalizedHeight = (emptyCellsHeight-minHeight)/(maxHeight-minHeight);
//min and max should have already been updated with custom empty cell height!
assert(normalizedHeight >= 0.0 && normalizedHeight <= 1.0);
emptyCellColorIndex = static_cast<unsigned>(floor(normalizedHeight*maxColorComp));
}
break;
case FILL_AVERAGE_HEIGHT:
default:
assert(false);
}
double range = maxHeight - minHeight;
if (range < ZERO_TOLERANCE)
range = 1.0;
// Filling the image with grid values
for (unsigned j=0; j<m_grid.height; ++j)
{
const RasterCell* aCell = m_grid.data[j];
for (unsigned i=0; i<m_grid.width; ++i,++aCell)
{
if (aCell->h == aCell->h)
{
double normalizedHeight = (aCell->h - minHeight)/range;
assert(normalizedHeight >= 0.0 && normalizedHeight <= 1.0);
unsigned char val = static_cast<unsigned char>(floor(normalizedHeight*maxColorComp));
bitmap8.setPixel(i,m_grid.height-1-j,val);
}
else //NaN
{
bitmap8.setPixel(i,m_grid.height-1-j,emptyCellColorIndex);
}
}
}
//open file saving dialog
{
//add images output file filters
QString filters;
//we grab the list of supported image file formats (writing)
QList<QByteArray> formats = QImageWriter::supportedImageFormats();
if (formats.empty())
{
ccLog::Error("No image format supported by your system?!\n(check that the 'imageformats' directory is alongside CC executable)");
}
else
{
//we convert this list into a proper "filters" string
for (int i=0; i<formats.size(); ++i)
filters.append(QString("%1 image (*.%2)\n").arg(QString(formats[i].data()).toUpper()).arg(formats[i].data()));
//.........这里部分代码省略.........
示例13: convertString
void convertString()
{
//int interval;
int dayN = 0;
while(dayN<sizeDay) {
for(int i = 0; i<fileString.size();i++)
{
switch (fileString.at(i).toLatin1())
{
case '|':
day[dayN].chetnost = true;
break;
case '_':
day[dayN].chetnost = false;
break;
case '^':{
QString buff;
bool ok = false;
buff = fileString.at(i+1);
day[dayN].numberDay = buff.toInt(&ok, 10);
i++;
break;
}
case '&':{
i++;
QString buff;
while(fileString.at(i).toLatin1()!=35)//56 90 97 112
{
buff.append(fileString.at(i));
//interval++;
if(fileString.at(i+1).toLatin1()==35)
{
day[dayN].numberClass.append(fileString.at(i+2));
day[dayN].classes.append(buff);
}
i++;
}
i++;
break;
}
case ';':
dayN++;
break;
default:
//interval = 5;
break;
}
}
}
}
示例14: on_sendButton_clicked
void SendCoinsDialog::on_sendButton_clicked()
{
if(!model || !model->getOptionsModel())
return;
QList<SendCoinsRecipient> recipients;
bool valid = true;
for(int i = 0; i < ui->entries->count(); ++i)
{
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
if(entry)
{
if(entry->validate())
{
recipients.append(entry->getValue());
}
else
{
valid = false;
}
}
}
if(!valid || recipients.isEmpty())
{
return;
}
fNewRecipientAllowed = false;
WalletModel::UnlockContext ctx(model->requestUnlock());
if(!ctx.isValid())
{
// Unlock wallet was cancelled
fNewRecipientAllowed = true;
return;
}
// prepare transaction for getting txFee earlier
WalletModelTransaction currentTransaction(recipients);
WalletModel::SendCoinsReturn prepareStatus;
if (model->getOptionsModel()->getCoinControlFeatures()) // coin control enabled
prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl);
else
prepareStatus = model->prepareTransaction(currentTransaction);
// process prepareStatus and on error generate message shown to user
processSendCoinsReturn(prepareStatus,
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
if(prepareStatus.status != WalletModel::OK) {
fNewRecipientAllowed = true;
return;
}
CAmount txFee = currentTransaction.getTransactionFee();
// Format confirmation message
QStringList formatted;
Q_FOREACH(const SendCoinsRecipient &rcp, currentTransaction.getRecipients())
{
// generate bold amount string
QString amount = "<b>" + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
amount.append("</b>");
// generate monospace address string
QString address = "<span style='font-family: monospace;'>" + rcp.address;
address.append("</span>");
QString recipientElement;
if (!rcp.paymentRequest.IsInitialized()) // normal payment
{
if(rcp.label.length() > 0) // label with address
{
recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label));
recipientElement.append(QString(" (%1)").arg(address));
}
else // just address
{
recipientElement = tr("%1 to %2").arg(amount, address);
}
}
else if(!rcp.authenticatedMerchant.isEmpty()) // authenticated payment request
{
recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant));
}
else // unauthenticated payment request
{
recipientElement = tr("%1 to %2").arg(amount, address);
}
formatted.append(recipientElement);
}
QString questionString = tr("Are you sure you want to send?");
questionString.append("<br /><br />%1");
if(txFee > 0)
{
// append fee string if a fee is required
//.........这里部分代码省略.........
示例15: run
void LogLoader::run()
{
QFile logfile(m_filename);
logfile.open(QIODevice::ReadOnly);
//QByteArray arr = logfile.readAll();
//logfile.close();
int curr = 0;
//bool escape = false;
bool inpacket = false;
QByteArray currPacket;
//while (!escape || curr >= arr.size())
QByteArray retval;
while (!logfile.atEnd())
{
//logfile.read(&retval,1);
emit logProgress(logfile.pos(),logfile.size());
retval = logfile.read(1);
if (retval[0] == (char)0xAA)
{
if (inpacket)
{
//in the middle of a packet
currPacket.clear();
}
currPacket.append(retval[0]);
//Start byte
//qDebug() << "Start byte";
inpacket = true;
}
else if (retval[0] == (char)0xCC)
{
//currPacket
currPacket.append(retval[0]);
QString output;
for (int i=0;i<currPacket.size();i++)
{
int num = (unsigned char)currPacket[i];
output.append(" ").append((num < 0xF) ? "0" : "").append(QString::number(num,16));
}
qDebug() << "Full packet:";
//qDebug() << output;
parseBuffer(currPacket);
currPacket.clear();
//qDebug() << "loop";
msleep(25);
}
else if (inpacket)
{
if (retval[0] == (char)0xBB)
{
//Need to escape the next byte
retval = logfile.read(1);
if (retval[0] == (char)0x55)
{
currPacket.append((char)0xAA);
}
else if (retval[0] == (char)0x44)
{
currPacket.append((char)0xBB);
}
else if (retval[0] == (char)0x33)
{
currPacket.append((char)0xCC);
}
}
else
{
currPacket.append(retval[0]);
}
}
curr++;
}
emit endOfLog();
logfile.close();
return;
/*for (int i=0;i<arr.size();i++)
{
//i++;
//qDebug() << QString::number(arr[i],16);
curr = i;
curr+=3;
curr += 1;
i += curr-1;
//i++;
}*/
}