本文整理汇总了C++中QListWidgetItem::icon方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidgetItem::icon方法的具体用法?C++ QListWidgetItem::icon怎么用?C++ QListWidgetItem::icon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidgetItem
的用法示例。
在下文中一共展示了QListWidgetItem::icon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShouldHide
bool AlbumCoverManager::ShouldHide(const QListWidgetItem& item,
const QString& filter,
HideCovers hide) const {
bool has_cover = item.icon().cacheKey() != no_cover_icon_.cacheKey();
if (hide == Hide_WithCovers && has_cover) {
return true;
} else if (hide == Hide_WithoutCovers && !has_cover) {
return true;
}
if (filter.isEmpty()) {
return false;
}
QStringList query = filter.split(' ');
for (const QString& s : query) {
if (!item.text().contains(s, Qt::CaseInsensitive) &&
!item.data(Role_ArtistName).toString().contains(s,
Qt::CaseInsensitive)) {
return true;
}
}
return false;
}
示例2: startDrag
void WidgetListing::startDrag( Qt::DropActions /*supportedActions*/ )
{
QListWidgetItem *item = currentItem();
QByteArray itemData;
QDataStream dataStream( &itemData, QIODevice::WriteOnly );
int i_type = item->data( Qt::UserRole ).toInt();
int i_option = parent->getOptions();
dataStream << i_type << i_option;
/* Create a new dragging event */
QDrag *drag = new QDrag( this );
/* With correct mimedata */
QMimeData *mimeData = new QMimeData;
mimeData->setData( "vlc/button-bar", itemData );
drag->setMimeData( mimeData );
/* And correct pixmap */
QPixmap aPixmap = item->icon().pixmap( QSize( 22, 22 ) );
drag->setPixmap( aPixmap );
drag->setHotSpot( QPoint( 20, 20 ) );
/* We want to keep a copy */
drag->exec( Qt::CopyAction | Qt::MoveAction );
}
示例3: on_previewPixmapItemButton_clicked
void ListWidgetEditor::on_previewPixmapItemButton_clicked()
{
int currentRow = ui.listWidget->currentRow();
if (currentRow == -1)
return;
QListWidgetItem *item = ui.listWidget->item(currentRow);
FindIconDialog dialog(m_form, this);
QString file_path;
QString qrc_path;
QIcon icon = item->icon();
if (!icon.isNull()) {
file_path = m_form->core()->iconCache()->iconToFilePath(icon);
qrc_path = m_form->core()->iconCache()->iconToQrcPath(icon);
}
dialog.setPaths(qrc_path, file_path);
if (dialog.exec()) {
file_path = dialog.filePath();
qrc_path = dialog.qrcPath();
if (!file_path.isEmpty()) {
icon = m_form->core()->iconCache()->nameToIcon(file_path, qrc_path);
item->setIcon(icon);
ui.previewPixmapItemButton->setIcon(icon);
ui.deletePixmapItemButton->setEnabled(!icon.isNull());
}
}
}
示例4: startDrag
void ResourceListWidget::startDrag(Qt::DropActions supportedActions)
{
if (supportedActions == Qt::MoveAction)
return;
QListWidgetItem *item = currentItem();
if (!item)
return;
const QString filePath = item->data(Qt::UserRole).toString();
const QIcon icon = item->icon();
QMimeData *mimeData = new QMimeData;
const QtResourceView::ResourceType type = icon.isNull() ? QtResourceView::ResourceOther : QtResourceView::ResourceImage;
mimeData->setText(QtResourceView::encodeMimeData(type , filePath));
QDrag *drag = new QDrag(this);
if (!icon.isNull()) {
const QSize size = icon.actualSize(iconSize());
drag->setPixmap(icon.pixmap(size));
drag->setHotSpot(QPoint(size.width() / 2, size.height() / 2));
}
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction);
}
示例5: UpdateFilter
void AlbumCoverManager::UpdateFilter() {
const QString filter = ui_->filter->text().toLower();
const bool hide_with_covers = filter_without_covers_->isChecked();
const bool hide_without_covers = filter_with_covers_->isChecked();
HideCovers hide = Hide_None;
if (hide_with_covers) {
hide = Hide_WithCovers;
} else if (hide_without_covers) {
hide = Hide_WithoutCovers;
}
qint32 total_count = 0;
qint32 without_cover = 0;
for (int i = 0; i < ui_->albums->count(); ++i) {
QListWidgetItem* item = ui_->albums->item(i);
bool should_hide = ShouldHide(*item, filter, hide);
item->setHidden(should_hide);
if (!should_hide) {
total_count++;
if (item->icon().cacheKey() == no_cover_icon_.cacheKey()) {
without_cover++;
}
}
}
ui_->total_albums->setText(QString::number(total_count));
ui_->without_cover->setText(QString::number(without_cover));
}
示例6: on_previewPixmapColumnButton_clicked
void TreeWidgetEditor::on_previewPixmapColumnButton_clicked()
{
QListWidgetItem *currentColumn = ui.listWidget->currentItem();
if (!currentColumn)
return;
int currentRow = ui.listWidget->currentRow();
FindIconDialog dialog(m_form, this);
QString file_path;
QString qrc_path;
QIcon icon = currentColumn->icon();
if (icon.isNull()) {
file_path = m_form->absoluteDir().absolutePath();
} else {
file_path = m_form->core()->iconCache()->iconToFilePath(icon);
qrc_path = m_form->core()->iconCache()->iconToQrcPath(icon);
}
dialog.setPaths(qrc_path, file_path);
if (dialog.exec()) {
file_path = dialog.filePath();
qrc_path = dialog.qrcPath();
if (!file_path.isEmpty()) {
icon = m_form->core()->iconCache()->nameToIcon(file_path, qrc_path);
currentColumn->setIcon(icon);
ui.treeWidget->headerItem()->setIcon(currentRow, icon);
ui.previewPixmapColumnButton->setIcon(icon);
ui.deletePixmapColumnButton->setEnabled(!icon.isNull());
}
}
}
示例7: editImageProperties
void NewGameTab::editImageProperties()
{
QListWidgetItem* item = m_images->currentItem();
if (!item || item->isHidden()) {
return;
}
QString filename = item->data(ImageRole).toString();
ImagePropertiesDialog dialog(item->icon(), item->text(), m_image_tags, filename, window());
if (dialog.exec() == QDialog::Accepted) {
// Update name
item->setText(dialog.name());
if (item->text() != item->data(NameRole).toString()) {
item->setData(NameRole, item->text());
QSettings details(Path::image("details"), QSettings::IniFormat);
details.setValue(filename + "/Name", item->text());
emit imageRenamed(filename, item->text());
m_images->sortItems();
m_images->scrollToItem(item);
}
// Update tags
item->setData(TagsRole, m_image_tags->tags(item->data(ImageRole).toString()));
updateToolTip(item);
}
}
示例8: friendRemove
/*
* Removes selected friend from friendsList.
* @emits friendRemoved(friend that is removed)
*/
void Facepamphlet::friendRemove()
{
// If the list is not empty and currentRow is valid
int currentRow = friendsList->currentRow();
if(friendsList->count() > 0 && currentRow >= 0) {
QListWidgetItem* selected = friendsList->takeItem(currentRow);
friendInfo selectedFriend;
selectedFriend.image = selected->icon();
selectedFriend.alias = selected->text();
emit(friendRemoved(selectedFriend));
}
}
示例9: startDrag
void IPProcessList::startDrag(Qt::DropActions)
{
QListWidgetItem* item = currentItem();
QMimeData* mimeData = new QMimeData;
QByteArray processID;
processID.append(item->toolTip());
mimeData->setData("application/x-imageplay", processID);
QPixmap dragPixmap = item->icon().pixmap(32,32);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->setPixmap(dragPixmap);
drag->setHotSpot(QPoint(16,16));
drag->exec(Qt::MoveAction);
//QListWidget::startDrag(supportedActions);
}
示例10: FetchAlbumCovers
void AlbumCoverManager::FetchAlbumCovers() {
for (int i = 0; i < ui_->albums->count(); ++i) {
QListWidgetItem* item = ui_->albums->item(i);
if (item->isHidden()) continue;
if (item->icon().cacheKey() != no_cover_icon_.cacheKey()) continue;
quint64 id =
cover_fetcher_->FetchAlbumCover(item->data(Role_ArtistName).toString(),
item->data(Role_AlbumName).toString());
cover_fetching_tasks_[id] = item;
jobs_++;
}
if (!cover_fetching_tasks_.isEmpty()) ui_->fetch->setEnabled(false);
progress_bar_->setMaximum(jobs_);
progress_bar_->show();
abort_progress_->show();
fetch_statistics_ = CoverSearchStatistics();
UpdateStatusText();
}
示例11: updateEditor
void ListWidgetEditor::updateEditor()
{
bool currentItemEnabled = false;
bool moveRowUpEnabled = false;
bool moveRowDownEnabled = false;
QListWidgetItem *item = ui.listWidget->currentItem();
if (item) {
currentItemEnabled = true;
int currentRow = ui.listWidget->currentRow();
if (currentRow > 0)
moveRowUpEnabled = true;
if (currentRow < ui.listWidget->count() - 1)
moveRowDownEnabled = true;
}
ui.moveItemUpButton->setEnabled(moveRowUpEnabled);
ui.moveItemDownButton->setEnabled(moveRowDownEnabled);
ui.deleteItemButton->setEnabled(currentItemEnabled);
ui.textLabel->setEnabled(currentItemEnabled);
ui.pixmapLabel->setEnabled(currentItemEnabled);
ui.deletePixmapItemButton->setEnabled(currentItemEnabled);
ui.previewPixmapItemButton->setEnabled(currentItemEnabled);
ui.itemTextLineEdit->setEnabled(currentItemEnabled);
QString itemText;
QIcon itemIcon;
if (item) {
itemText = item->text();
itemIcon = item->icon();
}
int cursorPos = ui.itemTextLineEdit->cursorPosition();
ui.itemTextLineEdit->setText(itemText);
ui.itemTextLineEdit->setCursorPosition(cursorPos);
ui.previewPixmapItemButton->setIcon(itemIcon);
ui.deletePixmapItemButton->setEnabled(!itemIcon.isNull());
}
示例12: startDrag
void TemplateWidget::startDrag(Qt::DropActions /*supportedActions*/)
{
QListWidgetItem *item = currentItem();
/*if (!itemTotemplate.contains(item))
return;*/
QNCLContourLine * cnl = itemTotemplate[item];
QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
//pass the template's name to dataset or dupilcate template.
dataStream<<item->text();
/*dataStream << cnl;*/
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/template", itemData);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
QPixmap pixmap = item->icon().pixmap(32);
drag->setHotSpot(QPoint(pixmap.width()/2, pixmap.height()/2));
drag->setPixmap(pixmap);
drag->exec(Qt::CopyAction);
}
示例13: ExportCovers
void AlbumCoverManager::ExportCovers() {
AlbumCoverExport::DialogResult result = cover_export_->Exec();
if (result.cancelled_) {
return;
}
DisableCoversButtons();
cover_exporter_->SetDialogResult(result);
for (int i = 0; i < ui_->albums->count(); ++i) {
QListWidgetItem* item = ui_->albums->item(i);
// skip hidden and coverless albums
if (item->isHidden() ||
item->icon().cacheKey() == no_cover_icon_.cacheKey()) {
continue;
}
cover_exporter_->AddExportRequest(ItemAsSong(item));
}
if (cover_exporter_->request_count() > 0) {
progress_bar_->setMaximum(cover_exporter_->request_count());
progress_bar_->show();
abort_progress_->show();
cover_exporter_->StartExporting();
} else {
QMessageBox msg;
msg.setWindowTitle(tr("Export finished"));
msg.setText(tr("No covers to export."));
msg.exec();
}
}
示例14: paintEvent
/** Redefined to be able to display items with the current theme. */
void AddressBarMenu::paintEvent(QPaintEvent *)
{
QStylePainter p(this->viewport());
// Vertical frame between icons and text
p.save();
QPalette palette = QApplication::palette();
p.setPen(palette.midlight().color());
p.drawLine(33, 0, 33, rect().height());
p.restore();
int offsetSB = 0;
if (verticalScrollBar()->isVisible()) {
offsetSB = verticalScrollBar()->width() - 1;
}
// Subdirectories in the popup menu
for (int i = 0; i < count(); i ++) {
QListWidgetItem *it = item(i);
QRect r = this->visualItemRect(it);
/// FIXME
//QSize s = it->sizeHint();
//QRect r(0, i * s.height(), );
//qDebug() << "r" << r;
r.setWidth(r.width() - offsetSB);
if (it->data(Qt::UserRole + 1).toBool()) {
p.save();
p.setPen(palette.midlight().color());
p.drawLine(r.x(), r.y() + (it->sizeHint().height()) / 2, r.width(), r.y() + (it->sizeHint().height()) / 2);
p.restore();
continue;
}
r.adjust(1, 1, -4, -1);
bool isHighlighted = r.contains(mapFromGlobal(QCursor::pos()));
// Draw: Highlight, Icon, Text
if (r.isValid()) {
QRect iconRect(r.x() + 6, r.y() + 2, 19, 19);
bool itemIsEnabled = true;
if (it->flags().testFlag(Qt::NoItemFlags)) {
p.drawPixmap(iconRect, it->icon().pixmap(QSize(19, 19), QIcon::Disabled));
itemIsEnabled = false;
} else {
p.save();
if (isHighlighted) {
p.setPen(palette.highlight().color());
p.setBrush(palette.highlight().color().lighter());
p.drawRect(r);
p.setPen(QColor(192, 192, 192, 128));
p.drawLine(33, r.top() + 1, 33, r.bottom());
}
p.restore();
p.drawPixmap(iconRect, it->icon().pixmap(QSize(19, 19)));
}
QRect textRect = r.adjusted(37, 0, 0, 0);
QString text = fontMetrics().elidedText(it->text(), Qt::ElideRight, textRect.width());
p.save();
p.setFont(it->font());
QColor lighterBG = palette.highlight().color().lighter();
QColor highlightedText = palette.highlightedText().color();
if (itemIsEnabled && isHighlighted && qAbs(lighterBG.saturation() - highlightedText.saturation()) > 128) {
p.setPen(highlightedText);
} else {
if (itemIsEnabled) {
p.setPen(palette.text().color());
} else {
p.setPen(palette.color(QPalette::Disabled, QPalette::WindowText));
}
}
p.drawText(textRect, text, Qt::AlignLeft | Qt::AlignVCenter);
p.restore();
}
}
}
示例15: findTileByID
QPixmap TileList::findTileByID(int tileID)
{
QListWidgetItem* searchedItem = this->item(tileID);
QPixmap pixmap = searchedItem->icon().pixmap(QSize(32, 32));
return pixmap;
}