Example #1
0
void ComponentView::searchForComponentAndAddToList(const ModelNode &node)
{
    QList<ModelNode> nodeList;
    nodeList.append(node);
    nodeList.append(node.allSubModelNodes());


    foreach (const ModelNode &node, nodeList) {
        if (node.nodeSourceType() == ModelNode::ComponentSource) {
            if (!node.id().isEmpty()) {
                QStandardItem *item = new QStandardItem(node.id());
                item->setData(QVariant::fromValue(node), ModelNodeRole);
                item->setEditable(false);
                removeSingleNodeFromList(node); //remove node if already present
                m_standardItemModel->appendRow(item);
            } else {
                QString description;
                ModelNode parentNode = node.parentProperty().parentModelNode();
                if (parentNode.isValid())
                    if (!parentNode.id().isEmpty())
                        description = node.parentProperty().parentModelNode().id() + QLatin1Char(' ');
                    else
                        description = node.parentProperty().parentModelNode().simplifiedTypeName() + QLatin1Char(' ');
                description += node.parentProperty().name();
                QStandardItem *item = new QStandardItem(description);
                item->setData(QVariant::fromValue(node), ModelNodeRole);
                item->setEditable(false);
                removeSingleNodeFromList(node); //remove node if already present
                m_standardItemModel->appendRow(item);
            }
        }
    }
}
Example #2
0
void SelectAuthorsDialog::addAuthor( void )
{
	//check bounds first
	if ( authorsCombo->currentText().length() > int(database->maxAuthorNameLength()) ) {
		KMessageBox::error( this, i18ncp( "@info", "Author name cannot be longer than 1 character.", "Author name cannot be longer than %1 characters." , database->maxAuthorNameLength() ) );
		authorsCombo->lineEdit() ->selectAll();
		return ;
	}

	if ( authorsCombo->lineEdit()->text().isEmpty() )
		return;

	if ( authorsCombo->contains( authorsCombo->currentText() ) )
		authorsCombo->setCurrentItem( authorsCombo->currentText() );

	createNewAuthorIfNecessary();

	int currentItem = authorsCombo->currentIndex();
	Element currentElement = authorList.getElement( currentItem );

	QStandardItem *itemId = new QStandardItem;
	itemId->setData( QVariant(currentElement.id), Qt::EditRole );
	itemId->setEditable( false ); 
	QStandardItem *itemAuthor = new QStandardItem( currentElement.name );
	itemAuthor->setEditable( false );
	QList<QStandardItem*> items;
	items << itemId << itemAuthor;
	authorListModel->appendRow( items );

	authorsCombo->lineEdit()->clear();
}
void list_handling::create_new_download(const download &new_download, QStandardItem *pkg, int dl_line){
	string color, status_text, time_left;
	color = build_status(status_text, time_left, new_download);

	QStandardItem *dl = new QStandardItem(QIcon("img/bullet_black.png"), QString("%1").arg(new_download.id));
	dl->setEditable(false);
	pkg->setChild(dl_line, 0, dl);

	dl = new QStandardItem(QString(new_download.title.c_str()));
	dl->setEditable(false);
	pkg->setChild(dl_line, 1, dl);

	dl = new QStandardItem(QString(new_download.url.c_str()));
	dl->setEditable(false);
	pkg->setChild(dl_line, 2, dl);

	dl = new QStandardItem(QString(time_left.c_str()));
	dl->setEditable(false);
	pkg->setChild(dl_line, 3, dl);

	string colorstring = "img/bullet_" + color + ".png";
	dl = new QStandardItem(QIcon(colorstring.c_str()), my_main_window->CreateQString(status_text.c_str()));
	dl->setEditable(false);
	pkg->setChild(dl_line, 4, dl);
}
Example #4
0
static void populateTableModel(QStandardItemModel *model)
{
    enum { ItemCount = 50 };

    const char *itemNames[] = { "potion", "ring", "amulet", "wand", "figurine" };
    const char *itemColors[] = { "black", "white", "red", "mauve", "blue", "green",
                                 "yellow", "ultramarine", "pink", "purple" };

    for (int i = 0; i < ItemCount; ++i) {
        QList<QStandardItem*> row;
        QStandardItem *item;
        item = new QStandardItem((i % 10 == 0) ? QString(itemNames[i / 10]) : QString());
        item->setEditable(false);
        row.append(item);
        item = new QStandardItem(QString("%1 %2").arg(QString(itemColors[i % 10])).
                    arg(QString(itemNames[i / 10])));
        item->setEditable(false);
        row.append(item);
        item = new QStandardItem(QString("%1 gold coins").arg(i * 10 + (i % 10) * 15 + 13));
        item->setTextAlignment(Qt::AlignCenter); // the Maemo 5 design spec recommends this.
        item->setEditable(false);
        row.append(item);
        model->appendRow(row);
    }
}
Example #5
0
	void CookiesEditModel::AddCookie (const QNetworkCookie& cookie)
	{
		int i = 0;
		if (Cookies_.size ())
			i = (Cookies_.end () - 1).key () + 1;
		Cookies_ [i] = cookie;
	
		QString domain = cookie.domain ();
	
		QList<QStandardItem*> foundItems = findItems (domain);
		QStandardItem *parent = 0;
		if (!foundItems.size ())
		{
			parent = new QStandardItem (domain);
			parent->setEditable (false);
			parent->setData (-1);
			invisibleRootItem ()->appendRow (parent);
		}
		else
			parent = foundItems.back ();
		QStandardItem *item = new QStandardItem (QString (Cookies_ [i].name ()));
		item->setData (i);
		item->setEditable (false);
		parent->appendRow (item);
	
		Jar_->setAllCookies (Cookies_.values ());
	}
	int ObjectTableView::addObject(const SceneObject *sceneObject)
	{
		QStandardItem *itemObjectName = new QStandardItem(QString::fromStdString(sceneObject->getName()));
		itemObjectName->setData(qVariantFromValue(sceneObject), Qt::UserRole + 1);
		itemObjectName->setEditable(false);

		std::string pathFileName;
		if(sceneObject->getModel()->getMeshes())
		{
			pathFileName = sceneObject->getModel()->getMeshes()->getMeshFilename();
		}
		QStandardItem *itemMeshFile = new QStandardItem(QString::fromStdString(FileHandler::getFileName(pathFileName)));
		itemMeshFile->setToolTip(QString::fromStdString(pathFileName));
		itemMeshFile->setData(qVariantFromValue(sceneObject), Qt::UserRole + 1);
		itemMeshFile->setEditable(false);

		int nextRow = objectsListModel->rowCount();
		objectsListModel->insertRow(nextRow);
		objectsListModel->setItem(nextRow, 0, itemObjectName);
		objectsListModel->setItem(nextRow, 1, itemMeshFile);

		resizeRowsToContents();

		return nextRow;
	}
void FileViewModel::addItem(const QString &name,
             const QString &size, const QString &type, const QString &date)
{

    QList<QStandardItem*> rowItems;

    QStandardItem *nameItem = new QStandardItem(name);
    QStandardItem *sizeItem = new QStandardItem(size);
    QStandardItem *typeItem = new QStandardItem(type);
    QStandardItem *dateItem = new QStandardItem(date);

    nameItem->setEditable(false);
    sizeItem->setEditable(false);
    typeItem->setEditable(false);
    dateItem->setEditable(false);

    rowItems.push_back(nameItem);
    rowItems.push_back(sizeItem);
    rowItems.push_back(typeItem);
    rowItems.push_back(dateItem);

    m_ItemModel->insertRow(0, rowItems);


//    m_ItemModel->setData(m_ItemModel->index(0, 0), name, Qt::DisplayRole);
//    m_ItemModel->setData(m_ItemModel->index(0, 1), size, Qt::DisplayRole);
//    m_ItemModel->setData(m_ItemModel->index(0, 2), type, Qt::DisplayRole);
//    m_ItemModel->setData(m_ItemModel->index(0, 3), date, Qt::DisplayRole);
}
void KreCategoriesListWidget::populate( QStandardItem * item, int id )
{
	int current_row = 0;

	CategoryTree categoryTree;
	m_database->loadCategories( &categoryTree, -1, 0, id, false );

	for ( CategoryTree * child_it = categoryTree.firstChild(); 
	child_it; child_it = child_it->nextSibling() ) {
		//The "Id" item.
		QStandardItem *itemId = new QStandardItem;
		itemId->setData( QVariant(child_it->category.id), Qt::EditRole );
		itemId->setEditable( false );

		//The "Category" item.
		QStandardItem *itemCategory = new QStandardItem( child_it->category.name );
		itemCategory->setEditable( true );
	
		//Insert the items as children
		item->setChild( current_row, 0, itemCategory );
		item->setChild( current_row, 1, itemId );
		populate( itemCategory, child_it->category.id );
		++current_row;
	}

}
Example #9
0
bool BookmarkWidget::eventFilter(QObject *object, QEvent *e)
{
    if ((object == this) || (object == treeView->viewport())) {
        QModelIndex index = treeView->currentIndex();
        if (e->type() == QEvent::KeyPress) {
            QKeyEvent *ke = static_cast<QKeyEvent*>(e);
            if (index.isValid() && searchField->text().isEmpty()) {
                const QModelIndex &src = filterBookmarkModel->mapToSource(index);
                if (ke->key() == Qt::Key_F2) {
                    QStandardItem *item =
                        bookmarkManager->treeBookmarkModel()->itemFromIndex(src);
                    if (item) {
                        item->setEditable(true);
                        treeView->edit(index);
                        item->setEditable(false);
                    }
                } else if (ke->key() == Qt::Key_Delete) {
                    bookmarkManager->removeBookmarkItem(treeView, src);
                }
            }

            switch (ke->key()) {
                default: break;
                case Qt::Key_Up: {
                case Qt::Key_Down:
                    treeView->subclassKeyPressEvent(ke);
                }   break;

                case Qt::Key_Enter: {
                case Qt::Key_Return:
                    index = treeView->selectionModel()->currentIndex();
                    if (index.isValid()) {
                        QString data = index.data(Qt::UserRole + 10).toString();
                        if (!data.isEmpty() && data != QLatin1String("Folder"))
                            emit requestShowLink(data);
                    }
                }   break;

                case Qt::Key_Escape: {
                    emit escapePressed();
                }   break;
            }
        } else if (e->type() == QEvent::MouseButtonRelease) {
            if (index.isValid()) {
                QMouseEvent *me = static_cast<QMouseEvent*>(e);
                bool controlPressed = me->modifiers() & Qt::ControlModifier;
                if(((me->button() == Qt::LeftButton) && controlPressed)
                    || (me->button() == Qt::MidButton)) {
                        QString data = index.data(Qt::UserRole + 10).toString();
                        if (!data.isEmpty() && data != QLatin1String("Folder"))
                        {
                            //CentralWidget::instance()->setSourceInNewTab(data);
                            emit requestShowLinkInNewTab(data);
                        }
                }
            }
        }
    }
    return QWidget::eventFilter(object, e);
}
void KreCategoriesListWidget::load( int limit, int offset )
{
	CategoryTree categoryTree;
	CategoryTree * pCategoryTree = &categoryTree;
	m_sourceModel->setRowCount( 0 );
	m_database->loadCachedCategories( &pCategoryTree, limit, offset, -1, true );

        for ( CategoryTree * child_it = pCategoryTree->firstChild(); child_it; child_it = child_it->nextSibling() ) {
		//The "Id" item.
		QStandardItem *itemId = new QStandardItem;
		itemId->setData( QVariant(child_it->category.id), Qt::EditRole );
		itemId->setEditable( false );

		//The "Category" item.
		QStandardItem *itemCategory = new QStandardItem( child_it->category.name );
		itemCategory->setEditable( true );

		//Insert the items in the model.
		QList<QStandardItem*> items;
		items << itemCategory << itemId;
		m_sourceModel->appendRow( items );

		//Populate the current element.
		populate( itemCategory, child_it->category.id );
        }

	emit loadFinishedPrivate();
}
void AELoadedResourcesTreeView::LoadModels()
{
	_modelResourcesItem->removeRows(0, _modelResourcesItem->rowCount());

	Anima::AnimaModelsManager* mgr = _document->GetEngine()->GetScenesManager()->GetScene("AnimaEditor")->GetModelsManager();
	for (int i = 0; i < mgr->GetModelsNumber(); i++)
	{
		Anima::AnimaModel* model = mgr->GetModel(i);
		
		QStandardItem *resourceNameItem = new QStandardItem(QString("%0").arg(model->GetName()));
		resourceNameItem->setData(QVariant::fromValue(model), ModelRole);
		resourceNameItem->setEditable(true);

		QStandardItem *resourceFileNameItem = new QStandardItem(QString("%0").arg(model->GetOriginFileName()));
		resourceFileNameItem->setData(QVariant::fromValue(model), ModelRole);
		resourceFileNameItem->setEditable(false);

		QList<QStandardItem*> newItem;
		newItem.append(resourceNameItem);
		newItem.append(resourceFileNameItem);

		resourceNameItem->removeRows(0, resourceNameItem->rowCount());

		LoadModelMeshes(model, resourceNameItem);
		LoadModelAnimations(model, resourceNameItem);

		_modelResourcesItem->appendRow(newItem);
	}
}
Example #12
0
void OnyxMainWindow::bookmarkModel(QStandardItemModel & model,
                                   QModelIndex & selected)
{
    CRFileHistRecord * rec = view_->getDocView()->getCurrentFileHistRecord();
    if ( !rec )
        return;
    LVPtrVector<CRBookmark> & list( rec->getBookmarks() );
    model.setColumnCount(2);
    int row = 0;
    for(int i  = 0; i < list.length(); ++i)
    {
        // skip cites
        CRBookmark * bmk = list[i];
        if (!bmk || (bmk->getType() == bmkt_comment || bmk->getType() == bmkt_correction))
            continue;

        QString t =cr2qt(view_->getDocView()->getPageText(true, list[i]->getBookmarkPage()));
        t.truncate(100);
        QStandardItem *title = new QStandardItem(t);
        title->setData((int)list[i]);
        title->setEditable(false);
        model.setItem(row, 0, title);

        int pos = list[i]->getPercent();
        QString str(tr("%1"));
        str = str.arg(pos);
        QStandardItem *page = new QStandardItem(str);
        page->setTextAlignment(Qt::AlignCenter);
        page->setEditable(false);
        model.setItem(row, 1, page);

        row++;
    }
}
Example #13
0
void RegistersModel::addItems(int startAddress, int noOfItems, bool valueIsEditable)
{
    int row;
    int col;
    m_startAddress = startAddress;
    m_noOfItems = noOfItems;
    m_offset = (startAddress % 10);
    m_firstRow = startAddress / 10;
    m_lastRow = (startAddress + noOfItems - 1) / 10;

    qDebug()<<  "RegistersModel : address " << startAddress << " ,noOfItems " << noOfItems
                << " ,offset " << m_offset << " ,first row " << m_firstRow << " ,last row " << m_lastRow;

    //Format Vertical - Horizontal Header
    clear();
    if (noOfItems > 1) {
        model->setHorizontalHeaderLabels(QStringList()<<RegModelHeaderLabels[0]<<RegModelHeaderLabels[1]
                                                    <<RegModelHeaderLabels[2]<<RegModelHeaderLabels[3]
                                                    <<RegModelHeaderLabels[4]<<RegModelHeaderLabels[5]
                                                    <<RegModelHeaderLabels[6]<<RegModelHeaderLabels[7]
                                                    <<RegModelHeaderLabels[8]<<RegModelHeaderLabels[9]);

        QStringList vertHeader;
        for (int i = m_firstRow; i <= m_lastRow ; i++) {
            vertHeader<<QString("%1").arg(i * 10, 2, 10, QLatin1Char('0'));
        }
        model->setVerticalHeaderLabels(vertHeader);
    }
    else {
        model->setHorizontalHeaderLabels(QStringList()<<RegModelHeaderLabels[0]);
        model->setVerticalHeaderLabels(QStringList()<<QString("%1").arg(startAddress, 2, 10, QLatin1Char('0')));
    }

    //Add data to model
    if (noOfItems == 1){
        QStandardItem *valueItem = new QStandardItem("-");model->setItem(0, 0, valueItem);
        valueItem->setEditable(valueIsEditable);
    }
    else {
        for (int i = 0; i < ((m_offset + noOfItems - 1) / 10 + 1) * 10 ; i++) {
            row = i / 10;
            col = i % 10;
            //Address
            if (i >= m_offset + noOfItems || i < m_offset){//not used cells
                QStandardItem *valueItem = new QStandardItem("x");model->setItem(row, col, valueItem);
                valueItem->setEditable(false);
                valueItem->setForeground(QBrush(Qt::red));
                valueItem->setBackground(QBrush(Qt::lightGray));
            }
            else {
                QStandardItem *valueItem = new QStandardItem("-");model->setItem(row, col, valueItem);
                valueItem->setEditable(valueIsEditable);
            }
        }
    }

    emit(refreshView());

}
QgsStyleV2GroupSelectionDialog::QgsStyleV2GroupSelectionDialog( QgsStyleV2 *style, QWidget *parent ) :
    QDialog( parent )
    , mStyle( style )
{
  setupUi( this );

  QStandardItemModel* model = new QStandardItemModel( groupTree );
  groupTree->setModel( model );

  QStandardItem *allSymbols = new QStandardItem( tr( "All Symbols" ) );
  allSymbols->setData( "all", Qt::UserRole + 2 );
  allSymbols->setEditable( false );
  setBold( allSymbols );
  model->appendRow( allSymbols );

  QStandardItem *group = new QStandardItem( "" ); //require empty name to get first order groups
  group->setData( "groupsheader", Qt::UserRole + 2 );
  group->setEditable( false );
  group->setFlags( group->flags() & ~Qt::ItemIsSelectable );
  buildGroupTree( group );
  group->setText( tr( "Groups" ) );//set title later
  QStandardItem *ungrouped = new QStandardItem( tr( "Ungrouped" ) );
  ungrouped->setData( 0 );
  ungrouped->setData( "group", Qt::UserRole + 2 );
  setBold( ungrouped );
  setBold( group );
  group->appendRow( ungrouped );
  model->appendRow( group );

  QStandardItem *tag = new QStandardItem( tr( "Smart Groups" ) );
  tag->setData( "smartgroupsheader" , Qt::UserRole + 2 );
  tag->setEditable( false );
  tag->setFlags( group->flags() & ~Qt::ItemIsSelectable );
  setBold( tag );
  QgsSymbolGroupMap sgMap = mStyle->smartgroupsListMap();
  QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
  while ( i != sgMap.constEnd() )
  {
    QStandardItem *item = new QStandardItem( i.value() );
    item->setEditable( false );
    item->setData( i.key() );
    item->setData( "smartgroup" , Qt::UserRole + 2 );
    tag->appendRow( item );
    ++i;
  }
  model->appendRow( tag );

  // expand things in the group tree
  int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
  for ( int i = 0; i < rows; i++ )
  {
    groupTree->setExpanded( model->indexFromItem( model->item( i ) ), true );
  }
  connect( groupTree->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( groupTreeSelectionChanged( const QItemSelection&, const QItemSelection& ) ) );
}
void MangaListWidget::initModel(QString mangaSelected) {
  _scansDirectory.setFilter(QDir::Dirs);
  QStringList dirsList = Utils::dirList(_scansDirectory);

  _model->removeRows(0, _model->rowCount());

  QModelIndex indexMangaSelected;

  for (const QString& mangaName: dirsList) {
    QString currDirStr = _scansDirectory.path() + "/" + mangaName;

    QStandardItem* currItem = new QStandardItem(mangaName);
    currItem->setEditable(false);
    _model->appendRow(currItem);

    QDir currDir(currDirStr);
    QStringList currDirsList = Utils::dirList(currDir, true);

    QList<bool> areChaptersRead = Utils::areChaptersRead(mangaName);
    if (!Utils::isMangaRead(areChaptersRead))
      currItem->setFont(QFont("", -1, 99));
    else
      currItem->setFont(QFont());

    if (mangaName == mangaSelected) {
      indexMangaSelected = _model->indexFromItem(currItem);
    }

    int k = 0;
    for (const QString& currChStr: currDirsList) {
      if (k >= areChaptersRead.size()) {
        QMessageBox::critical(this, "List error", "Error while tempting to edit manga read flags whithin MangaListWidget::initModel.");
        return;
      }
      bool isChapterRead = areChaptersRead.at(k);

      QStandardItem* currChItem = new QStandardItem(currChStr);
      currChItem->setEditable(false);
      setTextAccordingToRead(currChItem, isChapterRead);

      currItem->appendRow(currChItem);

      k++;
    }
  }

  if (indexMangaSelected.isValid()) {
    _view->selectionModel()->setCurrentIndex(indexMangaSelected, QItemSelectionModel::Current);
  }

  decorateMangaNames();
}
Example #16
0
void BookmarkWidget::customContextMenuRequested(const QPoint &point)
{
    QModelIndex index = treeView->indexAt(point);
    if (!index.isValid())
        return;

    QAction *showItem = 0;
    QAction *removeItem = 0;
    QAction *renameItem = 0;
    QAction *showItemNewTab = 0;

    QMenu menu(QLatin1String(""), this);
    QString data = index.data(Qt::UserRole + 10).toString();
    if (data == QLatin1String("Folder")) {
        removeItem = menu.addAction(tr("Delete Folder"));
        renameItem = menu.addAction(tr("Rename Folder"));
    } else {
        showItem = menu.addAction(tr("Show Bookmark"));
        showItemNewTab = menu.addAction(tr("Show Bookmark in New Tab"));
        if (searchField->text().isEmpty()) {
            menu.addSeparator();
            removeItem = menu.addAction(tr("Delete Bookmark"));
            renameItem = menu.addAction(tr("Rename Bookmark"));
        }
    }

    QAction *pickedAction = menu.exec(treeView->mapToGlobal(point));
    if (!pickedAction)
        return;

    if (pickedAction == showItem) {
        emit requestShowLink(data);
    }
    else if (pickedAction == showItemNewTab) {
        //CentralWidget::instance()->setSourceInNewTab(data);
        emit requestShowLinkInNewTab(data);
    }
    else if (pickedAction == removeItem) {
        bookmarkManager->removeBookmarkItem(treeView,
            filterBookmarkModel->mapToSource(index));
    }
    else if (pickedAction == renameItem) {
        const QModelIndex &source = filterBookmarkModel->mapToSource(index);
        QStandardItem *item =
            bookmarkManager->treeBookmarkModel()->itemFromIndex(source);
        if (item) {
            item->setEditable(true);
            treeView->edit(index);
            item->setEditable(false);
        }
    }
}
Example #17
0
   PropertyTree::ItemID  PropertyTree::addItem(const std::string & name,const std::string & val, ItemID parent)
   {
      if(!parent)
         parent = model_->invisibleRootItem();

      QStandardItem * firstCol  = new QStandardItem(QString::fromStdString(name));
      QStandardItem * secondCol = new QStandardItem(QString::fromStdString(val));
      firstCol->setEditable(false);
      secondCol->setEditable(false);
      parent->appendRow(QList<ItemID>() << firstCol << secondCol );

      return firstCol;
   }
	void ChannelConfigWidget::addInviteListItem (const QString& mask,
			const QString& nick, const QDateTime& date)
	{
		QStandardItem *itemMask = new QStandardItem (mask);
		itemMask->setEditable (false);
		QStandardItem *itemNick = new QStandardItem (nick);
		itemNick->setEditable (false);
		QStandardItem *itemDate = new QStandardItem (date.toString ("dd.MM.yyyy hh:mm:ss"));
		itemDate->setEditable (false);

		InviteModel_->appendRow (QList<QStandardItem*> () << itemMask
				<< itemNick
				<< itemDate);
	}
Example #19
0
  void CDInfoDialog::setInfo( const KCDDB::CDInfo &info, const KCDDB::TrackOffsetList &trackStartFrames )
  {
      d->info = info;

      d->ui->m_artist->setText(info.get(Artist).toString().trimmed());
      d->ui->m_title->setText(info.get(Title).toString().trimmed());
      d->ui->m_category->setItemText(d->ui->m_category->currentIndex(), d->categories.cddb2i18n(info.get(Category).toString()));

      // Make sure the revision is set before the genre to allow the genreChanged() handler to fire.
      d->ui->m_revision->setText(QString::number(info.get(QLatin1String( "revision" )).toInt()));
      d->ui->m_genre->setItemText(d->ui->m_genre->currentIndex(), d->genres.cddb2i18n(info.get(Genre).toString()));
      d->ui->m_year->setValue(info.get(Year).toInt());
      d->ui->m_comment->setText(info.get(Comment).toString().trimmed());
      d->ui->m_id->setText(info.get(QLatin1String( "discid" )).toString().trimmed());

      // Now do the individual tracks.
      unsigned tracks = info.numberOfTracks();
      if (tracks > 0)
      {
         d->ui->m_length->setText(framesTime(trackStartFrames[tracks] - trackStartFrames[0]));
      }

      m_trackModel->clear();
      QStringList labels;
      labels << i18n("Track") << i18n("Length") << i18n("Title") << i18n("Artist") << i18n("Comment");
      m_trackModel->setHorizontalHeaderLabels(labels);
      for (unsigned i = 0; i < tracks; i++) {
          QList<QStandardItem *> trackItems = QList<QStandardItem *>();
          TrackInfo ti(info.track(i));
          QStandardItem *trackNumberItem = new QStandardItem(QString().sprintf("%02d", i + 1));
		  trackNumberItem->setEditable(false);
          trackItems << trackNumberItem;
          QStandardItem *trackLengthItem = new QStandardItem(framesTime(trackStartFrames[i + 1] - trackStartFrames[i]));
		  trackLengthItem->setEditable(false);
          trackItems << trackLengthItem;
          QStandardItem *trackTitleItem = new QStandardItem(ti.get(Title).toString());
          trackItems << trackTitleItem;
          QStandardItem *trackArtistItem = new QStandardItem(ti.get(Artist).toString());
          trackItems << trackArtistItem;
          QStandardItem *trackCommentItem = new QStandardItem(ti.get(Comment).toString());
          trackItems << trackCommentItem;

          m_trackModel->appendRow(trackItems);
      }
      // FIXME KDE4: handle playorder here too, once KCDDBInfo::CDInfo is updated.

      if (info.get(Artist).toString() == QLatin1String( "Various" ) || d->ui->m_multiple->isChecked()){
          d->ui->m_trackList->resizeColumnToContents(Private::TRACK_ARTIST);
    }
  }
Example #20
0
void GlobalSettingsConfig::populateInputs()/*{{{*/
{
    m_inputsModel->clear();
    QStringList alsaList;
    QStringList jackList;
    if(gInputList.size())
    {
        //Select the rows
        for(int i = 0; i < gInputList.size(); ++i)
        {
            QPair<int, QString> input = gInputList.at(i);
            if(input.first == MidiDevice::JACK_MIDI)
                jackList.append(input.second);
            else
                alsaList.append(input.second);
        }
    }
    for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i)
    {
        if ((*i)->deviceType() == MidiDevice::ALSA_MIDI)
        {
            if ((*i)->rwFlags() & 0x2)
            {
                QStandardItem* item = new QStandardItem(QString((*i)->name()).append(" (ALSA)"));
                item->setData((*i)->name(), Qt::UserRole+1);
                item->setData(MidiDevice::ALSA_MIDI, Qt::UserRole+2);
                item->setEditable(false);
                item->setCheckable(true);
                if(alsaList.contains((*i)->name()))
                    item->setCheckState(Qt::Checked);
                m_inputsModel->appendRow(item);
            }
        }
    }
    if(audioDevice->deviceType() != AudioDevice::JACK_AUDIO)
        return;
    std::list<QString> sl = audioDevice->outputPorts(true, false);//No aliases
    for (std::list<QString>::iterator ip = sl.begin(); ip != sl.end(); ++ip)
    {
        QStandardItem* item = new QStandardItem(QString(*ip).append(" (JACK)"));
        item->setData(*ip, Qt::UserRole+1);
        item->setData(MidiDevice::JACK_MIDI, Qt::UserRole+2);
        item->setEditable(false);
        item->setCheckable(true);
        if(jackList.contains(*ip))
            item->setCheckState(Qt::Checked);
        m_inputsModel->appendRow(item);
    }
}/*}}}*/
Example #21
0
void CDialogGroups::setMesh ( CMesh * mesh )
{
    m_mesh = mesh;
    m_model->clear();

    QStringList headers;
    headers << trUtf8 ( "Nom" ) << trUtf8 ( "Faces" ) << trUtf8 ( "Matériau" );
    m_model->setHorizontalHeaderLabels ( headers );

    if ( m_mesh )
    {
        unsigned int nbr_groups = m_mesh->getNbrGroups();
        m_model->setRowCount ( nbr_groups );
        QStandardItem * item = NULL;

        // Pour chaque groupe
        for ( unsigned int i = 0 ; i < nbr_groups ; ++i )
        {
            CMeshGroup * group = m_mesh->getGroup ( i );

            item = new QStandardItem ( group->getName() );
            item->setEditable ( false );
            m_model->setItem ( i , 0 , item );

            QString str;
            str.setNum ( group->getNbrFaces() );

            item = new QStandardItem ( str );
            item->setEditable ( false );
            m_model->setItem ( i , 1 , item );

            if ( group->getMateriau() )
            {
                item = new QStandardItem ( group->getMateriau()->getName() );
            }
            else
            {
                item = new QStandardItem ( "" );
            }

            item->setEditable ( false );
            m_model->setItem ( i , 2 , item );
        }

        m_model->sort ( 0 );
    }

    return;
}
Example #22
0
	void ProfileWidget::FillFriends (const QList<LJFriendGroup>& groups)
	{
		for (const auto& group : groups)
		{
			QStandardItem *item = new QStandardItem (group.Name_);
			Item2FriendGroup_ [item] = group;
			item->setEditable (false);
			FriendsModel_->appendRow (item);
		}

		QStandardItem *withoutGroupItem = 0;
		for (const auto& fr : Profile_->GetFriends ())
		{
			QStandardItem *item = new QStandardItem (fr->GetUserName ());
			QStandardItem *itemName = new QStandardItem (fr->GetFullName ());
			QStandardItem *itemStatus = new QStandardItem (fr->GetFriendOf () ? "yes" : "no");
			QStandardItem *itemBirthday = new QStandardItem (fr->GetBirthday ());
			item->setEditable (false);
			itemName->setEditable (false);
			itemStatus->setEditable (false);
			itemBirthday->setEditable (false);

			item->setData (fr->GetBGColor ().name (), ItemColorRoles::BackgroundColor);
			item->setData (fr->GetFGColor ().name (), ItemColorRoles::ForegroundColor);

			bool found = false;
			for (const auto& parentItem : Item2FriendGroup_.keys ())
			{
				if (Item2FriendGroup_ [parentItem].RealId_ == fr->GetGroupMask ())
				{
					parentItem->appendRow ({ item, itemStatus, itemName, itemBirthday });
					found = true;
				}
			}

			if (!found)
			{
				if (!withoutGroupItem)
				{
					withoutGroupItem = new QStandardItem (tr ("Without group"));
					FriendsModel_->appendRow (withoutGroupItem);
				}

				withoutGroupItem->appendRow ({ item, itemStatus, itemName, itemBirthday });
			}
		}

		Ui_.FriendsView_->header ()->setResizeMode (QHeaderView::ResizeToContents);
	}
Example #23
0
	QList<QStandardItem*> CreateEntriesViewRow (const Entry& entry)
	{
		QStandardItem *dateItem = new QStandardItem (entry.Date_.date ()
				.toString (Qt::SystemLocaleShortDate) +
				" " +
				entry.Date_.time ().toString ("hh:mm"));
		dateItem->setData (entry.EntryId_, Utils::EntryIdRole::DBIdRole);
		dateItem->setEditable (false);
		dateItem->setData (entry.Subject_, Qt::ToolTipRole);
		QStandardItem *itemSubj = new QStandardItem (entry.Subject_);
		itemSubj->setEditable (false);
		itemSubj->setData (entry.Subject_, Qt::ToolTipRole);

		return { dateItem, itemSubj };
	}
void ComponentView::appendWholeDocumentAsComponent()
{
    QStandardItem *item = new QStandardItem(tr("whole document"));
    item->setData(QVariant::fromValue(rootModelNode()), ModelNodeRole);
    item->setEditable(false);
    m_standardItemModel->appendRow(item);
}
Example #25
0
DriveSelection::DriveSelection(BackupPlan *pBackupPlan, QWidget *parent)
   : QListView(parent), mBackupPlan(pBackupPlan), mSelectedAndAccessible(false), mSyncedBackupType(false)
{
	KConfigDialogManager::changedMap()->insert(QStringLiteral("DriveSelection"),
	                                           SIGNAL(selectedDriveChanged(QString)));

	mDrivesModel = new QStandardItemModel(this);
	setModel(mDrivesModel);
	setItemDelegate(new DriveSelectionDelegate(this));
	setSelectionMode(QAbstractItemView::SingleSelection);
	setWordWrap(true);

	if(!mBackupPlan->mExternalUUID.isEmpty()) {
		QStandardItem *lItem = new QStandardItem();
		lItem->setEditable(false);
		lItem->setData(QString(), DriveSelection::UDI);
		lItem->setData(mBackupPlan->mExternalUUID, DriveSelection::UUID);
		lItem->setData(0, DriveSelection::UsedSpace);
		lItem->setData(mBackupPlan->mExternalPartitionNumber, DriveSelection::PartitionNumber);
		lItem->setData(mBackupPlan->mExternalPartitionsOnDrive, DriveSelection::PartitionsOnDrive);
		lItem->setData(mBackupPlan->mExternalDeviceDescription, DriveSelection::DeviceDescription);
		lItem->setData(mBackupPlan->mExternalVolumeCapacity, DriveSelection::TotalSpace);
		lItem->setData(mBackupPlan->mExternalVolumeLabel, DriveSelection::Label);
		mDrivesModel->appendRow(lItem);
	}

	QList<Solid::Device> lDeviceList = Solid::Device::listFromType(Solid::DeviceInterface::StorageDrive);
	foreach (const Solid::Device &lDevice, lDeviceList) {
		deviceAdded(lDevice.udi());
	}
Example #26
0
	void ShowConfigDialog::reloadSettings ()
	{
		QSettings settings (QCoreApplication::organizationName (),
				QCoreApplication::applicationName () + "_Sidebar");
		settings.beginGroup (Context_);
		const int size = settings.beginReadArray ("Actions");

		for (int i = 0; i < size; ++i)
		{
			settings.setArrayIndex (i);

			const auto& icon = settings.value ("Icon").value<QIcon> ();
			QStandardItem *item = new QStandardItem (icon,
					settings.value ("Text").toString ());
			item->setCheckState (settings.value ("Enabled").toBool () ?
						Qt::Checked :
						Qt::Unchecked);
			item->setToolTip (settings.value ("Tooltip").toString ());
			item->setData (settings.value ("ID"), Roles::ActionID);
			item->setCheckable (true);
			item->setEditable (false);
			Model_->appendRow (item);
		}

		settings.endArray ();
		settings.endGroup ();
	}
Example #27
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() ) );
  }
}
QStandardItem *GoodsTVStandardItemModel::createCheckedItem() {
    QStandardItem* item = new QStandardItem(true);
    item->setCheckable(true);
    item->setCheckState(Qt::Unchecked);
    item->setEditable(false);
    return item;
}
Example #29
0
void QgsQueryBuilder::fillValues( int idx, int limit )
{
  // clear the model
  mModelValues->clear();

  // determine the field type
  QList<QVariant> values = mLayer->uniqueValues( idx, limit ).toList();
  std::sort( values.begin(), values.end() );

  QString nullValue = QgsApplication::nullRepresentation();

  QgsDebugMsg( QStringLiteral( "nullValue: %1" ).arg( nullValue ) );

  Q_FOREACH ( const QVariant &var, values )
  {
    QString value;
    if ( var.isNull() )
      value = nullValue;
    else if ( var.type() == QVariant::Date && mLayer->providerType() == QLatin1String( "ogr" ) && mLayer->storageType() == QLatin1String( "ESRI Shapefile" ) )
      value = var.toDate().toString( QStringLiteral( "yyyy/MM/dd" ) );
    else
      value = var.toString();

    QStandardItem *myItem = new QStandardItem( value );
    myItem->setEditable( false );
    myItem->setData( var, Qt::UserRole + 1 );
    mModelValues->insertRow( mModelValues->rowCount(), myItem );
    QgsDebugMsg( QStringLiteral( "Value is null: %1\nvalue: %2" ).arg( var.isNull() ).arg( var.isNull() ? nullValue : var.toString() ) );
  }
Example #30
0
QStandardItem *ResultsTree::CreateNormalItem(const QString &name)
{
    QStandardItem *item = new QStandardItem(name);
    item->setData(name, Qt::ToolTipRole);
    item->setEditable(false);
    return item;
}