当前位置: 首页>>代码示例>>C++>>正文


C++ QFileIconProvider类代码示例

本文整理汇总了C++中QFileIconProvider的典型用法代码示例。如果您正苦于以下问题:C++ QFileIconProvider类的具体用法?C++ QFileIconProvider怎么用?C++ QFileIconProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QFileIconProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QVariant

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();
}
开发者ID:NobodyIII,项目名称:genode-desktop-environment,代码行数:31,代码来源:archiveitemmodel.cpp

示例2: QTreeWidgetItem

/*
  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);
}
开发者ID:YTakami,项目名称:makecontroller,代码行数:33,代码来源:ProjectInfo.cpp

示例3: QLatin1Char

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();
	}
}
开发者ID:sietse,项目名称:otter-browser,代码行数:33,代码来源:WindowsPlatformIntegration.cpp

示例4: QTextCursor

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);
}
开发者ID:fejo,项目名称:TrollEdit-1,代码行数:25,代码来源:doc_block.cpp

示例5: 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) {
开发者ID:gadimli93,项目名称:client,代码行数:26,代码来源:selectivesyncdialog.cpp

示例6: QAction

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()));
}
开发者ID:dbluelle,项目名称:lxqt-panel,代码行数:25,代码来源:quicklaunchaction.cpp

示例7: directory_indexer

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++;
        }
    }
}
开发者ID:The-Prp,项目名称:Indexer,代码行数:25,代码来源:window.cpp

示例8:

QHelpProjectFolder::QHelpProjectFolder()
{
    if (m_icon.isNull()) {
        QFileIconProvider iconProvider;
        m_icon = iconProvider.icon(QFileIconProvider::Folder);
    }
}
开发者ID:ramons03,项目名称:qt-creator,代码行数:7,代码来源:qhelpprojectitems.cpp

示例9: disconnect

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_);
}
开发者ID:corelon,项目名称:paco,代码行数:58,代码来源:QxFileBrowser.cpp

示例10: 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();
}
开发者ID:nilrook,项目名称:Cockatrice,代码行数:10,代码来源:remotedecklist_treewidget.cpp

示例11: if

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();
    }
}
开发者ID:BackupTheBerlios,项目名称:juicer-svn,代码行数:10,代码来源:convert.cpp

示例12: 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();
}
开发者ID:Akira586,项目名称:Cockatrice,代码行数:10,代码来源:remotereplaylist_treewidget.cpp

示例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;
}
开发者ID:Shura0,项目名称:psi,代码行数:10,代码来源:filetransdlg.cpp

示例14: 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);
     }
 }
开发者ID:higgscc,项目名称:ResInsight,代码行数:13,代码来源:RiuMultiCaseImportDialog.cpp

示例15: RazorDeskIconBase

RazorDeskIconFile::RazorDeskIconFile(const QString & file,
                                     const QPoint & position,
                                     QWidget * parent
                                    )
    : RazorDeskIconBase(position, parent),
      m_file(file)
{
    QFileInfo fi(file);
    QFileIconProvider ip;

    setText(fi.fileName());
    setToolTip(file);
    setIcon(ip.icon(fi));
}
开发者ID:Alexandr-Galko,项目名称:razor-qt,代码行数:14,代码来源:razordeskicon.cpp


注:本文中的QFileIconProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。