コード例 #1
0
ファイル: dialogusers.cpp プロジェクト: OrbMind/daybook
void DialogUsers::on_tableWidget_customContextMenuRequested(const QPoint &pos)
{
    QTableWidgetItem *q = ui->tableWidget->itemAt(pos);
    if ( q == NULL ) return;
    ui->tableWidget->selectRow(q->row()); // fix bug with quick right click

    contextTableMenu->actions().at(2)->setEnabled( ( QVariant(ui->tableWidget->item(q->row(),0)->data(DataRole::deleted)).toInt() == 0 )
                                                   and Act::userPermission(Act::editDirection,currentUserRights));
    contextTableMenu->actions().at(4)->setEnabled( ( QVariant(ui->tableWidget->item(q->row(),0)->data(DataRole::deleted)).toInt() == 1 )
                                                   and Act::userPermission(Act::editDirection,currentUserRights));

    QAction* selectedItem = contextTableMenu->exec(QCursor::pos());
    if ( !selectedItem ) return;
    if ( selectedItem->text() == "Добавить")
    {
        addNewUser();
    } else if ( selectedItem->text() == "Править")
    {
        ui->tableWidget->setCurrentCell(q->row(),q->column());
        editUser();
    } else if ( selectedItem->text() == "Удалить")
    {
        ui->tableWidget->setCurrentCell(q->row(),q->column());
        deleteUser();
    } else if ( selectedItem->text() == "Восстановить")
    {
        ui->tableWidget->setCurrentCell(q->row(),q->column());
        restoreUser();
    }
}
コード例 #2
0
void    GamesList::eraseAll()
{
    std::map< int, std::list< QTableWidgetItem* > >::const_iterator it = _rowList.begin();

    for (; it != _rowList.end(); ++it)
    {
        std::list< QTableWidgetItem* > list = (*it).second;

        QTableWidgetItem *frontItem = list.front();
        QTableWidgetItem *backItem = list.back();

        _gameList->removeCellWidget(frontItem->row(), frontItem->column());
        _gameList->removeCellWidget(backItem->row(), frontItem->column());

        list.remove(frontItem);
        list.remove(backItem);

        delete frontItem;
        delete backItem;
    }

    _gameList->setRowCount(0);

    _rowList.clear();
}
コード例 #3
0
void VolumeListingDialog::loadClicked() {
    std::vector<VolumeOrigin> selectedOrigins;

    // map selected rows to origins by comparing url column to origin url
    QList<QTableWidgetItem*> selectedItems = table_->selectedItems();
    int urlColumn = table_->columnCount()-1; // last columns contains URL
    for (int i=0; i<selectedItems.size(); i++) {
        QTableWidgetItem* item = selectedItems.at(i);
        if (item->column() == urlColumn) {
            std::string url = item->text().toStdString();
            for (size_t j=0; j<filteredOrigins_.size(); j++) {
                VolumeOrigin& origin = filteredOrigins_.at(j);
                if (origin.getURL() == url) {
                    selectedOrigins.push_back(origin);
                    break;
                }
            }
        }
    }

    if (!selectedOrigins.empty()) {
        close();
        emit(originsSelected(selectedOrigins, reader_));
    }
    else {
        LWARNINGC("voreen.qt.VolumeListingDialog", "no origins selected");
    }
}
コード例 #4
0
ファイル: keyframeedit.cpp プロジェクト: alstef/kdenlive
void KeyframeEdit::slotAdjustKeyframeInfo(bool seek)
{
    QTableWidgetItem *item = keyframe_list->currentItem();
    if (!item)
        return;
    int min = m_min;
    int max = m_max;
    QTableWidgetItem *above = keyframe_list->item(item->row() - 1, item->column());
    QTableWidgetItem *below = keyframe_list->item(item->row() + 1, item->column());
    if (above)
        min = getPos(above->row()) + 1;
    if (below)
        max = getPos(below->row()) - 1;

    m_position->blockSignals(true);
    m_position->setRange(min, max, true);
    m_position->setPosition(getPos(item->row()));
    m_position->blockSignals(false);
    QLocale locale;

    for (int col = 0; col < keyframe_list->columnCount(); ++col) {
        DoubleParameterWidget *doubleparam = static_cast <DoubleParameterWidget*>(m_slidersLayout->itemAtPosition(col, 0)->widget());
        if (!doubleparam)
            continue;
        doubleparam->blockSignals(true);
        if (keyframe_list->item(item->row(), col)) {
            doubleparam->setValue(locale.toDouble(keyframe_list->item(item->row(), col)->text()));
        } else {
            //qDebug() << "Null pointer exception caught: http://www.kdenlive.org/mantis/view.php?id=1771";
        }
        doubleparam->blockSignals(false);
    }
    if (KdenliveSettings::keyframeseek() && seek)
        emit seekToPos(m_position->getPosition() - m_min);
}
コード例 #5
0
void QuizGroupView::on_tbtProperties_clicked()
{
    QTableWidgetItem *item = ui->table->selectedItems()[0];
    QuizCell *cell = (QuizCell *)(ui->table->cellWidget(item->row(), item->column()));
    QuizNode *node = cell->node();
    node->editProperties();
}
コード例 #6
0
void ArchivingRulesDialog::deleteItem()
{
  _changed = true;
  saveBtn->setDisabled(false);
  
  QList<QTableWidgetItem*> selectedItems = archivingItemsTbl->selectedItems();

  QList<int> itemsToRemove;
  QTableWidgetItem* item;

  if (selectedItems.size() > 0)
  {
    itemsToRemove.clear();

    for(int i=0; i<selectedItems.size(); i++)
    {
      item = selectedItems.at(i);
      if(item->column() != 0)
        continue;

      itemsToRemove.push_front(item->row());
    }

    qSort(itemsToRemove.begin(), itemsToRemove.end());

    for(int i = 0; i < itemsToRemove.size();)
      archivingItemsTbl->removeRow(itemsToRemove.takeLast());
  }
}
コード例 #7
0
void qtDLGAttach::OnReturnPressed()
{
	if(tblProcList->selectedItems().count() <= 0) return;

	QTableWidgetItem *pItem = tblProcList->selectedItems()[0];

	OnProcessDoubleClick(pItem->row(),pItem->column());
}
コード例 #8
0
ファイル: Queue.cpp プロジェクト: dtamayo/OGRE
/*! @brief Called when the queue is right clicked.

    Connected to the customContextMenuRequested signal from the queue. It creates and displays a menu.
*/
void Queue::provideContextMenu(QPoint p) {
    QTableWidgetItem* item = itemAt(p);
    if (item->column() == 0 && item->row() != 0) {
        rowToRemove = item->row();
        QMenu menu;
        QAction* remove = new QAction("Remove", this);
        connect(remove, SIGNAL(triggered()), this, SLOT(removeAction()));
        menu.addAction(remove);
        menu.exec(QCursor::pos());
    }
}
コード例 #9
0
void QuizGroupView::timerEvent (QTimerEvent *)
{
	ui->tbtMoveUp->setEnabled(ui->table->rowCount()>0 && !ui->table->item(0, 0)->isSelected() && ui->table->selectedItems().count()>0);
	ui->tbtMoveDown->setEnabled(ui->table->rowCount()>0 && !ui->table->item(ui->table->rowCount()-1, 0)->isSelected() && ui->table->selectedItems().count()>0);
	ui->tbtUpLevel->setEnabled(node()->parent()!=NULL);
    if (ui->table->selectedItems().count()>0)
    {
        QTableWidgetItem *item = ui->table->selectedItems()[0];
        QuizCell *cell = (QuizCell *)(ui->table->cellWidget(item->row(), item->column()));
        QuizNode *node = cell->node();
        ui->tbtProperties->setEnabled(node->hasProperties());
    }
	ui->tbtRemove->setEnabled(ui->table->selectedItems().count()>0);
}
コード例 #10
0
ファイル: mainwindow.cpp プロジェクト: sevenbitbyte/fctdev
void MainWindow::selectionChanged() {
    QList<NetNode*> selectedNodes;
    QList<QTableWidgetItem*> items = ui->tableWidget->selectedItems();

    for(int i=0; i<items.size(); i++) {
        QTableWidgetItem* item = items[i];

        if(item->column() == 0) {
            NetNode* node = network->getNode(item->text());
            selectedNodes.push_back(node);
        }
    }

    netgraphics->updateSelection(selectedNodes);
}
コード例 #11
0
std::vector<QString>
UnusedAudioSelectionDialog::getSelectedAudioFileNames() const
{
    std::vector<QString> selectedNames;

    QList<QTableWidgetItem *> sItems = m_listView->selectedItems();
    QTableWidgetItem *item;
    
    for (int i = 0; i < sItems.size(); i++) {
            item = sItems.at(i);
            // Only reutrn items from column 0, which contains the filename
            // we're after:
            if (item->column() == 0) selectedNames.push_back(item->text());
    }

    return selectedNames;
};
コード例 #12
0
// Accept button:  set up to return editID pre-filter information
void US_SelectEdits::accepted()
{
   editIDs.clear();

   QList< QTableWidgetItem* > selitems = tw_data->selectedItems();

   if ( selitems.size() == 0 )
   {
      QMessageBox::information( this,
            tr( "No Data Selected" ),
            tr( "You have not selected any data.\nSelect or Cancel" ) );
      return;
   }

   // Get and return editIDs from selected runID items
   elabels                   = editmap.keys();

   for ( int ii = 0; ii < selitems.size(); ii++ )
   {  // Loop thru selected runIDs
      QTableWidgetItem* twi  = selitems.at( ii );
      if ( twi->column() != 0 )
      {
         int row  = twi->row();
         twi      = tw_data->item( row, 0 );
      }
      QString     rlabel = twi->text() + " :";

      // Get a list of edit items whose label contains runID label
      QStringList elabs  = elabels.filter( rlabel );

      for ( int jj = 0; jj < elabs.size(); jj++ )
      {  // Return editIDs from each edit in a run
         QString editID = editmap[ elabs[ jj ] ].editID;

         if ( ! editIDs.contains( editID ) )
            editIDs << editID;
      }
   }
qDebug() << "Acpt: editIDs size" << editIDs.size();
qDebug() << "Acpt: editIDs" << editIDs;

   accept();        // Signal that selection was accepted
   close();
}
コード例 #13
0
ファイル: tool_layerwidget.cpp プロジェクト: galek/Magus
/****************************************************************************
**
** Copyright (C) 2015
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

// Include
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QMessageBox>
#include <QHeaderView>
#include <QEvent>
#include <QPixmap>
#include <QImage>
#include <QMimeData>
#include <QTableWidgetItem>
#include <QTreeWidgetItem>
#include "tool_layerwidget.h"

namespace Magus
{
    //****************************************************************************/
    QtLayerWidget::QtLayerWidget(const QString& iconDir, QtSceneViewWidget* sceneViewWidget, QWidget* parent) : QWidget(parent)
    {
        setWindowTitle(QString("Layers"));
        QHBoxLayout* mainLayout = new QHBoxLayout;
        QVBoxLayout* tableLayout = new QVBoxLayout;
        mIconDir = iconDir;
        mLayerIdCounter = 1;
        mSceneViewWidget = sceneViewWidget;
        mListenToSceneViewWidget = 0;
        mListenToSceneId = 0;
        mListenToDropEvents = true;
        mListenToDeleteEvents = true;

        // Create table
        mTable = new QTableWidget(0, 3, this);
        mTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        mTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
        mTable->setAcceptDrops(true);
        mTable->setShowGrid(false);
        mTable->viewport()->installEventFilter(this);
        mTable->setColumnWidth(TOOL_LAYER_COLUMN_ICON, 2 * TOOL_LAYER_ICON_WIDTH);
        mTable->setColumnWidth(TOOL_LAYER_COLUMN_NAME, TOOL_LAYER_NAME_WIDTH);
        mTable->setColumnWidth(TOOL_LAYER_COLUMN_VISIBILITY, 2 * TOOL_LAYER_ICON_WIDTH);
        mTable->setSelectionBehavior(QAbstractItemView::SelectRows);
        setStyleSheet("QLineEdit{padding: 0 0px; margin-left: 0px; margin-right: 0px; max-height: 28px; height: 28px;}");
        connect(mTable, SIGNAL(clicked(QModelIndex)), this, SLOT(tableClicked(QModelIndex)));

        // Set headers
        QStringList headers;
        headers << tr("Layer") << tr("") << tr("Visibility");
        mTable->setHorizontalHeaderLabels(headers);
        QFont font;
        font.setBold(true);
        mTable->horizontalHeader()->setFont(font);

        // Contextmenu
        setContextMenuPolicy(Qt::CustomContextMenu);
        mContextMenu = new QMenu(mTable);
        mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_CREATE_LAYER, mTable));
        mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_DELETE_LAYER, mTable));
        mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_RENAME_LAYER, mTable));
        mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_ALL_VISIBLE, mTable));
        //mContextMenu->addAction(new QAction(QString("TEST"), mTable));
        connect(mContextMenu, SIGNAL(triggered(QAction*)), this, SLOT(contextMenuItemSelected(QAction*)));

        // Layout
        tableLayout->addWidget(mTable);
        mainLayout->addLayout(tableLayout);
        setLayout(mainLayout);
    }

    //****************************************************************************/
    QtLayerWidget::~QtLayerWidget(void)
    {
        QVector<QtLayer*>::iterator it;
        for (it = mLayerVec.begin(); it != mLayerVec.end(); ++it)
            delete *it;

        mLayerVec.clear(); // The table is automatically deleted when this widget is deleted
    }

    //****************************************************************************/
    bool QtLayerWidget::eventFilter(QObject* object, QEvent* event)
    {
        QMouseEvent* mouseEvent = (QMouseEvent*) event;
        switch ((int) event->type())
        {
            case QEvent::MouseButtonPress:
                mouseClickHandler(mouseEvent);
            break;

            case QEvent::MouseButtonDblClick:
                mouseDblClickHandler(mouseEvent);
            break;

            case QEvent::Drop:
                dropHandler(object, event);
            break;
        }
        return QObject::eventFilter(object, event);
    }

    //****************************************************************************/
    void QtLayerWidget::tableClicked(QModelIndex index)
    {
        // Toggle visibility
        int row = index.row();
        int col = index.column();
        QtLayer* layer = mLayerVec.at(row);
        if (col == TOOL_LAYER_COLUMN_VISIBILITY)
        {
            if (layer->visible == true)
                updateVisibilityIcon(row, false);
            else
                updateVisibilityIcon(row, true);
        }

        // Set associated sceneview to visible (if mSceneView available)
        if (mSceneViewWidget)
            mSceneViewWidget->setSceneViewVisible(layer->layerId);

        // Signal that layer is selected
        emit layerSelected(layer->layerId, layer->name);
}

    //****************************************************************************/
    void QtLayerWidget::mouseClickHandler(QMouseEvent* event)
    {
        switch ((int) event->button())
        {
            case Qt::LeftButton:
            {
                // TODO
            }
            break;

            case Qt::RightButton:
            {
                QPoint pos;
                pos.setX(event->screenPos().x());
                pos.setY(event->screenPos().y());
                mContextMenu->popup(pos);
            }
            break;
        }
    }

    //****************************************************************************/
    void QtLayerWidget::mouseDblClickHandler(QMouseEvent* event)
    {
        switch ((int) event->button())
        {
            case Qt::LeftButton:
            {
                if (mTable->currentColumn() == TOOL_LAYER_COLUMN_NAME)
                {
                    QTableWidgetItem* item = mTable->currentItem();
                    if (item->column() == TOOL_LAYER_COLUMN_NAME)
                    {
                        // Its the name; edit it
                        mTable->editItem(item);
                    }
                }
            }
            break;
        }
    }
コード例 #14
0
/****************************************************************************
**
** Copyright (C) 2016 - 2017
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

// Include
#include <QApplication>
#include <QDesktopWidget>
#include <QRect>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QMessageBox>
#include <QHeaderView>
#include <QEvent>
#include <QPixmap>
#include <QImage>
#include <QMimeData>
#include <QTableWidgetItem>
#include <QTreeWidgetItem>
#include <QVector2D>
#include "constants.h"
#include "paintlayer_widget.h"
#include "paintlayer_dockwidget.h"
#include "paintlayer_dialog.h"

//****************************************************************************/
PaintLayerWidget::PaintLayerWidget(const QString& iconDir, PaintLayerDockWidget* paintLayerDockWidget, QWidget* parent) :
    QWidget(parent),
    mPaintLayerDockWidget(paintLayerDockWidget)
{
    setWindowTitle(QString("Layers"));
    QHBoxLayout* mainLayout = new QHBoxLayout;
    QVBoxLayout* tableLayout = new QVBoxLayout;
    mIconDir = iconDir;
    mLayerIdCounter = 1;
    mListenToSceneId = 0;
    mListenToDeleteEvents = true;
    helperIntVector.clear();

    // Create table
    mTable = new QTableWidget(0, 4, this);
    mTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    mTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
    mTable->setAcceptDrops(false);
    mTable->setShowGrid(false);
    mTable->viewport()->installEventFilter(this);
    QRect rect = QApplication::desktop()->screenGeometry();
    mTable->setColumnWidth(TOOL_LAYER_COLUMN_ICON, 2 * TOOL_LAYER_ICON_WIDTH);
    mTable->setColumnWidth(TOOL_LAYER_COLUMN_NAME, TOOL_LAYER_NAME_WIDTH);
    mTable->setColumnWidth(TOOL_LAYER_COLUMN_VISIBILITY, 2 * TOOL_LAYER_ICON_WIDTH);
    mTable->setColumnWidth(TOOL_LAYER_COLUMN_FILLER, rect.width());
    mTable->setSelectionBehavior(QAbstractItemView::SelectRows);
    setStyleSheet("QLineEdit{padding: 0 0px; margin-left: 0px; margin-right: 0px; max-height: 28px; height: 28px;}");
    connect(mTable, SIGNAL(clicked(QModelIndex)), this, SLOT(tableClicked(QModelIndex)));
    connect(mTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(handleTableDoubleClicked(QModelIndex)));

    // Set headers
    QStringList headers;
    headers << tr("Edit") << tr("Layer name") << tr("Visibility") << tr("");
    mTable->setHorizontalHeaderLabels(headers);
    QFont font;
    font.setBold(true);
    mTable->horizontalHeader()->setFont(font);
    mTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);

    // Contextmenu
    setContextMenuPolicy(Qt::CustomContextMenu);
    mContextMenu = new QMenu(mTable);
    mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_CREATE_LAYER, mTable));
    mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_EDIT_LAYER, mTable));
    mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_DELETE_LAYER, mTable));
    mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_RENAME_LAYER, mTable));
    mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_ALL_VISIBLE, mTable));
    //mContextMenu->addAction(new QAction(QString("TEST"), mTable));
    connect(mContextMenu, SIGNAL(triggered(QAction*)), this, SLOT(contextMenuItemSelected(QAction*)));

    // Layout
    tableLayout->addWidget(mTable);
    mainLayout->addLayout(tableLayout);
    setLayout(mainLayout);
}

//****************************************************************************/
PaintLayerWidget::~PaintLayerWidget(void)
{
    QVector<QtLayer*>::iterator it;
    for (it = mLayerVec.begin(); it != mLayerVec.end(); ++it)
        delete *it;

    mLayerVec.clear(); // The table is automatically deleted when this widget is deleted
}

//****************************************************************************/
bool PaintLayerWidget::eventFilter(QObject* object, QEvent* event)
{
    QMouseEvent* mouseEvent = (QMouseEvent*) event;
    switch ((int) event->type())
    {
        case QEvent::MouseButtonPress:
            mouseClickHandler(mouseEvent);
        break;

        case QEvent::MouseButtonDblClick:
            mouseDblClickHandler(mouseEvent);
        break;

        break;
    }
    return QObject::eventFilter(object, event);
}

//****************************************************************************/
void PaintLayerWidget::tableClicked(QModelIndex index)
{
    // Toggle visibility
    int row = index.row();
    int col = index.column();
    QtLayer* layer = mLayerVec.at(row);
    if (col == TOOL_LAYER_COLUMN_VISIBILITY)
    {
        if (layer->visible)
            updateVisibilityIcon(row, false);
        else
            updateVisibilityIcon(row, true);
    }

    // Signal that layer is selected
    emit layerSelected(layer->layerId, layer->name);
}

//****************************************************************************/
QVector<int> PaintLayerWidget::getSelectedLayerIds(void)
{
    helperIntVector.clear();
    QList<QTableWidgetItem*> itemList = mTable->selectedItems();
    foreach(QTableWidgetItem* item, itemList)
    {
        // Do not append all items, but only the rows; so only mark in case of a distinct column
        if (item->column() == TOOL_LAYER_COLUMN_ICON)
            helperIntVector.append(item->data(Qt::UserRole).toInt());
    }

    return helperIntVector;
}

//****************************************************************************/
void PaintLayerWidget::mouseClickHandler(QMouseEvent* event)
{
    switch ((int) event->button())
    {
        case Qt::LeftButton:
        {
            // TODO
        }
        break;

        case Qt::RightButton:
        {
            QPoint pos;
            pos.setX(event->screenPos().x());
            pos.setY(event->screenPos().y());
            mContextMenu->popup(pos);
        }
        break;
    }
}

//****************************************************************************/
void PaintLayerWidget::mouseDblClickHandler(QMouseEvent* event)
{
    switch ((int) event->button())
    {
        case Qt::LeftButton:
        {
            if (mTable->currentColumn() == TOOL_LAYER_COLUMN_NAME)
            {
                QTableWidgetItem* item = mTable->currentItem();
                if (item->column() == TOOL_LAYER_COLUMN_NAME)
                {
                    // Its the name; edit it
                    mTable->editItem(item);
                }
            }
        }
        break;
    }
}

//****************************************************************************/
void PaintLayerWidget::contextMenuItemSelected(QAction* action)
{
    // ---------------- Create layer action ----------------
    if (action->text() == TOOL_LAYER_ACTION_CREATE_LAYER)
    {
        createDefaultPaintLayer();
        return;
    }
    else if (action->text() == TOOL_LAYER_ACTION_EDIT_LAYER)
    {
        editSelectedPaintLayer();
        return;
    }
    else if (action->text() == TOOL_LAYER_ACTION_DELETE_LAYER)
    {
        deleteSelectedPaintLayer();
    }
    else if (action->text() == TOOL_LAYER_ACTION_RENAME_LAYER)
    {
        QTableWidgetItem* item = mTable->currentItem();
        if (item && item->column() == TOOL_LAYER_COLUMN_NAME)
        {
            // Its the name; edit it
            mTable->editItem(item);
        }
    }
    else if (action->text() == TOOL_LAYER_ACTION_ALL_VISIBLE)
    {
        int rows = mTable->rowCount();
        for(int row = 0; row < rows; ++row)
            if (mLayerVec.at(row)->visible == false)
                updateVisibilityIcon(row, true);
    }
    else if (action->text() == QString ("TEST"))
    {
        //setLayerName(3, QString("Test"));
        //deleteLayer(QString("New layer 4"));
    }
}
コード例 #15
0
// context menu for table
void PublicTalks::showContextMenu(const QPoint &pos)
{
    qDebug() << "context menu" << pos.x() << pos.y();
    QMenu myMenu;
    myMenu.addAction(tr("Show Details..."));

    QTableWidgetItem *item = etable->itemAt(pos);
    if (!item) {
        qDebug() << "empty area";
        return;
    }
    if (item->column() != 1 || item->row() == 0) return;
    if (item->text() == "") return;
    bool speaker = (item->row() == 1);

    QAction* selectedItem = myMenu.exec(QCursor::pos());
    if (selectedItem) {
        if (item) {
            emit contextMenuShowPerson(item->text(),speaker);
        }
    }
}
void ScheduledTableManoeuvres::mousePressEvent(QMouseEvent *event)
{
    int column;
    // Get current selection
    QTableWidgetItem *selectedItem = currentItem();

    if ((event->buttons() & Qt::RightButton)){
        this->removeColumn(this->currentColumn());

        return;

    }



    // If the selected Item exists
    if (selectedItem)
    {

        QByteArray itemData;
        column=selectedItem->column();
        itemData.append(this->item(0,column)->text());

        //Erasing text
        this->item(0,column)->setText(" ");

        QMimeData *mimeData = new QMimeData;
        mimeData->setData("application/x-qabstractitemmodeldatalist",itemData);

        // Create drag
        QDrag *drag = new QDrag(this);
        drag->setMimeData(mimeData);

        drag->exec(Qt::CopyAction);
   }

    QTableWidget::mousePressEvent(event);
}
コード例 #17
0
ファイル: mainwindow.cpp プロジェクト: equation314/CCR-Plus
void MainWindow::onMenuTableEvent(const QPoint& pos)
{
    action_create_file->setEnabled(true);
    action_create_dir->setEnabled(true);
    action_open_dir->setEnabled(true);
    action_open_dir->setText("打开目录(&O)...");
    menu_table->clear();
    QTableWidgetItem* item = board_table->itemAt(pos);
    if (item)
    {
        int r = item->row(), c = item->column();
        detail_table->onShowDetail(r, c);
        r = Global::GetLogicalRow(r);
        Player* player = Global::g_contest.players[r];
        if (c > 1)
        {
            Problem* problem = Global::g_contest.problems[c - 2];
            dirByAction = Global::g_contest.src_path + player->Name() + "/" + problem->Directory() + "/";
            const Compiler* compiler = problem->GetCompiler(player->Name());
            fileByAction = !compiler ? "" : compiler->SourceFile();

            if (fileByAction.isEmpty())
            {
                playerByAction = player, problemByAction = problem;
                if (problem->Type() == Global::AnswersOnly || !problem->CompilerCount())
                    action_create_file->setEnabled(false);
                menu_table->addAction(action_create_file);
            }
            else
            {
                action_edit_file->setText(QString("编辑 \"%1\" (&E)...").arg(fileByAction));
                menu_table->addAction(action_edit_file);
            }

            menu_table->addSeparator();

            if (QDir(dirByAction).exists())
                menu_table->addAction(action_open_dir);
            else if (problem->Type() == Global::AnswersOnly || !problem->CompilerCount())
                menu_table->addAction(action_create_dir);
            else
            {
                action_open_dir->setEnabled(false);
                menu_table->addAction(action_open_dir);
            }
        }
        else
        {
            dirByAction = Global::g_contest.src_path + player->Name() + "/";
            fileByAction = player->Name();

            if (QDir(dirByAction).exists())
            {
                menu_table->addAction(action_open_dir);
                menu_table->addSeparator();
                action_remove_dir->setText(QString("删除选手 \"%1\" (&R)").arg(fileByAction));
                menu_table->addAction(action_remove_dir);
            }
            else menu_table->addAction(action_create_dir);
        }
    }
    else
    {
        menu_table->addAction(ui->action_refresh);
        menu_table->addSeparator();
        menu_table->addAction(ui->action_judge_selected);
        menu_table->addAction(ui->action_judge_unjudged);
        menu_table->addAction(ui->action_judge_all);

        menu_table->addAction(ui->action_stop);
    }
    menu_table->popup(QCursor::pos());
}
コード例 #18
0
void ArchivingRulesDialog::executeArchiving()
{ 
  if(_changed)
  { 
    QMessageBox::StandardButton answer;
    answer = QMessageBox::question(this, tr("O banco de dados deve ser atulalizado antes da execução"), 
        tr("Deseja salvar as regras de arquivamento?"),
      QMessageBox::Yes | QMessageBox::Cancel,
      QMessageBox::Cancel);

    if(answer == QMessageBox::Cancel)
      return;

    // Save the archiving roles
    std::vector<struct wsArchivingRule> rules = getFields();
    _manager->saveArchivingRules(rules);
    
    // Update the table with the generated IDS for each archiving role in database
    std::vector<struct wsArchivingRule> archivingRules;
    _manager->getArchivingRules(archivingRules);
    setFields(archivingRules);

    saveBtn->setDisabled(true);
    _changed = false;
  }

  QList<QTableWidgetItem*> selectedItems = archivingItemsTbl->selectedItems();

  QStringList arguments;
  arguments.push_back(_configFileName);

  QTableWidgetItem* item;

  if (selectedItems.size() > 0)
  {
    for(int i=0; i<selectedItems.size(); i++)
    {
      item = selectedItems.at(i);
      if(item->column() != 0)
        continue;

      arguments.push_back(item->data(Qt::UserRole).toString());
    }
  }
  else
  {
    QMessageBox::warning(this, tr("Resultado"), tr("Nenhuma regra de arquivamento está selecionada!\nO arquivamento não foi realizado!"), QMessageBox::Ok);
    return;
  }

  enableButtons(false);
  QString archivingProgramPath = QCoreApplication::applicationDirPath() + "/arquivador";

  #ifdef WIN32
    archivingProgramPath.append(".exe");
  #endif

  // Check if the "arquivador" program is at correct folder and it can be executed
  if(!QFile::exists(archivingProgramPath))
  {
    enableButtons(true);
    QMessageBox::warning(this, tr("Resultado"), tr("O arquivamento não foi realizado!\n Programa \"arquivador\" não foi encontrado."), QMessageBox::Ok);
    return;
  }

  _process.start(archivingProgramPath, arguments);
}
コード例 #19
0
int TableWidgetItem::column ( lua_State * L ) // int
{
	QTableWidgetItem* lhs = ValueInstaller2<QTableWidgetItem>::check( L, 1 );
	Util::push( L, lhs->column() );
	return 1;
}