本文整理汇总了C++中QFileIconProvider::icon方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileIconProvider::icon方法的具体用法?C++ QFileIconProvider::icon怎么用?C++ QFileIconProvider::icon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileIconProvider
的用法示例。
在下文中一共展示了QFileIconProvider::icon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant ArchiveItemModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role == Qt::DisplayRole) {
ArchiveTree::Node node = _tree.lookup(index.internalId());
switch (index.column()) {
case 0:
return node.entry.name;
case 1:
if (node.entry.type == ENTRY_TYPE_STDFILE)
return (qulonglong) node.entry.size;
else
return "";
}
} else if (role == Qt::DecorationRole) {
if (index.column() == 0) {
ArchiveTree::Node node = _tree.lookup(index.internalId());
QFileIconProvider p;
if (node.entry.type == ENTRY_TYPE_DIR)
return p.icon(QFileIconProvider::Folder);
else
return p.icon(QFileIconProvider::File);
}
}
return QVariant();
}
示例2: updateGotoMenu
void QxFileBrowser::updateGotoMenu()
{
for (int i = 0, n = cwdPast_.count(); i < n; ++i) {
if (!QDir(cwdPast_.at(i)).exists()) {
cwdPast_.removeAt(i);
--i;
--n;
}
}
if (gotoMenu_) {
disconnect(gotoMenu_, 0, 0, 0);
gotoMenu_->setAttribute(Qt::WA_DeleteOnClose, true); // destruction workaround, HACK
gotoMenu_->close();
}
gotoMenu_ = new QMenu(this);
{
QFont font = gotoMenu_->font();
font.setPixelSize(styleManager()->constant("dirOpenMenuFontSizePx"));
gotoMenu_->setFont(font);
}
connect(gotoMenu_, SIGNAL(triggered(QAction*)), this, SLOT(cwdSet(QAction*)));
actionToPath_.clear();
QFileIconProvider iconProvider;
QDir dir = QDir::current();
while (!dir.isRoot()) {
dir.cdUp();
QAction* action = gotoMenu_->addAction(iconProvider.icon(QFileInfo(dir.path())), dir.isRoot() ? QDir::separator() : dir.dirName());
actionToPath_[action] = dir.path();
}
gotoMenu_->addSeparator();
recentMenu_ = gotoMenu_->addMenu(tr("Recent Places"));
{
QFont font = recentMenu_->font();
font.setPixelSize(styleManager()->constant("dirOpenMenuFontSizePx"));
recentMenu_->setFont(font);
}
// QxDesignHack::beautify(recentMenu_);
connect(recentMenu_, SIGNAL(triggered(QAction*)), this, SLOT(cwdSet(QAction*)));
int n = cwdPast_.count();
recentMenu_->setDisabled(n == 0);
for (int i = n-1; i >= 0; --i)
{
QString path = cwdPast_[i];
QString name = path; // QFileInfo(path).fileName();
if (name == QString()) name = QDir::separator();
QAction* action = recentMenu_->addAction(iconProvider.icon(QFileInfo(path)), name);
actionToPath_[action] = path;
}
gotoButton_->setMenu(gotoMenu_);
}
示例3: QAbstractItemModel
RemoteDeckList_TreeModel::RemoteDeckList_TreeModel(AbstractClient *_client, QObject *parent)
: QAbstractItemModel(parent), client(_client)
{
QFileIconProvider fip;
dirIcon = fip.icon(QFileIconProvider::Folder);
fileIcon = fip.icon(QFileIconProvider::File);
root = new DirectoryNode;
refreshTree();
}
示例4: QAbstractItemModel
RemoteReplayList_TreeModel::RemoteReplayList_TreeModel(AbstractClient *_client, QObject *parent)
: QAbstractItemModel(parent), client(_client)
{
QFileIconProvider fip;
dirIcon = fip.icon(QFileIconProvider::Folder);
fileIcon = fip.icon(QFileIconProvider::File);
lockIcon = QIcon(":/resources/lock.svg");
refreshTree();
}
示例5: getFileIcon
QIcon Convert::getFileIcon(const QUrlInfo& url) {
static QFileIconProvider fileIconProvider;
if(url.isFile()) {
return fileIconProvider.icon(QFileIconProvider::File);
} else if(url.isDir()) {
return fileIconProvider.icon(QFileIconProvider::Folder);
} else {
return QIcon();
}
}
示例6: addLink
void DocBlock::addLink(QUrl url)
{
myTextItem->setTextInteractionFlags(Qt::TextSelectableByKeyboard);
docType = Link;
path = url.toString();
QString str = path;
// add file icon
QTextCursor cursor = QTextCursor(myTextItem->document());
QFileInfo info(url.toLocalFile());
QFileIconProvider *provider = new QFileIconProvider();
QImage image(provider->icon(info).pixmap(16, 16).toImage());
cursor.document()->setPlainText(" ");
cursor.insertImage(image);
if (str.lastIndexOf("/") > -1)
str = str.right(str.size() - str.lastIndexOf("/") - 1);
QString html = "<a href=\""+path+"\">"+str+"</a>";
cursor.insertHtml(html);
if (arrow != 0) arrow->setColor(getHoverColor());
updateBlock(false);
}
示例7:
QHelpProjectFolder::QHelpProjectFolder()
{
if (m_icon.isNull()) {
QFileIconProvider iconProvider;
m_icon = iconProvider.icon(QFileIconProvider::Folder);
}
}
示例8: recursiveInsert
void SelectiveSyncTreeView::recursiveInsert(QTreeWidgetItem* parent, QStringList pathTrail, QString path, qint64 size)
{
QFileIconProvider prov;
QIcon folderIcon = prov.icon(QFileIconProvider::Folder);
if (pathTrail.size() == 0) {
if (path.endsWith('/')) {
path.chop(1);
}
parent->setToolTip(0, path);
parent->setData(0, Qt::UserRole, path);
} else {
SelectiveSyncTreeViewItem *item = static_cast<SelectiveSyncTreeViewItem*>(findFirstChild(parent, pathTrail.first()));
if (!item) {
item = new SelectiveSyncTreeViewItem(parent);
if (parent->checkState(0) == Qt::Checked
|| parent->checkState(0) == Qt::PartiallyChecked) {
item->setCheckState(0, Qt::Checked);
foreach(const QString &str , _oldBlackList) {
if (str == path || str == QLatin1String("/")) {
item->setCheckState(0, Qt::Unchecked);
break;
} else if (str.startsWith(path)) {
item->setCheckState(0, Qt::PartiallyChecked);
}
}
} else if (parent->checkState(0) == Qt::Unchecked) {
示例9: fi
QuickLaunchAction::QuickLaunchAction(const QString & fileName, QWidget * parent)
: QAction(parent),
m_valid(true)
{
m_type = ActionFile;
setText(fileName);
setData(fileName);
m_settingsMap["file"] = fileName;
QFileInfo fi(fileName);
if (fi.isDir())
{
QFileIconProvider ip;
setIcon(ip.icon(fi));
}
else
{
QMimeDatabase db;
XdgMimeType mi(db.mimeTypeForFile(fi));
setIcon(mi.icon());
}
connect(this, SIGNAL(triggered()), this, SLOT(execAction()));
}
示例10: loadFileBrowser
/*
Update the file browser to show files in the project.
Read these from the project's project file.
*/
void ProjectInfo::loadFileBrowser(QDir *projectDir, QDomDocument *projectFile)
{
// setup the file browser
fileBrowser->clear(); // get rid of anything previously in there
QDomNodeList allFiles = projectFile->elementsByTagName("files").at(0).childNodes();
QTreeWidgetItem *top = new QTreeWidgetItem(QStringList() << projectDir->dirName());
top->setIcon(0, QApplication::style()->standardIcon(QStyle::SP_DirIcon));
fileBrowser->addTopLevelItem(top);
// only deals with files in the top level directory at the moment
QFileIconProvider ip;
for(int i = 0; i < allFiles.count(); i++)
{
QFileInfo fi(projectDir->filePath(allFiles.at(i).toElement().text()));
if(!fi.fileName().isEmpty())
{
if(projectDir->exists(fi.fileName()))
{
QString buildtype = allFiles.at(i).toElement().attribute("type");
QTreeWidgetItem *child = new QTreeWidgetItem(QStringList() << fi.fileName() << buildtype);
child->setData(FILENAME_COLUMN, FULLPATH_ROLE, fi.filePath());
child->setToolTip(FILENAME_COLUMN, fi.filePath());
child->setIcon(FILENAME_COLUMN, ip.icon(fi));
top->addChild(child);
}
}
}
top->setExpanded(true);
}
示例11: getApplicationInformation
void WindowsPlatformIntegration::getApplicationInformation(ApplicationInformation &information)
{
const QString rootPath = information.command.left(information.command.indexOf(QLatin1String("\\"))).remove(QLatin1Char('%'));
if (m_environment.contains(rootPath))
{
information.command.replace(QLatin1Char('%') + rootPath + QLatin1Char('%'), m_environment.value(rootPath));
}
const QString fullApplicationPath = information.command.left(information.command.indexOf(QLatin1String(".exe"), 0, Qt::CaseInsensitive) + 4);
const QFileInfo fileInfo(fullApplicationPath);
const QFileIconProvider fileIconProvider;
information.icon = fileIconProvider.icon(fileInfo);
HKEY key = NULL;
TCHAR readBuffer[128];
DWORD bufferSize = sizeof(readBuffer);
if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache"), 0, KEY_QUERY_VALUE, &key) == ERROR_SUCCESS)
{
if (RegQueryValueEx(key, fullApplicationPath.toStdWString().c_str(), NULL, NULL, (LPBYTE)readBuffer, &bufferSize) == ERROR_SUCCESS)
{
information.name = QString::fromWCharArray(readBuffer);
}
RegCloseKey(key);
}
if (information.name.isEmpty())
{
information.name = fileInfo.baseName();
}
}
示例12: on_bSearch_clicked
void Window::on_bSearch_clicked()
{
searchmodel->clear();
QString directory_path = ui->directory->text();
QString searchtext = ui->searchtext->text();
QDirIterator directory_indexer(directory_path, QDir::Files | QDir::NoSymLinks, QDirIterator::Subdirectories);
uint count = 0;
QFileIconProvider iconprovider;
while(directory_indexer.hasNext())
{
directory_indexer.next();
QString path = directory_indexer.fileInfo().absoluteFilePath();
if(QFileInfo(path).fileName().contains(searchtext))
{
QStandardItem *item = new QStandardItem(path);
item->setIcon(iconprovider.icon(path));
searchmodel->setItem(count, item);
count++;
}
}
}
示例13: fileIcon
QPixmap FileTransferHandler::fileIcon() const
{
QPixmap icon;
QFileIconProvider provider;
QFileInfo file(d->filePath);
if (file.exists()){
icon = provider.icon(file).pixmap(32, 32);
}
return icon;
}
示例14: getIcon
QPixmap lmcTransferWindow::getIcon(QString filePath) {
QFileIconProvider iconProvider;
QFileInfo fileInfo(filePath);
QPixmap icon;
if(QFile::exists(filePath))
icon = iconProvider.icon(fileInfo).pixmap(32, 32);
else {
QString fileName = fileInfo.fileName();
QString path = QDir::temp().absoluteFilePath(fileName);
QFile file(path);
file.open(QIODevice::WriteOnly);
file.close();
icon = iconProvider.icon(QFileInfo(path)).pixmap(32, 32);
QFile::remove(path);
}
return icon;
}
示例15: data
virtual QVariant data ( const QModelIndex & index, int role ) const
{
if (role == Qt::DecorationRole)
{
QFileInfo fileInfo(stringList()[index.row()]);
QFileIconProvider iconProv;
return QVariant(iconProv.icon(fileInfo));
}
else
{
return QStringListModel::data(index, role);
}
}