예제 #1
0
// Check if any managed widgets are selected. If so, iterate over
// selection and deselect all unmanaged objects
bool ObjectInspector::ObjectInspectorPrivate::checkManagedWidgetSelection(const QModelIndexList &rowSelection)
{
    bool isManagedWidgetSelection = false;
    QItemSelectionModel *selectionModel = m_treeView->selectionModel();
    const QModelIndexList::const_iterator cscend = rowSelection.constEnd();
    for (QModelIndexList::const_iterator it = rowSelection.constBegin(); it != cscend; ++it) {
        QObject *object = m_model->objectAt(*it);
        if (selectionType(m_formWindow, object) == ManagedWidgetSelection) {
            isManagedWidgetSelection = true;
            break;
        }
    }

    if (!isManagedWidgetSelection)
        return false;
    // Need to unselect unmanaged ones
    const bool blocked = selectionModel->blockSignals(true);
    for (QModelIndexList::const_iterator it = rowSelection.constBegin(); it != cscend; ++it) {
        QObject *object = m_model->objectAt(*it);
        if (selectionType(m_formWindow, object) != ManagedWidgetSelection)
            selectionModel->select(*it, QItemSelectionModel::Deselect|QItemSelectionModel::Rows);
    }
    selectionModel->blockSignals(blocked);
    return true;
}
예제 #2
0
파일: GeoTreeView.cpp 프로젝트: wenqing/ogs
void GeoTreeView::selectionChangedFromOutside( const QItemSelection &selected,
                                               const QItemSelection &deselected )
{
    QItemSelectionModel* selModel = this->selectionModel();

    selModel->blockSignals(true);
    selModel->select(deselected, QItemSelectionModel::Deselect);
    selModel->select(selected, QItemSelectionModel::Select);
    selModel->blockSignals(false);

    QTreeView::selectionChanged(selected, deselected);
}
예제 #3
0
void MainWindow::move(int i)
{
	Queue* q = getCurrentQueue(false);
	QList<int> sel = getSelection();
	QModelIndex eVisible;
	
	if(!q) return;
	
	if(!sel.empty())
	{
		QItemSelectionModel* model = treeTransfers->selectionModel();
		
		int size = sel.size();
		model->blockSignals(true);
		model->clearSelection();
		
		switch(i)
		{
			case 0:
			{
				for(int j=0;j<size;j++)
				{
					q->moveToTop(sel[size-j-1]+j);
					model->select(m_modelTransfers->index(j), QItemSelectionModel::Select | QItemSelectionModel::Rows);
				}
				
				eVisible = m_modelTransfers->index(size-1);
				break;
			}
			case 1:
				for(int i=0;i<size;i++)
				{
					int newpos;
					
					newpos = q->moveUp(sel[i]);
					model->select(m_modelTransfers->index(newpos), QItemSelectionModel::Select | QItemSelectionModel::Rows);
					
					if(i == 0)
						eVisible = m_modelTransfers->index(newpos);
				}
				break;
			case 2:
				for(int i=size-1;i>=0;i--)
				{
					int newpos;
					
					newpos = q->moveDown(sel[i]);
					model->select(m_modelTransfers->index(newpos), QItemSelectionModel::Select | QItemSelectionModel::Rows);
					
					if(i == size-1)
						eVisible = m_modelTransfers->index(newpos);
				}
				break;
			case 3:
			{
				int qsize = q->size();
				QItemSelectionModel* model = treeTransfers->selectionModel();
				
				for(int i=0;i<size;i++)
				{
					q->moveToBottom(sel[i]-i);
					model->select(m_modelTransfers->index(qsize-i-1), QItemSelectionModel::Select | QItemSelectionModel::Rows);
					
					if(i == 0)
						eVisible = m_modelTransfers->index(qsize-i-1);
				}
				break;
			}
		}
		
		model->blockSignals(false);
	}
	
	doneQueue(q,false);
	Queue::saveQueuesAsync();
	
	treeTransfers->scrollTo(eVisible);
}