Ejemplo n.º 1
0
void CList::selectNext()
{
    int index = getSelectedIndex();
    if (index < 0)
        selectIndex(0);
    else if (index + 1 < list->size())
        selectIndex(index+1);
}
Ejemplo n.º 2
0
void CList::selectPrev()
{
    int index = getSelectedIndex();
    if (index <= 0)
        selectIndex(0);
    else
        selectIndex(index-1);
}
void TreeViewComboBox::rowsRemoved(const QModelIndex &parent, int, int) {
  QModelIndex currentIndex = selectedIndex();

  if (currentIndex.isValid())
    selectIndex(currentIndex);
  else
    selectIndex(parent);
}
bool PsiFilteredContactListView::handleKeyPressEvent(QKeyEvent* e)
{
	updateKeyboardModifiers(e);

	switch (e->key()) {
	case Qt::Key_Enter:
	case Qt::Key_Return: {
		if (state() == EditingState)
			return false;

		QModelIndex currentIndex = this->currentIndex();
		if (currentIndex.isValid()) {
			// TODO: probably should select the item from the filteredListView_
			// in the contactListView_ as well
			activate(currentIndex);
		}
		return true;
	}
	case Qt::Key_Home: {
		selectIndex(0);
		return true;
	}
	case Qt::Key_End: {
		selectIndex(model()->rowCount()-1);
		return true;
	}
	case Qt::Key_Up:
	case Qt::Key_Down: {
		moveSelection(1, e->key() == Qt::Key_Up ? Backward : Forward);
		return true;
	}
	case Qt::Key_PageUp:
	case Qt::Key_PageDown: {
		int delta = 0;
		QModelIndex index = model()->index(0, 0, QModelIndex());
		if (index.isValid()) {
			int itemHeight = itemDelegate()->sizeHint(QStyleOptionViewItem(), index).height();
			if (itemHeight)
				delta = viewport()->height() / itemHeight;
		}
		moveSelection(delta, e->key() == Qt::Key_PageUp ? Backward : Forward);
		return true;
	}
	default:
		;
	}

	return false;
}
Ejemplo n.º 5
0
SideBarView::SideBarView ( QWidget* parent ) : QTreeView(parent), _model(NULL) {
    installEventFilter(this);

    _model = new SideBarModel(this);
    
    setModel(_model);
    setItemsExpandable(true);
    setHeaderHidden(true);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setContextMenuPolicy(Qt::CustomContextMenu);
    setItemDelegate(new SideBarDelegate(this));
    expandAll();
    
    connect(ArenaWidgetManager::getInstance(), SIGNAL(activated(ArenaWidget*)), this,   SLOT(activated(ArenaWidget*)));
    connect(ArenaWidgetManager::getInstance(), SIGNAL(added(ArenaWidget*)),     this,   SLOT(added(ArenaWidget*)));
    connect(ArenaWidgetManager::getInstance(), SIGNAL(removed(ArenaWidget*)),   this,   SLOT(removed(ArenaWidget*)));
    connect(ArenaWidgetManager::getInstance(), SIGNAL(activated(ArenaWidget*)), _model, SLOT(mapped(ArenaWidget*)));
    connect(ArenaWidgetManager::getInstance(), SIGNAL(toggled(ArenaWidget*)),   _model, SLOT(toggled(ArenaWidget*)));
    connect(ArenaWidgetManager::getInstance(), SIGNAL(updated(ArenaWidget*)),   _model, SLOT(updated(ArenaWidget*)));
    
    connect(this, SIGNAL(doubleClicked(QModelIndex)),           this,   SLOT(slotSideBarDblClicked(QModelIndex)));
    connect(this, SIGNAL(customContextMenuRequested(QPoint)),   this,   SLOT(slotSidebarContextMenu()));
    connect(this, SIGNAL(clicked(QModelIndex)),                 this,   SLOT(slotSidebarHook(QModelIndex)));
    connect(this, SIGNAL(clicked(QModelIndex)),                 _model, SLOT(slotIndexClicked(QModelIndex)));
   
    
    connect(GlobalTimer::getInstance(), SIGNAL(second()), _model, SLOT(redraw()));
    
    connect(_model,    SIGNAL(mapWidget(ArenaWidget*)),     ArenaWidgetManager::getInstance(),  SLOT(activate(ArenaWidget*)));
    connect(_model,    SIGNAL(selectIndex(QModelIndex)),    this,                               SLOT(slotWidgetActivated(QModelIndex)));
}
Ejemplo n.º 6
0
void SpikeNoteWidget::addSpike() {
  QStandardItem* i = new QStandardItem("Edit Text");
  SpikePtr s(new Spike());
  stm_->appendRow(i, s);
  ui_.spikestreeview->setCurrentIndex(i->index());
  ui_.spikestreeview->edit(i->index());

  selectIndex(i->index());
}
void PsiFilteredContactListView::moveSelection(uint delta, PsiFilteredContactListView::Direction direction)
{
	QModelIndex currentIndex = this->currentIndex();
	int row = currentIndex.row();
	if (currentIndex.isValid())
		row = direction == Forward ? (row + delta) : (row - delta);
	else
		row = 0;
	selectIndex(row);
}
void TreeViewComboBox::hidePopup() {
  if (!_popupVisible)
    return;

  if (_skipNextHide)
    _skipNextHide = false;
  else {
    QComboBox::hidePopup();
    _popupVisible = false;
    selectIndex(view()->currentIndex());
  }
}
Ejemplo n.º 9
0
bool QFTreeViewComboBox::setCurrentFromModelData(const QVariant &data, const QModelIndex &parent, int role)
{
    for (int i=0; i<model()->rowCount(parent); i++) {
        QModelIndex idx=model()->index(i,0,parent);
        if (model()->hasChildren(idx)){
            if (setCurrentFromModelData(data, idx, role)) return true;
        }
        if (model()->data(idx, role)==data) {
            selectIndex(idx);
            return true;
        }
    }
    return false;
}
Ejemplo n.º 10
0
void SpikeNoteWidget::deleteSelectedSpike() {  
  const QModelIndexList li = ui_.spikestreeview->selectionModel()->selectedIndexes();
  if (li.isEmpty()) return;
  const QModelIndex i = li.first();
  if (!i.isValid()) return;  
  const SpikePtr spike = stm_->getPointerFromIndex(i);
  const QString question = QString("Do you want to delete Spike \"%1\",\n with directory \"%2\"").arg(
    spike->name()).arg(spike->dir());
  QMessageBox::StandardButton res = QMessageBox::question(this, "Do you want to delete?", question);
  if (res==QMessageBox::Yes) {
    stm_->removeItemAtIndex(i);

    const QModelIndex i = ui_.spikestreeview->selectionModel()->selectedIndexes().first();
    selectIndex(i);
  }
}
Ejemplo n.º 11
0
void XListBox::mouseLPressEvent(X_Event *event)
{
	XItem *item=selectIndex(event);
	if(item)
	{
		//1.先恢复选择过的item
		//2.绘制现在的item
		//3.保存现在的item;

		if(pList){
			pList->resumeItem();
		}
		paintSelectItem(item);
		setResumeItem(this,item);
		if(indexListener)
		{
			indexListener->selectIndex(event,(ID)item,index);
		}
	}
}
void 
DataVisualizer::retranslateUi()
{
	Ui::DataVisualizer::retranslateUi(this);

	int selectedIndex = cbCharacteristic->currentIndex();
	// remove all characteristics items first, add the retranslated again
	cbCharacteristic->clear();
	int count = Element::propertyCount()-1;
	for(int i=0; i < count; i++)
	{
		cbCharacteristic->insertItem(
			cbCharacteristic->count(), 
			tr(Element::propertyName(Element::getProperty(i))), 
			QVariant(i));
	}

	// redisplay the data
	selectIndex(selectedIndex);
}
Ejemplo n.º 13
0
bool Solver::solve(Grid& solution, int& steps, Grid& grid) {
  int index = selectIndex(grid);

  if (index == -1) {
    solution = grid;
    return true;
  }

  vector<int> moves(begin(grid[index]), end(grid[index]));
  sortMoves(grid, moves, index);

  for (auto& value : moves) {
    steps++;

    Grid nextGrid(grid);
    if (nextGrid.assign(index, value) && solve(solution, steps, nextGrid))
      return true;
  }

  return false;
}
Ejemplo n.º 14
0
void SideBarModel::mapped(ArenaWidget *awgt){
    if (!awgt)
        return;

    QModelIndex s;

    if (items.contains(awgt)){
        SideBarItem *root  = roots[awgt->role()];
        SideBarItem *child = items[awgt];

        QModelIndex par_root = index(root->row(), 0, QModelIndex());
        s = index(child->row(), 0, par_root);
    }
    else {
        SideBarItem *root  = roots[awgt->role()];

        s = index(root->row(), 0, QModelIndex());
    }

    historyPush(awgt);

    emit selectIndex(s);
}
Ejemplo n.º 15
0
SpikeNoteWidget::SpikeNoteWidget(QWidget* parent) : QWidget(parent) {
  ui_.setupUi(this);

  stm_ = new SpikesTreeModel(this);

  ui_.spikestreeview->setModel(stm_);
  ui_.spikestreeview->expandAll();
  ui_.spikestreeview->header()->hide();
  connect(ui_.noteView, &NoteView::stopCommitTimer, stm_, &SpikesTreeModel::stopCommitTimer);
  connect(ui_.spikestreeview, &QAbstractItemView::customContextMenuRequested, this, &SpikeNoteWidget::spikestreeContextMenu);

  ui_.spikestreeview->setContextMenuPolicy(Qt::CustomContextMenu);
  connect(ui_.spikestreeview, &QAbstractItemView::clicked, this, &SpikeNoteWidget::activated);  

  //restore index
  QSettings s("Foo", "reknote");
  const int row = s.value("selected-spike-row").toInt();
  const int column = s.value("selected-spike-column").toInt();
  const QModelIndex i = stm_->index(row, column);
  selectIndex(i);

  stm_->load();
}
Ejemplo n.º 16
0
Imath::Box2i Select::computeDataWindow( const Gaffer::Context *context, const ImagePlug *parent ) const
{
	return inPlug( selectIndex() )->dataWindowPlug()->getValue();
}
Ejemplo n.º 17
0
bool ListBox::onProcessMessage(Message* msg)
{
  switch (msg->type()) {

    case kOpenMessage:
      centerScroll();
      break;

    case kMouseDownMessage:
      captureMouse();

    case kMouseMoveMessage:
      if (hasCapture()) {
        gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();
        int select = getSelectedIndex();
        View* view = View::getView(this);
        bool pick_item = true;

        if (view) {
          gfx::Rect vp = view->getViewportBounds();

          if (mousePos.y < vp.y) {
            int num = MAX(1, (vp.y - mousePos.y) / 8);
            selectIndex(select-num);
            pick_item = false;
          }
          else if (mousePos.y >= vp.y + vp.h) {
            int num = MAX(1, (mousePos.y - (vp.y+vp.h-1)) / 8);
            selectIndex(select+num);
            pick_item = false;
          }
        }

        if (pick_item) {
          Widget* picked;

          if (view) {
            picked = view->getViewport()->pick(mousePos);
          }
          else {
            picked = pick(mousePos);
          }

          /* if the picked widget is a child of the list, select it */
          if (picked && hasChild(picked)) {
            if (ListItem* pickedItem = dynamic_cast<ListItem*>(picked))
              selectChild(pickedItem);
          }
        }

        return true;
      }
      break;

    case kMouseUpMessage:
      releaseMouse();
      break;

    case kMouseWheelMessage: {
      View* view = View::getView(this);
      if (view) {
        gfx::Point scroll = view->getViewScroll();
        scroll += static_cast<MouseMessage*>(msg)->wheelDelta() * getTextHeight()*3;
        view->setViewScroll(scroll);
      }
      break;
    }

    case kKeyDownMessage:
      if (hasFocus() && !getChildren().empty()) {
        int select = getSelectedIndex();
        View* view = View::getView(this);
        int bottom = MAX(0, getChildren().size()-1);
        KeyMessage* keymsg = static_cast<KeyMessage*>(msg);

        switch (keymsg->scancode()) {
          case kKeyUp:
            // Select previous element.
            if (select >= 0)
              select--;
            // Or select the bottom of the list if there is no
            // selected item.
            else
              select = bottom;
            break;
          case kKeyDown:
            select++;
            break;
          case kKeyHome:
            select = 0;
            break;
          case kKeyEnd:
            select = bottom;
            break;
          case kKeyPageUp:
            if (view) {
              gfx::Rect vp = view->getViewportBounds();
              select -= vp.h / getTextHeight();
            }
            else
              select = 0;
            break;
          case kKeyPageDown:
            if (view) {
              gfx::Rect vp = view->getViewportBounds();
              select += vp.h / getTextHeight();
            }
            else
              select = bottom;
            break;
          case kKeyLeft:
          case kKeyRight:
            if (view) {
              gfx::Rect vp = view->getViewportBounds();
              gfx::Point scroll = view->getViewScroll();
              int sgn = (keymsg->scancode() == kKeyLeft) ? -1: 1;

              scroll.x += vp.w/2*sgn;

              view->setViewScroll(scroll);
            }
            break;
          default:
            return Widget::onProcessMessage(msg);
        }

        selectIndex(MID(0, select, bottom));
        return true;
      }
      break;

    case kDoubleClickMessage:
      onDoubleClickItem();
      return true;
  }

  return Widget::onProcessMessage(msg);
}
void TreeViewComboBox::currentIndexChanged() {
  selectIndex(selectedIndex());
}
void 
DataVisualizer::show()
{
	QWidget::show();
	selectIndex(initialSelection);
}
Ejemplo n.º 20
0
void SoilTypePage::setModel(SiteResponseModel *model)
{
    updateUnits();

    m_soilTypeCatalog = model->siteProfile()->soilTypeCatalog();
    m_soilTypeTableBox->setModel(m_soilTypeCatalog);
    m_modulusDelegate->setModel(
        m_soilTypeCatalog->nlCatalog()->modulusFactory());
    m_dampingDelegate->setModel(
        m_soilTypeCatalog->nlCatalog()->dampingFactory());

    connect(m_soilTypeTableBox, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
            this, SLOT(selectIndex(QModelIndex, QModelIndex)));

    m_soilPropsGroupBox->setEnabled(false);
    m_nlPropTableBox->setEnabled(false);

    updateNonlinearPropertiesRequired(model->nonlinearPropertiesRequired());
    connect(model, SIGNAL(nonlinearPropertiesRequiredChanged(bool)),
            this, SLOT(updateNonlinearPropertiesRequired(bool)));

    updateDampingRequired(model->dampingRequired());
    connect(model, SIGNAL(dampingRequiredChanged(bool)),
            this, SLOT(updateDampingRequired(bool)));

    updateVariedColumn(model->siteProfile()->nonlinearPropertyRandomizer()->enabled());
    connect(model->siteProfile()->nonlinearPropertyRandomizer(), SIGNAL(enabledChanged(bool)),
            this, SLOT(updateVariedColumn(bool)));

    RockLayer* rl = model->siteProfile()->bedrock();

    m_bedrockUntWtSpinBox->setValue(rl->untWt());
    connect(m_bedrockUntWtSpinBox, SIGNAL(valueChanged(double)),
            rl, SLOT(setUntWt(double)));

    m_bedrockDampingSpinBox->setValue(rl->avgDamping());
    connect(m_bedrockDampingSpinBox, SIGNAL(valueChanged(double)),
            rl, SLOT(setAvgDamping(double)));

    m_waterTableDepthSpinBox->setValue(
        model->siteProfile()->waterTableDepth());
    connect(m_waterTableDepthSpinBox, SIGNAL(valueChanged(double)),
            model->siteProfile(), SLOT(setWaterTableDepth(double)));

    NonlinearPropertyRandomizer* npr
        = model->siteProfile()->nonlinearPropertyRandomizer();

    m_varyBedrockDampingCheckBox->setChecked(npr->bedrockIsEnabled());
    connect(m_varyBedrockDampingCheckBox, SIGNAL(toggled(bool)),
            npr, SLOT(setBedrockIsEnabled(bool)));

    m_varyBedrockDampingCheckBox->setVisible(npr->enabled());
    connect(npr, SIGNAL(enabledChanged(bool)),
            m_varyBedrockDampingCheckBox, SLOT(setVisible(bool)));

    m_nprModelComboBox->setCurrentIndex(npr->model());
    connect(m_nprModelComboBox, SIGNAL(currentIndexChanged(int)),
            npr, SLOT(setModel(int)));

    m_modulusUncertWidget->setUncertaintyModel(npr->model());
    m_modulusUncertWidget->setModel(npr->modulusUncert());
    connect(npr, SIGNAL(modelChanged(int)),
            m_modulusUncertWidget, SLOT(setUncertaintyModel(int)));

    m_dampingUncertWidget->setUncertaintyModel(npr->model());
    m_dampingUncertWidget->setModel(npr->dampingUncert());
    connect(npr, SIGNAL(modelChanged(int)),
            m_dampingUncertWidget, SLOT(setUncertaintyModel(int)));

    m_correlSpinBox->setValue(npr->correl());
    connect(m_correlSpinBox, SIGNAL(valueChanged(double)),
            npr, SLOT(setCorrel(double)));

    m_randomizerGroupBox->setVisible(npr->enabled());
    connect(npr, SIGNAL(enabledChanged(bool)),
            m_randomizerGroupBox, SLOT(setVisible(bool)));
}
Ejemplo n.º 21
0
void Select::hashDataWindow( const GafferImage::ImagePlug *output, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	inPlug( selectIndex() )->dataWindowPlug()->hash(h);
}
Ejemplo n.º 22
0
//Setup the GUI
NameList::NameList(QWidget *parent) :
    QWidget(parent)
{
    //Main layout
    QVBoxLayout *mainLayout = new QVBoxLayout(this);

    //Horizontal layout for the title and button
    QHBoxLayout *hLayout = new QHBoxLayout();
    hLayout->setStretch(0,1);
    mainLayout->addLayout(hLayout);

    //Title (empty)
    _title = new QLabel();
    hLayout->addWidget(_title);

    //Spacer
    QSpacerItem *spacer = new QSpacerItem(0,0);
    hLayout->addSpacerItem(spacer);
    hLayout->setStretch(1,1);

    //Buttons
    b_load = new QToolButton();
    b_load->setIcon(QIcon(":/images/open.png"));
    b_load->setToolTip(QString("Load existing"));
    b_up = new QToolButton();
    b_up->setIcon(QIcon::fromTheme("go-up",QIcon(":images/up.png")));
    b_down = new QToolButton();
    b_down->setIcon(QIcon::fromTheme("go-down",QIcon(":images/down.png")));
    b_add = new QToolButton();
    b_add->setIcon(QIcon::fromTheme("list-add",QIcon(":images/add.png")));
    b_add->setToolTip(QString("Add new"));
    b_remove = new QToolButton();
    b_remove->setIcon(QIcon::fromTheme("list-remove",QIcon(":images/delete.png")));
    b_remove->setToolTip(QString("Remove"));
    hLayout->addWidget(b_up);
    hLayout->addWidget(b_down);
    hLayout->addWidget(b_load);
    hLayout->addWidget(b_add);
    hLayout->addWidget(b_remove);

    //The list and its model
    _table = new QTableWidget();
    _table->setColumnCount(1);
    _table->horizontalHeader()->setSectionResizeMode(0,QHeaderView::Stretch);
    _table->horizontalHeader()->hide();
    _table->verticalHeader()->hide();
    _table->setSelectionBehavior(QAbstractItemView::SelectRows);
    _table->setMinimumHeight(100);

    mainLayout->addWidget(_table);

    //Connect the buttons
    CONNECT(b_up, SIGNAL(clicked()), this, SLOT(up()));
    CONNECT(b_down, SIGNAL(clicked()), this, SLOT(down()));
    CONNECT(b_load, SIGNAL(clicked()), this, SIGNAL(loadClicked()));
    CONNECT(b_add, SIGNAL(clicked()), this, SIGNAL(addClicked()));
    CONNECT(b_remove, SIGNAL(clicked()), this, SLOT(removeCurrent()));

    //Enable/disables the buttons
    CONNECT(this, SIGNAL(appened(void*)), this, SLOT(checkSize()));
    CONNECT(this, SIGNAL(removed(void*)), this, SLOT(checkSize()));
    CONNECT(this, SIGNAL(appened(void*)), this, SLOT(checkUpDown()));
    CONNECT(this, SIGNAL(removed(void*)), this, SLOT(checkUpDown()));
    CONNECT(_table, SIGNAL(clicked(QModelIndex)), this, SLOT(checkUpDown()));
    CONNECT(_table->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(checkUpDown()));

    //Redirect list signals
    CONNECT(_table, SIGNAL(activated(QModelIndex)), this, SLOT(activateIndex(QModelIndex)));
    CONNECT(_table, SIGNAL(clicked(QModelIndex)), this, SLOT(selectIndex(QModelIndex)));

    //By default, do not show all buttons
    hideUpDown(true);
//    hideLoad(true);
    hideAdd(true);
    //And they are disabled
    b_up->setEnabled(false);
    b_down->setEnabled(false);
    //The remove button too
    b_remove->setEnabled(false);

    //Lower our minimal height and change our vertical policy
    this->setMinimumHeight(100);
    this->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding);
}
Ejemplo n.º 23
0
IECore::ConstStringVectorDataPtr Select::computeChannelNames( const Gaffer::Context *context, const ImagePlug *parent ) const
{
	return inPlug( selectIndex() )->channelNamesPlug()->getValue();
}
Ejemplo n.º 24
0
IECore::ConstFloatVectorDataPtr Select::computeChannelData( const std::string &channelName, const Imath::V2i &tileOrigin, const Gaffer::Context *context, const ImagePlug *parent ) const
{
	return inPlug( selectIndex() )->channelDataPlug()->getValue();
}
Ejemplo n.º 25
0
void CHeroList::select(const CGHeroInstance * hero)
{
    selectIndex(vstd::find_pos(LOCPLINT->wanderingHeroes, hero));
}
Ejemplo n.º 26
0
void Select::hashFormat( const GafferImage::ImagePlug *output, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	inPlug( selectIndex() )->formatPlug()->hash(h);
}
Ejemplo n.º 27
0
void Select::hashChannelData( const GafferImage::ImagePlug *output, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	inPlug( selectIndex() )->channelDataPlug()->hash(h);
}
Ejemplo n.º 28
0
void CTownList::select(const CGTownInstance * town)
{
    selectIndex(vstd::find_pos(LOCPLINT->towns, town));
}
Ejemplo n.º 29
0
GafferImage::Format Select::computeFormat( const Gaffer::Context *context, const ImagePlug *parent ) const
{
	return inPlug( selectIndex() )->formatPlug()->getValue();
}