예제 #1
0
/** Initializes this widget. */
void CModuleResultView::initView() {
    // see also csearchresultview.cpp
    setToolTip(tr("Works chosen for the search and the number of the hits in each work"));
    setHeaderLabels( QStringList(tr("Work")) << tr("Hits") );

    setColumnWidth(0, util::tool::mWidth(this, 8));
    setColumnWidth(1, util::tool::mWidth(this, 4));
    QSize sz(util::tool::mWidth(this, 13), util::tool::mWidth(this, 5));
    //setMinimumSize(sz);
    m_size = sz;
    /// \todo sorting
    //setSorting(0, true);
    //setSorting(1, true);

    //setup the popup menu
    m_popup = new QMenu(this);

    m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
    m_actions.copyMenu->setIcon(CResMgr::searchdialog::result::moduleList::copyMenu::icon());
    m_actions.copy.result = new QAction(tr("Reference only"), this);
    BT_CONNECT(m_actions.copy.result, SIGNAL(triggered()),
               this,                  SLOT(copyResult()));
    m_actions.copyMenu->addAction(m_actions.copy.result);
    m_actions.copy.resultWithText = new QAction(tr("Reference with text"), this);
    BT_CONNECT(m_actions.copy.resultWithText, SIGNAL(triggered()),
               this,                           SLOT(copyResultWithText()));
    m_actions.copyMenu->addAction(m_actions.copy.resultWithText);
    m_popup->addMenu(m_actions.copyMenu);

    m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
    m_actions.saveMenu->setIcon(CResMgr::searchdialog::result::moduleList::saveMenu::icon());
    m_actions.save.result = new QAction(tr("Reference only"), this);
    BT_CONNECT(m_actions.save.result, SIGNAL(triggered()),
               this,                  SLOT(saveResult()));
    m_actions.saveMenu->addAction(m_actions.save.result);
    m_actions.save.resultWithText = new QAction(tr("Reference with text"), this);
    BT_CONNECT(m_actions.save.resultWithText, SIGNAL(triggered()),
               this,                          SLOT(saveResultWithText()));
    m_actions.saveMenu->addAction(m_actions.save.resultWithText);
    m_popup->addMenu(m_actions.saveMenu);

    m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
    m_actions.printMenu->setIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon());
    m_actions.print.result = new QAction(tr("Reference with text"), this);
    BT_CONNECT(m_actions.print.result, SIGNAL(triggered()),
               this,                   SLOT(printResult()));
    m_actions.printMenu->addAction(m_actions.print.result);
    m_popup->addMenu(m_actions.printMenu);
}
예제 #2
0
  void ParallelCGCudaTask<N, T>::execute(const Thread* caller){
    /*Zero range, skip allocation/computation*/
    if(cmat->getMRange(TID)->range == 0)
      return;

    if(TID == 0){
      Vector<T>::mul(*r, *b, *b);
      bnorm = Sqrt(r->sum());
    }
    caller->sync();

    switch(subTask){
    case Allocate:
#if 1
      try{
        /*Try to allocate all the memory needed. If this fails,
          deallocate and throw an exception*/
        allocate(caller);
      }catch(CUDAException& e){
        std::cerr << e.getError();
        valid = false;
        deallocate(caller);
        throw;
      }catch(Exception& e){
        std::cerr << e.getError();
        throw;
      }
#else
      allocate(caller);
#endif
      break;
    case Deallocate:
      deallocate(caller);
      break;
    case CopyResult:
      copyResult(caller);
      break;
    case UpdateBlocks:
      updateBlocks(caller);
      break;
    case SolveSystem:
      solveSystem(caller);
      break;
    }
  }
예제 #3
0
void MainWindow::setupUi()
{
	QHBoxLayout *horizontalLayout, *buttonLayout, *button2Layout;
	QVBoxLayout *verticalLayout, *leftLayout;

	QWidget* widget = new QWidget;
	setCentralWidget(widget);
	tableWidget = new QTableWidget;
	horizontalLayout = new QHBoxLayout;
	buttonLayout = new QHBoxLayout;
	button2Layout = new QHBoxLayout;
	verticalLayout = new QVBoxLayout;
	leftLayout = new QVBoxLayout;
	bAdd = new QPushButton("Add", this);
	bRemove = new QPushButton("Remove", this);
	buttonLayout->addWidget(bAdd);
	buttonLayout->addWidget(bRemove);
	bUp = new QPushButton("Move Up", this);
	bDown = new QPushButton("Move Down", this);
	button2Layout->addWidget(bUp);
	button2Layout->addWidget(bDown);
	leftLayout->addWidget(tableWidget);
	leftLayout->addLayout(buttonLayout);
	leftLayout->addLayout(button2Layout);
	connect(bAdd, SIGNAL(clicked()), this, SLOT(slAddRow()));
	connect(bRemove, SIGNAL(clicked()), this, SLOT(slRemoveRow()));
	connect(bUp, SIGNAL(clicked()), this, SLOT(slUp()));
	connect(bDown, SIGNAL(clicked()), this, SLOT(slDown()));
	bUp->setEnabled(false);
	bDown->setEnabled(false);
	horizontalLayout->addLayout(leftLayout, 30);
	horizontalLayout->addLayout(verticalLayout, 70);
	openSchema = new QAction(tr("&Open Schema"), this);
	openSchema->setStatusTip(tr("Open a schema file"));
	openSchema->setShortcut(QKeySequence("Ctrl+O"));
	saveSchema = new QAction(tr("&Save Schema"), this);
	saveSchema->setStatusTip(tr("Save this schema file"));
	saveSchema->setShortcut(QKeySequence("Ctrl+S"));
	openText = new QAction(tr("&Load a text file"), this);
	openText->setStatusTip(tr("Load a text file"));
	openText->setShortcut(QKeySequence("Ctrl+L"));
	updateText = new QAction(tr("Update result"), this);
	updateText->setStatusTip(tr("Update the text replacement"));
	updateText->setShortcut(QKeySequence("Ctrl+U"));
	schemaMenu = menuBar()->addMenu(tr("File"));
	textMenu = menuBar()->addMenu(tr("Edit"));
	menuBar()->addAction(updateText);
	bAdd->setEnabled(true);
	bRemove->setEnabled(false);
	aAdd = new QAction(tr("Add Row"), this);
	aAdd->setShortcut(QKeySequence("Ctrl++"));
	aRemove = new QAction(tr("Remove Row"), this);
	aRemove->setShortcut(QKeySequence("Ctrl+-"));
	aUp = new QAction(tr("Move Up"), this);
	aUp->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up));
	aDown = new QAction(tr("Move Down"), this);
	aDown->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down));
	copy = new QAction(tr("Copy result to clipboard"), this);
	menuBar()->addAction(copy);
	batch = new QAction(tr("Batch Transform"), this);
	menuBar()->addAction(batch);
	schemaMenu->addAction(openSchema);
	schemaMenu->addAction(saveSchema);
	schemaMenu->addAction(openText);
	textMenu->addAction(aAdd);
	textMenu->addAction(aRemove);
	textMenu->addAction(aUp);
	textMenu->addAction(aDown);
	aUp->setEnabled(false);
	aDown->setEnabled(false);
	aAdd->setEnabled(true);
	aRemove->setEnabled(false);
	connect(tableWidget, SIGNAL(currentCellChanged(int,int,int,int)), this,
			SLOT(CurrentCellChanged(int,int,int,int)));
	connect(openSchema, SIGNAL(triggered()), this, SLOT(slOpenSchema()));
	connect(saveSchema, SIGNAL(triggered()), this, SLOT(slSaveSchema()));
	connect(openText, SIGNAL(triggered()), this, SLOT(slOpenText()));
	connect(updateText, SIGNAL(triggered()), this, SLOT(slUpdateText()));
	connect(batch, SIGNAL(triggered()), this, SLOT(batchTransform()));
	connect(copy, SIGNAL(triggered()), this, SLOT(copyResult()));
	before = new QTextEdit(this);
	after = new QTextEdit(this);
	verticalLayout->addWidget(before);
	verticalLayout->addWidget(after);
	after->setReadOnly(true);
	tableWidget->insertColumn(0);
	tableWidget->insertColumn(1);
	tableWidget->insertColumn(2);
	tableWidget->insertColumn(3);
	tableWidget->insertColumn(4);
	QStringList headers;
	headers << "RE";
	headers << "R";
	headers << "CS";
	headers << "Replace";
	headers << "With";
	tableWidget->setHorizontalHeaderLabels(headers);
	tableWidget->setColumnWidth(0, 22);
	tableWidget->setColumnWidth(1, 22);
	tableWidget->setColumnWidth(2, 22);
	tableWidget->setColumnWidth(3, 140);
	tableWidget->setColumnWidth(4, 140);
	tableWidget->setMaximumWidth(365);
	tableWidget->setMinimumWidth(365);
	tableWidget->setShowGrid(0);
	widget->setLayout(horizontalLayout);
	connect(aAdd, SIGNAL(triggered()), this, SLOT(slAddRow()));
	connect(aRemove, SIGNAL(triggered()), this, SLOT(slRemoveRow()));
	connect(aUp, SIGNAL(triggered()), this, SLOT(slUp()));
	connect(aDown, SIGNAL(triggered()), this, SLOT(slDown()));
	tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
	tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
	this->setWindowTitle(
			tr(
					"Replacement Workspace (written by Adam Baker; released under GPL)"));
}