QStandardItem* QgsMilXLibrary::addItem( QStandardItem* parent, const QString& value, const QImage& image, bool isLeaf, const QString& symbolXml, const QString& symbolMilitaryName, int symbolPointCount , bool symbolHasVariablePoints )
{
  QIcon icon;
  QSize iconSize = isLeaf ? mTreeView->iconSize() : !image.isNull() ? QSize( 32, 32 ) : QSize( 1, 32 );
  QImage iconImage( iconSize, QImage::Format_ARGB32 );
  iconImage.fill( Qt::transparent );
  if ( !image.isNull() )
  {
    double scale = qMin( 1., image.width() > image.height() ? iconImage.width() / double( image.width() ) : iconImage.height() / double( image.height() ) );
    QPainter painter( &iconImage );
    painter.setRenderHint( QPainter::SmoothPixmapTransform );
    painter.drawImage(
      QRectF( 0.5 * ( iconSize.width() - scale * image.width() ), 0.5 * ( iconSize.height() - scale * image.height() ), scale * image.width(), scale * image.height() ),
      image );
  }
  icon = QIcon( QPixmap::fromImage( iconImage ) );
  if ( !parent )
  {
    parent = mGalleryModel->invisibleRootItem();
  }
  // Create category group item if necessary
  if ( !isLeaf )
  {
    // Don't create subgroups with same text as parent
    if ( parent->text() == value )
    {
      return parent;
    }
    QStandardItem* groupItem = 0;
    for ( int i = 0, n = parent->rowCount(); i < n; ++i )
    {
      if ( parent->child( i )->text() == value )
      {
        groupItem = parent->child( i );
        break;
      }
    }
    if ( !groupItem )
    {
      groupItem = new QStandardItem( value );
      groupItem->setDragEnabled( false );
      parent->setChild( parent->rowCount(), groupItem );
      groupItem->setIcon( icon );
    }
    return groupItem;
  }
  else
  {
    QStandardItem* item = new QStandardItem( QString( "%1" ).arg( symbolMilitaryName ) );
    parent->setChild( parent->rowCount(), item );
    item->setData( symbolXml, SymbolXmlRole );
    item->setData( symbolMilitaryName, SymbolMilitaryNameRole );
    item->setData( symbolPointCount, SymbolPointCountRole );
    item->setData( symbolHasVariablePoints, SymbolVariablePointsRole );
    item->setToolTip( item->text() );
    item->setIcon( icon );
    return item;
  }
}
Example #2
0
QStandardItem* SelfTestDialog::report( ResultType type, const KLocalizedString & summary, const KLocalizedString & details)
{
  QStandardItem *item = new QStandardItem( summary.toString() );
  switch ( type ) {
    case Skip:
      item->setIcon( KIcon( QString::fromLatin1( "dialog-ok" ) ) );
      break;
    case Success:
      item->setIcon( KIcon( QString::fromLatin1( "dialog-ok-apply" ) ) );
      break;
    case Warning:
      item->setIcon( KIcon( QString::fromLatin1( "dialog-warning" ) ) );
      break;
    case Error:
    default:
      item->setIcon( KIcon( QString::fromLatin1( "dialog-error" ) ) );
  }
  item->setEditable( false );
  item->setWhatsThis( details.toString() );
  item->setData( type, ResultTypeRole );
  item->setData( summary.toString( 0 ), SummaryRole );
  item->setData( details.toString( 0 ), DetailsRole );
  mTestModel->appendRow( item );
  return item;
}
Example #3
0
void TreeView::showExample(void)
{
    this->setColumn(1, 100,QStringLiteral("GPRS_STRUCT"));
    for(int i = 0; i < 10; ++i)
    {
        QList<QStandardItem *>  leve0;
        QStandardItem * item = new QStandardItem(QString("GRPS_%0").arg(i));
        item->setCheckable(1);//使能复选框
        item->setIcon(QIcon(":/image/Aqua Ball.ico"));
        leve0.append(item);

        mode->appendRow(leve0);

        for(int j = 0; j < 5; ++j)
        {
            QList<QStandardItem *> leve1;
            QStandardItem * item = new QStandardItem(QString("Sensor_%0").arg(j));
            item->setCheckable(1);//使能复选框
            item->setIcon(QIcon(":/image/Aqua Ball Green.ico"));
            leve1.append(item);
         /*   for(int i = 1; i < 4; ++i)
            {
                QStandardItem * item = new QStandardItem(QString("state_%0").arg(i));
                leve1.append(item);
            }*/
            leve0.at(0)->appendRow(leve1);
        }

    }

   // ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);//设置多选
    this->setEditTriggers(0);//取消双击修改
   this->setContextMenuPolicy(Qt::CustomContextMenu);//设置treeView右键单击产生相应信号,并设置连接
}
Example #4
0
void BookmarkList::dropEvent(QDropEvent *event)
{
	const QMimeData* data = event->mimeData();
	if(data->hasUrls())
	{
		//TODO: Add insert to the dropped row, except row 0
		QStandardItemModel* mod = (QStandardItemModel*)model();
		QString path = data->urls()[0].path(); 
		QFileInfo f(path);
		if(mod)
		{
			QList<QStandardItem*> items = mod->findItems(f.fileName());
			if(f.isDir() && items.isEmpty())
			{
				QStandardItem *it = new QStandardItem();
				it->setText(f.fileName());
				it->setData(path);
#if QT_VERSION >= 0x040600
				// Todo: Use a "favorites folder" icon instead
				it->setIcon(*globalIcon);
#else
				it->setIcon(QIcon(":/images/icons/clip-folder-bookmark.png"));
#endif	
				it->setDropEnabled(true);
				mod->appendRow(it);
				emit bookmarkAdded();
			}
		}
	}
	event->acceptProposedAction();
}
void ctkCmdLineModuleExplorerModulesSettings::pathsAdded(const QStringList &paths)
{
  // Check the validity of the entries
  foreach(const QString& path, paths)
  {
    ctkCmdLineModuleReference moduleRef = this->ModuleManager->moduleReference(QUrl::fromLocalFile(path));
    if (!moduleRef || !moduleRef.xmlValidationErrorString().isEmpty())
    {
      QStandardItem* item = ui->PathListWidget->item(path);
      if (this->WarningIcon.isNull())
      {
        this->WarningIcon = ctkCmdLineModuleExplorerUtils::createIconOverlay(
              item->icon().pixmap(item->icon().availableSizes().front()),
              QApplication::style()->standardPixmap(QStyle::SP_MessageBoxWarning));
      }

      QString toolTip = path + "\n\n" + tr("Warning") + ":\n\n";
      if (moduleRef)
      {
        item->setIcon(this->WarningIcon);
        toolTip += moduleRef.xmlValidationErrorString();
      }
      else if (this->ModulesRegistered)
      {
        item->setIcon(this->WarningIcon);
        toolTip += tr("No XML output available.");
      }
      else
      {
        toolTip = path;
      }
      item->setToolTip(toolTip);
    }
  }
Example #6
0
	void Player::handleSourceChanged (const Phonon::MediaSource& source)
	{
		for (int i = 0; i < QueueModel_->rowCount (); ++i)
		{
			QStandardItem *item = QueueModel_->item (i);
			if (source == *item->data (SourceRole).value<MediaSource*> ())
				item->setIcon (Core::Instance ().GetCoreProxy ()->GetIcon ("lmp_play"));
			else
				item->setIcon (QIcon ());
		}
	}
bool QgsStyleExportImportDialog::populateStyles( QgsStyle *style )
{
  // load symbols and color ramps from file
  if ( mDialogMode == Import )
  {
    // NOTE mTempStyle is style here
    if ( !style->importXml( mFileName ) )
    {
      QMessageBox::warning( this, tr( "Import error" ),
                            tr( "An error occurred during import:\n%1" ).arg( style->errorString() ) );
      return false;
    }
  }

  QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() );
  model->clear();

  // populate symbols
  QStringList styleNames = style->symbolNames();
  QString name;

  for ( int i = 0; i < styleNames.count(); ++i )
  {
    name = styleNames[i];
    QStringList tags = style->tagsOfSymbol( QgsStyle::SymbolEntity, name );
    QgsSymbol *symbol = style->symbol( name );
    QStandardItem *item = new QStandardItem( name );
    QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( symbol, listItems->iconSize(), 15 );
    item->setIcon( icon );
    item->setToolTip( QString( "<b>%1</b><br><i>%2</i>" ).arg( name, tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) );
    // Set font to 10points to show reasonable text
    QFont itemFont = item->font();
    itemFont.setPointSize( 10 );
    item->setFont( itemFont );
    model->appendRow( item );
    delete symbol;
  }

  // and color ramps
  styleNames = style->colorRampNames();

  for ( int i = 0; i < styleNames.count(); ++i )
  {
    name = styleNames[i];
    std::unique_ptr< QgsColorRamp > ramp( style->colorRamp( name ) );

    QStandardItem *item = new QStandardItem( name );
    QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), listItems->iconSize(), 15 );
    item->setIcon( icon );
    model->appendRow( item );
  }
  return true;
}
Example #8
0
/* 
  Update the contents for the message pointed to by 'msg', if it's in the
  model, otherwise ignore the request.  Currently the contents are the
  status (icon) and the priority. Other changes such as in the subject
  or the date could be visually reflected by this function if the UI
  permitted those changes.
*/
void
mail_item_model::update_msg(const mail_msg* msg)
{
  DBG_PRINTF(4, "update_msg of " MAIL_ID_FMT_STRING, msg->get_id());
  QStandardItem* item=item_from_id(msg->get_id());
  if (!item)
    return;
  QModelIndex index=item->index();
  QStandardItem* isubject = itemFromIndex(index);
  bool bold=isubject->font().bold();
  DBG_PRINTF(5, "mail_id=" MAIL_ID_FMT_STRING ", status=%d, bold=%d",
	     msg->get_id(), msg->status(), bold);
  if ((msg->status()!=0 && bold) || (msg->status()==0 && !bold)) {
    // reverse bold attribute
    QFont f=isubject->font();
    f.setBold(!bold);
    isubject->setFont(f);
    itemFromIndex(index.sibling(index.row(), column_sender))->setFont(f);
    itemFromIndex(index.sibling(index.row(), column_date))->setFont(f);
    itemFromIndex(index.sibling(index.row(), column_pri))->setFont(f);
    itemFromIndex(index.sibling(index.row(), column_recipient))->setFont(f);
  }

  // status icon
  QIcon* icon = icon_status(msg->status());
  QStandardItem* istatus = itemFromIndex(index.sibling(index.row(), column_status));
  if (istatus) {
    if (icon)
      istatus->setIcon(*icon);
    else
      istatus->setIcon(QIcon());
  }

  // priority
  QStandardItem* ipri = itemFromIndex(index.sibling(index.row(), column_pri));
  if (ipri) {
    if (msg->priority()!=0)
      ipri->setText(QString("%1").arg(msg->priority()));
    else
      ipri->setText("");
  }

  // note
  QStandardItem* inote = itemFromIndex(index.sibling(index.row(), column_note));
  if (inote) {
    inote->setData(msg->has_note());
    if (msg->has_note())
      inote->setIcon(STATUS_ICON(FT_ICON16_EDIT_NOTE));
    else
      inote->setIcon(QIcon());
  }

}
void SingleGenreView::browseAllGenres(uint browseId, int remainingCount, uint, QString objectId, GHashTable* metadata, QString error)
{
    if (browseId != browseGenreId) return;

    if (metadata != NULL) {
        QString title;
        int songCount = -1;
        int albumCount = -1;
        GValue *v;

        QStandardItem *item = new QStandardItem();

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_TITLE);
        title = v ? QString::fromUtf8(g_value_get_string(v)) : tr("(unknown artist)");

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_CHILDCOUNT_1);
        albumCount = v ? g_value_get_int (v) : -1;

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_CHILDCOUNT_2);
        songCount = v ? g_value_get_int (v) : -1;

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_ALBUM_ART_SMALL_URI);
        if (v != NULL) {
            const gchar* file_uri = g_value_get_string(v);
            gchar* filename = NULL;
            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(defaultAlbumIcon));
        }

        if (title.isEmpty()) title = tr("(unknown artist)");

        item->setText(title);
        item->setData(songCount, UserRoleSongCount);
        item->setData(albumCount, UserRoleAlbumCount);
        item->setData(objectId, UserRoleObjectID);

        objectModel->appendRow(item);
        visibleSongs += songCount; updateSongCount();

    }

    if (!error.isEmpty())
        qDebug() << error;

    if (remainingCount == 0) {
        disconnect(mafwTrackerSource, SIGNAL(browseResult(uint,int,uint,QString,GHashTable*,QString)),
                   this, SLOT(browseAllGenres(uint,int,uint,QString,GHashTable*,QString)));
        setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
    }
Example #10
0
void Priorities::fillingModel(QSqlQuery &stored)
{
    m_model->clear();
    m_model->insertColumns(0, MODEL_COLUMN_COUNT);
    m_model->insertRows(0, stored.numRowsAffected());

    unsigned  j(0);
    QString   m_item;

    unsigned ncols = stored.record().count();
#ifndef QT_NO_CURSOR
    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
#endif
    while(stored.next())
    {
        for (unsigned i = 0; i != ncols; ++i){
            if (stored.value(i).toDateTime().isValid()) {
                m_item = stored.value(i).toDateTime().toString("yyyy-MM-dd hh:mm:ss");
            } else {
                m_item = stored.value(i).toString();
            }
            QStandardItem *item = new QStandardItem(m_item.trimmed());
            if (i == 1){
                item->setIcon(QIcon("data/picture/sidebar/priority.ico"));
            } else
            if (i == 5){
                QStandardItem *item = new QStandardItem();
                unsigned m_value = stored.record().field("pt_level").value().toUInt();
                switch (m_value) {
                case 0:
                    item->setIcon(QIcon("data/picture/additionally/red.ico"));
                    break;
                case 1:
                    item->setIcon(QIcon("data/picture/additionally/yellow.ico"));
                    break;
                case 2:
                    item->setIcon(QIcon("data/picture/additionally/green.ico"));
                    break;
                default:
                    break;
                }
                m_model->setItem(j, ncols, item);
            }
            m_model->setItem(j, i, item);
        }
        ++j;
    }
#ifndef QT_NO_CURSOR
    QApplication::restoreOverrideCursor();
#endif
}
void CommunicationTree::insertItems(const int socketDescriptor, const QString & ip, const quint16 port, int linkIndex) {
    //    QList<QStandardItem*> list;
    //    list.append(new QStandardItem(QString(socketDescriptor)));
    //    list.append(new QStandardItem(ip));
    //    list.append(new QStandardItem(QString(port)));
    //    QString channelInfo = QStringLiteral("%1(%2):%3").arg(ip).arg(socketDescriptor).arg(port);

    QStandardItem *item = new QStandardItem(QStringLiteral("%1(%2)").arg(ip).arg(socketDescriptor));
    if(linkIndex == LINKINFO_CONNECTED)
        item->setIcon(QIcon(":/res/images/256/ligthbulb_on.png"));
    else
        item->setIcon(QIcon(":/res/images/256/ligthbulb_off.png"));
    communication->appendRow(item);
}
void PlaylistListContainer::RecursivelySetIcons(QStandardItem* parent) const {
  for (int i = 0; i < parent->rowCount(); ++i) {
    QStandardItem* child = parent->child(i);
    switch (child->data(PlaylistListModel::Role_Type).toInt()) {
      case PlaylistListModel::Type_Folder:
        child->setIcon(model_->folder_icon());
        RecursivelySetIcons(child);
        break;

      case PlaylistListModel::Type_Playlist:
        child->setIcon(model_->playlist_icon());
        break;
    }
  }
}
Example #13
0
QgsSvgSelectorGroupsModel::QgsSvgSelectorGroupsModel( QObject* parent )
    : QStandardItemModel( parent )
{
  QStringList svgPaths = QgsApplication::svgPaths();
  QStandardItem *parentItem = invisibleRootItem();

  for ( int i = 0; i < svgPaths.size(); i++ )
  {
    QDir dir( svgPaths[i] );
    QStandardItem *baseGroup;

    if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
    {
      baseGroup = new QStandardItem( tr( "App Symbols" ) );
    }
    else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
    {
      baseGroup = new QStandardItem( tr( "User Symbols" ) );
    }
    else
    {
      baseGroup = new QStandardItem( dir.dirName() );
    }
    baseGroup->setData( QVariant( svgPaths[i] ) );
    baseGroup->setEditable( false );
    baseGroup->setCheckable( false );
    baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
    baseGroup->setToolTip( dir.path() );
    parentItem->appendRow( baseGroup );
    createTree( baseGroup );
    QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
  }
}
void QgsStyleManagerDialog::populateSymbols( const QStringList& symbolNames, bool check )
{
  QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() );
  model->clear();

  int type = currentItemType();

  for ( int i = 0; i < symbolNames.count(); ++i )
  {
    QString name = symbolNames[i];
    QgsSymbol* symbol = mStyle->symbol( name );
    if ( symbol && symbol->type() == type )
    {
      QStandardItem* item = new QStandardItem( name );
      QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( symbol, listItems->iconSize() );
      item->setIcon( icon );
      item->setData( name ); // used to find out original name when user edited the name
      item->setCheckable( check );
      item->setToolTip( name );
      // add to model
      model->appendRow( item );
    }
    delete symbol;
  }
  selectedSymbolsChanged( QItemSelection(), QItemSelection() );
  symbolSelected( listItems->currentIndex() );
}
Example #15
0
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++;
        }
    }
}
Example #16
0
void CTaskType::fillTaskModel(QSqlQuery &stored)
{
    modelTask->removeRows(0, modelTask->rowCount(QModelIndex()), QModelIndex());
    modelTask->insertRows(stored.numRowsAffected(), 0);

#ifndef QT_NO_CURSOR
    QApplication::setOverrideCursor(QCursor(QPixmap("data/picture/additionally/wait.png")));
#endif

    QString   it;
    int ncols = stored.record().count();
    int row(0);

    while(stored.next())
    {
        for (int i = 0; i != ncols; ++i){
            it = stored.value(i).toString();
            QStandardItem *item = new QStandardItem(it);
            if (i == stored.record().indexOf("tt_name")){
                   item->setIcon(QIcon("data/picture/sidebar/tasktype.ico"));
            }
            modelTask->setItem(row ,i, item);
        }
        ++row;
    }

#ifndef QT_NO_CURSOR
    QApplication::restoreOverrideCursor();
#endif
}
void QgsSymbolV2SelectorDialog::populateSymbolView()
{
  QSize previewSize = viewSymbols->iconSize();
  QPixmap p( previewSize );
  QPainter painter;

  QStandardItemModel* model = qobject_cast<QStandardItemModel*>( viewSymbols->model() );
  if ( !model )
  {
    return;
  }
  model->clear();

  QStringList names = mStyle->symbolNames();
  for ( int i = 0; i < names.count(); i++ )
  {
    QgsSymbolV2* s = mStyle->symbol( names[i] );
    if ( s->type() != mSymbol->type() )
    {
      delete s;
      continue;
    }
    QStandardItem* item = new QStandardItem( names[i] );
    item->setData( names[i], Qt::UserRole ); //so we can show a label when it is clicked
    item->setText( "" ); //set the text to nothing and show in label when clicked rather
    item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
    // create preview icon
    QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( s, previewSize );
    item->setIcon( icon );
    // add to model
    model->appendRow( item );
    delete s;
  }
}
Example #18
0
void AlbumCoverSearcher::SearchFinished(quint64 id,
                                        const CoverSearchResults& results) {
  if (id != id_) return;

  ui_->search->setEnabled(true);
  ui_->artist->setEnabled(true);
  ui_->album->setEnabled(true);
  ui_->covers->setEnabled(true);
  ui_->search->setText(tr("Search"));
  id_ = 0;

  for (const CoverSearchResult& result : results) {
    if (result.image_url.isEmpty()) continue;

    quint64 id = app_->album_cover_loader()->LoadImageAsync(
        options_, result.image_url.toString(), QString());

    QStandardItem* item = new QStandardItem;
    item->setIcon(no_cover_icon_);
    item->setText(result.description);
    item->setData(result.image_url, Role_ImageURL);
    item->setData(id, Role_ImageRequestId);
    item->setData(false, Role_ImageFetchFinished);
    item->setData(QVariant(Qt::AlignTop | Qt::AlignHCenter),
                  Qt::TextAlignmentRole);
    item->setData(result.provider, GroupedIconView::Role_Group);

    model_->appendRow(item);

    cover_loading_tasks_[id] = item;
  }

  if (cover_loading_tasks_.isEmpty()) ui_->busy->hide();
}
Example #19
0
void AlbumCoverSearcher::ImageLoaded(quint64 id, const QImage& image) {
  if (!cover_loading_tasks_.contains(id)) return;
  QStandardItem* item = cover_loading_tasks_.take(id);

  if (cover_loading_tasks_.isEmpty()) ui_->busy->hide();

  if (image.isNull()) {
    model_->removeRow(item->row());
    return;
  }

  QIcon icon(QPixmap::fromImage(image));

  // Create a pixmap that's padded and exactly the right size for the icon.
  QImage scaled_image(image.scaled(ui_->covers->iconSize(), Qt::KeepAspectRatio,
                                   Qt::SmoothTransformation));

  QImage padded_image(ui_->covers->iconSize(),
                      QImage::Format_ARGB32_Premultiplied);
  padded_image.fill(0);

  QPainter p(&padded_image);
  p.drawImage((padded_image.width() - scaled_image.width()) / 2,
              (padded_image.height() - scaled_image.height()) / 2,
              scaled_image);
  p.end();

  icon.addPixmap(QPixmap::fromImage(padded_image));

  item->setData(true, Role_ImageFetchFinished);
  item->setData(image.width() * image.height(), Role_ImageDimensions);
  item->setData(image.size(), Role_ImageSize);
  item->setIcon(icon);
}
void SelectResourceImage::listDirectory(QDir dir, QStandardItem *parentItem, const QString& pathPrefix)
{
    QStringList dirs=dir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name);
    QStringList filters;
    filters<<"*.png"<<"*.jpg"<<"*.bmp"<<"*.svg"<<"*.tif";
    QStringList files=dir.entryList(filters,QDir::Files,QDir::Name);
    for (int i = 0; i < dirs.size(); ++i) {
        QStandardItem *item = new QStandardItem(dirs[i]);
        item->setData(dir.absolutePath()+"/"+dirs[i]+"/");
        item->setData(false, Qt::UserRole+2);
        item->setIcon(QIcon(":/lib/file_opendir.png"));
        parentItem->appendRow(item);
        QDir d=dir;
        d.cd(dirs[i]);
        if (pathPrefix.isEmpty()) {
            listDirectory(d, item, "");
        } else {
            listDirectory(d, item, pathPrefix+dirs[i]+"/");
        }
    }
    for (int i = 0; i < files.size(); ++i) {
        QString abspath=dir.absoluteFilePath(files[i]);
        QStandardItem *item = new QStandardItem(QIcon(abspath), files[i]);
        item->setData(true, Qt::UserRole+2);
        if (pathPrefix.isEmpty()) {
            item->setData(abspath);
        } else {
            item->setData(pathPrefix+files[i]);
        }
        parentItem->appendRow(item);
    }
}
void list_handling::compare_one_download(const download &new_download, const download &old_download, QStandardItem *pkg, int dl_line){
	QStandardItem *dl;

	if(old_download.id != new_download.id){
		dl = pkg->child(dl_line, 0);
		dl->setText(QString("%1").arg(new_download.id));
	}

	if(old_download.title != new_download.title){
		dl = pkg->child(dl_line, 1);
		dl->setText(QString(new_download.title.c_str()));
	}

	if(old_download.url != new_download.url){
		dl = pkg->child(dl_line, 2);
		dl->setText(QString(new_download.url.c_str()));
	}

	if((new_download.status != old_download.status) || (new_download.downloaded != old_download.downloaded) || (new_download.size != old_download.size) ||
	   (new_download.wait != old_download.wait) || (new_download.error != old_download.error) || (new_download.speed != old_download.speed)){

		string color, status_text, time_left;
		color = build_status(status_text, time_left, new_download);

		dl = pkg->child(dl_line, 3);
		dl->setText(QString(time_left.c_str()));

		string colorstring = "img/bullet_" + color + ".png";

		dl = pkg->child(dl_line, 4);
		dl->setText(QString(my_main_window->CreateQString(status_text.c_str())));
		dl->setIcon(QIcon(colorstring.c_str()));
	}
}
void PlaylistListContainer::UpdateActiveIcon(int id, const QIcon& icon) {
  if (id == -1) {
    return;
  }

  QStandardItem* item = model_->PlaylistById(id);
  if (!item) {
    return;
  }

  if (icon.isNull()) {
    item->setIcon(model_->playlist_icon());
  } else {
    item->setIcon(icon);
  }
}
Example #23
0
QStandardItem *ResultsTree::EnsureFileItem(const QString &fullpath, const QString &file0, bool hide)
{
    QString name = StripPath(fullpath, false);
    // Since item has path with native separators we must use path with
    // native separators to find it.
    QStandardItem *item = FindFileItem(QDir::toNativeSeparators(name));

    if (item) {
        return item;
    }

    // Ensure shown path is with native separators
    name = QDir::toNativeSeparators(name);
    item = CreateNormalItem(name);
    item->setIcon(QIcon(":images/text-x-generic.png"));

    //Add user data to that item
    QMap<QString, QVariant> data;
    data["file"] = fullpath;
    data["file0"] = file0;
    item->setData(QVariant(data));
    mModel.appendRow(item);

    setRowHidden(mModel.rowCount() - 1, QModelIndex(), hide);

    return item;
}
Example #24
0
void TreeView::insertNode(int rootID, int nodeID, QString nodeName)
{
        QStandardItem * item = new QStandardItem(nodeName);
        item->setCheckable(1);//使能复选框
        item->setIcon(QIcon(":/image/Aqua Ball Green.ico"));
        mode->item(rootID-1)->insertRow(nodeID, item);
}
Example #25
0
void TreeView::addRoot(QString rootName)
{
        QStandardItem * item = new QStandardItem(rootName);
        item->setCheckable(1);
        item->setIcon(QIcon(":/image/Aqua Ball.ico"));
        mode->appendRow(item);
}
Example #26
0
void TreeView::addNode(void)
{
    QModelIndex index = currentIndex();

    if(index.parent().row() == -1)
    {
        bool isOK;

        QString text = QInputDialog::getText(NULL, "Input Dialog",
                                                           "Please input the node name",
                                                           QLineEdit::Normal,
                                                           "sensor_",
                                                            &isOK);
        if(isOK)
        {
            QStandardItem * item = new QStandardItem(text);
            item->setCheckable(1);//使能复选框
            item->setIcon(QIcon(":/image/Aqua Ball Green.ico"));
            mode->item(index.row())->appendRow(item);


        }


    }
}
Example #27
0
	void PendingManager::EnablePackageInto (int id, PendingManager::Action action)
	{
		DepTreeBuilder builder (id);
		if (!builder.IsFulfilled ())
		{
			QStringList unful = builder.GetUnfulfilled ();
			qWarning () << Q_FUNC_INFO
					<< id
					<< "isn't fulfilled, aborting:"
					<< unful;
			QString list = QString ("<ul><li>%1</li></ul>")
					.arg (unful.join ("</li><li>"));
			throw std::runtime_error (tr ("Package dependencies "
					"could not be fulfilled: %1").arg (list)
					.toUtf8 ().constData ());
		}

		const auto& deps = builder.GetPackagesToInstall ();
		Deps_ [id] = deps;

		ScheduledForAction_ [action] << id;

		ListPackageInfo info = Core::Instance ().GetListPackageInfo (id);
		QStandardItem *packageItem = new QStandardItem (QString ("%1 (%2)")
				.arg (info.Name_)
				.arg (info.ShortDescription_));
		packageItem->setIcon (Core::Instance ().GetIconForLPI (info));
		Q_FOREACH (int dep, deps)
		{
			info = Core::Instance ().GetListPackageInfo (dep);
			QStandardItem *item = new QStandardItem (QString ("%1 (%2)")
					.arg (info.Name_)
					.arg (info.ShortDescription_));
			packageItem->appendRow (item);
		}
Example #28
0
QStandardItem* DbManager::columnsItem(QList<SqlColumn> columns) {
    QStandardItem *cItem =
        new QStandardItem(IconManager::get("folder_columns"),
                          tr("Columns (%1)")
                          .arg(columns.size()));

    foreach (SqlColumn c, columns) {
        QStandardItem *i = new QStandardItem();
        i->setText(c.name);
        if (c.primaryKey) {
            i->setIcon(IconManager::get("column_key"));
        } else {
            i->setIcon(IconManager::get("column"));
        }
        cItem->appendRow(i);
    }
Example #29
0
void TreeView::showExample2(void)
{
    this->setColumn(4, 100, QStringLiteral("Abnormal sensor"), QStringLiteral("state"));

    for(int i = 0; i < 10; ++i)
    {
        QList<QStandardItem *>  leve2;
        QStandardItem * item = new QStandardItem(QString("GRPS_%0").arg(i));
        item->setCheckable(1);//使能复选框
        item->setIcon(QIcon(":/image/Aqua Ball Red.ico"));
        item->setText(QString("%0").arg(i));
        leve2.append(item);
        for(int i = 1; i < 4; ++i)
       {
           QStandardItem * item = new QStandardItem(QString("state_%0").arg(i));
           leve2.append(item);
       }

        mode->appendRow(leve2);

    }

   // ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);//设置多选
    this->setEditTriggers(0);//取消双击修改
   this->setContextMenuPolicy(Qt::CustomContextMenu);//设置treeView右键单击产生相应信号,并设置连接
}
Example #30
0
void SoundThemeSelector::fillModel(const SoundTheme &theme)
{
	QStringList headers;
	headers.append(QT_TRANSLATE_NOOP("Notifications", "Type"));
	headers.append(QT_TRANSLATE_NOOP("SoundTheme", "Preview"));
	m_model->setHorizontalHeaderLabels(headers);

	for (int i = 0; i <= Notification::LastType; ++i) {
		Notification::Type type = static_cast<Notification::Type>(i);
		QList<QStandardItem *> items;

		QStandardItem *item = new QStandardItem(Notification::typeString(type));
		item->setToolTip(QT_TRANSLATE_NOOP("SoundTheme","Type"));
		item->setSelectable(false);
		items << item;

		item = new QStandardItem();
		item->setEditable(false);
		item->setIcon(Icon("media-playback-start"));
		item->setToolTip(QT_TRANSLATE_NOOP("SoundTheme","Play"));
		item->setEnabled(!theme.path(type).isNull());
		item->setSelectable(false);
		items << item;

		m_model->appendRow(items);
	}
	ui->treeView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
}