Ejemplo n.º 1
0
void ListBox::flipRowSelection (const int row)
{
    if (isRowSelected (row))
        deselectRow (row);
    else
        selectRowInternal (row, false, false, true);
}
void CProcessListTable::copy_data_func(QString *cpy, CMySQLQuery *qry, QTableSelection *sel, QMap<uint, ulong> *max_length_map)
{
  uint length;
  QString tmp;
  qry->dataSeek(0);
  for (int current_row = 0; current_row < numRows(); current_row++)
  {
    qry->next();
    if (!isRowSelected(current_row))
      continue;    
    *cpy += "|";
    for (int current_col = sel->leftCol(); current_col <= sel->rightCol(); current_col++)
    {
      if (horizontalHeader()->sectionSize(current_col) <= 0)
        continue;
      const char *str= query()->row(current_col) ? query()->row(current_col) : NULL_TEXT;
      length = (*max_length_map)[current_col];
      
      if (length > MAX_COLUMN_LENGTH)
      {
        *cpy += str;
        *cpy += "|";
      }
      else
      {
        tmp.sprintf(IS_NUM(qry->fields(current_col).type) ? "%*s |" : " %-*s|", length, str);
        *cpy += tmp;
      }
    }
    *cpy += "\n";
  }
}
Ejemplo n.º 3
0
void ListBox::selectRowInternal (const int row,
                                 bool dontScroll,
                                 bool deselectOthersFirst,
                                 bool isMouseClick)
{
    if (! multipleSelection)
        deselectOthersFirst = true;

    if ((! isRowSelected (row))
         || (deselectOthersFirst && getNumSelectedRows() > 1))
    {
        if (isPositiveAndBelow (row, totalItems))
        {
            if (deselectOthersFirst)
                selected.clear();

            selected.addRange (Range<int> (row, row + 1));

            if (getHeight() == 0 || getWidth() == 0)
                dontScroll = true;

            viewport->selectRow (row, getRowHeight(), dontScroll,
                                 lastRowSelected, totalItems, isMouseClick);

            lastRowSelected = row;
            model->selectedRowsChanged (row);
        }
        else
        {
            if (deselectOthersFirst)
                deselectAllRows();
        }
    }
}
Ejemplo n.º 4
0
int Matrix::numSelectedRows()
{
	int r=0;
	for(int i=0; i<numRows(); i++)
		if (isRowSelected(i, true))
			r++;
	return r;
}
Ejemplo n.º 5
0
void ListBox::selectRowsBasedOnModifierKeys (const int row,
                                             const ModifierKeys& mods,
                                             const bool isMouseUpEvent)
{
    if (multipleSelection && mods.isCommandDown())
    {
        flipRowSelection (row);
    }
    else if (multipleSelection && mods.isShiftDown() && lastRowSelected >= 0)
    {
        selectRangeOfRows (lastRowSelected, row);
    }
    else if ((! mods.isPopupMenu()) || ! isRowSelected (row))
    {
        selectRowInternal (row, false, ! (multipleSelection && (! isMouseUpEvent) && isRowSelected (row)), true);
    }
}
Ejemplo n.º 6
0
Image ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY)
{
    Rectangle<int> imageArea;
    const int firstRow = getRowContainingPosition (0, 0);

    int i;
    for (i = getNumRowsOnScreen() + 2; --i >= 0;)
    {
        Component* rowComp = viewport->getComponentForRowIfOnscreen (firstRow + i);

        if (rowComp != nullptr && isRowSelected (firstRow + i))
        {
            const Point<int> pos (getLocalPoint (rowComp, Point<int>()));
            const Rectangle<int> rowRect (pos.getX(), pos.getY(), rowComp->getWidth(), rowComp->getHeight());
            imageArea = imageArea.getUnion (rowRect);
        }
    }

    imageArea = imageArea.getIntersection (getLocalBounds());
    imageX = imageArea.getX();
    imageY = imageArea.getY();
    Image snapshot (Image::ARGB, imageArea.getWidth(), imageArea.getHeight(), true);

    for (i = getNumRowsOnScreen() + 2; --i >= 0;)
    {
        Component* rowComp = viewport->getComponentForRowIfOnscreen (firstRow + i);

        if (rowComp != nullptr && isRowSelected (firstRow + i))
        {
            const Point<int> pos (getLocalPoint (rowComp, Point<int>()));

            Graphics g (snapshot);
            g.setOrigin (pos.getX() - imageX, pos.getY() - imageY);

            if (g.reduceClipRegion (rowComp->getLocalBounds()))
            {
                g.beginTransparencyLayer (0.6f);
                rowComp->paintEntireComponent (g, false);
                g.endTransparencyLayer();
            }
        }
    }

    return snapshot;
}
Ejemplo n.º 7
0
void EventTableWidget::handleCellPressedEvent(int row) {
	QString eventId = getEventId(row);

	if ( isRowSelected(row) && _controlKeyPressed ) {
		setSelectedRow(-1);
		clearSelection();
		emit eventDeselected(eventId);
	} else {
		setSelectedRow(row);
		emit eventSelected(eventId);
	}
}
/**
 * @brief ChordTableWidget::insertChordRow
 *
 * Insère une nouvelle ligne dans la grille.
 * @todo insérer SOIT après la case sélectionnée (si une seule case sélectionnée), SOIT à la fin du fichier
 */
void ChordTableWidget::insertChordRow() {
	if (isRowSelected())
	{
		QList<int> rows = expand_list(rowsSelected());
		for (QList<int>::Iterator it = rows.begin() ; it != rows.end() ; it ++)
			insertChordRow(*it);
	}
	else
	{
		insertChordRow(this->rowCount());
	}

	emit somethingChanged();
}
Ejemplo n.º 9
0
void ListBox::setSelectedRows (const SparseSet<int>& setOfRowsToBeSelected,
                               const bool sendNotificationEventToModel)
{
    selected = setOfRowsToBeSelected;
    selected.removeRange (Range <int> (totalItems, std::numeric_limits<int>::max()));

    if (! isRowSelected (lastRowSelected))
        lastRowSelected = getSelectedRow (0);

    viewport->updateContents();

    if ((model != nullptr) && sendNotificationEventToModel)
        model->selectedRowsChanged (lastRowSelected);
}
Ejemplo n.º 10
0
bool Matrix::rowsSelected()
{
	QList<QTableWidgetSelectionRange> sel = d_table->selectedRanges();
	QListIterator<QTableWidgetSelectionRange> it(sel);
	QTableWidgetSelectionRange cur;

	if( it.hasNext() )
	{
		cur = it.next();
		for(int i=cur.topRow(); i<=cur.bottomRow(); i++)
		{
			if (!isRowSelected (i, true))
				return false;
		}
	}
	return true;
}
Ejemplo n.º 11
0
void GUITabla::removerFilaSeleccionada()
{
	for(int fila = 0; fila <= numRows(); fila++)
	{
		if ( isRowSelected( fila, false))
		{
			removeRow(fila);
			insertRows(numRows(), 1);
			break;
		}
		
		else
		{
			qDebug("GUIFormularios::removerFilaSeleccionada() no hay ninguna fila seleccionada");
		}
	}
}
Ejemplo n.º 12
0
void Matrix::deleteSelectedRows()
{
	QVarLengthArray<int> rows(1);
	int n=0;
	for (int i=0; i<numRows(); i++)
	{
		if (isRowSelected(i, true))
		{
			n++;
			rows.resize(n);
			rows[n-1]= i;
		}
	}

	// rows need to be removed from bottom to top
	for(int i=rows.count()-1; i>=0; i--)
		d_table->removeRow(rows[i]);
	emit modifiedWindow(this);
}
Ejemplo n.º 13
0
void TableEditor::contextMenu(int,int,const QPoint &pos)
{
    Q3PopupMenu *menu = new Q3PopupMenu(viewport());
    menu->insertItem(tr("Copy"),1);
    menu->insertItem(tr("Paste"),2);
	int nSelRows=0;
	Q3MemArray<int> selRows(numRows());
	for(int r=0;r<numRows()-1;r++) if(isRowSelected(r,1)) selRows[nSelRows++]=r;
	selRows.resize(nSelRows);
	if(nSelRows) menu->insertItem(tr("Delete rows"),3);
	//menu->insertItem("Clear",3);
    int r=menu->exec(pos,0);
	switch(r)
	{
	case 1: copy(); break;
	case 2: paste(); break;
	case 3: removeRows(selRows); break;
    }
}
Ejemplo n.º 14
0
/**
 * @brief ChordTableWidget::copy_down_rows
 *
 * Copie les lignes actuellement sélectionnées et les insère dans la grille.
 */
void ChordTableWidget::copyDownRows()
{
	if (isRowSelected())
	{
		QList<QList<int>*> ranges = rowsSelected();
		int count = 0;
		QList<int>::Iterator i;
		QList<QList<int>*>::Iterator it;

		for (it = ranges.begin() ; it != ranges.end() ; it ++)
		{
			for (i = (**it).begin(), count = 1 ; i != (**it).end() ; i ++, count ++)
			{
				insertChordRow((**it).last() + count);
				for (int c = 0 ; c < this->columnCount() ; c ++)
				{
					this->setItem((**it).last() + count, c, this->item(*i, c)->clone());
				}
			}
		}
	}
}
Ejemplo n.º 15
0
//==============================================================================
bool ListBox::keyPressed (const KeyPress& key)
{
    const int numVisibleRows = viewport->getHeight() / getRowHeight();

    const bool multiple = multipleSelection
                            && (lastRowSelected >= 0)
                            && (key.getModifiers().isShiftDown()
                                 || key.getModifiers().isCtrlDown()
                                 || key.getModifiers().isCommandDown());

    if (key.isKeyCode (KeyPress::upKey))
    {
        if (multiple)
            selectRangeOfRows (lastRowSelected, lastRowSelected - 1);
        else
            selectRow (jmax (0, lastRowSelected - 1));
    }
    else if (key.isKeyCode (KeyPress::returnKey)
              && isRowSelected (lastRowSelected))
    {
        if (model != nullptr)
            model->returnKeyPressed (lastRowSelected);
    }
    else if (key.isKeyCode (KeyPress::pageUpKey))
    {
        if (multiple)
            selectRangeOfRows (lastRowSelected, lastRowSelected - numVisibleRows);
        else
            selectRow (jmax (0, jmax (0, lastRowSelected) - numVisibleRows));
    }
    else if (key.isKeyCode (KeyPress::pageDownKey))
    {
        if (multiple)
            selectRangeOfRows (lastRowSelected, lastRowSelected + numVisibleRows);
        else
            selectRow (jmin (totalItems - 1, jmax (0, lastRowSelected) + numVisibleRows));
    }
    else if (key.isKeyCode (KeyPress::homeKey))
    {
        if (multiple && key.getModifiers().isShiftDown())
            selectRangeOfRows (lastRowSelected, 0);
        else
            selectRow (0);
    }
    else if (key.isKeyCode (KeyPress::endKey))
    {
        if (multiple && key.getModifiers().isShiftDown())
            selectRangeOfRows (lastRowSelected, totalItems - 1);
        else
            selectRow (totalItems - 1);
    }
    else if (key.isKeyCode (KeyPress::downKey))
    {
        if (multiple)
            selectRangeOfRows (lastRowSelected, lastRowSelected + 1);
        else
            selectRow (jmin (totalItems - 1, jmax (0, lastRowSelected) + 1));
    }
    else if ((key.isKeyCode (KeyPress::deleteKey) || key.isKeyCode (KeyPress::backspaceKey))
               && isRowSelected (lastRowSelected))
    {
        if (model != nullptr)
            model->deleteKeyPressed (lastRowSelected);
    }
    else if (multiple && key == KeyPress ('a', ModifierKeys::commandModifier, 0))
    {
        selectRangeOfRows (0, std::numeric_limits<int>::max());
    }
    else
    {
        return false;
    }

    return true;
}
Ejemplo n.º 16
0
int ListBox::getLastRowSelected() const
{
    return (isRowSelected (lastRowSelected)) ? lastRowSelected : -1;
}
void CProcessListTable::ContextMenuRequested(int row, int col, const QPoint &pos)
{
  if (isBlocked())
    return;

  QPopupMenu *menu = new QPopupMenu();
  
    
  menu->insertItem(getPixmapIcon("chooseFieldsIcon"), tr("Choose Fields"), MENU_COLUMNS_WINDOW);  
  menu->insertSeparator();

  menu->insertItem(getPixmapIcon("copyIcon"), tr("Copy"), MENU_COPY);

  menu->insertSeparator();
  menu->setItemEnabled(MENU_COPY, numRows() > 0 && numCols() > 0);

  menu->insertItem(getPixmapIcon("killProcessIcon"), "Kill Process", MENU_KILL_PROCESS);
  menu->insertSeparator();
  menu->insertItem(getPixmapIcon("saveIcon"), "Save", MENU_SAVE);
  menu->insertSeparator();  
  menu->insertItem(getPixmapIcon("refreshTablesIcon"), "Refresh", MENU_REFRESH);
  
  int res = menu->exec(pos);
  delete menu;
  
  switch (res)
  {
    case MENU_COLUMNS_WINDOW:
      columnsWindow->show();
      columnsWindow->raise();
      columnsWindow->setFocus();
    break;

    case MENU_COPY:
      copy(row, col);
      break;

    case MENU_REFRESH:
      refresh();
      break;
    
    case MENU_SAVE:
      save();
      break;
    
    case MENU_KILL_PROCESS:
      {
        bool ok = false;
        for (int current_row = 0; current_row < numRows(); current_row++)
        {
          if (!isRowSelected(current_row))
            continue;
          if (mysql()->mysql()->mysqlKill(text(current_row,0).toLong()))
          {
            mysql()->messagePanel()->information(tr("Process killed successfully") + " :" +  text(current_row,0));
            ok = true;
          }
        }
        if (ok)
          refresh();
      }
      break;
  }
}