本文整理汇总了C++中QStandardItem::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::setData方法的具体用法?C++ QStandardItem::setData怎么用?C++ QStandardItem::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::setData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: headers
void
ListView::answerReceived(int id, const QList<QByteArray>& answer)
{
/* We received something, so the sensor is probably ok. */
sensorError(id, false);
switch (id)
{
case 100: {
/* We have received the answer to a '?' command that contains
* the information about the table headers. */
if (answer.count() != 2)
{
kWarning(1215) << "wrong number of lines";
return;
}
KSGRD::SensorTokenizer headers(answer[0], '\t');
KSGRD::SensorTokenizer colTypes(answer[1], '\t');
/* add the new columns */
mModel.clear();
QStringList translatedHeaders;
for (uint i = 0; i < headers.count(); i++) {
translatedHeaders.append( i18nc("heading from daemon", headers[i]) );
}
for(uint i =0 ; i < colTypes.count(); i++) {
ColumnType type = convertColumnType(colTypes[i]);
mColumnTypes.append(type);
if (type == Text || type == DiskStat)
mModel.addColumnAlignment(Qt::AlignLeft);
else
mModel.addColumnAlignment(Qt::AlignRight);
}
mModel.setHorizontalHeaderLabels(translatedHeaders);
//If we have some header settings to restore, we can do so now
if(!mHeaderSettings.isEmpty()) {
mView->header()->restoreState(mHeaderSettings);
mModel.sort( mView->header()->sortIndicatorSection(), mView->header()->sortIndicatorOrder() );
}
break;
}
case 19: {
for (int i = 0; i < answer.count(); i++) {
KSGRD::SensorTokenizer records(answer[i], '\t');
for (uint j = 0; j < records.count() && j < mColumnTypes.count(); j++) {
QStandardItem *item = new QStandardItem();
item->setEditable(false);
switch( mColumnTypes[j] ) {
case Int:
item->setData(records[j].toLongLong(), Qt::UserRole);
item->setText(records[j]);
break;
case Percentage:
item->setData(records[j].toInt(), Qt::UserRole);
item->setText(records[j] + "%");
break;
case Float:
item->setData(records[j].toFloat(), Qt::DisplayRole);
item->setData(records[j].toFloat(), Qt::UserRole);
break;
case Time:
item->setData(QTime::fromString(records[j]), Qt::DisplayRole);
item->setData(QTime::fromString(records[j]), Qt::UserRole);
break;
case KByte: {
item->setData(records[j].toInt(), Qt::UserRole);
item->setText(formatByteSize(records[j].toLongLong(), mUnits));
break;
}
case DiskStat:
case Text:
default:
item->setText(records[j]);
item->setData(records[j], Qt::UserRole);
}
mModel.setItem(i, j, item);
}
}
mModel.setRowCount(answer.count());
mModel.sort( mView->header()->sortIndicatorSection(), mView->header()->sortIndicatorOrder() );
break;
}
}
}
示例2: InitChanInfo
void PreferencesDialog::InitChanInfo()
{
QHash<MachineType, int> toprows;
chanModel->clear();
toplevel.clear();
toprows.clear();
QStringList headers;
headers.append(tr("Name"));
headers.append(tr("Color"));
headers.append(tr("Overview"));
headers.append(tr("Flag Type"));
headers.append(tr("Label"));
headers.append(tr("Details"));
chanModel->setHorizontalHeaderLabels(headers);
ui->chanView->setColumnWidth(0, 200);
ui->chanView->setColumnWidth(1, 40);
ui->chanView->setColumnWidth(2, 60);
ui->chanView->setColumnWidth(3, 100);
ui->chanView->setColumnWidth(4, 100);
ui->chanView->setSelectionMode(QAbstractItemView::SingleSelection);
ui->chanView->setSelectionBehavior(QAbstractItemView::SelectItems);
chanModel->setColumnCount(6);
QStandardItem *hdr = nullptr;
QMap<MachineType, QString> Section;
Section[MT_CPAP] = tr("CPAP Events");
Section[MT_OXIMETER] = tr("Oximeter Events");
Section[MT_POSITION] = tr("Positional Events");
Section[MT_SLEEPSTAGE] = tr("Sleep Stage Events");
Section[MT_UNCATEGORIZED] = tr("Unknown Events");
QMap<MachineType, QString>::iterator it;
QHash<QString, schema::Channel *>::iterator ci;
for (it = Section.begin(); it != Section.end(); ++it) {
toplevel[it.key()] = hdr = new QStandardItem(it.value());
hdr->setEditable(false);
QList<QStandardItem *> list;
list.append(hdr);
for (int i=0; i<5; i++) {
QStandardItem *it = new QStandardItem();
it->setEnabled(false);
list.append(it);
}
chanModel->appendRow(list);
}
ui->chanView->setAlternatingRowColors(true);
// ui->graphView->setFirstColumnSpanned(0,daily->index(),true); // Crashes on windows.. Why do I need this again?
ComboBoxDelegate * combobox = new ComboBoxDelegate(ui->waveView);
ui->chanView->setItemDelegateForColumn(3,combobox);
int row = 0;
for (ci = schema::channel.names.begin(); ci != schema::channel.names.end(); ci++) {
schema::Channel * chan = ci.value();
if ((chan->type() == schema::DATA) || (chan->type() == schema::SETTING) || chan->type() == schema::WAVEFORM) continue;
QList<QStandardItem *> items;
QStandardItem *it = new QStandardItem(chan->fullname());
it->setCheckable(true);
it->setCheckState(chan->enabled() ? Qt::Checked : Qt::Unchecked);
it->setEditable(true);
it->setData(chan->id(), Qt::UserRole);
// Dear translators: %1 is a unique ascii english string used to indentify channels in the code, I'd like feedback on how this goes..
// It's here in case users mess up which field is which.. it will always show the Channel Code underneath in the tooltip.
it->setToolTip(tr("Double click to change the descriptive name the '%1' channel.").arg(chan->code()));
items.push_back(it);
it = new QStandardItem();
it->setBackground(QBrush(chan->defaultColor()));
it->setEditable(false);
it->setData(chan->defaultColor().rgba(), Qt::UserRole);
it->setToolTip(tr("Double click to change the default color for this channel plot/flag/data."));
it->setSelectable(false);
items.push_back(it);
it = new QStandardItem(QString());
it->setToolTip(tr("Whether this flag has a dedicated overview chart."));
it->setCheckable(true);
it->setCheckState(chan->showInOverview() ? Qt::Checked : Qt::Unchecked);
it->setTextAlignment(Qt::AlignCenter);
it->setData(chan->id(), Qt::UserRole);
items.push_back(it);
schema::ChanType type = chan->type();
it = new QStandardItem(channeltype[type]);
it->setToolTip(tr("Here you can change the type of flag shown for this event"));
it->setEditable(type != schema::UNKNOWN);
//.........这里部分代码省略.........
示例3: user
AddRecipients::AddRecipients(QLineEdit & listRecipients,QWidget *parent) :
QDialog(parent)
{
setFixedWidth(300);
setWindowTitle("Ajouter un destinataire");
currentListRecipients = &listRecipients;
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("database.db");
if (!db.open())
{
qDebug() << "Impossible de se connecter à la base de données." << endl;
return;
}
listView_users = new QListView();
listView_users->setEditTriggers(0);
QSqlQuery query;
query.exec("SELECT * FROM Contacts");
modelListUsers = new QStandardItemModel();
int index = 0;
while(query.next())
{
User user(query.value(1).toInt(),QString(query.value(2).toString()));
QStandardItem *item = new QStandardItem();
item->setText(user.address());
QVariant data;
data.setValue(user);
item->setData(data);
modelListUsers->setItem(index,item);
index++;
}
listView_users->setModel(modelListUsers);
QVBoxLayout *layout_add_users = new QVBoxLayout();
layout_add_users->addWidget(listView_users);
btn_add_user = new QPushButton("Ajouter le contact");
QVBoxLayout *layout_btn_add_users = new QVBoxLayout();
layout_btn_add_users->addWidget(btn_add_user);
list_users = new QGroupBox("Contacts");
form_list_users = new QFormLayout();
form_list_users->addRow("Liste des contacts : ", listView_users);
form_list_users->addRow("", layout_btn_add_users);
list_users->setLayout(form_list_users);
QVBoxLayout *layout_main = new QVBoxLayout;
layout_main->addWidget(list_users);
setLayout(layout_main);
connect(btn_add_user, SIGNAL(clicked()), this, SLOT(addUser()));
show();
}
示例4: LazyLoadImage
void PodcastDiscoveryModel::LazyLoadImage(const QUrl& url,
const QModelIndex& index) {
QStandardItem* item = itemFromIndex(index);
item->setData(true, Role_StartedLoadingImage);
icon_loader_->LoadIcon(url.toString(), QString(), item);
}
示例5: AddErrorItem
void ResultsTree::AddErrorItem(const ErrorItem &item)
{
if (item.files.isEmpty()) {
return;
}
QString realfile = StripPath(item.files[0], false);
if (realfile.isEmpty()) {
realfile = tr("Undefined file");
}
bool hide = !mShowSeverities.isShown(item.severity);
//bool hide = !mShowTypes[SeverityToShowType(item.severity)];
//If specified, filter on summary, message, filename, and id
if (!hide && !mFilter.isEmpty()) {
if (!item.summary.contains(mFilter, Qt::CaseInsensitive) &&
!item.message.contains(mFilter, Qt::CaseInsensitive) &&
!item.file.contains(mFilter, Qt::CaseInsensitive) &&
!item.errorId.contains(mFilter, Qt::CaseInsensitive)) {
hide = true;
}
}
//if there is at least one error that is not hidden, we have a visible error
if (!hide) {
mVisibleErrors = true;
}
ErrorLine line;
line.file = realfile;
line.errorId = item.errorId;
line.inconclusive = item.inconclusive;
line.line = item.lines[0];
line.summary = item.summary;
line.message = item.message;
line.severity = item.severity;
//Create the base item for the error and ensure it has a proper
//file item as a parent
QStandardItem *stditem = AddBacktraceFiles(EnsureFileItem(line.file, hide),
line,
hide,
SeverityToIcon(line.severity));
if (!stditem)
return;
//Add user data to that item
QMap<QString, QVariant> data;
data["hide"] = false;
data["severity"] = ShowTypes::SeverityToShowType(item.severity);
data["summary"] = item.summary;
data["message"] = item.message;
data["file"] = item.files[0];
data["line"] = item.lines[0];
data["id"] = item.errorId;
data["inconclusive"] = item.inconclusive;
stditem->setData(QVariant(data));
//Add backtrace files as children
for (int i = 1; i < item.files.size(); i++) {
line.file = StripPath(item.files[i], false);
line.line = item.lines[i];
QStandardItem *child_item;
child_item = AddBacktraceFiles(stditem,
line,
hide,
":images/go-down.png");
//Add user data to that item
QMap<QString, QVariant> child_data;
child_data["severity"] = ShowTypes::SeverityToShowType(line.severity);
child_data["summary"] = line.summary;
child_data["message"] = line.message;
child_data["file"] = item.files[i];
child_data["line"] = line.line;
child_data["id"] = line.errorId;
child_data["inconclusive"] = line.inconclusive;
child_item->setData(QVariant(child_data));
}
//TODO just hide/show current error and it's file
//since this does a lot of unnecessary work
if (!hide) {
ShowFileItem(realfile);
}
}
示例6: addModules
void QgsGrassTools::addModules( QTreeWidgetItem *parent, QDomElement &element )
{
QDomNode n = element.firstChild();
QTreeWidgetItem *item;
QTreeWidgetItem *lastItem = 0;
while ( !n.isNull() )
{
QDomElement e = n.toElement();
if ( !e.isNull() )
{
// QgsDebugMsg(QString("tag = %1").arg(e.tagName()));
if ( e.tagName() == "section" && e.tagName() == "grass" )
{
QgsDebugMsg( QString( "Unknown tag: %1" ).arg( e.tagName() ) );
continue;
}
if ( parent )
{
item = new QTreeWidgetItem( parent, lastItem );
}
else
{
item = new QTreeWidgetItem( mModulesTree, lastItem );
}
if ( e.tagName() == "section" )
{
QString label = QApplication::translate( "grasslabel", e.attribute( "label" ).toUtf8() );
QgsDebugMsg( QString( "label = %1" ).arg( label ) );
item->setText( 0, label );
item->setExpanded( false );
addModules( item, e );
lastItem = item;
}
else if ( e.tagName() == "grass" )
{ // GRASS module
QString name = e.attribute( "name" );
QgsDebugMsg( QString( "name = %1" ).arg( name ) );
QString path = QgsApplication::pkgDataPath() + "/grass/modules/" + name;
QString label = QgsGrassModule::label( path );
QPixmap pixmap = QgsGrassModule::pixmap( path, 32 );
item->setText( 0, name + " - " + label );
item->setIcon( 0, QIcon( pixmap ) );
item->setText( 1, name );
lastItem = item;
//
// Experimental work by Tim - add this item to our list model
//
QStandardItem * mypDetailItem = new QStandardItem( name + "\n" + label );
mypDetailItem->setData( name, Qt::UserRole + 1 ); //for calling runModule later
QString mySearchText = name + " - " + label;
mypDetailItem->setData( mySearchText, Qt::UserRole + 2 ); //for filtering later
mypDetailItem->setData( pixmap, Qt::DecorationRole );
mypDetailItem->setCheckable( false );
mypDetailItem->setEditable( false );
// setData in the delegate with a variantised QgsDetailedItemData
QgsDetailedItemData myData;
myData.setTitle( name );
myData.setDetail( label );
myData.setIcon( pixmap );
myData.setCheckable( false );
myData.setRenderAsWidget( false );
QVariant myVariant = qVariantFromValue( myData );
mypDetailItem->setData( myVariant, Qt::UserRole );
mModelTools->appendRow( mypDetailItem );
//
// End of experimental work by Tim
//
}
}
n = n.nextSibling();
}
}
示例7: AMBottomBar
bool AMDatamanAppControllerForActions2::startupCreateUserInterface()
{
AMErrorMon::information(this, AMDATAMANAPPCONTROLLER_STARTUP_MESSAGES, "Acquaman Startup: Populating User Interface");
qApp->processEvents();
settingsMasterView_ = 0;
issueSubmissionView_ = 0;
bottomBar_ = new AMBottomBar();
// These buttons are never used. Hiding them.
bottomBar_->fullScreenButton->hide();
bottomBar_->adjustScanFinishButton->hide();
bottomBar_->restartScanButton->hide();
mw_->addBottomWidget(bottomBar_);
connect(bottomBar_, SIGNAL(addButtonClicked()), this, SLOT(onAddButtonClicked()));
connect(bottomBar_, SIGNAL(pauseScanIssued()), this, SIGNAL(pauseScanIssued()));
connect(bottomBar_, SIGNAL(resumeScanIssued()), this, SIGNAL(resumeScanIssued()));
connect(bottomBar_, SIGNAL(stopScanIssued()), this, SIGNAL(stopScanIssued()));
// Create panes in the main window:
////////////////////////////////////
// A heading for the scan editors
scanEditorsParentItem_ = mw_->windowPaneModel()->headingItem("Open Scans");
// Make a dataview widget and add it under two links/headings: "Runs" and "Experiments". See AMMainWindowModel for more information.
////////////////////////////////////
dataView_ = new AMDataViewWithActionButtons();
dataView_->setWindowTitle("Data");
QStandardItem* dataViewItem = new QStandardItem();
dataViewItem->setData(qVariantFromValue((QWidget*)dataView_), AM::WidgetRole);
dataViewItem->setFlags(Qt::ItemIsEnabled); // enabled, but should not be selectable
QFont font = QFont("Lucida Grande", 10, QFont::Bold);
font.setCapitalization(QFont::AllUppercase);
dataViewItem->setFont(font);
dataViewItem->setData(QBrush(QColor::fromRgb(100, 109, 125)), Qt::ForegroundRole);
dataViewItem->setData(true, AMWindowPaneModel::DockStateRole);
mw_->windowPaneModel()->appendRow(dataViewItem);
runsParentItem_ = new QStandardItem(QIcon(":/22x22/view_calendar_upcoming_days.png"), "Runs");
mw_->windowPaneModel()->initAliasItem(runsParentItem_, dataViewItem, "Runs", -1);
dataViewItem->appendRow(runsParentItem_);
experimentsParentItem_ = new QStandardItem(QIcon(":/applications-science.png"), "Experiments");
mw_->windowPaneModel()->initAliasItem(experimentsParentItem_, dataViewItem, "Experiments", -1);
dataViewItem->appendRow(experimentsParentItem_);
// Hook into the sidebar and add Run and Experiment links below these headings.
runExperimentInsert_ = new AMRunExperimentInsert(AMDatabase::database("user"), runsParentItem_, experimentsParentItem_, this);
connect(runExperimentInsert_, SIGNAL(newExperimentAdded(QModelIndex)), this, SLOT(onNewExperimentAdded(QModelIndex)));
// connect the activated signal from the dataview to our own slot
connect(dataView_, SIGNAL(selectionActivated(QList<QUrl>)), this, SLOT(onDataViewItemsActivated(QList<QUrl>)));
connect(dataView_, SIGNAL(selectionActivatedSeparateWindows(QList<QUrl>)), this, SLOT(onDataViewItemsActivatedSeparateWindows(QList<QUrl>)));
connect(dataView_, SIGNAL(selectionExported(QList<QUrl>)), this, SLOT(onDataViewItemsExported(QList<QUrl>)));
connect(dataView_, SIGNAL(launchScanConfigurationsFromDb(QList<QUrl>)), this, SLOT(onLaunchScanConfigurationsFromDb(QList<QUrl>)));
connect(dataView_, SIGNAL(fixCDF(QUrl)), this, SLOT(fixCDF(QUrl)));
// When 'alias' links are clicked in the main window sidebar, we might need to notify some widgets of the details
connect(mw_, SIGNAL(aliasItemActivated(QWidget*,QString,QVariant)), this, SLOT(onMainWindowAliasItemActivated(QWidget*,QString,QVariant)));
/////////////////////////
// Make connections:
//////////////////////////////
connect(mw_, SIGNAL(currentPaneChanged(QWidget*)), this, SLOT(onCurrentPaneChanged(QWidget*)));
// show main window
mw_->show();
return true;
}
示例8: tr
QStandardItem *FlagColumn::build_cell(Dwarf *d) {
QStandardItem *item = init_cell(d);
item->setData(CT_FLAGS, DwarfModel::DR_COL_TYPE);
item->setData(0,DwarfModel::DR_STATE); //default
QString info_msg = "";
QString info_col_name = "";
short rating = 0;
if(d->get_flag_value(m_bit_pos))
rating = 1;
//check to fix butchering pets. currently this will cause the butchered parts to still be recognized as a pet
//and they'll put them into a burial recepticle, but won't use them as a food source
ViewColumn::CELL_STATE state = STATE_TOGGLE;
if(m_bit_pos == FLAG_BUTCHER){
if(d->is_pet()){
info_msg = tr("<b>Pets cannot be slaughtered!</b>");
state = STATE_DISABLED;
}else if(!d->get_caste() || !d->get_caste()->flags().has_flag(BUTCHERABLE)){
info_msg = tr("<b>This caste cannot be slaughtered!</b>");
state = STATE_DISABLED;
}else if(rating == 1){
info_msg = tr("<b>This creature has been marked for slaughter.</b>");
state = STATE_PENDING;
}else if(d->trained_level() >= Dwarf::unknown_trained){
info_msg = tr("<b>Captured wild animals cannot be butchered!</b>");
state = STATE_DISABLED;
}else{
state = STATE_TOGGLE;
}
}else if(m_bit_pos == FLAG_GELD){
if(d->get_gender() != Dwarf::SEX_M){
info_msg = tr("<b>Only males can be gelded!</b>");
state = STATE_DISABLED;
}else if(d->has_health_issue(eHealth::HI_GELDED,0)){
info_msg = tr("<b>This creature has already been gelded!</b>");
state = STATE_ACTIVE;
}else if(rating == 1){
info_msg = tr("<b>This creature has been marked for gelding.</b>");
state = STATE_PENDING;
}else if(!d->get_caste()->is_geldable()){ //check last as it's the most expensive
info_msg = tr("<b>This caste is not geldable!</b>");
state = STATE_DISABLED;
}else{
state = STATE_TOGGLE;
}
}
item->setData(state,DwarfModel::DR_STATE);
info_col_name = get_state_color(state).name();//item->data(Qt::BackgroundColorRole).value<QColor>().name();
item->setData(rating, DwarfModel::DR_SORT_VALUE);
item->setData(m_bit_pos, DwarfModel::DR_OTHER_ID);
item->setData(m_set->name(), DwarfModel::DR_SET_NAME);
QString tooltip = QString("<center><h3>%1</h3>%2</center>%3")
.arg(m_title)
.arg(QString("<font color=%1>%2</font>").arg(info_col_name).arg(info_msg))
.arg(tooltip_name_footer(d));
item->setToolTip(tooltip);
return item;
}
示例9: QDialog
//------------------------------------------------------------------------
GMapDialog::GMapDialog(QWidget *parent, const QString &gpxFileName, QPlainTextEdit *te): QDialog(parent)
{
ui.setupUi(this);
this->setWindowTitle(QString(appName) + " " + QString("Google Maps"));
gpx.read(gpxFileName);
mapWidget = new Map(this, gpx, te);
QHBoxLayout *lay = new QHBoxLayout(ui.frame);
lay->setContentsMargins(0, 0, 0, 0);
lay->addWidget(mapWidget);
model = new QStandardItemModel(this);
wptItem = new StandardItem(tr("Waypoints"));
wptItem->setCheckable(true);
wptItem->setCheckState(Qt::Checked);
model->appendRow(wptItem);
for (int i=0; i<gpx.getWaypoints().size(); i++) {
GpxWaypoint &wpt = gpx.getWaypoints()[i];
QStandardItem *it = new StandardItem(wpt.getName());
wptItem->appendRow(it);
it->setCheckable(true);
it->setCheckState(Qt::Checked);
it->setData(qVariantFromValue((void *)&wpt));
appendWaypointInfo(it, wpt);
wptList << it;
}
trkItem = new StandardItem(tr("Tracks"));
trkItem->setCheckable(true);
trkItem->setCheckState(Qt::Checked);
model->appendRow(trkItem);
for (int i=0; i<gpx.getTracks().size(); i++) {
GpxTrack &trk = gpx.getTracks()[i];
QStandardItem *it = new StandardItem(trk.getName());
trkItem->appendRow(it);
it->setCheckable(true);
it->setCheckState(Qt::Checked);
it->setData(qVariantFromValue((void *)&trk));
appendTrackInfo(it, trk);
trkList << it;
}
rteItem = new StandardItem(tr("Routes"));
rteItem->setCheckable(true);
rteItem->setCheckState(Qt::Checked);
model->appendRow(rteItem);
for (int i=0; i<gpx.getRoutes().size(); i++) {
GpxRoute &rte = gpx.getRoutes()[i];
QStandardItem *it = new StandardItem(rte.getName());
rteItem->appendRow(it);
it->setCheckable(true);
it->setCheckState(Qt::Checked);
it->setData(qVariantFromValue((void *)&rte));
appendRouteInfo(it, rte);
rteList << it;
}
ui.treeView->header()->hide();
ui.treeView->setModel(model);
ui.treeView->setExpandsOnDoubleClick(false);
connect(model, SIGNAL(itemChanged(QStandardItem *)),
this, SLOT(itemChangedX(QStandardItem *)));
connect(mapWidget, SIGNAL(waypointClicked(int)), this, SLOT(waypointClickedX(int)));
connect(mapWidget, SIGNAL(routeClicked(int)), this, SLOT(routeClickedX(int)));
connect(mapWidget, SIGNAL(trackClicked(int)), this, SLOT(trackClickedX(int)));
connect(ui.treeView, SIGNAL(doubleClicked(const QModelIndex &)),
this, SLOT(treeDoubleClicked(const QModelIndex&)));
connect(ui.treeView->selectionModel(), SIGNAL(selectionChanged (const QItemSelection &, const QItemSelection &)),
this, SLOT(selectionChangedX(const QItemSelection &, const QItemSelection &)));
ui.treeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui.treeView, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showContextMenu(const QPoint &)));
connect(ui.copyButton, SIGNAL(clicked()), this, SLOT(copyButtonClickedX()));
ui.copyButton->hide(); // Hide for now, not working
}
示例10: createEntry
QStandardItem* ToolBarDialog::createEntry(const QString &identifier)
{
QStandardItem *item = new QStandardItem();
item->setData(identifier, Qt::UserRole);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemNeverHasChildren);
if (identifier == QLatin1String("separator"))
{
item->setText(tr("--- separator ---"));
}
else if (identifier == QLatin1String("spacer"))
{
item->setText(tr("--- spacer ---"));
}
else if (identifier == QLatin1String("AddressWidget"))
{
item->setText(tr("Address Field"));
}
else if (identifier == QLatin1String("ClosedWindowsWidget"))
{
item->setText(tr("List of Closed Windows and Tabs"));
}
else if (identifier == QLatin1String("MenuBarWidget"))
{
item->setText(tr("Menu Bar"));
}
else if (identifier == QLatin1String("MenuButtonWidget"))
{
item->setText(tr("Menu Button"));
}
else if (identifier == QLatin1String("PanelChooserWidget"))
{
item->setText(tr("Sidebar Panel Chooser"));
}
else if (identifier == QLatin1String("SearchWidget"))
{
item->setText(tr("Search Field"));
}
else if (identifier == QLatin1String("StatusMessageWidget"))
{
item->setText(tr("Status Message Field"));
}
else if (identifier == QLatin1String("TabBarWidget"))
{
item->setText(tr("Tab Bar"));
}
else if (identifier == QLatin1String("ZoomWidget"))
{
item->setText(tr("Zoom Slider"));
}
else if (identifier.startsWith(QLatin1String("bookmarks:")))
{
BookmarksItem *bookmark = (identifier.startsWith(QLatin1String("bookmarks:/")) ? BookmarksManager::getModel()->getItem(identifier.mid(11)) : BookmarksManager::getBookmark(identifier.mid(10).toULongLong()));
if (bookmark)
{
item->setText(bookmark->data(BookmarksModel::TitleRole).isValid() ? bookmark->data(BookmarksModel::TitleRole).toString() : tr("(Untitled)"));
item->setIcon(bookmark->data(Qt::DecorationRole).value<QIcon>());
}
else
{
item->setText(tr("Invalid Bookmark"));
}
}
else if (identifier.endsWith(QLatin1String("Action")))
{
const int actionIdentifier = ActionsManager::getActionIdentifier(identifier.left(identifier.length() - 6));
if (actionIdentifier < 0)
{
item->setText(tr("Invalid Entry"));
}
else
{
const ActionDefinition definition = ActionsManager::getActionDefinition(actionIdentifier);
item->setText(QCoreApplication::translate("actions", (definition.description.isEmpty() ? definition.text : definition.description).toUtf8().constData()));
item->setIcon(definition.icon);
}
}
else
{
item->setText(tr("Invalid Entry"));
}
return item;
}
示例11: url
Load::Load(QObject *parent) : QObject(parent), d_ptr(new LoadPrivate(this))
{
Q_D(Load);
ins = this;
setObjectName("Load");
auto avProcess = [this](QNetworkReply *reply){
Q_D(Load);
Task &task = d->queue.head();
int sharp = task.code.indexOf(QRegularExpression("[#_]"));
switch (task.state){
case None:
{
QString i = task.code.mid(2, sharp - 2);
QString p = sharp == -1 ? QString() : task.code.mid(sharp + 1);
QString url("http://www.%1/video/av%2/");
url = url.arg(Utils::customUrl(Utils::Bilibili)).arg(i);
if (!p.isEmpty()){
url += QString("index_%1.html").arg(p);
}
forward(QNetworkRequest(url), Page);
break;
}
case Page:
{
d->model->clear();
QString api, id, video(reply->readAll());
int part = video.indexOf("<select");
if (part != -1 && sharp == -1){
QRegularExpression r("(?<=>).*?(?=</option>)");
QStringRef list(&video, part, video.indexOf("</select>", part) - part);
QRegularExpressionMatchIterator i = r.globalMatch(list);
api = "http://www.%1/video/%2/index_%3.html";
api = api.arg(Utils::customUrl(Utils::Bilibili));
while (i.hasNext()){
int index = d->model->rowCount() + 1;
QStandardItem *item = new QStandardItem;
item->setData(QUrl(api.arg(task.code).arg(index)), UrlRole);
item->setData((task.code + "#%1").arg(index), StrRole);
item->setData(Page, NxtRole);
item->setData(Utils::decodeXml(i.next().captured()), Qt::EditRole);
d->model->appendRow(item);
}
}
if (d->model->rowCount() > 0){
emit stateChanged(task.state = Part);
}
else{
QRegularExpression r = QRegularExpression("cid[=\":]*\\d+", QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatchIterator i = r.globalMatch(video);
while (i.hasNext()){
QString m = i.next().captured();
m = QRegularExpression("\\d+").match(m).captured();
if (id.isEmpty()){
id = m;
}
else if (id != m){
id.clear();
break;
}
}
if (!id.isEmpty()){
api = "http://comment.%1/%2.xml";
api = api.arg(Utils::customUrl(Utils::Bilibili));
forward(QNetworkRequest(api.arg(id)), File);
}
else{
emit stateChanged(203);
qDebug() << "Fail to load danmaku, try biliApi";
dequeue();
}
}
break;
}
case File:
{
dumpDanmaku(reply->readAll(), Utils::Bilibili, false);
emit stateChanged(task.state = None);
dequeue();
break;
}
}
};
auto avRegular = [](QString &code){
code.remove(QRegularExpression("/index(?=_\\d+\\.html)"));
QRegularExpression r("a(v(\\d+([#_])?(\\d+)?)?)?");
r.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
return getRegular(r)(code);
};
d->pool.append({ avRegular, 0, avProcess });
auto bbProcess = [this, avProcess](QNetworkReply *reply) {
Q_D(Load);
Task &task = d->queue.head();
switch (task.state) {
case None:
{
QString i = task.code.mid(2);
QString u = "http://www.%1/bangumi/i/%2/";
u = u.arg(Utils::customUrl(Utils::Bilibili)).arg(i);
//.........这里部分代码省略.........
示例12: cardIcon
QWidget *TTriadEditor::buildPage1()
{
QWidget *ret = new QWidget(this);
QFont font;
font.setPointSize(10);
cardE_model = new QStandardItemModel(ret);
cardE_view = new QTreeView(ret);
cardE_view->setModel(cardE_model);
cardE_view->setEditTriggers(QAbstractItemView::DoubleClicked);
cardE_view->setFont(font);
cardE_view->setItemDelegate(new SpinBoxDelegate(ret));
cardE_view->setIndentation(0);
cardE_view->setItemsExpandable(false);
cardE_view->header()->setStretchLastSection(false);
cardE_view->setUniformRowHeights(true);
cardE_view->setAllColumnsShowFocus(true);
cardE_model2 = new QStandardItemModel(ret);
cardE_view2 = new QTreeView(ret);
cardE_view2->setModel(cardE_model2);
cardE_view2->setEditTriggers(QAbstractItemView::DoubleClicked);
cardE_view2->setFont(font);
cardE_view2->setItemDelegate(new SpinBoxDelegate(ret));
cardE_view2->setIndentation(0);
cardE_view2->setItemsExpandable(false);
cardE_view2->header()->setStretchLastSection(false);
cardE_view2->setUniformRowHeights(true);
cardE_view2->setAllColumnsShowFocus(true);
QStringList labels;
QStandardItem *standardItem;
QIcon cardIcon(":/images/icons/carte.png");
labels << tr("Nom") << tr("Qté");
cardE_model->setHorizontalHeaderLabels(labels);
for(quint8 i=0 ; i<77 ; ++i)
{
if(i % 11 == 0) {
QList<QStandardItem *> items;
standardItem = new QStandardItem(tr("Niveau %1").arg(i/11 + 1));
standardItem->setEditable(false);
standardItem->setEnabled(false);
standardItem->setCheckable(false);
standardItem->setData(-1, Qt::UserRole+2);
items.append(standardItem);
standardItem = new QStandardItem();
standardItem->setEditable(false);
standardItem->setEnabled(false);
standardItem->setCheckable(false);
standardItem->setData(-1, Qt::UserRole+2);
items.append(standardItem);
cardE_model->appendRow(items);
}
QList<QStandardItem *> items;
standardItem = new QStandardItem(Data::cards().at(i));
standardItem->setEditable(false);
standardItem->setCheckable(true);
standardItem->setIcon(cardIcon);
standardItem->setData(i, Qt::UserRole+2);
items.append(standardItem);
standardItem = new QStandardItem();
standardItem->setData(i, Qt::UserRole+2);
standardItem->setData(SpinBoxDelegate::SpinBox127, Qt::UserRole);
items.append(standardItem);
cardE_model->appendRow(items);
}
cardE_view->header()->HEADER_VIEW_SET_RESIZE_MODE(0, QHeaderView::Stretch);
cardE_view->header()->HEADER_VIEW_SET_RESIZE_MODE(1, QHeaderView::ResizeToContents);
labels.replace(1, tr("Possesseur"));
cardE_model2->setHorizontalHeaderLabels(labels);
for(quint8 i=0 ; i<33 ; ++i)
{
if(i % 11 == 0) {
QList<QStandardItem *> items;
standardItem = new QStandardItem(tr("Niveau %1").arg(i/11 + 8));
standardItem->setEditable(false);
standardItem->setEnabled(false);
standardItem->setCheckable(false);
standardItem->setData(-1, Qt::UserRole+2);
items.append(standardItem);
standardItem = new QStandardItem();
standardItem->setEditable(false);
standardItem->setEnabled(false);
standardItem->setCheckable(false);
standardItem->setData(-1, Qt::UserRole+2);
//.........这里部分代码省略.........
示例13: initSessionFiles
void KateSessionApplet::initSessionFiles()
{
// Obtain list of items previously configured as hidden
const QStringList hideList = config().readEntry("hideList", QStringList());
// Construct a full list of items (m_fullList) so we can display them
// in the config dialog, but leave out the hidden stuff for m_kateModel
// that is actually displayed
int index=0;
QStandardItem *item = new QStandardItem();
item->setData(i18n("Start Kate (no arguments)"), Qt::DisplayRole);
item->setData( KIcon( "kate" ), Qt::DecorationRole );
item->setData( index++, Index );
m_fullList << item->data(Qt::DisplayRole).toString();
if (!hideList.contains(item->data(Qt::DisplayRole).toString())) {
m_kateModel->appendRow(item);
}
item = new QStandardItem();
item->setData( i18n("New Kate Session"), Qt::DisplayRole);
item->setData( KIcon( "document-new" ), Qt::DecorationRole );
item->setData( index++, Index );
m_fullList << item->data(Qt::DisplayRole).toString();
if (!hideList.contains(item->data(Qt::DisplayRole).toString())) {
m_kateModel->appendRow(item);
}
item = new QStandardItem();
item->setData( i18n("New Anonymous Session"), Qt::DisplayRole);
item->setData( index++, Index );
item->setData( KIcon( "document-new" ), Qt::DecorationRole );
m_fullList << item->data(Qt::DisplayRole).toString();
if (!hideList.contains(item->data(Qt::DisplayRole).toString())) {
m_kateModel->appendRow(item);
}
const QStringList list = KGlobal::dirs()->findAllResources( "data", "kate/sessions/*.katesession", KStandardDirs::NoDuplicates );
KUrl url;
for (QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it)
{
url.setPath(*it);
QString name=url.fileName();
name = QUrl::fromPercentEncoding(QFile::encodeName(url.fileName()));
name.chop(12);///.katesession==12
/* KConfig _config( *it, KConfig::SimpleConfig );
KConfigGroup config(&_config, "General" );
QString name = config.readEntry( "Name" );*/
m_sessions.append( name );
}
qSort(m_sessions.begin(),m_sessions.end(),katesessions_compare_sessions);
for(QStringList::ConstIterator it=m_sessions.constBegin();it!=m_sessions.constEnd();++it)
{
m_fullList << *it;
if (!hideList.contains(*it)) {
item = new QStandardItem();
item->setData(*it, Qt::DisplayRole);
item->setData( index++, Index );
m_kateModel->appendRow( item);
}
}
}
示例14: browseAllVideos
void VideosWindow::browseAllVideos(uint browseId, int remainingCount, uint index, QString objectId, GHashTable *metadata)
{
if (this->browseId != browseId) return;
if (index == 0) {
recordingsBufferList.clear();
filmsBufferList.clear();
if (sortByDate->isChecked()) {
int delta = remainingCount+1 - objectModel->rowCount();
if (delta > 0)
for (int i = 0; i < delta; i++)
objectModel->appendRow(new QStandardItem());
else
for (int i = delta; i < 0; i++)
objectModel->removeRow(objectModel->rowCount()-1);
}
}
if (metadata != NULL) {
GValue *v;
v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_TITLE);
QString title = v ? QString::fromUtf8(g_value_get_string (v)) : tr("(unknown clip)");
v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_VIDEO_SOURCE);
QString source = v ? QString::fromUtf8(g_value_get_string (v)) : QString();
v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_DURATION);
int duration = v ? g_value_get_int (v) : Duration::Unknown;
QStandardItem *item = sortByCategory->isChecked() ? new QStandardItem() : objectModel->item(index);
v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_PAUSED_THUMBNAIL_URI);
if (v != NULL) {
const gchar* filename = g_value_get_string(v); // the uri is really a filename
if (filename != NULL)
item->setIcon(QIcon(QString::fromUtf8(filename)));
} else {
v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_THUMBNAIL_URI);
if (v != NULL) {
const gchar* file_uri = g_value_get_string(v); // here uri is a uri
gchar* filename;
if (file_uri != NULL && (filename = g_filename_from_uri(file_uri, NULL, NULL)) != NULL)
item->setIcon(QIcon(QString::fromUtf8(filename)));
} else {
item->setIcon(QIcon::fromTheme(defaultVideoIcon));
}
}
item->setData(objectId, UserRoleObjectID);
item->setData(title, UserRoleTitle);
if (sortByCategory->isChecked()) {
item->setData(duration, UserRoleSongDuration);
(source.startsWith("noki://") ? recordingsBufferList : filmsBufferList).append(item);
}
else { // sortByDate->isChecked()
if (duration != Duration::Unknown) {
QTime t(0, 0);
t = t.addSecs(duration);
item->setData(t.toString("h:mm:ss"), UserRoleValueText);
} else
item->setData("-:--:--", UserRoleValueText);
}
}
if (remainingCount == 0) {
disconnect(mafwTrackerSource, SIGNAL(browseResult(uint,int,uint,QString,GHashTable*,QString)),
this, SLOT(browseAllVideos(uint,int,uint,QString,GHashTable*)));
if (sortByCategory->isChecked()) {
bool drawHeaders = !recordingsBufferList.isEmpty() && !filmsBufferList.isEmpty();
int delta = recordingsBufferList.size() + filmsBufferList.size() - objectModel->rowCount();
if (drawHeaders) delta += 2;
if (delta > 0)
for (int i = 0; i < delta; i++)
objectModel->appendRow(new QStandardItem());
else
for (int i = delta; i < 0; i++)
objectModel->removeRow(objectModel->rowCount()-1);
int i = 0;
if (!recordingsBufferList.isEmpty()) {
if (drawHeaders) {
objectModel->item(i)->setData(true, UserRoleHeader);
objectModel->item(i)->setData(tr("Recorded by device camera"), UserRoleTitle);
objectModel->item(i)->setData(Duration::Blank, UserRoleSongDuration);
++i;
}
while (!recordingsBufferList.isEmpty()) {
objectModel->item(i)->setData(false, UserRoleHeader);
objectModel->item(i)->setData(recordingsBufferList.first()->data(UserRoleTitle), UserRoleTitle);
objectModel->item(i)->setData(recordingsBufferList.first()->data(UserRoleObjectID), UserRoleObjectID);
objectModel->item(i)->setData(recordingsBufferList.first()->data(UserRoleSongDuration), UserRoleSongDuration);
objectModel->item(i)->setIcon(recordingsBufferList.first()->icon());
delete recordingsBufferList.takeFirst();
//.........这里部分代码省略.........
示例15: addTableEntry
void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProperty )
{
QgsDebugMsg( layerProperty.toString() );
// is there already a root item with the given scheme Name?
QStandardItem *schemaItem = nullptr;
for ( int i = 0; i < layerProperty.size(); i++ )
{
QgsWkbTypes::Type wkbType = layerProperty.types[ i ];
int srid = layerProperty.srids[ i ];
if ( wkbType == QgsWkbTypes::Unknown && layerProperty.geometryColName.isEmpty() )
{
wkbType = QgsWkbTypes::NoGeometry;
}
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 && srid == INT_MIN )
{
tip = tr( "Enter a SRID into the '%1' column" ).arg( tr( "SRID" ) );
}
else if ( !layerProperty.pkCols.isEmpty() )
{
tip = tr( "Select columns in the '%1' column that uniquely identify features of this layer" ).arg( tr( "Feature id" ) );
}
QStandardItem *schemaNameItem = new QStandardItem( layerProperty.schemaName );
QStandardItem *typeItem = new QStandardItem( iconForWkbType( wkbType ), wkbType == QgsWkbTypes::Unknown ? tr( "Select..." ) : QgsPostgresConn::displayStringForWkbType( wkbType ) );
typeItem->setData( wkbType == QgsWkbTypes::Unknown, Qt::UserRole + 1 );
typeItem->setData( wkbType, Qt::UserRole + 2 );
if ( wkbType == QgsWkbTypes::Unknown )
typeItem->setFlags( typeItem->flags() | Qt::ItemIsEditable );
QStandardItem *geomTypeItem = new QStandardItem( QgsPostgresConn::displayStringForGeomType( layerProperty.geometryColType ) );
QStandardItem *tableItem = new QStandardItem( layerProperty.tableName );
QStandardItem *commentItem = new QStandardItem( layerProperty.tableComment );
QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName );
QStandardItem *sridItem = new QStandardItem( wkbType != QgsWkbTypes::NoGeometry ? QString::number( srid ) : QLatin1String( "" ) );
sridItem->setEditable( wkbType != QgsWkbTypes::NoGeometry && srid == INT_MIN );
if ( sridItem->isEditable() )
{
sridItem->setText( tr( "Enter..." ) );
sridItem->setFlags( sridItem->flags() | Qt::ItemIsEditable );
}
QStandardItem *pkItem = new QStandardItem( QLatin1String( "" ) );
if ( !layerProperty.pkCols.isEmpty() )
{
pkItem->setText( tr( "Select..." ) );
pkItem->setFlags( pkItem->flags() | Qt::ItemIsEditable );
}
else
pkItem->setFlags( pkItem->flags() & ~Qt::ItemIsEditable );
pkItem->setData( layerProperty.pkCols, Qt::UserRole + 1 );
pkItem->setData( "", Qt::UserRole + 2 );
QStandardItem *selItem = new QStandardItem( QLatin1String( "" ) );
selItem->setFlags( selItem->flags() | Qt::ItemIsUserCheckable );
selItem->setCheckState( Qt::Checked );
selItem->setToolTip( tr( "Disable 'Fast Access to Features at ID' capability to force keeping the attribute table in memory (e.g. in case of expensive views)." ) );
QStandardItem *sqlItem = new QStandardItem( layerProperty.sql );
QList<QStandardItem *> childItemList;
childItemList << schemaNameItem;
childItemList << tableItem;
childItemList << commentItem;
childItemList << geomItem;
childItemList << geomTypeItem;
childItemList << typeItem;
childItemList << sridItem;
childItemList << pkItem;
childItemList << selItem;
childItemList << sqlItem;
Q_FOREACH ( QStandardItem *item, childItemList )
{
if ( tip.isEmpty() )
{
item->setFlags( item->flags() | Qt::ItemIsSelectable );
item->setToolTip( QLatin1String( "" ) );
}
else
{
item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
if ( item == schemaNameItem )
item->setData( QgsApplication::getThemeIcon( QStringLiteral( "/mIconWarning.svg" ) ), Qt::DecorationRole );
if ( item == schemaNameItem || item == tableItem || item == geomItem )
{
item->setToolTip( tip );
//.........这里部分代码省略.........