예제 #1
0
파일: regionmap.cpp 프로젝트: ace13/openmw
QModelIndexList CSVWorld::RegionMap::getMissingRegionCells() const
{
    const QAbstractItemModel *model = QTableView::model();

    QModelIndexList selected = selectionModel()->selectedIndexes();

    std::set<std::string> regions;

    for (QModelIndexList::const_iterator iter (selected.begin()); iter!=selected.end(); ++iter)
    {
        std::string region =
            model->data (*iter, CSMWorld::RegionMap::Role_Region).toString().toUtf8().constData();

        if (!region.empty())
            regions.insert (region);
    }

    QModelIndexList list;

    QModelIndexList unselected = getUnselectedCells();

    for (QModelIndexList::const_iterator iter (unselected.begin()); iter!=unselected.end(); ++iter)
    {
        std::string region =
            model->data (*iter, CSMWorld::RegionMap::Role_Region).toString().toUtf8().constData();

        if (!region.empty() && regions.find (region)!=regions.end())
            list.push_back (*iter);
    }

    return list;
}
예제 #2
0
파일: regionmap.cpp 프로젝트: ace13/openmw
QModelIndexList CSVWorld::RegionMap::getUnselectedCells() const
{
    const QAbstractItemModel *model = QTableView::model();

    int rows = model->rowCount();
    int columns = model->columnCount();

    QModelIndexList selected = selectionModel()->selectedIndexes();
    std::sort (selected.begin(), selected.end());

    QModelIndexList all;

    for (int y=0; y<rows; ++y)
        for (int x=0; x<columns; ++x)
        {
            QModelIndex index = model->index (y, x);
            if (model->data (index, Qt::BackgroundRole)!=QBrush (Qt::DiagCrossPattern))
                all.push_back (index);
        }

    std::sort (all.begin(), all.end());

    QModelIndexList list;

    std::set_difference (all.begin(), all.end(), selected.begin(), selected.end(),
                         std::back_inserter (list));

    return list;
}
예제 #3
0
QModelIndexList Model::itemsToIndices(const QSet<QStandardItem*> items) const noexcept
{
	QModelIndexList list;
	for (auto&& item : items)
	{
		list.push_back(indexFromItem(item));
	}
	return list;
}
QModelIndexList selectedIndexes(QTableWidget *table)
{
	QModelIndexList list;
	for (int row = 0; row < table->model()->rowCount(table->rootIndex()); ++row)
	{
		QModelIndex index = table->model()->index(row, 1, table->rootIndex());
		if (table->selectionModel()->isSelected(index))
			list.push_back(index);
	}
	return list;
}
void UserphraseSortFilterProxyModel::remove(QModelIndexList indexList)
{
    if (indexList.empty()) {
        qDebug() << "indexList is empty";
        return;
    }

    QModelIndexList sourceIndexList;

    for (auto i = indexList.constBegin(); i != indexList.constEnd(); ++i) {
        sourceIndexList.push_back(mapToSource(*i));
    }

    sourceModel()->remove(std::move(sourceIndexList));
}
예제 #6
0
파일: regionmap.cpp 프로젝트: ace13/openmw
QModelIndexList CSVWorld::RegionMap::getSelectedCells (bool existent, bool nonExistent) const
{
    const QAbstractItemModel *model = QTableView::model();

    QModelIndexList selected = selectionModel()->selectedIndexes();

    QModelIndexList list;

    for (QModelIndexList::const_iterator iter (selected.begin()); iter!=selected.end(); ++iter)
    {
        bool exists = model->data (*iter, Qt::BackgroundRole)!=QBrush (Qt::DiagCrossPattern);

        if ((exists && existent) || (!exists && nonExistent))
            list.push_back (*iter);
    }

    return list;
}
예제 #7
0
		QModelIndexList searchLeafs(const QModelIndex& curentIndex) const
		{
			QModelIndexList res;
			if(curentIndex.isValid())
			{
				int childCount=curentIndex.model()->columnCount(curentIndex);
				if(childCount)
				{
					for(int i=0; i<childCount; ++i)
						res+=searchLeafs(curentIndex.child(0, i));
				}
				else
				{
					res.push_back(curentIndex);
				}
			}
			return res;
		}
예제 #8
0
void PublicHubs::slotContextMenu(){
    QItemSelectionModel *sel_model = treeView->selectionModel();
    QModelIndexList indexes = sel_model->selectedRows(0);

    if (indexes.isEmpty())
        return;

    if (proxy){
        QModelIndexList list;
        foreach (QModelIndex i, indexes)
            list.push_back(proxy->mapToSource(i));
        indexes = list;
    }

    WulforUtil *WU = WulforUtil::getInstance();

    QMenu *m = new QMenu();
    QAction *connect = new QAction(WU->getPixmap(WulforUtil::eiCONNECT), tr("Connect"), m);
    QAction *add_fav = new QAction(WU->getPixmap(WulforUtil::eiBOOKMARK_ADD), tr("Add to favorites"), m);
    QAction *copy    = new QAction(WU->getPixmap(WulforUtil::eiEDITCOPY), tr("Copy &address to clipboard"), m);

    m->addActions(QList<QAction*>() << connect << add_fav << copy);

    QAction *ret = m->exec(QCursor::pos());

    m->deleteLater();

    if (ret == connect){
        PublicHubItem * item = NULL;
        MainWindow *MW = MainWindow::getInstance();

        foreach (QModelIndex i, indexes){
            item = reinterpret_cast<PublicHubItem*>(i.internalPointer());

            if (item)
                MW->newHubFrame(item->data(COLUMN_PHUB_ADDRESS).toString(), "");

            item = NULL;
        }
예제 #9
0
QMimeData* ModItemsTree::mimeData(const QModelIndexList &indexes) const
{
    QMimeData *mimeData = new QMimeData();
    QString csv;

    // select only first column indexes (since selection is made by row)
    QModelIndexList rowIndexes;
    QList<ModItem*> items;
    for(int i=0;i<indexes.size();i++)
    {
        if(indexes.at(i).column()==0)
        {
            rowIndexes.push_back(indexes.at(i));
            items.push_back((ModItem*)indexes.at(i).internalPointer());
        }
    }

    // Remove children of contained parents -> avoid twice copying
    QList<ModItem*> uniqueItems;
    for(int i=0;i<items.size();i++)
    {
        //    if(!items.contains(items.at(i)->parent()) || (items.at(i)->parent()==_rootElement))
        uniqueItems.push_back(items.at(i));
    }

    // create text data
    for(int i=0;i<uniqueItems.size();i++)
    {
        ModItem* item = uniqueItems.at(i);
        csv.push_back(item->name(ModItem::FULL)+"\n");
    }
    if(csv.size()>0)
        csv.remove(csv.size()-QString("\n").size(),QString("\n").size());
    mimeData->setText(csv);
    mimeData->setData("application/ModItemName",csv.toAscii());
    return mimeData;
}