コード例 #1
0
ファイル: GuiTools.cpp プロジェクト: cephdon/OMOptim
QMenu* GuiTools::createProblemPopupMenu(ProjectBase* project, QWidget* mainWindow, const QPoint & iPoint,Problem* selectedProblem,int numProblem)
{
    QMenu *menu = new QMenu();

    //Open folder
    //Open folder
    QAction *openFolderAct = new QAction("Open folder",menu);
    connect(openFolderAct,SIGNAL(triggered()),selectedProblem,SLOT(openFolder()));
    QIcon icon;
    icon.addPixmap(QPixmap(QString::fromUtf8(":/icons/folder")), QIcon::Normal, QIcon::Off);
    openFolderAct->setIcon(icon);
    //openFolderAct->setIconSize(QSize(20, 20));
    menu->addAction(openFolderAct);

    //Rename problem
    QAction *renameAct = new QAction("Rename problem...",menu);
    renameAct->setData(numProblem);
    connect(renameAct,SIGNAL(triggered()),mainWindow,SLOT(renameProblem()));
    menu->addAction(renameAct);

    //Remove problem
    QAction *removeAct = new QAction("Remove problem",menu);
    removeAct->setData(numProblem);
    connect(removeAct,SIGNAL(triggered()),mainWindow,SLOT(removeProblem()));
    QIcon iconRem;
    iconRem.addPixmap(QPixmap(QString::fromUtf8(":/icons/Remove")), QIcon::Normal, QIcon::Off);
    removeAct->setIcon(iconRem);
    menu->addAction(removeAct);

    return menu;
}
コード例 #2
0
ファイル: ProjectBase.cpp プロジェクト: OpenModelica/OMOptim
void ProjectBase::removeCases(QList<OMCase*> cases)
{
    Problem* problem;
    Result* result;
    for(int i=0;i<cases.size();i++)
    {
        problem = dynamic_cast<Problem*>(cases.at(i));
        if(problem)
            removeProblem(problem);
        else
        {
            result = dynamic_cast<Result*>(cases.at(i));
            if(result)
                removeResult(result);
        }
    }
}
コード例 #3
0
ファイル: XJudgerMain.cpp プロジェクト: davidsun/XJudger
XJudgerMain::XJudgerMain(QMainWindow *parent): QMainWindow(parent){
	//Basic Building
	CurrentDir = getCwd();
	if (objectName().isEmpty()) setObjectName("XJudgerMain");
	setGeometry((QApplication::desktop() -> width() - 800) / 2, (QApplication::desktop() -> height() - 600) / 2, 800, 600);
	QIcon WindowIcon;
	setWindowIcon(QIcon(":/Icons/XJudgerMain.png"));
    MainActionExit = new QAction(this);
    MainActionExit -> setObjectName("MainActionExit");
	MainActionAbout = new QAction(this);
	MainActionAbout -> setObjectName("MainActionAbout");
    CentralWidget = new QWidget(this);
    CentralWidget -> setObjectName("CentralWidget");
    TestForm = new XJudgerTest(this);
	ViewForm = new XJudgerView(this);
	setCentralWidget(CentralWidget);
    MenuBar = new QMenuBar(this);
    MenuBar -> setObjectName("MenuBar");
    MainMenuFile = new QMenu(MenuBar);
    MainMenuFile -> setObjectName("MainMenuFile");
	MainMenuHelp = new QMenu(MenuBar);
	MainMenuHelp -> setObjectName("MainMenuHelp");
    setMenuBar(MenuBar);
    StatusBar = new QStatusBar(this);
    StatusBar -> setObjectName("StatusBar");
    setStatusBar(StatusBar);
    MenuBar -> addAction(MainMenuFile -> menuAction());
    MainMenuFile -> addAction(MainActionExit);
    MenuBar -> addAction(MainMenuHelp -> menuAction());
	MainMenuHelp -> addAction(MainActionAbout);
	MainTab = new QTabWidget(this);
	MainTab -> setObjectName("MainTab");
	DataConfig = new DataInfo(CurrentDir);
	LayoutMain = new QGridLayout(CentralWidget);
	LayoutMain -> setObjectName("LayoutMain");
	LayoutMain -> addWidget(MainTab, 0, 0, 0, 0);
	
	//Building TabData
	TabData = new QWidget;
	TabData -> setObjectName(QString::fromUtf8("TabData"));
	MainTab -> addTab(TabData, QString::fromUtf8("Data"));
	GroupViewProb = new QGroupBox(TabData);
	GroupViewProb -> setObjectName(QString::fromUtf8("GroupViewProb"));
	GroupViewCase = new QGroupBox(TabData);
	GroupViewCase -> setObjectName(QString::fromUtf8("GroupViewCase"));
	GroupViewData = new QGroupBox(TabData);
	GroupViewData -> setObjectName(QString::fromUtf8("GroupViewData"));
	MainViewData = new TreeView(GroupViewData);
	MainViewData -> setObjectName(QString::fromUtf8("MainViewData"));
	MainViewData -> setMaximumWidth(200);

	TextProbName = new QPlainTextEdit(GroupViewProb);
	TextProbName -> setObjectName("TextProbName");
	TextProbName -> setMaximumHeight(30);
	TextProbName -> setTabChangesFocus(1);
	LabelProb = new QLabel(GroupViewProb);
	LabelProb -> setObjectName("LabelProb");
	LabelProb -> setText("Problem Name: ");
	TextInput = new QPlainTextEdit(GroupViewProb);
	TextInput -> setObjectName("TextInput");
	TextInput -> setMaximumHeight(30);
	TextInput -> setTabChangesFocus(1);
	LabelInput = new QLabel(GroupViewProb);
	LabelInput -> setObjectName("LabelInput");
	LabelInput -> setText("Input File Name: ");
	TextOutput = new QPlainTextEdit(GroupViewProb);
	TextOutput -> setObjectName("TextOutput");
	TextOutput -> setMaximumHeight(30);
	TextOutput -> setTabChangesFocus(1);
	LabelOutput = new QLabel(GroupViewProb);
	LabelOutput -> setObjectName("LabelOutput");
	LabelOutput -> setText("Output File Name: ");
	TextSource = new QPlainTextEdit(GroupViewProb);
	TextSource -> setObjectName("TextSource");
	TextSource -> setMaximumHeight(30);
	TextSource -> setTabChangesFocus(1);
	LabelSource = new QLabel(GroupViewProb);
	LabelSource -> setObjectName("LabelSource");
	LabelSource -> setText("Source File Name: ");
	
	LabelCaseInput = new QLabel(GroupViewCase);
	LabelCaseInput -> setObjectName("LabelCaseInput");
	LabelCaseInput -> setText("Input File Name: ");
	TextCaseInput = new QPlainTextEdit(GroupViewCase);
	TextCaseInput -> setObjectName("TextCaseInput");
	TextCaseInput -> setMaximumHeight(30);
	TextCaseInput -> setTabChangesFocus(1);
	LabelCaseOutput = new QLabel(GroupViewCase);
	LabelCaseOutput -> setObjectName("LabelCaseOutput");
	LabelCaseOutput -> setText("Output File Name: ");
	TextCaseOutput = new QPlainTextEdit(GroupViewProb);
	TextCaseOutput -> setObjectName("TextCaseOutput");
	TextCaseOutput -> setMaximumHeight(30);
	TextCaseOutput -> setTabChangesFocus(1);
	LabelCaseScore = new QLabel(GroupViewCase);
	LabelCaseScore -> setObjectName("LabelCaseScore");
	LabelCaseScore -> setText("Score: ");
	TextCaseScore = new QPlainTextEdit(GroupViewCase);
	TextCaseScore -> setObjectName("TextCaseScore");
	TextCaseScore -> setMaximumHeight(30);
	TextCaseScore -> setTabChangesFocus(1);
	LabelCaseTL = new QLabel(GroupViewCase);
	LabelCaseTL -> setObjectName("LabelCaseTL");
	LabelCaseTL -> setText("Time Limit (second): ");
	TextCaseTL = new QPlainTextEdit(GroupViewCase);
	TextCaseTL -> setObjectName("TextCaseTL");
	TextCaseTL -> setMaximumHeight(30);
	TextCaseTL -> setTabChangesFocus(1);
	LabelCaseML = new QLabel(GroupViewCase);
	LabelCaseML -> setObjectName("LabelCaseML");
	LabelCaseML -> setText("Memory Limit (kb): ");
	TextCaseML = new QPlainTextEdit(GroupViewCase);
	TextCaseML -> setObjectName("TextCaseML");
	TextCaseML -> setMaximumHeight(30);
	TextCaseML -> setTabChangesFocus(1);

	LayoutTabData = new QGridLayout(TabData);
	LayoutTabData -> setObjectName("LayoutTabData");
	LayoutTabData -> addWidget(GroupViewData, 0, 0, 10, 1, Qt::AlignLeft);
	LayoutTabData -> addWidget(GroupViewProb, 0, 1, 10, 1, Qt::AlignTop);
	LayoutTabData -> addWidget(GroupViewCase, 0, 1, 10, 1, Qt::AlignTop);
	GroupViewProb -> setVisible(0);
	GroupViewCase -> setVisible(0);
	LayoutGroupProb = new QGridLayout(GroupViewProb);
	LayoutGroupProb -> setObjectName("LayoutGroupProb");
	LayoutGroupProb -> addWidget(TextProbName, 0, 1, 1, 1);
	LayoutGroupProb -> addWidget(LabelProb, 0, 0, 1, 1);
	LayoutGroupProb -> addWidget(TextInput, 1, 1, 1, 1);
	LayoutGroupProb -> addWidget(LabelInput, 1, 0, 1, 1);
	LayoutGroupProb -> addWidget(TextOutput, 2, 1, 1, 1);
	LayoutGroupProb -> addWidget(LabelOutput, 2, 0, 1, 1);
	LayoutGroupProb -> addWidget(TextSource, 3, 1, 1, 1);
	LayoutGroupProb -> addWidget(LabelSource, 3, 0, 1, 1);
	LayoutGroupProb -> setSizeConstraint(QLayout::SetMinAndMaxSize);
	LayoutGroupData = new QGridLayout(GroupViewData);
	LayoutGroupData -> setObjectName("LayoutGroupData");
	LayoutGroupData -> setSizeConstraint(QLayout::SetMinAndMaxSize);
	LayoutGroupData -> addWidget(MainViewData, 0, 0, 1, 1);
	LayoutGroupCase = new QGridLayout(GroupViewCase);
	LayoutGroupCase -> setObjectName("LayoutGroupCase");
	LayoutGroupCase -> addWidget(TextCaseInput, 0, 1, 1, 1);
	LayoutGroupCase -> addWidget(LabelCaseInput, 0, 0, 1, 1);
	LayoutGroupCase -> addWidget(TextCaseOutput, 1, 1, 1, 1);
	LayoutGroupCase -> addWidget(LabelCaseOutput, 1, 0, 1, 1);
	LayoutGroupCase -> addWidget(TextCaseScore, 2, 1, 1, 1);
	LayoutGroupCase -> addWidget(LabelCaseScore, 2, 0, 1, 1);
	LayoutGroupCase -> addWidget(TextCaseTL, 3, 1, 1, 1);
	LayoutGroupCase -> addWidget(LabelCaseTL, 3, 0, 1, 1);
	LayoutGroupCase -> addWidget(TextCaseML, 4, 1, 1, 1);
	LayoutGroupCase -> addWidget(LabelCaseML, 4, 0, 1, 1);
	
	//Building TabTest
	TabTest = new QWidget;
	TabTest -> setObjectName(QString::fromUtf8("TabTest"));
	MainTab -> addTab(TabTest, QString::fromUtf8("Test"));
	MainViewScore = new TreeView(TabTest);
	MainViewScore -> setObjectName(QString::fromUtf8("MainViewScore"));
	MainViewScore -> setSelectionMode(QAbstractItemView::ExtendedSelection);
	MainViewScore -> setRootIsDecorated(0);
	MainViewScore -> setSortingEnabled(1);
	MainButtonTest = new QPushButton(TabTest);
	MainButtonTest -> setObjectName(QString::fromUtf8("MainButtonTest"));
	MainButtonTestAll = new QPushButton(TabTest);
	MainButtonTestAll -> setObjectName(QString::fromUtf8("MainButtonTestAll"));
    MainButtonRefresh = new QPushButton(TabTest);
	MainButtonRefresh -> setObjectName(QString::fromUtf8("MainButtonRefresh"));
	LayoutTabTest = new QGridLayout(TabTest);
	LayoutTabTest -> setObjectName("LayoutTabTest");
	LayoutTabTest -> addWidget(MainViewScore, 0, 0, 1, 4);
	LayoutTabTest -> addWidget(MainButtonTest, 1, 0, 1, 1);
	LayoutTabTest -> addWidget(MainButtonTestAll, 1, 1, 1, 1);
	LayoutTabTest -> addWidget(MainButtonRefresh, 1, 2, 1, 1);
	
	//Building MenuData
	MenuData = new QMenu(this);
	MenuData -> setObjectName("MenuData");
	MainViewData -> setMenu(MenuData);
	QAction *ActProbInsert = MenuData -> addAction("Insert Problem");
	QAction *ActProbRemove = MenuData -> addAction("Remove Problem");
	MenuData -> addSeparator();
	QAction *ActCaseInsert = MenuData -> addAction("Insert Test Case");
	QAction *ActCaseRemove = MenuData -> addAction("Remove Test Case");
	MenuData -> addSeparator();
	QAction *ActConfigCase = MenuData -> addAction("Automatically Configing Test Cases");

	//Set Title
    setWindowTitle(ProjectName " - " MainVersion " - " VersionNumber);
    MainActionExit -> setText("Exit");
	MainActionAbout -> setText("About");
    MainMenuFile -> setTitle("File");
	MainMenuHelp -> setTitle("Help");
    MainButtonTest -> setText("Test");
    MainButtonTestAll -> setText("Test All");
    MainButtonRefresh -> setText("Refresh");
	
	//Connecting Objects
	connect(MainActionExit, SIGNAL(triggered()), this, SLOT(shut()));
	connect(MainActionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
	connect(ActProbInsert, SIGNAL(triggered()), this, SLOT(insertProblem()));
	connect(ActProbRemove, SIGNAL(triggered()), this, SLOT(removeProblem()));
	connect(ActCaseInsert, SIGNAL(triggered()), this, SLOT(insertTestCase()));
	connect(ActCaseRemove, SIGNAL(triggered()), this, SLOT(removeTestCase()));
	connect(ActConfigCase, SIGNAL(triggered()), this, SLOT(configTestCase()));
	connect(MainButtonTest, SIGNAL(clicked()), this, SLOT(testSelUser()));
	connect(MainButtonTestAll, SIGNAL(clicked()), this, SLOT(testAllUser()));
	connect(MainButtonRefresh, SIGNAL(clicked()), this, SLOT(scoreRefresh()));
	connect(MainViewData, SIGNAL(leftClicked()), this, SLOT(showProbCase()));
	connect(MainViewData, SIGNAL(rightClicked()), this, SLOT(showProbCase()));
	connect(MainViewData, SIGNAL(keyPressed(int)), this, SLOT(showProbCase()));
	connect(MainViewScore, SIGNAL(doubleClicked()), this, SLOT(viewUserInfo()));
	//Connect to Case Change
	connect(TextCaseInput, SIGNAL(textChanged()), this, SLOT(updateTestCase()));
	connect(TextCaseScore, SIGNAL(textChanged()), this, SLOT(updateTestCase()));
	connect(TextCaseOutput, SIGNAL(textChanged()), this, SLOT(updateTestCase()));
	connect(TextCaseTL, SIGNAL(textChanged()), this, SLOT(updateTestCase()));
	connect(TextCaseML, SIGNAL(textChanged()), this, SLOT(updateTestCase()));
	//Connect to Problem Change
	connect(TextInput, SIGNAL(textChanged()), this, SLOT(updateProblem()));
	connect(TextSource, SIGNAL(textChanged()), this, SLOT(updateProblem()));
	connect(TextOutput, SIGNAL(textChanged()), this, SLOT(updateProblem()));
	connect(TextProbName, SIGNAL(textChanged()), this, SLOT(updateProblem()));
	
	//List -- Show Objects
	updateDir();
	showData();
}