Widget::Widget(QWidget *parent) : QWidget (parent) { mainLayout=new QVBoxLayout(this); m_input=new inputWidget; m_help=new QWebView; m_help->load(QUrl("help/help.html")); QHBoxLayout* v=new QHBoxLayout; QPushButton* p1=new QPushButton(tr("Почати розрахунки")); QPushButton* pF=new QPushButton(tr("Завантажити з файлу")); p2=new QPushButton(tr("Показати поля вводу")); p2->setCheckable(true); p2->setChecked(true); QPushButton* p3=new QPushButton(tr("Очистити результати")); QPushButton* pH=new QPushButton(tr("Допомога")); p1->setMinimumWidth(160); p2->setMinimumWidth(200); p3->setMinimumWidth(200); v->addWidget(p1); v->addWidget(pF); v->addWidget(p2); v->addWidget(p3); v->addWidget(pH); m_buttonGroupBox=new QGroupBox; m_buttonGroupBox->setLayout(v); connect(p1,SIGNAL(clicked()),this,SLOT(getDatasFromForm())); connect(p2,SIGNAL(clicked(bool)),this,SLOT(showHideInput(bool))); connect(p3,SIGNAL(clicked()),this,SLOT(deleteData())); connect(pF,SIGNAL(clicked()),this,SLOT(getDatasFromFile())); connect(pH,SIGNAL(clicked()),this,SLOT(showHelp())); connect(m_input,SIGNAL(nEqChanged(QSize)),this,SLOT(myResize(QSize))); #ifdef WITH_EFFECTS QCheckBox* ch=new QCheckBox(tr("Увімкнути ефекти")); ch->setChecked(true); connect(ch,SIGNAL(clicked(bool)),this,SLOT(changeEffects(bool))); //v->addWidget(ch); m_enableEffects=true; m_ani=new QPropertyAnimation(this,"size"); #endif mainLayout->addWidget(m_buttonGroupBox,0,Qt::AlignTop); QVBoxLayout* m_inputL=new QVBoxLayout; m_inputL->addWidget(m_input); m_inputGB=new QGroupBox; m_inputGB->setLayout(m_inputL); mainLayout->addWidget(m_inputGB,0,Qt::AlignTop); mainLayout->addStretch(1); f=NULL; tablesScrollArea=NULL; tablesGroupBox=NULL; tablesLayout=NULL; m_isTables=false; m_isData=false; }
CQueryWindowOptionsDialog::CQueryWindowOptionsDialog(QWidget* parent, CMySQLServer *m, const char* name) :CConfigDialog(parent, name), mysql(m) { #ifdef DEBUG qDebug("CQueryWindowOptionsDialog::CQueryWindowOptionsDialog()"); #endif if (!name) setName("CQueryWindowOptionsDialog"); setMinimumHeight(308); setCaption(tr("Query Configuration Dialog")); insertTab(new CQueryWindowOptionsTab((QWidget *) tab())); insertTab(new CQueryOptionsTab((QWidget *) tab())); okPushButton->setText(tr("&Apply")); QWhatsThis::add(okPushButton, tr("Click to Apply changes.")); myResize(460, 308); config = new CConfig(m->connectionName(), m->connectionsPath()); setDefaultValues(config); }
void Widget::deleteData() { if(m_isData) { simplex.clear(); if(f!=NULL) delete [] f; while(!tables.isEmpty()) { QTableWidget* t=tables.dequeue(); tablesLayout->removeWidget(t); delete t; } m_isTables=false; mainLayout->removeWidget(tablesScrollArea); if(tablesScrollArea!=NULL) delete tablesScrollArea; myResize(0,0); } m_isData=false; if(mainLayout->itemAt(2)==0) mainLayout->addStretch(1); }
/* Handle user input */ void myKeyHandler(unsigned char ch, int x, int y) { switch(ch) { case 'c': resetCamera(); printf("Camera reset.\n"); break; case 's': case 'S': if (disp_style == DS_SOLID) { disp_style = DS_WIRE; } else { disp_style = DS_SOLID; } print_disp_style(); break; case 'd': /* Cycle through the various display modes */ disp_mode = (disp_mode + 1) % DM_MAX; print_disp_mode(); break; case 'D': /* Cycle through the various display modes backwards */ /* By adding DM_MAX, the args to "%" wil never be negative */ disp_mode = (disp_mode + DM_MAX - 1) % DM_MAX; print_disp_mode(); break; case ',': rotateCamera(5, X_AXIS); break; case '<': rotateCamera(-5, X_AXIS); break; case '.': rotateCamera(5, Y_AXIS); break; case '>': rotateCamera(-5, Y_AXIS); break; case '/': rotateCamera(5, Z_AXIS); break; case '?': rotateCamera(-5, Z_AXIS); break; case '+': /* Zoom in */ zoomCamera(-0.1); break; case '=': /* Zoom out */ zoomCamera(0.1); break; case 'z': myResize(win_width, win_height); printf("Window set to default size.\n"); break; case 't': performanceTest(); break; case 'q': /* Quit with exit code 0 */ endCanvas(0); break; /*********************************************/ /* ADD ADDITIONAL KEYS HERE */ /*********************************************/ case 'i': // If disp mode is not in cone_tri_calc, don't change variable if (disp_mode != DM_CONE_TRI_CALC) { break; } // if // Increases the radius of triangles in draw_cone_tri_calc r += 0.1; printf("Radius increased by 0.1\n"); break; case 'I': // If disp mode is not in cone_tri_calc, don't change variable if (disp_mode != DM_CONE_TRI_CALC) { break; } // if r -= 0.1; if (r < 0.1) { r = 0.1; } // if else { printf("Radius decreased by 0.1\n"); } // else break; case 'o': // If disp mode is not in cone_tri_calc, don't change variable if (disp_mode != DM_CONE_TRI_CALC) { break; } // if // Increase the height of triangles in draw_cone_tri_calc h += 0.1; printf("Height increased by 0.1\n"); break; case 'O': // If disp mode is not in cone_tri_calc, don't change variable if (disp_mode != DM_CONE_TRI_CALC) { break; } // if h -= 0.1; if (h < 0.1) { h = 0.1; } // if else { printf("Height decreased by 0.1\n"); } // else break; case 'p': // If disp mode is not in cone_tri_calc, don't change variable if (disp_mode != DM_CONE_TRI_CALC) { break; } // if // Increase number of triangles in draw_cone_tri_calc n += 1; printf("Number of triangles increased by 1\n"); break; case 'P': // If disp mode is not in cone_tri_calc, don't change variable if (disp_mode != DM_CONE_TRI_CALC) { break; } // if n -= 1; if (n < 3) { n = 3; } // if else { printf("Number of triangles decreased by 1\n"); } // else break; case 'v': if (disp_mode != DM_VRML) { break; } // if vr_object = (vr_object + 1) % VR_MAX; print_vrml_object(); break; default: /* Unrecognized key press, just return */ return; break; } /* * If control reaches here, the key press was recognized. Refresh * the screen, since most key presses change the display in some way. */ myDisplay(); return; }
CAdministrationWindow::CAdministrationWindow(QWidget* parent, CMySQLServer *m) : CMyWindow(parent, "CAdministrationWindow") { (void)statusBar(); blocked = false; myApp()->incCritical(); setCaption("[" + m->connectionName() + "] " + trUtf8("Administration Panel")); setIcon(getPixmapIcon("applicationIcon")); enableMessageWindow(true); if (!m->oneConnection()) { m_mysql = new CMySQLServer(m->connectionName(), messagePanel()); m_mysql->connect(); delete_mysql = true; } else { m_mysql = m; //POSIBLE BUG ... need to make m_mysql redirect messages & errors to this->messagePanel() also. Currently they are in consoleWindow() //probably need to disable the timer ! delete_mysql = false; } setCentralWidget( new QWidget( this, "qt_central_widget")); CAdministrationWindowLayout = new QGridLayout( centralWidget(), 1, 1, 4, 2, "CAdministrationWindowLayout"); tabWidget = new QTabWidget( centralWidget(), "tabWidget"); processList = new CProcessListTable(tabWidget, m_mysql); tabWidget->insertTab(processList, getPixmapIcon("showProcessListIcon"), tr("Process List"), SHOW_PROCESSLIST); status = new CServerStatusTable(tabWidget, m_mysql); tabWidget->insertTab(status, getPixmapIcon("showStatusIcon"), tr("Status"), SHOW_STATUS); variables = new CShowServerVariables(tabWidget, m_mysql); tabWidget->insertTab(variables, getPixmapIcon("showVariablesIcon"), tr("Variables"), SHOW_VARIABLES); save_menu = new QPopupMenu(this); connect(save_menu, SIGNAL(activated(int)), this, SLOT(save(int))); save_menu->insertItem(getPixmapIcon("showProcessListIcon"), tr("&Process List"), MENU_SAVE_PROCESSLIST); save_menu->insertItem(getPixmapIcon("showStatusIcon"), tr("&Status"), MENU_SAVE_STATUS); save_menu->insertItem(getPixmapIcon("showVariablesIcon"), tr("&Variables"), MENU_SAVE_VARIABLES); save_menu->insertItem(tr("&InnoDB Status"), MENU_SAVE_INNODB_STATUS); has_innodb = CInnoDBStatus::hasInnoDB(m_mysql); if (has_innodb) { innoDBStatus = new CInnoDBStatus(tabWidget, m_mysql); tabWidget->insertTab(innoDBStatus, tr("InnoDB Status"), SHOW_INNODB_STATUS); } else save_menu->setItemEnabled(MENU_SAVE_INNODB_STATUS, false); CAdministrationWindowLayout->addWidget( tabWidget, 0, 0 ); viewShowMessagesAction = new CAction (tr("Show Messages"), tr("Show &Messages"), Qt::CTRL + Qt::Key_M, this, "fileShowMessagesAction", true); viewShowMessagesAction->setParentMenuText(tr("View")); connect(viewShowMessagesAction, SIGNAL(toggled(bool)), this, SLOT(showMessages(bool))); CAction * fileCloseAction = new CAction (tr("Close"), getPixmapIcon("closeIcon"), tr("&Close"), 0, this, "fileCloseAction"); fileCloseAction->setParentMenuText(tr("File")); connect(fileCloseAction, SIGNAL(activated()), this, SLOT(close())); fileRefreshAction = new CAction (tr("Refresh"), getPixmapIcon("refreshIcon"), tr("&Refresh"), Qt::Key_F5, this, "fileRefreshAction"); fileRefreshAction->setParentMenuText(tr("File")); connect(fileRefreshAction, SIGNAL(activated()), this, SLOT(refresh())); actionKillProcessAction = new CAction (tr("Kill Process"), getPixmapIcon("killProcessIcon"), tr("&Kill Process"), Qt::CTRL + Qt::Key_K, this, "actionKillProcessAction"); actionKillProcessAction->setParentMenuText(tr("Action")); connect(actionKillProcessAction, SIGNAL(activated()), this, SLOT(killProcesses())); CAction * actionPingAction = new CAction (tr("Ping"), getPixmapIcon("pingIcon"), tr("&Ping"), Qt::CTRL + Qt::Key_P, this, "actionPingAction"); actionPingAction->setParentMenuText(tr("Action")); connect(actionPingAction, SIGNAL(activated()), this, SLOT(ping())); CAction * actionShutdownAction = new CAction (tr("Shutdown"), getPixmapIcon("serverShutdownIcon"), tr("&Shutdown"), 0, this, "actionShutdownAction"); actionShutdownAction->setParentMenuText(tr("Action")); connect(actionShutdownAction, SIGNAL(activated()), this, SLOT(shutdown())); fileTimerAction = new CAction (tr("Start Refresh Timer"), getPixmapIcon("timerIcon"), tr("Start Refresh &Timer"), Qt::CTRL + Qt::Key_T, this, "fileTimerAction", true); fileTimerAction->setParentMenuText(tr("File")); connect(fileTimerAction, SIGNAL(toggled(bool)), this, SLOT(fileTimerActionToggled(bool))); QPopupMenu *fileMenu = new QPopupMenu(this); QPopupMenu *actionMenu = new QPopupMenu(this); QPopupMenu *viewMenu = new QPopupMenu(this); connect(viewMenu, SIGNAL(aboutToShow()), this, SLOT(viewMenuAboutToShow())); fileMenu->insertItem(getPixmapIcon("saveIcon"), tr("Save"), save_menu); fileMenu->insertSeparator(); fileRefreshAction->addTo(fileMenu); fileMenu->insertSeparator(); fileTimerAction->addTo(fileMenu); fileMenu->insertSeparator(); fileCloseAction->addTo(fileMenu); menuBar()->insertItem(tr("&File"), fileMenu); viewShowMessagesAction->addTo(viewMenu); menuBar()->insertItem(tr("&View"), viewMenu); actionKillProcessAction->addTo(actionMenu); flush_menu = flushMenu(m_mysql->mysql()); connect(flush_menu, SIGNAL(activated(int)), this, SLOT(flush(int))); actionMenu->insertItem(getPixmapIcon("flushIcon"),tr("Flush"), flush_menu); actionPingAction->addTo(actionMenu); actionMenu->insertSeparator(); actionShutdownAction->addTo(actionMenu); menuBar()->insertItem(tr("&Action"), actionMenu); new CHotKeyEditorMenu(this, menuBar(), "HotKeyEditor"); QToolBar * actionToolBar = new QToolBar(tr("Action Bar"), this, Top); QToolButton * saveTypeButton = new QToolButton(actionToolBar); saveTypeButton->setPopup(save_menu); saveTypeButton->setPixmap(getPixmapIcon("saveIcon")); saveTypeButton->setTextLabel(tr("Save"), true); saveTypeButton->setPopupDelay(0); actionToolBar->addSeparator(); actionKillProcessAction->addTo(actionToolBar); QToolButton * flushTypeButton = new QToolButton(actionToolBar); flushTypeButton->setPopup(flush_menu); flushTypeButton->setPixmap(getPixmapIcon("flushIcon")); flushTypeButton->setTextLabel(tr("Flush"), true); flushTypeButton->setPopupDelay(0); actionPingAction->addTo(actionToolBar); actionToolBar->addSeparator(); actionShutdownAction->addTo(actionToolBar); QToolBar * refreshToolBar = new QToolBar(tr("Refresh Bar"), this, Top ); fileRefreshAction->addTo(refreshToolBar); refreshToolBar->addSeparator(); QLabel * delayLabel = new QLabel(refreshToolBar, "delayLabel" ); delayLabel->setMinimumSize(QSize(65, 0)); delayLabel->setText(tr("Refresh Rate (sec)")); delay = new QSpinBox(refreshToolBar, "delayBox"); delay->setMinimumSize(QSize( 50, 0)); delay->setMaxValue(7200); delay->setMinValue(1); CConfig *cfg = new CConfig(); delay->setValue(cfg->readNumberEntry("Refresh Rate", 30)); status->setTraditionalMode(strtobool(cfg->readStringEntry("Status Traditional Mode", "true"))); delete cfg; status->refresh(); fileTimerAction->addTo(refreshToolBar); refreshTimer = new QTimer(this); connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refresh())); connect(tabWidget, SIGNAL(currentChanged (QWidget *)), this, SLOT(tabChanged(QWidget *))); myResize(600, 400); }
/* Handle user input */ void myKeyHandler(unsigned char ch, int x, int y) { switch(ch) { case 'c': resetCamera(); printf("Camera reset.\n"); break; case 's': case 'S': if (disp_style == DS_SOLID) { disp_style = DS_WIRE; } else { disp_style = DS_SOLID; } print_disp_style(); break; case 'd': /* Cycle through the various display modes */ disp_mode = (disp_mode + 1) % DM_MAX; print_disp_mode(); break; case 'D': /* Cycle through the various display modes backwards */ /* By adding DM_MAX, the args to "%" wil never be negative */ disp_mode = (disp_mode + DM_MAX - 1) % DM_MAX; print_disp_mode(); break; case ',': rotateCamera(5, X_AXIS); break; case '<': rotateCamera(-5, X_AXIS); break; case '.': rotateCamera(5, Y_AXIS); break; case '>': rotateCamera(-5, Y_AXIS); break; case '/': rotateCamera(5, Z_AXIS); break; case '?': rotateCamera(-5, Z_AXIS); break; case '+': /* Zoom in */ zoomCamera(-0.1); break; case '=': /* Zoom out */ zoomCamera(0.1); break; case 'z': myResize(win_width, win_height); printf("Window set to default size.\n"); break; case 't': performanceTest(); break; case 'q': /* Quit with exit code 0 */ endCanvas(0); break; /*********************************************/ /* ADD ADDITIONAL KEYS HERE */ /*********************************************/ //Controls for cone triangle calculation case 'I': radius += 0.1; printf("Radius increased to %.1f.\n", radius); break; case 'i': if(radius > 0.1) { radius -= 0.1; } printf("Radius decreased to %.1f.\n", radius); break; case 'O': height += 0.1; printf("Height increased to %.1f.\n", height); break; case 'o': if(height > 0.1) { height -= 0.1; } printf("Height decreased to %.1f.\n", height); break; case 'P': sides += 1; printf("Sides increased to %d.\n", sides); break; case 'p': if(sides > 3) { sides -= 1; } printf("Sides decreased to %d.\n", sides); break; //Controls for switching between vrml objects case 'v': vr_object++; if(vr_object >= VR_MAX) { vr_object = 0; } print_vrml_object(); break; /* Switching between free scene modes */ case 'f': free_scene_mode++; break; case 'F': free_scene_mode--; case 'a': animate = !animate; if(animate) { printf("Animation engaged.\n"); } else { printf("Animation disengaged.\n"); } break; /* Allows mathematical shading on display mode 7 */ case 'y': color_change = !color_change; if(color_change) { printf("Mathematical shading for Display Mode 7.\n"); } else { printf("Regular displace in Display Mode 7.\n"); } break; case 'l': lighting = !lighting; if(lighting) { printf("Lighting Engaged. \n"); light_me_up(); glutPostRedisplay(); } else { printf("Lighting Disengaged. \n"); turn_out_lights(); glutPostRedisplay(); } default: /* Unrecognized key press, just return */ return; break; } /* * If control reaches here, the key press was recognized. Refresh * the screen, since most key presses change the display in some way. */ myDisplay(); return; }
void Widget::myResize(int w, int h) { myResize(QSize(w,h)); }
void Widget::fillTables() { mainLayout->removeItem(mainLayout->itemAt(2)); m_isTables=true; tablesScrollArea=new QScrollArea; tablesGroupBox=new QGroupBox; tablesLayout=new QVBoxLayout; QString _f("z = "); QString restr; for(int i=0;i<nArgs+2*nEq;i++) { QString t; if(f[i]==-DBL_MAX) t=tr(" - M"); else { if(i!=0) { if(f[i]<0) t=tr(" - "); else t=tr(" + "); } t+=QString::number(abs(f[i])); } t+=tr("x%1").arg(QString::number(i+1)); restr+=tr("x%1, ").arg(QString::number(i+1)); _f+=t; } _f+=tr(" -> ")+direction; restr.resize(restr.size()-2); restr+=tr(" >= 0"); tablesLayout->addWidget(new QLabel(_f)); tablesLayout->addWidget(new QLabel(restr)); for(int i=0;i<simplex.count();i++) { tables.enqueue(simplex[i]->getTable()); if(i!=0) { QPoint* r=simplex[i-1]->findR(); if(r!=NULL) { tablesLayout->addWidget(new QLabel(tr("Найменша сума у %1 стовпцю, найменше відношення у %2 рядку.").arg(QString::number(r->y()+1),QString::number(r->x()+1)))); tablesLayout->addWidget(new QLabel(tr("Вибраний розв'язувальний елемент: A[%1,%2] = %3").arg(QString::number(r->x()+1),QString::number(r->y()+1),QString::number(simplex[i-1]->A[r->x()][r->y()])))); tablesLayout->addWidget(new QLabel(tr("Перераховуємо таблицю: "))); } delete r; } tablesLayout->addWidget(tables.last()); } QString res; int* ires; switch(m_result) { case RESULT_SUCCESS: tablesLayout->addWidget(new QLabel(tr("Відповідь:"))); ires=new int[nArgs+2*nEq]; res=tr("x = ("); for(int i=0;i<nArgs+2*nEq;i++) { ires[i]=0; } for(int i=0;i<nEq;i++) { ires[simplex.last()->basis[i]]=simplex.last()->B[i]; } for(int i=0;i<nArgs+2*nEq;i++) { res+=tr("%1, ").arg(QString::number(ires[i])); } res.resize(res.size()-2); res+=tr(")"); delete [] ires; tablesLayout->addWidget(new QLabel(res)); tablesLayout->addWidget(new QLabel(tr("z = %1").arg(QString::number(simplex.last()->sumB1)))); break; case RESULT_CYCLE: QMessageBox::critical(NULL,tr(""),tr("Зациклення."),QMessageBox::Ok); tablesLayout->addWidget(new QLabel(tr("Зациклення. Задача розв'язку не має."))); break; case RESULT_NO: QMessageBox::information(NULL,tr(""),tr("Розв'язок М-задачі знайдено, вихідна задача розв'язку немає."),QMessageBox::Ok); tablesLayout->addWidget(new QLabel(tr("Вихідна задача розв'язку немає."))); break; case RESULT_INF: QMessageBox::information(NULL,tr(""),tr("Цільова функція необмежена."),QMessageBox::Ok); tablesLayout->addWidget(new QLabel(tr("Цільова функція необмежена."))); break; } tablesGroupBox->setLayout(tablesLayout); tablesScrollArea->setWidget(tablesGroupBox); tablesScrollArea->setWidgetResizable(true); tablesScrollArea->setMinimumWidth(tables.last()->minimumWidth()+80); mainLayout->addWidget(tablesScrollArea,2); move(pos().x(),0); myResize(size().width(),QApplication::desktop()->height()-100); m_isTables=true; }
void Widget::showHideInput(bool state) { m_inputGB->setShown(state); if(!m_isTables) myResize(0,0); }