Beispiel #1
0
FilterDlgImpl::FilterDlgImpl(QWidget* parent)
    : QDialog(parent)
{
    _setupUi();
	
    m_query->setRootIsDecorated(false);
    m_query->setSelectionMode(QAbstractItemView::NoSelection);
	
	QStandardItemModel *model = new QStandardItemModel(0, 5, this);

	model->setHeaderData(0, Qt::Horizontal, QObject::tr("Column"));
	model->setHeaderData(1, Qt::Horizontal, QObject::tr("Condition1"));
	model->setHeaderData(2, Qt::Horizontal, QObject::tr("Pattern1"));
	model->setHeaderData(3, Qt::Horizontal, QObject::tr("Condition2"));
	model->setHeaderData(4, Qt::Horizontal, QObject::tr("Pattern2"));
	
	model->insertRow(0);
	model->insertRow(1);
	model->insertRow(2);
	model->setData(model->index(0, 0), tr("Date"));
	model->setData(model->index(0, 1), "=");
	model->setData(model->index(1, 0), tr("Count"));
	model->setData(model->index(1, 1), "=");
	model->setData(model->index(2, 0), tr("Description"));
		
    m_query->setModel(model);
		
    setMinimumSize(680,100);
}
void QgsComposerLegendWidget::on_mMoveUpToolButton_clicked()
{
  if ( !mLegend )
  {
    return;
  }

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

  QModelIndex currentIndex = mItemTreeView->currentIndex();
  if ( !currentIndex.isValid() )
  {
    return;
  }

  mLegend->beginCommand( "Moved legend item up" );
  //is there an older sibling?
  int row = currentIndex.row();
  QModelIndex olderSibling = currentIndex.sibling( row - 1, 0 );

  if ( !olderSibling.isValid() )
  {
    return;
  }

  QModelIndex parentIndex = currentIndex.parent();
  QList<QStandardItem*> itemToMove;
  QList<QStandardItem*> olderSiblingItem;

  if ( !parentIndex.isValid() ) //move toplevel item
  {
    itemToMove = itemModel->takeRow( row );
    olderSiblingItem = itemModel->takeRow( row - 1 );
    itemModel->insertRow( row - 1, itemToMove );
    itemModel->insertRow( row, olderSiblingItem );

  }
  else //move classification items
  {
    QStandardItem* parentItem = itemModel->itemFromIndex( parentIndex );
    itemToMove = parentItem->takeRow( row );
    olderSiblingItem = parentItem->takeRow( row - 1 );
    parentItem->insertRow( row - 1, itemToMove );
    parentItem->insertRow( row, olderSiblingItem );
  }

  mItemTreeView->setCurrentIndex( itemModel->indexFromItem( itemToMove.at( 0 ) ) );
  mLegend->update();
  mLegend->endCommand();
}
void QgsComposerLegendWidget::on_mMoveDownPushButton_clicked()
{
  QStandardItemModel* itemModel = dynamic_cast<QStandardItemModel*>( mItemTreeView->model() );
  if ( !itemModel )
  {
    return;
  }

  QModelIndex currentIndex = mItemTreeView->currentIndex();
  if ( !currentIndex.isValid() )
  {
    return;
  }

  //is there an older sibling?
  int row = currentIndex.row();
  QModelIndex youngerSibling = currentIndex.sibling( row + 1, 0 );

  if ( !youngerSibling.isValid() )
  {
    return;
  }

  QModelIndex parentIndex = currentIndex.parent();
  QList<QStandardItem*> itemToMove;
  QList<QStandardItem*> youngerSiblingItem;

  if ( !parentIndex.isValid() ) //move toplevel (layer) item
  {
    youngerSiblingItem = itemModel->takeRow( row + 1 );
    itemToMove = itemModel->takeRow( row );
    itemModel->insertRow( row, youngerSiblingItem );
    itemModel->insertRow( row + 1, itemToMove );
  }
  else //move child (classification) item
  {
    QStandardItem* parentItem = itemModel->itemFromIndex( parentIndex );
    youngerSiblingItem = parentItem->takeRow( row + 1 );
    itemToMove = parentItem->takeRow( row );
    parentItem->insertRow( row, youngerSiblingItem );
    parentItem->insertRow( row + 1, itemToMove );
  }

  mItemTreeView->setCurrentIndex( itemModel->indexFromItem( itemToMove.at( 0 ) ) );
  if ( mLegend )
  {
    mLegend->update();
  }
}
void GameObjectSelectAssetDialog::PopulateGameAssetsTree(GameContentType gameContentType)
{
	AEAssert(m_GameAssetManager != nullptr);

	if(m_GameAssetManager == nullptr)
	{
		return;
	}

	QStandardItemModel* standardModel = reinterpret_cast<QStandardItemModel*>(m_StringProxyFilterModel->sourceModel());

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

	const GameAssetMap& gameAssetMap = m_GameAssetManager->GetGameAssetMap();

	for (auto gameAssetIt : gameAssetMap)
	{
		GameAsset* gameAsset = gameAssetIt.second;

		if(gameAsset->GetGameContentType() == gameContentType)
		{
			standardModel->insertRow(0);
			standardModel->setData(standardModel->index(0, 0), QString::fromStdWString(gameAsset->GetName()), Qt::ItemDataRole::DisplayRole);
			standardModel->setData(standardModel->index(0, 0), gameAsset->GetUniqueAssetID(), AE_QT_ITEM_DATA_ROLE_GAME_ASSET_UNIQUE_ID);
		}
	}
}
Beispiel #5
0
void MainWindow::loadScore()
{
    //QMessageBox::information(0, "wer", "wer");
    ui->tableView->reset();

    QStandardItemModel *model = new QStandardItemModel();

    QList< QList<QStandardItem *> > list = user->scoreDetail();

    for (int i = 0; i < list.count(); i++)
    {
        model->insertRow(i, list.at(i));
        qDebug() << list.at(i).at(1)->text();
    }

    model->setHeaderData(0, Qt::Horizontal, QObject::tr("Course Name"));
    model->setHeaderData(1, Qt::Horizontal, QObject::tr("Middleterm Score"));
    model->setHeaderData(2, Qt::Horizontal, QObject::tr("Final Score"));

    for (int i = 0; i < model->rowCount(); i++)
        for (int j = 0; j < model->columnCount(); j++)
            model->item(i,j)->setEditable(false);

    ui->tableView->setModel(model);

    ui->tableView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
    ui->tableView->resizeColumnToContents(1);
    ui->tableView->resizeColumnToContents(2);
//    ui->tableView->setColumnWidth(2, 100);
//    ui->tableView->setColumnWidth(3, 100);
    ui->tableView->verticalHeader()->hide();
    ui->tableView->setSelectionMode(QAbstractItemView::NoSelection);

}
void Ui_pluginManagerWindow::moveSelectedItem(bool up)
{
	const int sourceRow = ui.pluginTableView->selectionModel()->currentIndex().row();
	const int destRow = (up ? sourceRow - 1 : sourceRow);

	QStandardItemModel *model = (QStandardItemModel*)ui.pluginTableView->model();
	QList<QStandardItem*> sourceItems = model->takeRow(sourceRow);
	QList<QStandardItem*> destItems = model->takeRow(destRow);

	model->insertRow(destRow, sourceItems);
	model->insertRow(sourceRow, destItems);

	ui.pluginTableView->selectRow(up ? destRow : sourceRow + 1);
}
Beispiel #7
0
int main(int argc, char** argv) {
  QApplication app(argc, argv);

#if GUI
  checkScansDirectoryExists();

  MainWindow window;
  window.show();
#endif

#if PIE
  QStandardItemModel* model = new QStandardItemModel(0, 2);
  model->setHeaderData(0, Qt::Horizontal, "Label");
  model->setHeaderData(1, Qt::Horizontal, "Quantity");

  QDir scanDirectory("/home/valentin/Images/Scans");
  QStringList mangasList = scanDirectory.entryList(QDir::Dirs | QDir::NoDotAndDotDot);

  int row = 0;
  for (const QString& manga: mangasList) {
    model->insertRow(row, QModelIndex());

    QDir mangaDirectory(scanDirectory.path()+"/"+manga);
    QString nbChapters = QString::number(mangaDirectory.entryList(QDir::Dirs | QDir::NoDotAndDotDot).size());

    int r = (16*(row+1))%256;
    int g = (32*(row+1))%256;
    int b = (64*(row+1))%256;

    model->setData(model->index(row, 0, QModelIndex()), manga);
    model->setData(model->index(row, 1, QModelIndex()), nbChapters);
    model->setData(model->index(row, 0, QModelIndex()), QColor(r, g, b), Qt::DecorationRole);

    row++;
  }

  PieView* view = new PieView;
  //QTableView* view = new QTableView;
  view->setModel(model);

  //QHeaderView* headerView = view->horizontalHeader();
  //headerView->setStretchLastSection(true);

  view->show();
#endif

  return app.exec();
}
Beispiel #8
0
void CMessageDock::addMessage(const QUuid& uuid, int lineNo, CategoryType category, const QString& description)
{
	QString iconPath, categoryName;
	switch(category)
	{
	case InfomationCategory:
		iconPath     = ":/images/tango/small/dialog-information.png";
		categoryName = tr("Information");
		m_countOfInfomationMessages++;
		break;
	case WarningCategory:
		iconPath     = ":/images/icons/small/software-update-urgent-yellow.png";
		categoryName = tr("Warning");
		m_countOfWarningMessages++;
		break;
	case ErrorCategory:
		iconPath     = ":/images/tango/small/dialog-error.png";
		categoryName = tr("Error");
		m_countOfErrorMessages++;
		break;
	default:
		break;
	}

	QStandardItemModel* model
		= static_cast<QStandardItemModel*>(
			static_cast<QSortFilterProxyModel*>(m_listWidget->model())->sourceModel()) ;
	int row = model->rowCount();
	model->insertRow(row);
	if( !iconPath.isEmpty() ) {
		model->setData(model->index(row, CategoryColumn   ), QIcon(iconPath), Qt::DecorationRole);
		model->setData(model->index(row, CategoryColumn   ), categoryName);
	}
	model->setData(model->index(row, RefIndexColumn   ), m_messages.size(), Qt::UserRole + 1);
	model->setData(model->index(row, DescriptionColumn), description);
	model->setData(model->index(row, FileNameColumn   ), theFile->fileName(uuid));
	model->setData(model->index(row, LineNoColumn     ), 0 < lineNo ? QString("%1").arg(lineNo) : "");
	model->setData(model->index(row, LineNoColumn     ), Qt::AlignRight, Qt::TextAlignmentRole);

	MessageInfoType info;
	info.description= description;
	info.category	= category;
	info.uuid		= uuid;
	info.lineNo		= lineNo;
	m_messages.push_back(info);

	updateMessagesCount();
}
Beispiel #9
0
    void testItemAddBeginning() {
        QStandardItemModel smallerModel;

        PaginateModel pm;
        new ModelTest(&pm, &pm);
        pm.setSourceModel(&smallerModel);
        pm.setPageSize(5);
        QCOMPARE(pm.pageCount(), 1);
        QCOMPARE(pm.rowCount(), 0);
        smallerModel.insertRow(0, new QStandardItem(QStringLiteral("just one")));
        QCOMPARE(pm.pageCount(), 1);
        QCOMPARE(pm.rowCount(), 1);
        smallerModel.removeRow(0);
        QCOMPARE(pm.pageCount(), 1);
        QCOMPARE(pm.rowCount(), 0);
    }
Beispiel #10
0
void MainWindow::openProject()
{
  const QString sfm_data_fileName = QFileDialog::getOpenFileName(this, tr("Choose a sfm_data project file"),
    QString::null, tr("sfm_data (*.json *.xml *.bin)"));
  if (sfm_data_fileName.isEmpty())
    return;

  m_sfm_data_filename = sfm_data_fileName.toStdString();

  if (m_doc.loadData(sfm_data_fileName.toStdString()))
  {
    //Add image names in the QT tree view
    {
      QStandardItemModel * model = new QStandardItemModel(0,1, this);
      model->setHeaderData(0, Qt::Horizontal, QObject::tr("Views"));
      m_treeView_Images->setModel(model);

      for (Views::const_reverse_iterator iterV = m_doc._sfm_data.GetViews().rbegin();
        iterV != m_doc._sfm_data.GetViews().rend();
        ++iterV)
      {
        const View * view = iterV->second.get();
        if (m_doc._sfm_data.IsPoseAndIntrinsicDefined(view))
        {
          std::ostringstream os;
          os << view->id_view << " " << view->s_Img_path;
          model->insertRow(0);
          model->setData(model->index(0, 0), QString::fromStdString(os.str()));
        }
      }
    }
  }
  else
  {
    QMessageBox msgBox;
    msgBox.setText("Cannot open the provided sfm_data file.");
    msgBox.exec();
  }
}
Beispiel #11
0
void MainWindow::loadElective()
{
    //QMessageBox::information(0, "User", "Elective");
    ui->tableView->reset();

    QStandardItemModel *model = new QStandardItemModel();
    //MyStandardItemModel *model = new MyStandardItemModel();
    MyItemDelegate *delegate = new MyItemDelegate();

    connect(model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(saveElectiveChange(QStandardItem*)));

    QList< QList<QStandardItem *> > list = user->electiveDetail();

    for (int i = 0; i < list.count(); i++)
    {
        model->insertRow(i, list.at(i));
        qDebug() << list.at(i).at(1)->text();
    }

    model->setHeaderData(0, Qt::Horizontal, QObject::tr("Status"));
    model->setHeaderData(1, Qt::Horizontal, QObject::tr("Course ID"));
    model->setHeaderData(2, Qt::Horizontal, QObject::tr("Course Name"));
    model->setHeaderData(3, Qt::Horizontal, QObject::tr("Teacher ID"));
    model->setHeaderData(4, Qt::Horizontal, QObject::tr("Teacher Name"));
    model->setHeaderData(5, Qt::Horizontal, QObject::tr("Course Addr."));

    ui->tableView->setModel(model);
    //ui->tableView->setItemDelegate(delegate);

    for (int i = 0; i < model->columnCount(); i++)
        ui->tableView->horizontalHeader()->setResizeMode(i, QHeaderView::Stretch);
    //ui->tableView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
    ui->tableView->resizeColumnToContents(1);
    ui->tableView->resizeColumnToContents(2);
//    ui->tableView->setColumnWidth(2, 100);
//    ui->tableView->setColumnWidth(3, 100);
    ui->tableView->verticalHeader()->hide();
    ui->tableView->setSelectionMode(QAbstractItemView::NoSelection);
}
Beispiel #12
0
void FMPanel::driveClicked( const QModelIndex &index )
{
    const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>( index.model() );
    if( model == NULL )
        return;
    QStandardItem* item = model->itemFromIndex(index);
#ifdef Q_WS_MAC
    QString path( item->whatsThis() );
#else
    QString path( item->text() );
#endif
    QDir dir( path );
    currentFile.clear();
    if( dir.entryInfoList().count()!=0 )
    {
        lastClick = QTime::currentTime ();
        currentDir.clear();
        currentDir.append( path );
        dirList->setRootPath( currentDir );
        setPathEditText( currentDir );
        driveJustLoaded = true;
        noDrive = false;
    }
    else
    {
        //TODO: check this out on win
        QStandardItemModel* model = new QStandardItemModel( 1, 1 );
        QStandardItem* empty = new QStandardItem("No drive available.");
        currentDir.clear();
        model->insertRow( 0, empty );
        dirList->setModel( model );
        setPathEditText( "No drive available." );
        noDrive = true;
        mainW->stopAnimation();
    }
    tab->setCurrentIndex(1);
    return;
}
Beispiel #13
0
/** Process results sent back from various search engines (local, remote). */
void SearchDialog::processResults(Request type, const QStandardItemList &results)
{
	QListView *listToProcess = nullptr;
	switch (type) {
	case Artist:
		listToProcess = _artists;
		break;
	case Album:
		listToProcess = _albums;
		break;
	case Track:
		listToProcess = _tracks;
		break;
	}
	QStandardItemModel *m = qobject_cast<QStandardItemModel*>(listToProcess->model());
	for (int i = 0; i < results.size(); i++) {
		m->insertRow(0, results.at(i));
	}
	m->sort(0);
	listToProcess->setFixedHeight(listToProcess->model()->rowCount() * listToProcess->sizeHintForRow(0));
	qDebug() << "number of items" << listToProcess->model()->rowCount();
	qDebug() << "size h f r 1" << _artists->sizeHintForRow(0) << _albums->sizeHintForRow(0) << _tracks->sizeHintForRow(0);
	qDebug() << "size h f r 2" << iconArtists->height() << iconAlbums->height() << iconTracks->height();
	int ar = qMax(_artists->model()->rowCount() * _artists->sizeHintForRow(0), iconArtists->height());
	int al = qMax(_albums->model()->rowCount() * _albums->sizeHintForRow(0), iconAlbums->height());
	int tr = qMax(_tracks->model()->rowCount() * _tracks->sizeHintForRow(0), iconTracks->height());
	artistLayoutWidget->setFixedHeight(ar);
	albumLayoutWidget->setFixedHeight(al);
	trackLayoutWidget->setFixedHeight(tr);
	qDebug() << "ar al tr" << ar << al << tr;

	int h = ar + al + tr;
	//int h = 300;
	h += labelSearchMore->height() + aggregated->height() + 3;
	int minW = qMax(iconArtists->width() + _artists->sizeHintForColumn(0), 400);
	this->resize(minW, h);
}
Beispiel #14
0
void KGetLinkView::showLinks( const QList<QString>& links )
{
    QStandardItemModel *model = new QStandardItemModel(0, 5, this);

    model->setHeaderData(0, Qt::Horizontal, i18n("Auxiliary header"));
    model->setHeaderData(1, Qt::Horizontal, i18n("File Name"));
    model->setHeaderData(2, Qt::Horizontal, i18n("Description"));
    model->setHeaderData(3, Qt::Horizontal, i18nc("list header: type of file", "File Type"));
    model->setHeaderData(4, Qt::Horizontal, i18n("Location (URL)"));

    foreach (const QString &linkitem, links)
    {
        KUrl url(linkitem);
        QString file = url.fileName();
        if (file.isEmpty())
        {
            file = QString(url.host());
        }

        KMimeType::Ptr mt = KMimeType::findByUrl(linkitem, 0, true, true);

        QList<QStandardItem*> items;

        QStandardItem *item = new QStandardItem(file);
        item->setIcon(KIcon(mt->iconName()));
        item->setCheckable(true);
        item->setData(QVariant(url.fileName()), Qt::DisplayRole);
        item->setData(QVariant(mt->name()), Qt::UserRole); // used for filtering DownloadFilterType

        items << new QStandardItem(QString::number(model->rowCount()));
        items << item;
        items << new QStandardItem();
        items << new QStandardItem(mt->comment());
        items << new QStandardItem(url.prettyUrl());

        model->insertRow(model->rowCount(), items);
    }
void FlatProxyModelTester::testInsertRemoveTop()
{
    QSortFilterProxyModel sf;
    FlatProxyModel fm;
    QStandardItemModel sm;

    sf.setSourceModel( &fm );
    fm.setSourceModel( &sm );

    sm.setHeaderData( 0, Qt::Horizontal, "Column 0" );
    QCOMPARE( sm.rowCount(), 0 );

    // insert
    sm.insertRow( 0, new QStandardItem( "First" ) );
    QCOMPARE( sm.rowCount(), 1 );
    QCOMPARE( fm.rowCount(), 1 );
    QCOMPARE( sf.rowCount(), 1 );
    QCOMPARE( sm.index( 0, 0 ).data(), sf.index( 0, 0 ).data() );
    QCOMPARE( sf.index( 0, 0 ).data(), QVariant( "First" ) );

    sm.insertRow( 1, new QStandardItem( "Second" ) );
    QCOMPARE( sm.rowCount(), 2 );
    QCOMPARE( fm.rowCount(), 2 );
    QCOMPARE( sf.rowCount(), 2 );
    QCOMPARE( sm.index( 0, 0 ).data(), sf.index( 0, 0 ).data() );
    QCOMPARE( sm.index( 1, 0 ).data(), sf.index( 1, 0 ).data() );
    QCOMPARE( sf.index( 0, 0 ).data(), QVariant( "First" ) );
    QCOMPARE( sf.index( 1, 0 ).data(), QVariant( "Second" ) );

    sm.insertRow( 1, new QStandardItem( "In between" ) );
    QCOMPARE( sm.rowCount(), 3 );
    QCOMPARE( fm.rowCount(), 3 );
    QCOMPARE( sf.rowCount(), 3 );
    QCOMPARE( sm.index( 0, 0 ).data(), sf.index( 0, 0 ).data() );
    QCOMPARE( sm.index( 1, 0 ).data(), sf.index( 1, 0 ).data() );
    QCOMPARE( sm.index( 2, 0 ).data(), sf.index( 2, 0 ).data() );
    QCOMPARE( sf.index( 0, 0 ).data(), QVariant( "First" ) );
    QCOMPARE( sf.index( 1, 0 ).data(), QVariant( "In between" ) );
    QCOMPARE( sf.index( 2, 0 ).data(), QVariant( "Second" ) );

    sm.insertRow( 0, new QStandardItem( "Before first" ) );
    QCOMPARE( sm.rowCount(), 4 );
    QCOMPARE( fm.rowCount(), 4 );
    QCOMPARE( sf.rowCount(), 4 );
    QCOMPARE( sm.index( 0, 0 ).data(), sf.index( 0, 0 ).data() );
    QCOMPARE( sm.index( 1, 0 ).data(), sf.index( 1, 0 ).data() );
    QCOMPARE( sm.index( 2, 0 ).data(), sf.index( 2, 0 ).data() );
    QCOMPARE( sm.index( 3, 0 ).data(), sf.index( 3, 0 ).data() );
    QCOMPARE( sf.index( 0, 0 ).data(), QVariant( "Before first" ) );
    QCOMPARE( sf.index( 1, 0 ).data(), QVariant( "First" ) );
    QCOMPARE( sf.index( 2, 0 ).data(), QVariant( "In between" ) );
    QCOMPARE( sf.index( 3, 0 ).data(), QVariant( "Second" ) );

    // remove
    sm.removeRow( 0 );
    QCOMPARE( sm.rowCount(), 3 );
    QCOMPARE( fm.rowCount(), 3 );
    QCOMPARE( sf.rowCount(), 3 );
    QCOMPARE( sm.index( 0, 0 ).data(), sf.index( 0, 0 ).data() );
    QCOMPARE( sm.index( 1, 0 ).data(), sf.index( 1, 0 ).data() );
    QCOMPARE( sm.index( 2, 0 ).data(), sf.index( 2, 0 ).data() );
    QCOMPARE( sf.index( 0, 0 ).data(), QVariant( "First" ) );
    QCOMPARE( sf.index( 1, 0 ).data(), QVariant( "In between" ) );
    QCOMPARE( sf.index( 2, 0 ).data(), QVariant( "Second" ) );

    sm.removeRow( 1 );
    QCOMPARE( sm.rowCount(), 2 );
    QCOMPARE( fm.rowCount(), 2 );
    QCOMPARE( sf.rowCount(), 2 );
    QCOMPARE( sm.index( 0, 0 ).data(), sf.index( 0, 0 ).data() );
    QCOMPARE( sm.index( 1, 0 ).data(), sf.index( 1, 0 ).data() );
    QCOMPARE( sf.index( 0, 0 ).data(), QVariant( "First" ) );
    QCOMPARE( sf.index( 1, 0 ).data(), QVariant( "Second" ) );

    sm.removeRow( 1 );
    QCOMPARE( sm.rowCount(), 1 );
    QCOMPARE( fm.rowCount(), 1 );
    QCOMPARE( sf.rowCount(), 1 );
    QCOMPARE( sm.index( 0, 0 ).data(), sf.index( 0, 0 ).data() );
    QCOMPARE( sf.index( 0, 0 ).data(), QVariant( "First" ) );

    sm.removeRow( 0 );
    QCOMPARE( sm.rowCount(), 0 );
    QCOMPARE( fm.rowCount(), 0 );
    QCOMPARE( sf.rowCount(), 0 );
}
void MpcImportWindow::populateCandidateObjects(QList<SsoElements> objects)
{
	candidatesForAddition.clear();

	//Get a list of the current objects
	QHash<QString,QString> defaultSsoIdentifiers = ssoManager->getDefaultSsoIdentifiers();
	QHash<QString,QString> loadedSsoIdentifiers = ssoManager->listAllLoadedSsoIdentifiers();

	//Separating the objects into visual groups in the list
	int newDefaultSsoIndex = 0;
	int newLoadedSsoIndex = 0;
	int newNovelSsoIndex = 0;
	int insertionIndex = 0;

	QStandardItemModel * model = candidateObjectsModel;
	model->clear();
	model->setColumnCount(1);

	foreach (SsoElements object, objects)
	{
		QString name = object.value("name").toString();
		if (name.isEmpty())
			continue;

		QString group = object.value("section_name").toString();
		if (group.isEmpty())
			continue;

		//Prevent name conflicts between asteroids and moons
		if (loadedSsoIdentifiers.contains(name))
		{
			if (loadedSsoIdentifiers.value(name) != group)
			{
				name.append('*');
				object.insert("name", name);
			}
		}

		QStandardItem * item = new QStandardItem();
		item->setText(name);
		item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
		item->setCheckState(Qt::Unchecked);

		if (defaultSsoIdentifiers.contains(name))
		{
			//Duplicate of a default solar system object
			QFont itemFont(item->font());
			itemFont.setBold(true);
			item->setFont(itemFont);

			candidatesForUpdate.append(object);

			insertionIndex = newDefaultSsoIndex;
			newDefaultSsoIndex++;
			newLoadedSsoIndex++;
			newNovelSsoIndex++;
		}
		else if (loadedSsoIdentifiers.contains(name))
		{
			//Duplicate of another existing object
			QFont itemFont(item->font());
			itemFont.setItalic(true);
			item->setFont(itemFont);

			candidatesForUpdate.append(object);

			insertionIndex = newLoadedSsoIndex;
			newLoadedSsoIndex++;
			newNovelSsoIndex++;
		}
		else
		{
			candidatesForAddition.append(object);

			insertionIndex = newNovelSsoIndex;
			newNovelSsoIndex++;
		}

		model->insertRow(insertionIndex, item);
	}
void FlatProxyModelTester::testInsertRemoveGrandChildren()
{
    QSortFilterProxyModel sf;
    FlatProxyModel fm;
    QStandardItemModel sm;

    sf.setSourceModel( &fm );
    fm.setSourceModel( &sm );

    sm.setHeaderData( 0, Qt::Horizontal, "Column 0" );
    QCOMPARE( sm.rowCount(), 0 );

    QStandardItem *pitem = new QStandardItem( "Parent" );
    sm.insertRow( 0, pitem );
    QCOMPARE( sm.rowCount(), 1 );
    QCOMPARE( fm.rowCount(), 1 );
    QCOMPARE( sf.rowCount(), 1 );
    QCOMPARE( sm.index( 0, 0 ).data(), sf.index( 0, 0 ).data() );
    QCOMPARE( sf.index( 0, 0 ).data(), QVariant( "Parent" ) );

    QModelIndex grandparent = sm.index( 0, 0 );
    QVERIFY( grandparent.isValid() );

    QStandardItem *gitem = new QStandardItem( "First child" );
    pitem->insertRow( 0, gitem );
    QCOMPARE( sm.rowCount( grandparent ), 1 );
    QCOMPARE( fm.rowCount(), 2 );
    QCOMPARE( sf.rowCount(), 2 );
    QCOMPARE( sm.index( 0, 0, grandparent ).data(), sf.index( 1, 0 ).data() );
    QCOMPARE( sf.index( 1, 0 ).data(), QVariant( "First child" ) );

    QModelIndex parent = sm.index( 0, 0, grandparent );
    QVERIFY( parent.isValid() );

    QStandardItem *item = new QStandardItem( "First grandchild" );
    gitem->insertRow( 0, item );
    QCOMPARE( sm.rowCount( parent ), 1 );
    QCOMPARE( fm.rowCount(), 3 );
    QCOMPARE( sf.rowCount(), 3 );
    QCOMPARE( sm.index( 0, 0, parent ).data(), sf.index( 2, 0 ).data() );
    QCOMPARE( sf.index( 2, 0 ).data(), QVariant( "First grandchild" ) );

    item = new QStandardItem( "Second grandchild" );
    gitem->insertRow( 1, item );
    QCOMPARE( sm.rowCount( parent ), 2 );
    QCOMPARE( fm.rowCount(), 4 );
    QCOMPARE( sf.rowCount(), 4 );
    QCOMPARE( sm.index( 0, 0, parent ).data(), sf.index( 2, 0 ).data() );
    QCOMPARE( sm.index( 1, 0, parent ).data(), sf.index( 3, 0 ).data() );
    QCOMPARE( sf.index( 2, 0 ).data(), QVariant( "First grandchild" ) );
    QCOMPARE( sf.index( 3, 0 ).data(), QVariant( "Second grandchild" ) );

    item = new QStandardItem( "In between" );
    gitem->insertRow( 1, item );
    QCOMPARE( sm.rowCount( parent ), 3 );
    QCOMPARE( fm.rowCount(), 5 );
    QCOMPARE( sf.rowCount(), 5 );
    QCOMPARE( sm.index( 0, 0, parent ).data(), sf.index( 2, 0 ).data() );
    QCOMPARE( sm.index( 1, 0, parent ).data(), sf.index( 3, 0 ).data() );
    QCOMPARE( sm.index( 2, 0, parent ).data(), sf.index( 4, 0 ).data() );
    QCOMPARE( sf.index( 2, 0 ).data(), QVariant( "First grandchild" ) );
    QCOMPARE( sf.index( 3, 0 ).data(), QVariant( "In between" ) );
    QCOMPARE( sf.index( 4, 0 ).data(), QVariant( "Second grandchild" ) );

    item = new QStandardItem( "Before first" );
    gitem->insertRow( 0, item );
    QCOMPARE( sm.rowCount( parent ), 4 );
    QCOMPARE( fm.rowCount(), 6 );
    QCOMPARE( sf.rowCount(), 6 );
    QCOMPARE( sm.index( 0, 0, parent ).data(), sf.index( 2, 0 ).data() );
    QCOMPARE( sm.index( 1, 0, parent ).data(), sf.index( 3, 0 ).data() );
    QCOMPARE( sm.index( 2, 0, parent ).data(), sf.index( 4, 0 ).data() );
    QCOMPARE( sm.index( 3, 0, parent ).data(), sf.index( 5, 0 ).data() );
    QCOMPARE( sf.index( 2, 0 ).data(), QVariant( "Before first" ) );
    QCOMPARE( sf.index( 3, 0 ).data(), QVariant( "First grandchild" ) );
    QCOMPARE( sf.index( 4, 0 ).data(), QVariant( "In between" ) );
    QCOMPARE( sf.index( 5, 0 ).data(), QVariant( "Second grandchild" ) );

    sm.removeRow( 0, parent );
    QCOMPARE( sm.rowCount( parent ), 3 );
    QCOMPARE( fm.rowCount(), 5 );
    QCOMPARE( sf.rowCount(), 5 );
    QCOMPARE( sm.index( 0, 0, parent ).data(), sf.index( 2, 0 ).data() );
    QCOMPARE( sm.index( 1, 0, parent ).data(), sf.index( 3, 0 ).data() );
    QCOMPARE( sm.index( 2, 0, parent ).data(), sf.index( 4, 0 ).data() );
    QCOMPARE( sf.index( 2, 0 ).data(), QVariant( "First grandchild" ) );
    QCOMPARE( sf.index( 3, 0 ).data(), QVariant( "In between" ) );
    QCOMPARE( sf.index( 4, 0 ).data(), QVariant( "Second grandchild" ) );

    sm.removeRow( 1, parent );
    QCOMPARE( sm.rowCount( parent ), 2 );
    QCOMPARE( fm.rowCount(), 4 );
    QCOMPARE( sf.rowCount(), 4 );
    QCOMPARE( sm.index( 0, 0, parent ).data(), sf.index( 2, 0 ).data() );
    QCOMPARE( sm.index( 1, 0, parent ).data(), sf.index( 3, 0 ).data() );
    QCOMPARE( sf.index( 2, 0 ).data(), QVariant( "First grandchild" ) );
    QCOMPARE( sf.index( 3, 0 ).data(), QVariant( "Second grandchild" ) );

    sm.removeRow( 1, parent );
    QCOMPARE( sm.rowCount( parent ), 1 );
    QCOMPARE( fm.rowCount(), 3 );
    QCOMPARE( sf.rowCount(), 3 );
    QCOMPARE( sm.index( 0, 0, parent ).data(), sf.index( 2, 0 ).data() );
    QCOMPARE( sf.index( 2, 0 ).data(), QVariant( "First grandchild" ) );

    sm.removeRow( 0, parent );
    QCOMPARE( sm.rowCount( parent ), 0 );
    QCOMPARE( fm.rowCount(), 2 );
    QCOMPARE( sf.rowCount(), 2 );
    QCOMPARE( sm.index( 0, 0, grandparent ).data(), sf.index( 1, 0 ).data() );
    QCOMPARE( sf.index( 1, 0 ).data(), QVariant( "First child" ) );

    QCOMPARE( sm.rowCount( grandparent ), 1 );
    sm.removeRow( 0, grandparent );
    QCOMPARE( sm.rowCount( grandparent ), 0 );
    QCOMPARE( fm.rowCount(), 1 );
    QCOMPARE( sf.rowCount(), 1 );
    QCOMPARE( sm.index( 0, 0 ).data(), sf.index( 0, 0 ).data() );
    QCOMPARE( sf.index( 0, 0 ).data(), QVariant( "Parent" ) );

    QCOMPARE( sm.rowCount(), 1 );
    sm.removeRow( 0 );
    QCOMPARE( sm.rowCount(), 0 );
    QCOMPARE( fm.rowCount(), 0 );
    QCOMPARE( sf.rowCount(), 0 );
}