本文整理汇总了C++中QStandardItem类的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem类的具体用法?C++ QStandardItem怎么用?C++ QStandardItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QStandardItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SystemStatisticProgression
void ClassesDatas::setDefault(QStandardItem *modelSkills,
QStandardItem *modelStatistics)
{
SystemClass* sysClass;
QStandardItem* item;
SuperListItem* skill;
SuperListItem* statistic;
SystemStatisticProgression* statisticProgression;
SystemClassSkill* classSkill;
QList<QStandardItem *> row;
QStandardItemModel* skills;
QStandardItemModel* statisticsProgression;
QString names[] = {"Knight", "Witch", "Mage", "Ninja", "Animal"};
int initialLevels[] = {1, 1, 1, 1, 1};
int maxLevels[] = {100, 100, 100, 100, 100};
int expBases[] = {5, 5, 5, 5, 5};
int expInflations[] = {20, 20, 20, 20, 20};
QVector<int> idsStatistics[] = {
QVector<int>({3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
QVector<int>({3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
QVector<int>({3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
QVector<int>({3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
QVector<int>({3, 4, 5, 6, 7, 8, 9, 10, 11, 12})
};
QVector<bool> isFix[] = {
QVector<bool>({true, true, true, false, false, true, true, true, true,
true}),
QVector<bool>({true, true, true, false, false, true, true, true, true,
true}),
QVector<bool>({true, true, true, false, false, true, true, true, true,
true}),
QVector<bool>({true, true, true, false, false, true, true, true, true,
true}),
QVector<bool>({true, true, true, false, false, true, true, true, true,
true})
};
QVector<int> initialValue[] = {
QVector<int>({20, 10, 10, 1, 1, 1, 1, 0, 0, 1}),
QVector<int>({20, 10, 10, 1, 1, 1, 1, 0, 0, 1}),
QVector<int>({20, 10, 10, 1, 1, 1, 1, 0, 0, 1}),
QVector<int>({20, 10, 10, 1, 1, 1, 1, 0, 0, 1}),
QVector<int>({5, 10, 10, 1, 1, 1, 1, 0, 0, 1})
};
QVector<int> finalValue[] = {
QVector<int>({1000, 500, 100, 999, 999, 200, 200, 50, 50, 200}),
QVector<int>({1000, 500, 100, 999, 999, 200, 200, 50, 50, 200}),
QVector<int>({1000, 500, 100, 999, 999, 200, 200, 50, 50, 200}),
QVector<int>({1000, 500, 100, 999, 999, 200, 200, 50, 50, 200}),
QVector<int>({1000, 500, 100, 999, 999, 200, 200, 50, 50, 200})
};
QVector<QString> formula[] = {
QVector<QString>({"", "", "", "Math.ceil(u.str * 0.3)",
"Math.ceil(u.int * 0.3)", "", "", "", "", ""}),
QVector<QString>({"", "", "", "Math.ceil(u.str * 0.3)",
"Math.ceil(u.int * 0.3)", "", "", "", "", ""}),
QVector<QString>({"", "", "", "Math.ceil(u.str * 0.3)",
"Math.ceil(u.int * 0.3)", "", "", "", "", ""}),
QVector<QString>({"", "", "", "Math.ceil(u.str * 0.3)",
"Math.ceil(u.int * 0.3)", "", "", "", "", ""}),
QVector<QString>({"", "", "", "Math.ceil(u.str * 0.3)",
"Math.ceil(u.int * 0.3)", "", "", "", "", ""})
};
QVector<int> skillIds[] = {
QVector<int>({6}),
QVector<int>({7}),
QVector<int>({8, 9, 10, 11}),
QVector<int>({12, 13}),
QVector<int>({})
};
QVector<int> skillLevels[] = {
QVector<int>({1}),
QVector<int>({1}),
QVector<int>({1,1,5,10}),
QVector<int>({1, 5}),
QVector<int>({})
};
int length = (sizeof(names)/sizeof(*names));
for (int i = 0; i < length; i++){
// Statistics progression
statisticsProgression = new QStandardItemModel;
for (int j = 0; j < idsStatistics[i].size(); j++){
statistic = SuperListItem::getById(modelStatistics, idsStatistics[i]
[j]);
statisticProgression = new SystemStatisticProgression(statistic->id(),
statistic->name(), new PrimitiveValue(finalValue[i][j]), isFix
[i][j], new SystemProgressionTable(new PrimitiveValue(
initialValue[i][j]), new PrimitiveValue(finalValue[i][j]), 0),
new PrimitiveValue(0), new PrimitiveValue(formula[i][j]));
row = statisticProgression->getModelRow();
statisticsProgression->appendRow(row);
}
item = new QStandardItem();
item->setText(SuperListItem::beginningText);
statisticsProgression->appendRow(item);
// Skills
skills = new QStandardItemModel;
for (int j = 0; j < skillIds[i].size(); j++){
//.........这里部分代码省略.........
示例2: bank
void ViewerModel::processParsedData(ParseJobFiles* parser)
{
Data::Bank& bank(parser->data());
if (bank.isEmpty()) return;
QString name(parser->name());
// Determine if we need to replace an existing Molecule in the Model View.
bool overwrite(parser->flags() & ParseJobFiles::Overwrite);
bool makeActive(parser->flags() & ParseJobFiles::MakeActive);
bool addStar(parser->flags() & ParseJobFiles::AddStar);
bool found(false);
Layer::Molecule* molecule(newMolecule());
molecule->setCheckState(Qt::Unchecked);
molecule->setText(name);
molecule->appendData(bank);
if (addStar) molecule->setIcon(QIcon(":/resources/icons/Favourites.png"));
QStandardItem* child;
QStandardItem* root(invisibleRootItem());
void* moleculePointer(parser->moleculePointer());
if (overwrite && moleculePointer) {
for (int row = 0; row < root->rowCount(); ++row) {
child = root->child(row);
if (child->text() == name) {
Layer::Base* base = QVariantPointer<Layer::Base>::toPointer(child->data());
Layer::Molecule* mol = qobject_cast<Layer::Molecule*>(base);
if (mol && mol == moleculePointer) {
molecule->setCheckState(mol->checkState());
// makeActive = makeActive || (mol->checkState() == Qt::Checked);
// This may result in a memory leak, but we need the Molecule
// to remain lying around in case of an undo action.
takeRow(row);
insertRow(row, molecule);
found = true;
qDebug() << "found existing molecule";
break;
}
}
}
}
// If we didn't find an existing Molecule to overwrite, we check the last
// Molecule on the list and if that is still 'Untitled' and empty, use it.
if (!found) {
child = root->child(root->rowCount()-1);
if (child->text() == DefaultMoleculeName && !child->hasChildren()) {
Layer::Base* base = QVariantPointer<Layer::Base>::toPointer(child->data());
Layer::Molecule* mol = qobject_cast<Layer::Molecule*>(base);
makeActive = makeActive || (mol->checkState() == Qt::Checked);
// This may result in a memory leak, but we need the Molecule
// to remain lying around in case of an undo action.
takeRow(child->row());
}
Command::AddMolecule* cmd = new Command::AddMolecule(molecule, root);
postCommand(cmd);
}
if (makeActive) {
forAllMolecules(boost::bind(&Layer::Molecule::setCheckState, _1, Qt::Unchecked));
molecule->setCheckState(Qt::Checked);
sceneRadiusChanged(sceneRadius());
changeActiveViewerMode(Viewer::Manipulate);
}
fileOpened(parser->filePath());
}
示例3: aicon
bool AlarmView::updateAlarms()
{
bool playSound = false;
QIcon aicon(":icon/audible");
QIcon sicon(":icon/silent");
mStandardModel->clear();
mAlarmCount = 0;
QString localDT;
QString tzDT;
// Filter out occurrences that do not have an alarm
for (int i=0; i < mModel->rowCount(); i++) {
QOccurrence o = mModel->occurrence(i);
QAppointment a = o.appointment();
if (a.hasAlarm() && (o.startInCurrentTZ() == mStartTime) /* && (o.alarmDelay() == warnDelay)*/) {
if (!playSound && (a.alarm() == QAppointment::Audible)) {
playSound = true;
}
QStandardItem* item = new QStandardItem();
if (a.alarm() == QAppointment::Audible)
item->setData(aicon, Qt::DecorationRole);
else
item->setData(sicon, Qt::DecorationRole);
if (!a.description().isEmpty())
item->setData(a.description(), Qt::DisplayRole);
else
item->setData(tr("No description", "no description for appointment"), Qt::DisplayRole);
QList< StringPair > subList;
if (!a.location().isEmpty()) {
subList.append(qMakePair(QString(), a.location()));
}
formatDateTime(o, true, localDT, tzDT);
if (a.isAllDay()) {
subList.append(qMakePair(tr("All day: "), localDT));
} else {
subList.append(qMakePair(tr("Starts: "), localDT));
if (!tzDT.isEmpty())
subList.append(qMakePair(QString(""), tzDT));
formatDateTime(o, false, localDT, tzDT);
subList.append(qMakePair(tr("Ends: "), localDT));
if (!tzDT.isEmpty())
subList.append(qMakePair(QString(""), tzDT));
}
item->setData(QVariant::fromValue(subList), TwoLevelDelegate::SubLabelsRole);
item->setData(i, TwoLevelDelegate::TwoLevelDelegateUserRole);
mStandardModel->appendRow(item);
}
}
int rowCount = mStandardModel->rowCount();
// Select the first item
mAlarmList->setCurrentIndex(mStandardModel->index(0,0));
// XXX i18n boneheadedness.
if (rowCount < 2) {
setWindowTitle(tr("Reminder"));
} else {
setWindowTitle(tr("Reminders"));
}
mSnoozeButton->setFocus();
// If we actually got any matching alarms...
if (rowCount > 0) {
if (playSound) {
Qtopia::soundAlarm();
mAlarmTimer.start(5000,this);
}
return true;
} else {
emit closeView();
return false;
}
}
示例4: QMainWindow
TicketListV::TicketListV(QMainWindow *parent) :
QMainWindow(parent),
ui(new Ui::TicketListV)
{
ui->setupUi(this);
// Make the main screen fixed size
this->setFixedSize(this->width(), this->height());
_flag = false; // undo vector has not been initialize at this point
//
// CUSTOM CSS AREA
//
QPixmap pixmap(":/new/prefix1/refresh2.png");
QIcon ButtonIcon(pixmap);
ui->refreshButton->setIcon(ButtonIcon);
ui->refreshButton->setIconSize(pixmap.rect().size());
QFile data(":/new/prefix1/greenButton.qss");
data.open(QFile::ReadOnly);
QTextStream styleIn(&data);
this->_greenButton = styleIn.readAll();
data.close();
//
// Instantiate all the QComboboxes with the correct data
//
// Custom number combo box
ui->ticketInput->addItem("10");
ui->ticketInput->addItem("25");
ui->ticketInput->addItem("50");
ui->ticketInput->addItem("100");
// Set to 25 as default
ui->ticketInput->setCurrentIndex(1);
// Filter list combo box
ui->filterList->addItem("Select filter(s) to apply");
ui->filterList->addItem("Ticket Number");
ui->filterList->addItem("Customer First Name");
ui->filterList->addItem("Customer Last Name");
ui->filterList->addItem("Category");
ui->filterList->addItem("Severity");
ui->filterList->addItem("Status");
ui->filterList->addItem("Assigned to");
ui->filterList->addItem("Open date/time range");
ui->filterList->addItem("Closed date/time range");
ui->filterBox->setEnabled(false);
ui->applyButton->setEnabled(false);
ui->applyButton->setStyleSheet("QPushButton { background: grey; }");
this->Model = new QStandardItemModel;
QStandardItem* defaultItem = new QStandardItem;
defaultItem->setText("Applied Filters");
this->Model->insertRow(0, defaultItem);
// Create all the items for the applied filters combo box
for (int i = 1; i < 10; i++) {
QStandardItem* tempItem = new QStandardItem;
tempItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
tempItem->setData(Qt::Unchecked, Qt::CheckStateRole);
this->Model->insertRow(i, tempItem);
}
// Add the appropriate names for each section of the box
this->Model->item(1,0)->setText("Ticket Number");
this->Model->item(2,0)->setText("Customer First Name");
this->Model->item(3,0)->setText("Customer Last Name");
this->Model->item(4,0)->setText("Category");
this->Model->item(5,0)->setText("Severity");
this->Model->item(6,0)->setText("Status");
this->Model->item(7,0)->setText("Assigned to");
this->Model->item(8,0)->setText("Open date/time range");
this->Model->item(9,0)->setText("Closed date/time range");
ui->appliedFilters->setModel(this->Model);
// Show/Hide specific columns combo box
this->Model2 = new QStandardItemModel;
QStandardItem* defaultItem2 = new QStandardItem;
defaultItem2->setText("Select column(s) to hide/show");
this->Model2->insertRow(0, defaultItem2);
// Create all the items for the combo box
for (int i = 1; i < 11; i++) {
QStandardItem* tempItem2 = new QStandardItem;
tempItem2->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
tempItem2->setData(Qt::Unchecked, Qt::CheckStateRole);
this->Model2->insertRow(i, tempItem2);
}
this->Model2->item(1,0)->setText("Ticket Number");
this->Model2->item(2,0)->setText("Customer First Name");
this->Model2->item(3,0)->setText("Customer Last Name");
this->Model2->item(4,0)->setText("Category");
this->Model2->item(5,0)->setText("Severity");
//.........这里部分代码省略.........
示例5: MainPage
/** Constructor */
BlogsDialog::BlogsDialog(QWidget *parent)
: MainPage (parent)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
connect(actionCreate_Blog, SIGNAL(triggered()), this, SLOT(createBlog()));
connect(postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeBlog ( void ) ) );
connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeBlog ( void ) ) );
connect(treeView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(selectBlog(const QModelIndex &)));
connect(treeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(toggleSelection(const QModelIndex &)));
connect(treeView, SIGNAL(customContextMenuRequested( QPoint ) ), this, SLOT( blogListCustomPopupMenu( QPoint ) ) );
mBlogId = "";
mPeerId = rsPeers->getOwnId(); // add your id
model = new QStandardItemModel(0, 2, this);
model->setHeaderData(0, Qt::Horizontal, tr("Name"), Qt::DisplayRole);
model->setHeaderData(1, Qt::Horizontal, tr("ID"), Qt::DisplayRole);
treeView->setModel(model);
treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
treeView->setItemDelegate(new ChanGroupDelegate());
// hide header and id column
treeView->setHeaderHidden(true);
treeView->hideColumn(1);
itemFont = QFont("ARIAL", 10);
itemFont.setBold(true);
QStandardItem *OwnBlogs = new QStandardItem(tr("My Blogs"));
OwnBlogs->setForeground(QBrush(QColor(79, 79, 79)));
OwnBlogs->setFont(itemFont);
QStandardItem *SubscribedBlogs = new QStandardItem(tr("Subscribed Blogs"));
SubscribedBlogs->setForeground(QBrush(QColor(79, 79, 79)));
SubscribedBlogs->setFont(itemFont);
QStandardItem *PopularBlogs = new QStandardItem(tr("Popular Blogs"));
PopularBlogs->setForeground(QBrush(QColor(79, 79, 79)));
PopularBlogs->setFont(itemFont);
QStandardItem *OtherBlogs = new QStandardItem(tr("Other Blogs"));
OtherBlogs->setForeground(QBrush(QColor(79, 79, 79)));
OtherBlogs->setFont(itemFont);
model->appendRow(OwnBlogs);
model->appendRow(SubscribedBlogs);
model->appendRow(PopularBlogs);
model->appendRow(OtherBlogs);
//added from ahead
updateBlogList();
mBlogFont = QFont("MS SANS SERIF", 22);
nameLabel->setFont(mBlogFont);
nameLabel->setMinimumWidth(20);
QMenu *blogmenu = new QMenu();
blogmenu->addAction(actionCreate_Blog);
blogmenu->addSeparator();
blogpushButton->setMenu(blogmenu);
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
timer->start(1000);
}
示例6: fontHeightCharacterMM
void QgsComposerLegend::drawLayerChildItems( QPainter* p, QStandardItem* layerItem, double& currentYCoord, double& maxXCoord, int layerOpacity )
{
if ( !layerItem )
{
return;
}
//Draw all symbols first and the texts after (to find out the x coordinate to have the text aligned)
QList<double> childYCoords;
QList<double> realItemHeights;
double textHeight = fontHeightCharacterMM( mItemFont, QChar( '0' ) );
double itemHeight = qMax( mSymbolHeight, textHeight );
double textAlignCoord = 0; //alignment for legend text
QStandardItem* currentItem;
int numChildren = layerItem->rowCount();
for ( int i = 0; i < numChildren; ++i )
{
//real symbol height. Can be different from standard height in case of point symbols
double realSymbolHeight;
double realItemHeight = itemHeight; //will be adjusted if realSymbolHeight turns out to be larger
currentYCoord += mSymbolSpace;
double currentXCoord = mBoxSpace;
currentItem = layerItem->child( i, 0 );
if ( !currentItem )
{
continue;
}
QgsSymbol* symbol = 0;
QgsComposerSymbolItem* symbolItem = dynamic_cast<QgsComposerSymbolItem*>( currentItem );
if ( symbolItem )
{
symbol = symbolItem->symbol();
}
QgsSymbolV2* symbolNg = 0;
QgsComposerSymbolV2Item* symbolV2Item = dynamic_cast<QgsComposerSymbolV2Item*>( currentItem );
if ( symbolV2Item )
{
symbolNg = symbolV2Item->symbolV2();
}
QgsComposerRasterSymbolItem* rasterItem = dynamic_cast<QgsComposerRasterSymbolItem*>( currentItem );
if ( symbol ) //item with symbol?
{
//draw symbol
drawSymbol( p, symbol, currentYCoord + ( itemHeight - mSymbolHeight ) / 2, currentXCoord, realSymbolHeight, layerOpacity );
realItemHeight = qMax( realSymbolHeight, itemHeight );
currentXCoord += mIconLabelSpace;
}
else if ( symbolNg ) //item with symbol NG?
{
drawSymbolV2( p, symbolNg, currentYCoord + ( itemHeight - mSymbolHeight ) / 2, currentXCoord, realSymbolHeight, layerOpacity );
realItemHeight = qMax( realSymbolHeight, itemHeight );
currentXCoord += mIconLabelSpace;
}
else if ( rasterItem )
{
if ( p )
{
p->setBrush( rasterItem->color() );
p->drawRect( QRectF( currentXCoord, currentYCoord + ( itemHeight - mSymbolHeight ) / 2, mSymbolWidth, mSymbolHeight ) );
}
currentXCoord += mSymbolWidth;
currentXCoord += mIconLabelSpace;
}
else //item with icon?
{
QIcon symbolIcon = currentItem->icon();
if ( !symbolIcon.isNull() && p )
{
symbolIcon.paint( p, currentXCoord, currentYCoord + ( itemHeight - mSymbolHeight ) / 2, mSymbolWidth, mSymbolHeight );
currentXCoord += mSymbolWidth;
currentXCoord += mIconLabelSpace;
}
}
childYCoords.push_back( currentYCoord );
realItemHeights.push_back( realItemHeight );
currentYCoord += realItemHeight;
textAlignCoord = qMax( currentXCoord, textAlignCoord );
}
maxXCoord = qMax( maxXCoord, textAlignCoord );
for ( int i = 0; i < numChildren; ++i )
{
if ( p )
{
p->setPen( QColor( 0, 0, 0 ) );
drawText( p, textAlignCoord, childYCoords.at( i ) + textHeight + ( realItemHeights.at( i ) - textHeight ) / 2, layerItem->child( i, 0 )->text(), mItemFont );
maxXCoord = qMax( maxXCoord, textAlignCoord + mBoxSpace + textWidthMillimeters( mItemFont, layerItem->child( i, 0 )->text() ) );
}
//.........这里部分代码省略.........
示例7: exportAsCSV
void MainWindow::exportAsCSV(QString fileName,const WorkSheet *ws)
{
QString str;
bool bstatus;
int i,j;
int linecount = 0;
QStandardItem *item;
QModelIndex index;
const ProxyFilter *proxyFilter = 0;
const WorkSheetModel *model = 0;
if (!ws || !ws->fixTable) {
qWarning() << "ws is null or HAS NO FIX TABLE" << __FILE__ << __LINE__;
GUI::ConsoleMessage msg("Export failed, work sheet is null or has no table",
GUI::ConsoleMessage::ErrorMsg);
displayConsoleMessage(msg);
return;
}
QFileInfo fi(fileName);
if (fi.suffix().toLower() != "csv")
fileName.append(".csv");
QFile file(fileName);
QTextStream ts(&file);
if (file.exists()) {
str = fileName + " already exists.";
QMessageBox::warning(this,"Export Failed",str);
GUI::ConsoleMessage msg ("Export failed" + str,
GUI::ConsoleMessage::ErrorMsg);
displayConsoleMessage(msg);
return;
}
bstatus = file.open(QIODevice::WriteOnly);
if (!bstatus) {
str = "Unable to open file: " + fileName;
QMessageBox::warning(this,"Export Failed",str);
GUI::ConsoleMessage msg("Export failed" + str,
GUI::ConsoleMessage::ErrorMsg);
displayConsoleMessage(msg);
return;
}
model = ws->fixTable->getWorkSheetModel();
bool proxyInUse = ws->fixTable->proxyFilterInUse();
if (proxyInUse) {
proxyFilter = ws->fixTable->getProxyFilter();
for (i=0;i<proxyFilter->rowCount(); i++ ) {
QStringList itemList;
for(j=0;j< proxyFilter->columnCount();j++) {
index = proxyFilter->index(i,j);
index = proxyFilter->mapToSource(index);
item = model->itemFromIndex(index);
if (item) {
itemList << item->text();
}
else {
itemList << " ";
}
}
ts << itemList.join(',') << "\n";
}
}
else {
for (i=0;i<model->rowCount(); i++ ) {
QStringList itemList;
for(j=0;j< model->columnCount();j++) {
index = model->index(i,j);
item = model->itemFromIndex(index);
if (item) {
itemList << item->text();
}
else {
itemList << " ";
}
}
ts << itemList.join(',') << "\n";
}
}
GUI::ConsoleMessage msg(QString("Exported to " + fileName + ", " + QString::number(i) + " lines."));
displayConsoleMessage(msg);
file.close();
}
示例8: itemFromIndex
void QgsPgTableModel::setSql( const QModelIndex &index, const QString &sql )
{
if ( !index.isValid() || !index.parent().isValid() )
{
return;
}
//find out schema name and table name
QModelIndex schemaSibling = index.sibling( index.row(), DbtmSchema );
QModelIndex tableSibling = index.sibling( index.row(), DbtmTable );
QModelIndex geomSibling = index.sibling( index.row(), DbtmGeomCol );
if ( !schemaSibling.isValid() || !tableSibling.isValid() || !geomSibling.isValid() )
{
return;
}
QString schemaName = itemFromIndex( schemaSibling )->text();
QString tableName = itemFromIndex( tableSibling )->text();
QString geomName = itemFromIndex( geomSibling )->text();
QList<QStandardItem *> schemaItems = findItems( schemaName, Qt::MatchExactly, DbtmSchema );
if ( schemaItems.empty() )
{
return;
}
QStandardItem *schemaItem = schemaItems.at( DbtmSchema );
int n = schemaItem->rowCount();
for ( int i = 0; i < n; i++ )
{
QModelIndex currentChildIndex = indexFromItem( schemaItem->child( i, DbtmSchema ) );
if ( !currentChildIndex.isValid() )
{
continue;
}
QModelIndex currentTableIndex = currentChildIndex.sibling( i, DbtmTable );
if ( !currentTableIndex.isValid() )
{
continue;
}
QModelIndex currentGeomIndex = currentChildIndex.sibling( i, DbtmGeomCol );
if ( !currentGeomIndex.isValid() )
{
continue;
}
if ( itemFromIndex( currentTableIndex )->text() == tableName && itemFromIndex( currentGeomIndex )->text() == geomName )
{
QModelIndex sqlIndex = currentChildIndex.sibling( i, DbtmSql );
if ( sqlIndex.isValid() )
{
itemFromIndex( sqlIndex )->setText( sql );
break;
}
}
}
}
示例9: out
void ItemsList::generateCSV()
{
QString separator = ";";
QList <QStandardItem*> itemsList;
QTextStream out( csvFile );
if ( !csvFile->open(QIODevice::WriteOnly | QIODevice::Append) )
{
runMsg("Nie można otworzyć pliku pomocniczego schedule.csv.");
return;
}
QBrush brush;
QFont checkedFont;
checkedFont.setFamily("Arial");
checkedFont.setBold(true);
checkedFont.setWeight(15);
brush.setColor(Qt::green);
if (!mainOrderActive)
{
out << m_order + separator << m_year + "-" + m_month + "-" + m_day + separator << m_recipient + separator << endl;
out << "Rodzaj stołu" + separator
<< "Elektryczna regulacja wysokości" + separator
<< "Uchwyty do pasów" + separator
<< "Regulacja kąta odchylenia" + separator
<< "Elektrycznie łamane leżysko" + separator
<< "Układ jezdny z hamulcami"+ separator
<< "Zagłówek 3-elementowy"+ separator
<< "Pozycja fotela"+ separator
<< "Sterowanie nożne"+ separator
<< "Pilot podblatowy"+ separator
<< "Kołki do stabilizacji"+ separator
<< "Uchwyt na prześcieradło"+ separator
<< "Zatyczka"+ separator
<< "Stal nierdzewna"+ separator
<< "Ilość sztuk"+ separator
<< "Kolor blatu"+ separator
<< "Kolor ramy" + separator
<< "Uwagi" << endl;
mainOrderActive = true;
}
out << m_actualTable + separator;
QStandardItem * item = new QStandardItem(m_actualTable);
item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
itemsList.push_back( item );
/* fill options */
for( uint row = 0 ; row < m_statesArray.size() ; ++row ) {
out << QString::number(m_statesArray[row]) + separator;
item = new QStandardItem(QString::number(m_statesArray[row]));
item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
if(item->text() == "1")
{
item -> setForeground(brush);
item -> setFont(checkedFont);
}
itemsList.push_back( item );
}
out << m_quantity + separator;
item = new QStandardItem(m_quantity);
item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
itemsList.push_back( item );
out << m_topColor + separator;
item = new QStandardItem(m_topColor);
item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
itemsList.push_back( item );
out << m_bottomColor + separator ;
item = new QStandardItem(m_bottomColor);
item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
itemsList.push_back( item );
out << m_notes + separator << endl;
item = new QStandardItem(m_notes);
item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
itemsList.push_back( item );
csvFile->close();
tableDialog->model->appendColumn(itemsList);
runMsg("Dodano do zamówienia.");
}
示例10: exportAsXLSXA
QTXLSX_USE_NAMESPACE
void MainWindow::exportAsXLSXA(QString fileName,WorkSheet *ws)
{
QString str;
QStringList headerArray;
//headerArray << "A"<<"B"<<"C"<<"D"<<"E"<<"F"<<"G"<<"H"<<"I"<<"J"<<"K"<<"L"<<"M"<<"N"<<"O"<<"P"<<"Q"<<"R"<<"S"<<"T"<<"U"<<"V"<<"W"<<"X"<<"Y"<<"Z"<<"AA"<<"AB"<<"AC"<<"AD"<<"AE"<<"AF"<<"AG"<<"AH"<<"AI"<<"AJ"<<"AK"<<"AL"<<"AM"<<"AN"<<"AO"<<"AP"<<"AQ"<<"AR"<<"AS"<<"AT"<<"AU"<<"AV"<<"AW"<<"AX"<<"AY"<<"AZ";
bool bstatus;
int i,j;
int linecount = 0;
QStandardItem *item;
QModelIndex index;
const ProxyFilter *proxyFilter = 0;
const WorkSheetModel *model = 0;
if (!ws || !ws->fixTable) {
qWarning() << "ws is null or HAS NO FIX TABLE" << __FILE__ << __LINE__;
GUI::ConsoleMessage msg("Export failed, work sheet is null or has no table",
GUI::ConsoleMessage::ErrorMsg);
displayConsoleMessage(msg);
return;
}
model = ws->fixTable->getWorkSheetModel();
QFileInfo fi(fileName);
if (fi.suffix().toLower() != "xlsx")
fileName.append(".xlsx");
Document xlsx;
QString xmlFileName = ws->getFileName();
xlsx.addSheet("From:" + xmlFileName);
Format headerStyle;
headerStyle.setFontBold(true);
headerStyle.setHorizontalAlignment(Format::AlignHCenter);
headerStyle.setVerticalAlignment(Format::AlignVCenter);
int w;
QFontMetrics fm(ws->fixTable->font());
xlsx.setColumnWidth(1,model->columnCount() + 1,20);
bool proxyInUse = ws->fixTable->proxyFilterInUse();
for (i=0;i<model->columnCount();i++) {
item = model->horizontalHeaderItem(i);
xlsx.setColumnFormat(1,i,headerStyle);
xlsx.write(1, i+1, item->text());
}
if (proxyInUse) {
proxyFilter = ws->fixTable->getProxyFilter();
for (i=0;i<proxyFilter->rowCount(); i++ ) {
QStringList itemList;
for(j=0;j< proxyFilter->columnCount();j++) {
index = proxyFilter->index(i,j);
index = proxyFilter->mapToSource(index);
item = model->itemFromIndex(index);
if (item) {
xlsx.write(i+2,j+1,item->text());
}
}
}
}
else {
for(i=0;i<model->rowCount();i++) {
for(j=0;j< model->columnCount();j++) {
index = model->index(i,j);
item = model->itemFromIndex(index);
if (item) {
xlsx.write(i+2,j+1,item->text());
}
}
}
}
xlsx.saveAs(fileName);
GUI::ConsoleMessage msg(QString("Exported to " + fileName + ", " + QString::number(i) + " lines."));
displayConsoleMessage(msg);
}
示例11: QStandardItem
void SpotifyService::PlaylistsUpdated(const pb::spotify::Playlists& response) {
if (login_task_id_) {
app_->task_manager()->SetTaskFinished(login_task_id_);
login_task_id_ = 0;
}
// Create starred and inbox playlists if they're not here already
if (!search_) {
search_ =
new QStandardItem(IconLoader::Load("edit-find", IconLoader::Base),
tr("Search results"));
search_->setToolTip(
tr("Start typing something on the search box above to "
"fill this search results list"));
search_->setData(Type_SearchResults, InternetModel::Role_Type);
search_->setData(InternetModel::PlayBehaviour_MultipleItems,
InternetModel::Role_PlayBehaviour);
starred_ = new QStandardItem(QIcon(":/star-on.png"), tr("Starred"));
starred_->setData(Type_StarredPlaylist, InternetModel::Role_Type);
starred_->setData(true, InternetModel::Role_CanLazyLoad);
starred_->setData(InternetModel::PlayBehaviour_MultipleItems,
InternetModel::Role_PlayBehaviour);
starred_->setData(true, InternetModel::Role_CanBeModified);
inbox_ = new QStandardItem(IconLoader::Load("mail-message",
IconLoader::Base), tr("Inbox"));
inbox_->setData(Type_InboxPlaylist, InternetModel::Role_Type);
inbox_->setData(true, InternetModel::Role_CanLazyLoad);
inbox_->setData(InternetModel::PlayBehaviour_MultipleItems,
InternetModel::Role_PlayBehaviour);
toplist_ = new QStandardItem(QIcon(), tr("Top tracks"));
toplist_->setData(Type_Toplist, InternetModel::Role_Type);
toplist_->setData(true, InternetModel::Role_CanLazyLoad);
toplist_->setData(InternetModel::PlayBehaviour_MultipleItems,
InternetModel::Role_PlayBehaviour);
root_->appendRow(search_);
root_->appendRow(toplist_);
root_->appendRow(starred_);
root_->appendRow(inbox_);
} else {
// Always reset starred playlist
// TODO: might be improved by including starred playlist in the response,
// and reloading it only when needed, like other playlists.
starred_->removeRows(0, starred_->rowCount());
LazyPopulate(starred_);
}
// Don't do anything if the playlists haven't changed since last time.
if (!DoPlaylistsDiffer(response)) {
qLog(Debug) << "Playlists haven't changed - not updating";
return;
}
qLog(Debug) << "Playlist have changed: updating";
// Remove and recreate the other playlists
for (QStandardItem* item : playlists_) {
item->parent()->removeRow(item->row());
}
playlists_.clear();
for (int i = 0; i < response.playlist_size(); ++i) {
const pb::spotify::Playlists::Playlist& msg = response.playlist(i);
QString playlist_title = QStringFromStdString(msg.name());
if (!msg.is_mine()) {
const std::string& owner = msg.owner();
playlist_title +=
tr(", by ") + QString::fromUtf8(owner.c_str(), owner.size());
}
QStandardItem* item = new QStandardItem(playlist_title);
item->setData(InternetModel::Type_UserPlaylist, InternetModel::Role_Type);
item->setData(true, InternetModel::Role_CanLazyLoad);
item->setData(msg.index(), Role_UserPlaylistIndex);
item->setData(msg.is_mine(), InternetModel::Role_CanBeModified);
item->setData(InternetModel::PlayBehaviour_MultipleItems,
InternetModel::Role_PlayBehaviour);
item->setData(QUrl(QStringFromStdString(msg.uri())),
InternetModel::Role_Url);
root_->appendRow(item);
playlists_ << item;
// Preload the playlist items so that drag & drop works immediately.
LazyPopulate(item);
}
}
示例12: tDebug
void
WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
if ( requestData.caller != s_whatsHotIdentifier )
return;
if ( output.isNull() )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Info came back empty";
return;
}
if ( !output.canConvert< QVariantMap >() )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: Could not parse output into a map";
return;
}
QVariantMap returnedData = output.toMap();
switch ( requestData.type )
{
case InfoSystem::InfoChartCapabilities:
{
QStandardItem *rootItem= m_crumbModelLeft->invisibleRootItem();
QVariantMap defaults;
if ( returnedData.contains( "defaults" ) )
defaults = returnedData.take( "defaults" ).toMap();
QString defaultSource = returnedData.take( "defaultSource" ).toString();
foreach ( const QString label, returnedData.keys() )
{
QStandardItem *childItem = parseNode( rootItem, label, returnedData[label] );
rootItem->appendRow(childItem);
}
// Set the default source
// Set the default chart for each source
for ( int i = 0; i < rootItem->rowCount(); i++ )
{
QStandardItem* source = rootItem->child( i, 0 );
if ( defaultSource.toLower() == source->text().toLower() )
{
source->setData( true, Breadcrumb::DefaultRole );
}
if ( defaults.contains( source->text().toLower() ) )
{
QStringList defaultIndices = defaults[ source->text().toLower() ].toStringList();
QStandardItem* cur = source;
foreach( const QString& index, defaultIndices )
{
// Go through the children of the current item, marking the default one as default
for ( int k = 0; k < cur->rowCount(); k++ )
{
if ( cur->child( k, 0 )->text() == index )
{
cur = cur->child( k, 0 ); // this is the default, drill down into the default to pick the next default
cur->setData( true, Breadcrumb::DefaultRole );
break;
}
}
}
}
}
m_sortedProxy->setSourceModel( m_crumbModelLeft );
m_sortedProxy->sort( 0, Qt::AscendingOrder );
ui->breadCrumbLeft->setModel( m_sortedProxy );
break;
}
case InfoSystem::InfoChart:
{
if( !returnedData.contains("type") )
break;
const QString type = returnedData["type"].toString();
if( !returnedData.contains(type) )
break;
const QString side = requestData.customData["whatshot_side"].toString();
const QString chartId = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >().value( "chart_id" );
m_queuedFetches.remove( chartId );
ChartDataLoader* loader = new ChartDataLoader();
loader->setProperty( "chartid", chartId );
loader->moveToThread( m_workerThread );
if ( type == "artists" )
{
loader->setType( ChartDataLoader::Artist );
loader->setData( returnedData[ "artists" ].value< QStringList >() );
connect( loader, SIGNAL( artists( Tomahawk::ChartDataLoader*, QList< Tomahawk::artist_ptr > ) ), this, SLOT( chartArtistsLoaded( Tomahawk::ChartDataLoader*, QList< Tomahawk::artist_ptr > ) ) );
TreeModel* artistsModel = new TreeModel( ui->artistsViewLeft );
artistsModel->setMode( InfoSystemMode );
artistsModel->setStyle( PlayableModel::Collection );
m_artistModels[ chartId ] = artistsModel;
//.........这里部分代码省略.........
示例13: tr
void NotifyOptionsWidget::createTreeModel()
{
static const struct { ushort kind; QString name; } KindsList[] = {
{ INotification::PopupWindow, tr("Display a notification in popup window") },
{ INotification::SoundPlay, tr("Play sound at the notification") },
{ INotification::ShowMinimized, tr("Show the corresponding window minimized in the taskbar") },
{ INotification::AlertWidget, tr("Highlight the corresponding window in the taskbar") },
{ INotification::TabPageNotify, tr("Display a notification in tab") },
{ INotification::RosterNotify, tr("Display a notification in your roster") },
{ INotification::TrayNotify, tr("Display a notification in tray") },
{ INotification::TrayAction, tr("Display a notification in tray context menu") },
{ INotification::AutoActivate, tr("Immediately activate the notification") },
{ 0, QString::null }
};
FModel.clear();
FModel.setColumnCount(2);
INotificationType globalType;
globalType.order = 0;
globalType.kindMask = 0xFFFF;
globalType.title = tr("Allowed types of notifications");
globalType.icon = IconStorage::staticStorage(RSR_STORAGE_MENUICONS)->getIcon(MNI_NOTIFICATIONS);
QMap<QString,INotificationType> notifyTypes;
notifyTypes.insert(QString::null,globalType);
foreach(const QString &typeId, FNotifications->notificationTypes())
notifyTypes.insert(typeId,FNotifications->notificationType(typeId));
for(QMap<QString,INotificationType>::const_iterator it=notifyTypes.constBegin(); it!=notifyTypes.constEnd(); ++it)
{
if (!it->title.isEmpty() && it->kindMask>0)
{
QStandardItem *typeNameItem = new QStandardItem(it->title);
typeNameItem->setFlags(Qt::ItemIsEnabled);
typeNameItem->setData(it.key(),MDR_TYPE);
typeNameItem->setData(it->order,MDR_SORT);
typeNameItem->setIcon(it->icon);
setItemBold(typeNameItem,true);
QStandardItem *typeEnableItem = new QStandardItem;
typeEnableItem->setFlags(Qt::ItemIsEnabled);
FTypeItems.insert(it.key(),typeNameItem);
FModel.invisibleRootItem()->appendRow(QList<QStandardItem *>() << typeNameItem << typeEnableItem);
for (int index =0; KindsList[index].kind!=0; index++)
{
if ((it->kindMask & KindsList[index].kind)>0)
{
QStandardItem *kindNameItem = new QStandardItem(KindsList[index].name);
kindNameItem->setFlags(Qt::ItemIsEnabled);
kindNameItem->setData(index,MDR_SORT);
QStandardItem *kindEnableItem = new QStandardItem();
kindEnableItem->setFlags(Qt::ItemIsEnabled);
kindEnableItem->setTextAlignment(Qt::AlignCenter);
kindEnableItem->setCheckable(true);
kindEnableItem->setCheckState(Qt::PartiallyChecked);
kindEnableItem->setData(it.key(),MDR_TYPE);
kindEnableItem->setData(KindsList[index].kind,MDR_KIND);
typeNameItem->appendRow(QList<QStandardItem *>() << kindNameItem << kindEnableItem);
}
}
}
}
}
示例14: ok
//*** class PathEnum ***
PathEnum::PathEnum(const CppReader &reader, CppObjList &objs):
ok(false), reader(reader)
{
//recognization?
if( !reader.header().startsWith("enum"))
return;
ok = true;
//yes!
//whether exists the enum name?
QString name;
QRegExp rn("^enum\\s+([a-zA-Z_]\\w*)\\s*$");
if(reader.header().contains(rn) &&
! objs.indexOf( name = rn.cap(1)) ) //query for the existance of the name.
{
QStandardItem *item = new Item::CppItem(Item::Enum);
item->setForeground(Qt::darkMagenta);
item->setData(rn.cap(1),Item::NameRole);
item->setData(reader.header(),Qt::ToolTipRole);
item->setEditable(false);
objs.append( item);
}
//the content of the enum.
QStringList list = reader.body().split(',',QString::SkipEmptyParts);
QRegExp rx("^\\s*([a-zA-Z_]\\w*)\\s*(?:=[^,;]+)?$");
foreach (const QString &it, list)
{
if(! it.contains(rx) )
continue;
if( ! objs.indexOf( rx.cap(1)))
{
QStandardItem *item = new Item::CppItem(Item::Enumerator);
item->setForeground(Qt::darkMagenta);
item->setData(rx.cap(1),Item::NameRole);
item->setData("enum: " + it,Qt::ToolTipRole);
item->setData( name.isEmpty() ? "int" : name, Item::PurifiedTypeRole);
item->setEditable(false);
objs.append( item);
}
}
}
示例15: tr
bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, int role )
{
if ( !QStandardItemModel::setData( idx, value, role ) )
return false;
if ( idx.column() == DbtmType || idx.column() == DbtmSrid || idx.column() == DbtmPkCol )
{
QgsWkbTypes::Type wkbType = ( QgsWkbTypes::Type ) idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt();
QString tip;
if ( wkbType == QgsWkbTypes::Unknown )
{
tip = tr( "Specify a geometry type in the '%1' column" ).arg( tr( "Data Type" ) );
}
else if ( wkbType != QgsWkbTypes::NoGeometry )
{
bool ok;
int srid = idx.sibling( idx.row(), DbtmSrid ).data().toInt( &ok );
if ( !ok || srid == std::numeric_limits<int>::min() )
tip = tr( "Enter a SRID into the '%1' column" ).arg( tr( "SRID" ) );
}
QStringList pkCols = idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 1 ).toStringList();
if ( tip.isEmpty() && !pkCols.isEmpty() )
{
QSet<QString> s0( idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 2 ).toStringList().toSet() );
QSet<QString> s1( pkCols.toSet() );
if ( !s0.intersects( s1 ) )
tip = tr( "Select columns in the '%1' column that uniquely identify features of this layer" ).arg( tr( "Feature id" ) );
}
for ( int i = 0; i < DbtmColumns; i++ )
{
QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) );
if ( tip.isEmpty() )
{
if ( i == DbtmSchema )
{
item->setData( QVariant(), Qt::DecorationRole );
}
item->setFlags( item->flags() | Qt::ItemIsSelectable );
item->setToolTip( QString() );
}
else
{
item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
if ( i == DbtmSchema )
item->setData( QgsApplication::getThemeIcon( QStringLiteral( "/mIconWarning.svg" ) ), Qt::DecorationRole );
if ( i == DbtmSchema || i == DbtmTable || i == DbtmGeomCol )
{
item->setFlags( item->flags() );
item->setToolTip( tip );
}
}
}
}
return true;
}