コード例 #1
0
// =============================================================================
void TimeTrackingWindow::paste() {

    QString str = QApplication::clipboard()->text();
    QStringList rowList = str.split('\n');
    QItemSelectionModel * itemSelectionModel = mTableView->selectionModel();

    int colInit = itemSelectionModel->currentIndex().column();
    int rowInit = itemSelectionModel->currentIndex().row();
    int maxColList = 0;
    for(int row = 1; row < rowList.size(); row++) {
        DEBUG(QString("paste: rowString %1 - row: %2").arg(rowList.at(row)).arg(row));

        QStringList preColList = rowList.at(row).split('|');
        maxColList = std::max(preColList.size() - 1, maxColList);
        for(int col = 1; col < preColList.size(); col++) {
            QString string = preColList.at(col);
            string = string.remove(QRegExp("\\s+$"));

            int curCol = colInit + col - 1;
            int curRow = rowInit + row - 1;
            QVariant variant;
            if(curCol != Col::COMMENT)  variant = MiscDateTime::stringToTime(string);
            else                        variant = string;
            DEBUG(QString("paste: variant %1, string %4 - curCol: %2, curRow: %3").arg(variant.toString()).arg(curCol).arg(curRow).arg(string));

            mTableView->model()->setData(mTableView->model()->index(curRow, curCol), variant);
        }
    }
    emit mTableView->model()->dataChanged(mTableView->model()->index(rowInit, colInit),
                     mTableView->model()->index(rowInit + rowList.size(), colInit + maxColList));
}
コード例 #2
0
ファイル: yumplugin.cpp プロジェクト: josuevhn/YUMRepoManager
void YUMPlugin::on_pushButtonEdit_clicked()
{

    QItemSelectionModel *selection = ui->listView->selectionModel();

    if(selection->hasSelection()) {

        //qDebug() << "Traying to open: " << DataFlow::getPluginDataList().at(selection->currentIndex().row()).pluginFileName;

        QFile myFile(DataFlow::getPluginDataList().at(selection->currentIndex().row()).pluginFileName);

        if(!myFile.open(QIODevice::ReadOnly | QIODevice::Text)) {

            YUMRepoManager::showMessage("Error", tr("Access denied when trying to open the config file"));

            return;

        }// if

        myFile.close();

        textEditor = new TextEditor(DataFlow::getPluginDataList().at(selection->currentIndex().row()).pluginFileName, "plugin", this);
        textEditor->setModal(true);
        textEditor->exec();

    }// if
    else {

        YUMRepoManager::showMessage("Information", tr("You have to select a plugin first."));

    }// else

}// Edit Clicked
コード例 #3
0
ファイル: qg_librarywidget.cpp プロジェクト: tytower/LibreCAD
/**
 * @return Path of the DXF file that is represented by the given item.
 */
QString QG_LibraryWidget::getItemPath(QStandardItem* item) {
    QItemSelectionModel* selDirView = dirView->selectionModel();
    QModelIndex idx = selDirView->currentIndex();
    QStandardItem * dirItem = dirModel->itemFromIndex ( idx );
    QString dir = getItemDir(dirItem);

    if (item) {
        // List of all directories that contain part libraries:
        QStringList directoryList = RS_SYSTEM->getDirectoryList("library");
        QStringList::Iterator it;
        QDir itemDir;

        // look in all possible system directories for DXF files in the current library path:
        for (it=directoryList.begin(); it!=directoryList.end(); ++it) {
            itemDir.setPath((*it)+dir);
            if (itemDir.exists()) {
                QString f = (*it) + dir + QDir::separator() + item->text() + ".dxf";
                if (QFileInfo(f).isReadable()) {
                    return f;
                }
            }
        }

        return "";
    } else {
        return "";
    }
}
コード例 #4
0
ファイル: qg_librarywidget.cpp プロジェクト: tytower/LibreCAD
/**
 * Insert.
 */
void QG_LibraryWidget::insert() {
    QItemSelectionModel* selIconView = ivPreview->selectionModel();
    QModelIndex idx = selIconView->currentIndex();
    QStandardItem * item = iconModel->itemFromIndex ( idx );
    if (item == 0)
        return;

    QString dxfPath = getItemPath(item);

    if (QFileInfo(dxfPath).isReadable()) {
        if (actionHandler) {
            RS_ActionInterface* a =
                actionHandler->setCurrentAction(RS2::ActionLibraryInsert);
            if (a) {
                RS_ActionLibraryInsert* action = (RS_ActionLibraryInsert*)a;
                action->setFile(dxfPath);
            } else {
                RS_DEBUG->print(RS_Debug::D_ERROR,
                                "QG_LibraryWidget::insert:"
                                "Cannot create action RS_ActionLibraryInsert");
            }
        }
    } else {
        RS_DEBUG->print(RS_Debug::D_ERROR,
                        "QG_LibraryWidget::insert: Can't read file: '%s'", dxfPath.toLatin1().data());
    }
}
コード例 #5
0
ファイル: winusers.cpp プロジェクト: dkmpos89/appSignals
void winUsers::on_toolButton_clicked()
{
    QItemSelectionModel *select = ui->tableView_2->selectionModel();
    QModelIndex index = select->currentIndex();

    if(select->hasSelection()){
        int row = index.row();
        QString rut = index.sibling(row, 0).data().toString();
        QString nombre = index.sibling(row, 1).data().toString();
        QString apellido = index.sibling(row, 2).data().toString();
        QString direccion = index.sibling(row, 3).data().toString();
        QString sexo = index.sibling(row, 4).data().toString();

        QVector<QString> s(5);
        s.insert(0,rut);
        s.insert(1,nombre);
        s.insert(2,apellido);
        s.insert(3,direccion);
        s.insert(4,sexo);

        emit nuevaSesion(s);
        close();

    }
    else{
        QMessageBox::critical(this, "warning!",
                              "Primero debes seleccionar un usuario de la tabla.",
                              QMessageBox::Ok);
    }
}
コード例 #6
0
void ObjcetControl::removeObject()
{
	QItemSelectionModel* selectionModel =mTreeView->selectionModel();
	QModelIndex selectionIndex=selectionModel->currentIndex();

	if(selectionIndex.isValid())
	{
		EntityTreeItem* childItem=static_cast<EntityTreeItem*>(selectionIndex.internalPointer());
		if(childItem->entityItemType==EntityItemType::Entity)
		{
			QMessageBox::StandardButton button=QMessageBox::information(NULL,"提示","真的要删除该对象?",(QMessageBox::Yes | QMessageBox::No));
			if(button==QMessageBox::Yes)
			{
				if (mSelectObject!=NULL)
				{
					mSelectObject->mNode->showBoundingBox(false);//隐藏包围盒
					mSelectObject=NULL;
				}
				mObjectModel->removeRow(selectionIndex.row());
				childItem->parent()->removeChild(childItem);		
				mTreeView->reset();//改变数据后,记得通知view刷新
				delete childItem;//切记!必须要让view刷新后,才能delete数据项
			}
		}
	}
}
コード例 #7
0
void MagicalObjectWindow::on_removeButton_clicked()
{
    QItemSelectionModel *selection = ui->treeViewExistingObjects->selectionModel();
    QModelIndex indexElementSelectionne = selection->currentIndex();

    if(indexElementSelectionne.isValid())
    {
        int rep = QMessageBox::question(this,tr("Effacer"),
                                        tr("Voulez-vous vraiment effacer cet object magique ?"),
                                        QMessageBox::Yes | QMessageBox::No);
        if (rep == QMessageBox::Yes)
        {
            QFile f;
            f.setFileName(MAGICAL_OBJECT_PATH + "/" + ui->comboRace->currentText() + "/" + objects->item(indexElementSelectionne.row(), 0)->text() + ".om");
            f.remove();
            updateTreeView(ui->comboRace->currentText());
        }
        else if (rep == QMessageBox::No)
        {
            QMessageBox::critical(this, tr("Annulation"), tr("Opération annulée"));
        }
    }
    else
    {
        QMessageBox::warning(this, tr("Info"), tr("Veuillez sélectionner un régiment a supprimer."));
    }
}
コード例 #8
0
ファイル: MantidMatrix.cpp プロジェクト: mducle/mantid
/**  Copies the current selection in the active table view into the system
 * clipboard.
*/
void MantidMatrix::copySelection() {
  QItemSelectionModel *selModel = activeView()->selectionModel();
  QString s = "";
  QString eol = applicationWindow()->endOfLine();
  if (!selModel->hasSelection()) {
    QModelIndex index = selModel->currentIndex();
    s = text(index.row(), index.column());
  } else {
    QItemSelection sel = selModel->selection();
    QListIterator<QItemSelectionRange> it(sel);
    if (!it.hasNext())
      return;

    QItemSelectionRange cur = it.next();
    int top = cur.top();
    int bottom = cur.bottom();
    int left = cur.left();
    int right = cur.right();
    for (int i = top; i <= bottom; i++) {
      for (int j = left; j < right; j++)
        s += text(i, j) + "\t";
      s += text(i, right) + eol;
    }
  }
  // Copy text into the clipboard
  QApplication::clipboard()->setText(s.trimmed());
}
コード例 #9
0
ファイル: edititems.cpp プロジェクト: tohojo/fvk-qt
void EditItems::on_removeButton_clicked()
{
	QItemSelectionModel * s = itemsView->selectionModel();
	int row = s->currentIndex().row();
	items->removeRows(row, 1);
	emit dataChanged();
}
コード例 #10
0
ファイル: studysceneeditor.cpp プロジェクト: josebur/UMSL
bool StudySceneEditor::removeScene()
{
    QItemSelectionModel *selectionModel = m_ui.sceneView->selectionModel();
    QModelIndex index = selectionModel->currentIndex();
    if (!index.isValid()) {
        return false;
    }
    int row = selectionModel->currentIndex().row();
    if (m_model->removeRows(row, 1)) {
        //m_ui.sceneView->hideRow(row);
        return true;
    }
    else {
        return false;
    }
}
コード例 #11
0
ファイル: edititems.cpp プロジェクト: tohojo/fvk-qt
void EditItems::on_addButton_clicked()
{
	QItemSelectionModel * s = itemsView->selectionModel();
	int row = s->currentIndex().row();
	items->insertRows(row+1, 1);
	emit dataChanged();
}
コード例 #12
0
ファイル: localview.cpp プロジェクト: caidongyun/nullfxp
void LocalView::slot_show_properties()
{
    //qDebug() <<__FUNCTION__<<": "<<__LINE__<<":"<< __FILE__;
    QItemSelectionModel *ism = this->curr_item_view->selectionModel();
    QModelIndex cidx, idx;
    
    if (ism == 0) {
        qDebug()<<"Why???? no QItemSelectionModel??";
        return;
    }
    
    // QModelIndexList mil = ism->selectedIndexes();
    if (!ism->hasSelection()) {
        qDebug()<<"Why???? no QItemSelectionModel??";
        return;
    }

    cidx = ism->currentIndex();
    idx = ism->model()->index(cidx.row(), 0, cidx.parent());

    QString local_file = this->curr_item_view==this->uiw->treeView
        ? this->dir_file_model->filePath(idx) : this->model->filePath(idx);
    //  文件类型,大小,几个时间,文件权限
    //TODO 从模型中取到这些数据并显示在属性对话框中。
    LocalFileProperties *fp = new LocalFileProperties(this);
    fp->set_file_info_model_list(local_file);
    fp->exec();
    delete fp;
}
コード例 #13
0
ファイル: modelwindow.cpp プロジェクト: kaosphere/Warhole
void ModelWindow::on_pushButtonRmv_clicked()
{
    QItemSelectionModel *selection = ui->viewModelCrew->selectionModel();
    QModelIndex indexElementSelectionne = selection->currentIndex();

    crew->removeRow(indexElementSelectionne.row());
}
コード例 #14
0
ファイル: folderview.cpp プロジェクト: rbazaud/pcmanfm-qt
// this slot handles auto-selection of items.
void FolderView::onAutoSelectionTimeout() {
  if(QApplication::mouseButtons() != Qt::NoButton)
    return;

  Qt::KeyboardModifiers mods = QApplication::keyboardModifiers();
  QPoint pos = view->viewport()->mapFromGlobal(QCursor::pos()); // convert to viewport coordinates
  QModelIndex index = view->indexAt(pos); // find out the hovered item
  QItemSelectionModel::SelectionFlags flags = (mode == DetailedListMode ? QItemSelectionModel::Rows : QItemSelectionModel::NoUpdate);
  QItemSelectionModel* selModel = view->selectionModel();

  if(mods & Qt::ControlModifier) { // Ctrl key is pressed
    if(selModel->isSelected(index) && index != lastAutoSelectionIndex_) {
      // unselect a previously selected item
      selModel->select(index, flags|QItemSelectionModel::Deselect);
      lastAutoSelectionIndex_ = QModelIndex();
    }
    else {
      // select an unselected item
      selModel->select(index, flags|QItemSelectionModel::Select);
      lastAutoSelectionIndex_ = index;
    }
    selModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate); // move the cursor
  }
  else if(mods & Qt::ShiftModifier) { // Shift key is pressed
    // select all items between current index and the hovered index.
    QModelIndex current = selModel->currentIndex();
    if(selModel->hasSelection() && current.isValid()) {
      selModel->clear(); // clear old selection
      selModel->setCurrentIndex(current, QItemSelectionModel::NoUpdate);
      int begin = current.row();
      int end = index.row();
      if(begin > end)
        qSwap(begin, end);
      for(int row = begin; row <= end; ++row) {
        QModelIndex sel = model_->index(row, 0);
        selModel->select(sel, flags|QItemSelectionModel::Select);
      }
    }
    else { // no items are selected, select the hovered item.
      if(index.isValid()) {
        selModel->select(index, flags|QItemSelectionModel::SelectCurrent);
        selModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
      }
    }
    lastAutoSelectionIndex_ = index;
  }
  else if(mods == Qt::NoModifier) { // no modifier keys are pressed.
    if(index.isValid()) {
      // select the hovered item
      view->clearSelection();
      selModel->select(index, flags|QItemSelectionModel::SelectCurrent);
      selModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
    }
    lastAutoSelectionIndex_ = index;
  }

  autoSelectionTimer_->deleteLater();
  autoSelectionTimer_ = nullptr;
}
コード例 #15
0
ファイル: tilesetdock.cpp プロジェクト: AbelS95/tiled
/**
 * Synchronizes the selection with the given stamp. Ignored when the stamp is
 * changing because of a selection change in the TilesetDock.
 */
void TilesetDock::selectTilesInStamp(const TileStamp &stamp)
{
    if (mEmittingStampCaptured)
        return;

    QSet<Tile*> processed;
    QMap<QItemSelectionModel*, QItemSelection> selections;

    for (const TileStampVariation &variation : stamp.variations()) {
        const TileLayer &tileLayer = *variation.tileLayer();
        for (const Cell &cell : tileLayer) {
            if (Tile *tile = cell.tile) {
                if (processed.contains(tile))
                    continue;

                processed.insert(tile); // avoid spending time on duplicates

                Tileset *tileset = tile->tileset();
                int tilesetIndex = mTilesets.indexOf(tileset->sharedPointer());
                if (tilesetIndex != -1) {
                    TilesetView *view = tilesetViewAt(tilesetIndex);
                    if (!view->model()) // Lazily set up the model
                        setupTilesetModel(view, tileset);

                    const TilesetModel *model = view->tilesetModel();
                    const QModelIndex modelIndex = model->tileIndex(tile);
                    QItemSelectionModel *selectionModel = view->selectionModel();
                    selections[selectionModel].select(modelIndex, modelIndex);
                }
            }
        }
    }

    if (!selections.isEmpty()) {
        mSynchronizingSelection = true;

        // Mark captured tiles as selected
        for (auto i = selections.constBegin(); i != selections.constEnd(); ++i) {
            QItemSelectionModel *selectionModel = i.key();
            const QItemSelection &selection = i.value();
            selectionModel->select(selection, QItemSelectionModel::SelectCurrent);
        }

        // Show/edit properties of all captured tiles
        mMapDocument->setSelectedTiles(processed.toList());

        // Update the current tile (useful for animation and collision editors)
        auto first = selections.begin();
        QItemSelectionModel *selectionModel = first.key();
        const QItemSelection &selection = first.value();
        const QModelIndex currentIndex = selection.first().topLeft();
        if (selectionModel->currentIndex() != currentIndex)
            selectionModel->setCurrentIndex(currentIndex, QItemSelectionModel::NoUpdate);
        else
            currentChanged(currentIndex);

        mSynchronizingSelection = false;
    }
}
コード例 #16
0
QgsRuleBasedRenderer::Rule *QgsRuleBasedRendererWidget::currentRule()
{
  QItemSelectionModel *sel = viewRules->selectionModel();
  QModelIndex idx = sel->currentIndex();
  if ( !idx.isValid() )
    return nullptr;
  return mModel->ruleForIndex( idx );
}
コード例 #17
0
ファイル: SQLiteViewer.cpp プロジェクト: trident99/SqLiteStar
void SQLiteViewer::OnUnDeleteRecord_Click(void)
{
	QItemSelectionModel* ptrSelModel = ui.tblRecords->selectionModel();
	if((ptrSelModel)&&(m_ptrQuerySetModel))
	{
		QModelIndex objSel = ptrSelModel->currentIndex();
		m_objQuery.UnDeleteRecord(objSel.row() );
		m_ptrQuerySetModel->updateVerticalHeaders();
	};
};
コード例 #18
0
ファイル: mainwindow.cpp プロジェクト: reidsimon/CIS190
void MainWindow::openGroup(){
    QItemSelectionModel *selected = ui->lstGroups->selectionModel();
    if(selected->hasSelection()){
        QModelIndex row = selected->currentIndex();
        Group *g = glm->get_group(row,Qt::DisplayRole);
        GroupEditor *ge = new GroupEditor();
        ge->set_group_to_edit(g);
        ge->show();
    }
}
コード例 #19
0
ファイル: groupeditor.cpp プロジェクト: reidsimon/CIS190
void GroupEditor::transactions(){
    QItemSelectionModel *selected = ui->lstMembers->selectionModel();
    if(selected->hasSelection()){
        QModelIndex row = selected->currentIndex();
        Member *member = mlm->get_member(row,Qt::DisplayRole);
        TransactionsForm *tf = new TransactionsForm();
        tf->set_member_to_display(member);
        tf->show();
    }
}
コード例 #20
0
ファイル: groupeditor.cpp プロジェクト: reidsimon/CIS190
void GroupEditor::openMember(){
    QItemSelectionModel *selected = ui->lstMembers->selectionModel();
    if(selected->hasSelection()){
        QModelIndex row = selected->currentIndex();
        Member *member = mlm->get_member(row,Qt::DisplayRole);
        NewMember *nm = new NewMember();
        nm->setWindowTitle("Edit Member");
        nm->set_member_to_edit(member);
        nm->show();
    }
}
コード例 #21
0
QModelIndexList BaseTreeView::activeRows() const
{
    QItemSelectionModel *selection = selectionModel();
    QModelIndexList indices = selection->selectedRows();
    if (indices.isEmpty()) {
        QModelIndex current = selection->currentIndex();
        if (current.isValid())
            indices.append(current);
    }
    return indices;
}
コード例 #22
0
ファイル: stickydialog.cpp プロジェクト: helihyv/KitchenAlert
void StickyDialog::remove()
{
    QItemSelectionModel* pSelected = pStickiesView_->selectionModel();
    QModelIndex index = pSelected->currentIndex(); //Only single selection allowed, so we only need to care about current item


    if (!index.isValid())
        return;         //Nothing selected, nothing to remove...

    pStickiesModel_->removeRows(index.row(),1);

}
コード例 #23
0
// Refreshner.
void drumkv1widget_elements::refresh (void)
{
	if (m_pModel == NULL)
		return;

	QItemSelectionModel *pSelectionModel = QTreeView::selectionModel();
	const QModelIndex& index = pSelectionModel->currentIndex();

	m_pModel->reset();

	pSelectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
}
コード例 #24
0
void EclipsesBrowserDialog::accept()
{
    QItemSelectionModel *s = m_browserWidget->treeView->selectionModel();
    QModelIndex selected = s->currentIndex();

    if( selected.isValid() ) {
        EclipsesItem *item = static_cast<EclipsesItem*>( selected.internalPointer() );
        emit buttonShowClicked( m_eclModel->year(), item->index() );
    }

    QDialog::accept();
}
コード例 #25
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatsGenPlotWidget::on_deleteRowBtn_clicked()
{
  QItemSelectionModel* selectionModel = m_TableView->selectionModel();
  if (!selectionModel->hasSelection()) { return; }
  QModelIndex index = selectionModel->currentIndex();
  if (!index.isValid()) { return; }
  m_TableModel->removeRow(index.row(), index.parent());
  if (m_TableModel->rowCount() > 0)
  {
    m_TableView->resizeColumnsToContents();
  }
}
コード例 #26
0
ファイル: CreatModel.cpp プロジェクト: addfour/CreateModel
/************************************************************
* 功能		: //删除QTableView中被选中的行
* 输入		: 无
* 返回值	: void
*************************************************************/
void CreatModel::OnDelete()
{
	QItemSelectionModel *ismItem =  tv_fileInfo->selectionModel();
	QModelIndex index = ismItem->currentIndex();
	m_infos->removeRow(index.row());

	m_flag--;

	if (m_flag == 0)
	{
		btn_delete->setEnabled(false);
	}
}
コード例 #27
0
// Refreshner.
void qtractorMidiEventListView::refresh (void)
{
	if (m_pListModel == NULL)
		return;

	QItemSelectionModel *pSelectionModel = QTreeView::selectionModel();

	const QModelIndex& index = pSelectionModel->currentIndex();

	m_pListModel->reset();

	pSelectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
}
コード例 #28
0
void ScriptDebugger::labelClicked()
{
	QItemSelectionModel *selected = labelView.selectionModel();
	if (selected)
	{
		QModelIndex idx = selected->currentIndex();
		QStandardItem *item = labelModel->itemFromIndex(labelModel->index(idx.row(), 0));
		if (item)
		{
			showLabel(item->text());
		}
	}
}
コード例 #29
0
ファイル: CreatModel.cpp プロジェクト: addfour/CreateModel
/************************************************************
* 功能		: 在itemmodel上添加右键操作
* 输入		: 无
* 返回值	: void
*************************************************************/
void CreatModel::showContextMenu(const QPoint& pos)
{

	QItemSelectionModel *ismItem =  tv_fileInfo->selectionModel();
	QModelIndex index = ismItem->currentIndex();
	int sRow = 0;
	sRow = index.row();

	if(menu_right && sRow != -1)
	{
		menu_right->exec(QCursor::pos());
	}
}
コード例 #30
0
ファイル: commanddialog.cpp プロジェクト: kyawkyaw/tiled
void CommandTreeView::handleRowsRemoved(const QModelIndex &parent, int, int)
{
    if (parent.isValid())
        return;

    // Reselect the same row index of the removed row
    QItemSelectionModel *sModel = selectionModel();
    QModelIndex index = sModel->currentIndex();

    sModel->select(index.sibling(index.row() + 1,index.column()),
                   QItemSelectionModel::ClearAndSelect |
                   QItemSelectionModel::Rows);
}