コード例 #1
0
ファイル: mystringtable.cpp プロジェクト: watrox/SegDSee
void MyStringTable::keyPressEvent(QKeyEvent*    event)
{
    QTableView::keyPressEvent(event);

    QItemSelectionModel *sel = selectionModel();

    if(!sel->hasSelection()) return;

//    QModelIndexList list = sel->selectedRows();
//    if(list.count()<1) return ;

//    int row = list.at(0).row();

    int key = event->key();

    if(key==Qt::Key_Enter || key==Qt::Key_Return)
    {
        int r = currentIndex().row();
        int c = currentIndex().column();

        if(ColEdit(c))
        {

            if(this->state()!=QAbstractItemView::EditingState)
            {
                edit(currentIndex());
            }
        }
        else
        {
            emit rowEvent(r, 2);
        }
    }
    else if(key==Qt::Key_Home)
    {
        QApplication::beep();
        QModelIndex index = _model->index(0,0, QModelIndex());

        sel->clearSelection();
        setCurrentIndex(index);
    }
    else if(key==Qt::Key_End)
    {
        QModelIndex index = _model->index(RowCount()-1,0, QModelIndex());

        sel->clearSelection();
        setCurrentIndex(index);
    }
}
コード例 #2
0
ファイル: NotesModel.cpp プロジェクト: miracle2k/mp3diags
void NotesModel::matchSelToMain()
{
    QModelIndexList lSelFiles (m_pCommonData->m_pFilesG->selectionModel()->selection().indexes());

    set<int> sSel;
    for (QModelIndexList::iterator it = lSelFiles.begin(), end = lSelFiles.end(); it != end; ++it)
    {
        int nCol (it->column());
        if (nCol > 0) // skip file name
        {
            sSel.insert(nCol - 1);
        }
    }

    QItemSelectionModel* pNotesSelModel (m_pCommonData->m_pNotesG->selectionModel());
    pNotesSelModel->clearSelection();
    bool bFirstFound (false);
    for (int i = 0, nNoteCnt = cSize(m_pCommonData->getCrtNotes()); i < nNoteCnt; ++i)
    {
        const Note* pNote (m_pCommonData->getCrtNotes()[i]);
        int nPos (m_pCommonData->findPos(pNote));
        if (sSel.count(nPos) > 0)
        {
            if (!bFirstFound)
            {
                bFirstFound = true;
                m_pCommonData->m_pNotesG->setCurrentIndex(index(i, 0));
            }
            pNotesSelModel->select(index(i, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
        }
    }
}
コード例 #3
0
ファイル: NotesModel.cpp プロジェクト: miracle2k/mp3diags
void NotesModel::matchSelToStreams()
{
    QModelIndexList lSelStreams (m_pCommonData->m_pStreamsG->selectionModel()->selection().indexes());

    const vector<DataStream*>& vCrtStreams (m_pCommonData->getViewHandlers()[m_pCommonData->getFilesGCrtRow()]->getStreams());
    vector<const DataStream*> vSelStreams;
    for (QModelIndexList::iterator it = lSelStreams.begin(), end = lSelStreams.end(); it != end; ++it)
    {
        int nRow (it->row());
        vSelStreams.push_back(vCrtStreams[nRow]);
    }

    QItemSelectionModel* pNotesSelModel (m_pCommonData->m_pNotesG->selectionModel());
    pNotesSelModel->clearSelection();
    bool bFirstFound (false);

    for (int i = 0, nNoteCnt = cSize(m_pCommonData->getCrtNotes()); i < nNoteCnt; ++i)
    {
        const Note* pNote (m_pCommonData->getCrtNotes()[i]);
        if (isInList(pNote, vSelStreams))
        {
            if (!bFirstFound)
            {
                bFirstFound = true;
                m_pCommonData->m_pNotesG->setCurrentIndex(index(i, 0));
            }
            pNotesSelModel->select(index(i, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
        }
    }
}
コード例 #4
0
ファイル: VtkVisPipelineView.cpp プロジェクト: envinf/ogs
void VtkVisPipelineView::selectItem(const QModelIndex &index)
{
	if (!index.isValid())
		return;

	QItemSelectionModel* selectionModel = this->selectionModel();
	selectionModel->clearSelection();
	selectionModel->select(index, QItemSelectionModel::Select);
}
コード例 #5
0
void AddMultipleDownloadsResultsPage::selectAll()
{
    QItemSelectionModel *selectionModel = m_view->selectionModel();
    if (selectionModel->selectedRows().length() >= m_model->rowCount()) {
        selectionModel->clearSelection();
    } else {
        m_view->selectAll();
    }
}
コード例 #6
0
void MList::setSelectionMode(MList::SelectionMode mode)
{
    Q_D(MList);
    d->selectionMode = mode;

    QItemSelectionModel *sModel = selectionModel();

    if (sModel)
        sModel->clearSelection();
}
コード例 #7
0
void VtkVisPipelineView::selectItem( vtkProp3D* actor )
{
	QModelIndex index = ((VtkVisPipeline*)(this->model()))->getIndex(actor);
	if (!index.isValid())
		return;

	blockSignals(true);
	QItemSelectionModel* selectionModel = this->selectionModel();
	selectionModel->clearSelection();
	selectionModel->select(index, QItemSelectionModel::Select);
	blockSignals(false);
}
コード例 #8
0
void TreeComboBox::showPopup()
{
    QComboBox::showPopup();
    // now clean up things we want different
    QItemSelectionModel *sm = view()->selectionModel();
    sm->clearSelection();
    view()->setSelectionMode( m_selectionmode );
    view()->setSelectionBehavior( QAbstractItemView::SelectRows );
    foreach ( const QModelIndex &i, m_currentIndexes ) {
        if ( i.isValid() ) {
            sm->select( i, QItemSelectionModel::Select | QItemSelectionModel::Rows );
        }
    }
    if ( ! sm->selectedRows().contains( sm->currentIndex() ) ) {
        sm->setCurrentIndex( sm->selectedRows().value( 0 ), QItemSelectionModel::NoUpdate );
    }
}
コード例 #9
0
void RequieredResourceDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    TreeComboBox *box = static_cast<TreeComboBox*>(editor);
    ResourceItemSFModel *pm = static_cast<ResourceItemSFModel*>( box->model() );
    ResourceItemModel *rm = qobject_cast<ResourceItemModel*>( pm->sourceModel() );
    Q_ASSERT( rm );
    const ResourceAllocationItemModel *model = qobject_cast<const ResourceAllocationItemModel*>( index.model() );
    Q_ASSERT( model );
    rm->setProject( model->project() );
    pm->addFilteredResource( model->resource( index ) );
    QItemSelectionModel *sm = box->view()->selectionModel();
    sm->clearSelection();
    foreach ( const Resource *r, model->required( index ) ) {
        QModelIndex i = pm->mapFromSource( rm->index( r ) );
        sm->select( i, QItemSelectionModel::Select | QItemSelectionModel::Rows );
    }
    box->setCurrentIndexes( sm->selectedRows() );
    box->view()->expandAll();
}
コード例 #10
0
ファイル: RootPanel.cpp プロジェクト: selma-grimm/Farever
void RootPanel::showA(STATE s)
{
    if (s == LEFT)
        move(0, m_posY);
    else
        move(m_rightPosX, m_posY);

    state(s);
    show();
    raise();   

    QItemSelectionModel* pSelModel = m_pTable->selectionModel();
    QModelIndex firstIndex = m_model.index(0,0);
    pSelModel->clearSelection();
    pSelModel->select(firstIndex, QItemSelectionModel::Select);
    m_pTable->setCurrentIndex(firstIndex);
    m_pTable->setFocus(Qt::MouseFocusReason);

}
コード例 #11
0
ファイル: MantidMatrix.cpp プロジェクト: mducle/mantid
/** Called when switching between tabs
*  @param index :: The index of the new active tab
*/
void MantidMatrix::viewChanged(int index) {
  // get the previous view and selection model
  QTableView *prevView = (QTableView *)m_tabs->widget(m_PrevIndex);
  if (prevView) {
    QItemSelectionModel *oldSelModel = prevView->selectionModel();
    QItemSelectionModel *selModel = activeView()->selectionModel();
    // Copy the selection from the previous tab into the newly-activated one
    selModel->select(oldSelModel->selection(), QItemSelectionModel::Select);
    // Clear the selection on the now-hidden tab
    oldSelModel->clearSelection();

    m_PrevIndex = index;
    // get the previous tab scrollbar positions
    int hValue = prevView->horizontalScrollBar()->value();
    int vValue = prevView->verticalScrollBar()->value();
    // to synchronize the views
    // set  the previous view  scrollbar positions to current view
    activeView()->horizontalScrollBar()->setValue(hValue);
    activeView()->verticalScrollBar()->setValue(vValue);
  }
}
コード例 #12
0
ファイル: historyform.cpp プロジェクト: huggle/huggle3-qt-lx
void HistoryForm::onTick01()
{
    if (this->CurrentEdit == nullptr)
        throw new Huggle::NullPointerException("local WikiEdit CurrentEdit", BOOST_CURRENT_FUNCTION);

    if (this->RetrievingEdit && this->RetrievedEdit != nullptr)
    {
        if (this->RetrievedEdit->IsPostProcessed())
        {
            MainWindow::HuggleMain->ProcessEdit(this->RetrievedEdit, false, true);
            this->RetrievingEdit = false;
            this->RetrievedEdit = nullptr;
            this->t1->stop();
            this->MakeSelectedRowBold();
            MainWindow::HuggleMain->wEditBar->RefreshPage();
        }
        return;
    }

    if (this->query == nullptr || !this->query->IsProcessed())
        return;

    if (this->query->IsFailed())
    {
        this->ui->pushButton->setEnabled(true);
        Huggle::Syslog::HuggleLogs->ErrorLog(_l("history-failure"));
        this->query = nullptr;
        this->t1->stop();
        return;
    }
    bool IsLatest = false;
    QList<ApiQueryResultNode*> revision_data = this->query->GetApiQueryResult()->GetNodes("rev");
    int x = 0;
    while (x < revision_data.count())
    {
        ApiQueryResultNode *rv = revision_data.at(x);
        WikiPageHistoryItem *item = new WikiPageHistoryItem(this->query->GetSite());
        if (rv->Attributes.contains("revid"))
        {
            item->RevID = rv->GetAttribute("revid");
        }
        else
        {
            x++;
            continue;
        }
        bool founder = false;
        item->Name = this->CurrentEdit->Page->PageName;
        item->Site = this->CurrentEdit->GetSite();
        if (rv->Attributes.contains("user"))
            item->User = rv->GetAttribute("user");
        if (rv->Attributes.contains("size"))
            item->Size = rv->GetAttribute("size");
        if (rv->Attributes.contains("timestamp"))
            item->Date = rv->GetAttribute("timestamp");
        if (rv->Attributes.contains("comment") && !rv->GetAttribute("comment").isEmpty())
            item->Summary = rv->GetAttribute("comment");
        this->ui->tableWidget->insertRow(x);
        QIcon icon(":/huggle/pictures/Resources/blob-none.png");
        if (this->CurrentEdit->Page->FounderKnown() && WikiUser::CompareUsernames(item->User, this->CurrentEdit->Page->GetFounder()))
            founder = true;
        if (WikiUtil::IsRevert(item->Summary))
        {
            item->Type = EditType_Revert;
            icon = QIcon(":/huggle/pictures/Resources/blob-revert.png");
        }
        else if (WikiUser::IsIPv6(item->User) || WikiUser::IsIPv4(item->User))
        {
            item->Type = EditType_Anon;
            icon = QIcon(":/huggle/pictures/Resources/blob-anon.png");
        }
        else if (this->CurrentEdit->GetSite()->GetProjectConfig()->WhiteList.contains(item->User))
        {
            item->Type = EditType_W;
            icon = QIcon(":/huggle/pictures/Resources/blob-ignored.png");
        }
        WikiUser *wu = WikiUser::RetrieveUser(item->User, item->Site);
        if (wu != nullptr)
        {
            if (wu->IsReported)
            {
                item->Type = EditType_Reported;
                icon = QIcon(":/huggle/pictures/Resources/blob-reported.png");
            }
            else if (wu->GetWarningLevel() > 0)
            {
                switch (wu->GetWarningLevel())
                {
                case 1:
                    item->Type = EditType_1;
                    icon = QIcon(":/huggle/pictures/Resources/blob-warn-1.png");
                    break;
                case 2:
                    item->Type = EditType_2;
                    icon = QIcon(":/huggle/pictures/Resources/blob-warn-2.png");
                    break;
                case 3:
                    item->Type = EditType_3;
                    icon = QIcon(":/huggle/pictures/Resources/blob-warn-3.png");
                    break;
                case 4:
                    item->Type = EditType_4;
                    icon = QIcon(":/huggle/pictures/Resources/blob-warn-4.png");
                    break;
                }
            }
        }
        bool selected = this->CurrentEdit->RevID == item->RevID.toInt();
        if (selected && x == 0)
            IsLatest = true;
        item->IsCurrent = true;
        if (selected)
            this->SelectedRow = x;
        QFont font;
        font.setItalic(founder);
        font.setBold(selected);
        QTableWidgetItem *i = new QTableWidgetItem(icon, "");
        this->ui->tableWidget->setItem(x, 0, i);
        i = new QTableWidgetItem(item->User);
        i->setFont(font);
        this->ui->tableWidget->setItem(x, 1, i);
        i = new QTableWidgetItem(item->Size);
        i->setFont(font);
        this->ui->tableWidget->setItem(x, 2, i);
        i = new QTableWidgetItem(item->Summary);
        i->setFont(font);
        this->ui->tableWidget->setItem(x, 3, i);
        i = new QTableWidgetItem(item->Date);
        i->setFont(font);
        this->ui->tableWidget->setItem(x, 4, i);
        i = new QTableWidgetItem(item->RevID);
        i->setFont(font);
        this->ui->tableWidget->setItem(x, 5, i);
        this->Items.append(item);
        x++;
    }
    this->ui->tableWidget->resizeRowsToContents();
    this->query = nullptr;
    this->t1->stop();
    if (!this->CurrentEdit->NewPage && !Configuration::HuggleConfiguration->ForceNoEditJump && !IsLatest)
    {
        if (Configuration::HuggleConfiguration->UserConfig->LastEdit)
        {
            this->Display(0, Resources::Html_StopFire, true);
            return;
        }
        else
        {
            QPoint pntr(0, this->pos().y());
            if (this->pos().x() > 400)
                pntr.setX(this->pos().x() - 200);
            else
                pntr.setX(this->pos().x() + 100);

            if (hcfg->UserConfig->ShowWarningIfNotOnLastRevision)
                QToolTip::showText(pntr, "<b><big>" + _l("historyform-not-latest-tip") + "</big></b>", this);
        }
    }
    if (hcfg->UserConfig->AutomaticallyGroup)
    {
        // Check if edits made around of this one weren't made by same user
        // in case they were we need to display a range of them
        QString user = this->CurrentEdit->User->Username;
        int RangeStart = this->SelectedRow;
        int RangeEnd = this->SelectedRow;
        int row = this->SelectedRow;
        while (row > 0)
        {
            if (user != this->ui->tableWidget->item(row - 1, 1)->text())
                break;
            row--;
        }
        RangeStart = row;
        row = this->SelectedRow;
        while (row < (this->ui->tableWidget->rowCount() - 1))
        {
            if (user != this->ui->tableWidget->item(row + 1, 1)->text())
                break;
            row++;
        }
        RangeEnd = row;
        if (RangeStart != RangeEnd)
        {
            QItemSelectionModel *selectionModel = this->ui->tableWidget->selectionModel();
            row = RangeStart;
            this->IgnoreSelectionChanges = true;
            this->ui->tableWidget->clearSelection();
            QItemSelection itemSelection = selectionModel->selection();
            while (row <= RangeEnd)
            {
                this->ui->tableWidget->selectRow(row++);
                itemSelection.merge(selectionModel->selection(), QItemSelectionModel::Select);
            }
            selectionModel->clearSelection();
            this->IgnoreSelectionChanges = false;
            selectionModel->select(itemSelection, QItemSelectionModel::Select);
        }
    }
    this->IgnoreSelectionChanges = false;
    MainWindow::HuggleMain->wEditBar->RefreshPage();
}
コード例 #13
0
ファイル: localview.cpp プロジェクト: caidongyun/nullfxp
void LocalView::slot_rmdir()
{
    QString dir_name;
    
    QItemSelectionModel *ism = this->curr_item_view->selectionModel();
    // QModelIndexList mil;
    QModelIndex cidx, idx;

    if (ism == 0 || !ism->hasSelection()) {
        qDebug()<<"SelectedIndexes count :"<< ism->hasSelection() << " why no item selected????";
        QMessageBox::critical(this, tr("Warning..."), tr("No item selected"));
        return;
    }    
    
    // mil = ism->selectedIndexes();
    cidx = ism->currentIndex();
    idx = ism->model()->index(cidx.row(), 0, cidx.parent());
    
    QModelIndex midx = idx;
    QModelIndex aim_midx = (this->curr_item_view == this->uiw->treeView) 
        ? this->dir_file_model->mapToSource(midx): midx;

    //检查所选择的项是不是目录
    if (!this->model->isDir(aim_midx)) {
        QMessageBox::critical(this, tr("Warning..."), tr("The selected item is not a directory."));
        return ;
    }
    // qDebug()<<QDir(this->model->filePath(aim_midx)).count();
    if (QDir(this->model->filePath(aim_midx)).count() > 2) {
        QMessageBox::critical(this, tr("Warning..."), tr("Selected director not empty."));
        return;
    }

    QModelIndex tree_midx = this->dir_file_model->mapFromSource(aim_midx);
    QModelIndex pidx = aim_midx.parent();
    int it_row = tree_midx.row();
    QModelIndex nidx = tree_midx.parent();
    QString next_select_path;
    
    if (this->dir_file_model->rowCount(nidx) == 1) {
        // goto parent 
        next_select_path = this->dir_file_model->filePath(nidx);
    } else if (it_row == this->dir_file_model->rowCount(nidx)-1) {
        // goto privious
        next_select_path = this->dir_file_model->filePath(this->dir_file_model->index(it_row-1, 0, nidx));
    } else if (it_row > this->dir_file_model->rowCount(nidx)-1) {
        // not possible
    } else if (it_row < this->dir_file_model->rowCount(nidx)-1) {
        // goto next
        next_select_path = this->dir_file_model->filePath(this->dir_file_model->index(it_row+1, 0, nidx));
    } else {
        // not possible
    }

    Q_ASSERT(!next_select_path.isEmpty());
    
    if (this->model->rmdir(aim_midx)) {
        if (this->curr_item_view == this->uiw->treeView) {
            // this->slot_dir_tree_item_clicked(tree_midx.parent());
            // A: if has next sible, will select next sible
            // B: if has priv sible, will select privious sible
            // C: if no next and no priv, will select parent 

            // ism = this->curr_item_view->selectionModel();
            idx = ism->currentIndex();
            qDebug()<<idx<<this->dir_file_model->filePath(idx);

            // set selection and go on
            ism->clearSelection();
            QItemSelection *selection = new QItemSelection();
                                                           
            // ism->select(this->dir_file_model->index(next_select_path), QItemSelectionModel::Select | QItemSelectionModel::Current  | QItemSelectionModel::Rows);
            ism->setCurrentIndex(this->dir_file_model->index(next_select_path), QItemSelectionModel::Select | QItemSelectionModel::Current  | QItemSelectionModel::Rows);

            idx = ism->currentIndex();
            qDebug()<<idx<<this->dir_file_model->filePath(idx);

            this->slot_dir_tree_item_clicked(this->dir_file_model->index(next_select_path));
        }
    } else {
        QMessageBox::critical(this, tr("Warning..."),
                              tr("Delete directory faild. Maybe the directory is not empty."));
    }

    // if (!QDir().rmdir(this->model->filePath(aim_midx))) {
    //     QMessageBox::critical(this, tr("Warning..."), tr("Delete directory faild. Mayby the directory is not empty."));
    // } else {
    //     this->slot_refresh_directory_tree();
    // }
}
コード例 #14
0
ファイル: MainWindow.cpp プロジェクト: franckikalogic/fatrat
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);
}