// ------------------------------------------------------------- TRasterMapsDialog::TRasterMapsDialog(IMapAdapterInterfaces MapInterfaces_, QString Organization_, QString Application_, QWidget *Parent_) : QDialog(Parent_), PI(acos(-1.0)), m_Organization(Organization_), m_Application(Application_), m_Mode(Consts::ListMode), m_KeyControlPressed(false) { setWindowTitle(QNetMapTranslator::tr("Raster map list" /* Russian: Список растровых карт */)); QPalette palette/*(palette())*/; palette.setColor(backgroundRole(), Qt::white); setPalette(palette); setAutoFillBackground(true); setMinimumSize(800, 600); // карта w_MapWidget = new TMapWidget(MapInterfaces_, "", 12, QPointF(0,0), Organization_, Application_); // Лайаут основной setLayout(&m_MainVerticalLayout); m_MainVerticalLayout.setSpacing(8); m_MainVerticalLayout.setMargin(8); // Лайаут для размещения элементов верхней строки с подсказкой QHBoxLayout *TopLayout = new QHBoxLayout; m_MainVerticalLayout.addLayout(TopLayout); TopLayout->addWidget(&m_TextHint); hint(QNetMapTranslator::tr("Select the map or action" /* Russian: Выберите карту или действие */)); TopLayout->addStretch(); // Лайаут для списка, кнопок и карты QHBoxLayout *MiddleLayout = new QHBoxLayout; m_MainVerticalLayout.addLayout(MiddleLayout); // Лайаут для списка и кнопок QVBoxLayout *ListLayout = new QVBoxLayout; // Лайаут для карты QVBoxLayout *MapLayout = new QVBoxLayout; // Путь к карте MapLayout->addWidget(&m_MapPath); // Рамка для виджета карты QFrame *MapWidgetFrame = new QFrame; MapWidgetFrame->setFrameStyle(QFrame::Box | QFrame::Plain); QHBoxLayout *MapWidgetFrameLayout = new QHBoxLayout(MapWidgetFrame); MapWidgetFrameLayout->setMargin(0); MapWidgetFrameLayout->addWidget(w_MapWidget); MapLayout->addWidget(MapWidgetFrame); // лайоут для списка точек привязки w_MapAnchors = new QVBoxLayout; w_MapAnchors->setMargin(0); MapLayout->addLayout(w_MapAnchors); // Список карт QStringList ListMaps; IMapAdapterInterfaces RasterMapInterfaces = w_MapWidget->rasterMapInterfaces(); foreach(IMapAdapterInterface* Interface, RasterMapInterfaces) { ListMaps << Interface->pluginName(); } m_Model.setStringList(ListMaps); m_MapsListView.setModel(&m_Model); ListLayout->addWidget(&m_MapsListView); QGroupBox *ListGroup = new QGroupBox(QNetMapTranslator::tr("Raster maps" /* Russian: Растровые карты */)); ListGroup->setMaximumWidth(200); ListGroup->setLayout(ListLayout); // кнопки m_CenterMapButton.setText(QNetMapTranslator::tr("Map's center" /* Russian: Центр карты */)); m_LinkingButton.setText(QNetMapTranslator::tr("Add reference points..." /* Russian: Привязать... */)); m_DeleteLinkingButton.setText(QNetMapTranslator::tr("Delete reference points" /* Russian: Удалить привязку */)); m_AddButton.setText(QNetMapTranslator::tr("Add to list..." /* Russian: Добавить в список... */)); m_DeleteButton.setText(QNetMapTranslator::tr("Delete from list" /* Ru: Удалить из списка */)); m_ExitDialogButton.setText(QNetMapTranslator::tr("OK")); ListLayout->addWidget(&m_CenterMapButton); ListLayout->addWidget(&m_LinkingButton); ListLayout->addWidget(&m_DeleteLinkingButton); ListLayout->addWidget(&m_AddButton); ListLayout->addWidget(&m_DeleteButton); ListLayout->addItem(new QSpacerItem(0, 7)); ListLayout->addWidget(&m_ExitDialogButton); // Кнопки подтверждения / отмены m_ButtonBox.setMinimumSize(QSize(0, 30)); m_ButtonBox.setOrientation(Qt::Horizontal); m_ButtonBox.setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); // находим кнопку ОК и делаем ее недоступной QList<QAbstractButton*> ListButtons = m_ButtonBox.buttons(); foreach(QAbstractButton* Button, ListButtons) { if(m_ButtonBox.buttonRole(Button) == QDialogButtonBox::AcceptRole) { w_ButtonOK = Button; w_ButtonOK->setEnabled(false); break; } } MapLayout->addWidget(&m_ButtonBox); m_ButtonBox.setVisible(false); MiddleLayout->addWidget(ListGroup); MiddleLayout->addLayout(MapLayout); // устанавливаем текущей первую карту в списке if(m_Model.rowCount()) mapNameClicked(m_Model.index(0, 0)); // сигналы QNM_DEBUG_CHECK(connect(&m_MapsListView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(mapNameClicked(const QModelIndex&)))); QNM_DEBUG_CHECK(connect(&m_MapsListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(mapNameClicked(const QModelIndex&)))); QNM_DEBUG_CHECK(connect(&m_ButtonBox, SIGNAL(accepted()), this, SLOT(acceptLinking()))); QNM_DEBUG_CHECK(connect(&m_ButtonBox, SIGNAL(rejected()), this, SLOT(rejectLinking()))); QNM_DEBUG_CHECK(connect(&m_AddButton, SIGNAL(clicked()), this, SLOT(addMap()))); QNM_DEBUG_CHECK(connect(&m_DeleteButton, SIGNAL(clicked()), this, SLOT(deleteMap()))); QNM_DEBUG_CHECK(connect(&m_LinkingButton, SIGNAL(clicked()), this, SLOT(viewMap()))); QNM_DEBUG_CHECK(connect(&m_DeleteLinkingButton, SIGNAL(clicked()), this, SLOT(deleteLinking()))); QNM_DEBUG_CHECK(connect(&m_CenterMapButton, SIGNAL(clicked()), this, SLOT(viewCenterMap()))); QNM_DEBUG_CHECK(connect(&m_ExitDialogButton, SIGNAL(clicked()), this, SLOT(accept()))); // widgetsEnabling(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->setWindowIcon(QIcon(":/new/prefix1/images/VirtualPool.png")); testLabel = new QLabel(); testLabel2 = new QLabel(); testLabel3 = new QLabel(); button_new = createToolButton(QIcon(":/new/prefix1/images/new.png"), tr("新建")); button_start = createToolButton(QIcon(":/new/prefix1/images/right.png"), tr("启动")); button_delete = createToolButton(QIcon(":/new/prefix1/images/delete.png"), tr("删除")); button_login = createToolButton(QIcon(":/new/prefix1/images/login.png"), tr("远程登录")); button_test = createToolButton(QIcon(":/new/prefix1/images/network.png"), tr("网络体检")); QGroupBox *vmInfo = new QGroupBox(tr("配置信息")); QGroupBox *vmList = new QGroupBox(tr("虚拟机池")); processBar = new CRoundProcessBar(this); nameEdit = new QLineEdit(); ostypeEdit = new QLineEdit(); cpuEdit = new QLineEdit(); memoryEdit = new QLineEdit(); vramEdit = new QLineEdit(); bootEdit = new QLineEdit(); diskTypeEdit = new QLineEdit(); diskSpaceEdit = new QLineEdit(); networkEdit = new QLineEdit(); ipEdit = new QLineEdit(); netmaskEdit = new QLineEdit(); testEdit = new QLineEdit(); memorySpinBox = new QSpinBox(); memorySlider = new QSlider(Qt::Horizontal); memorySlider->setTickPosition(QSlider::TicksBelow); memorySlider->setTickInterval(100); /* 以下为layout部分 */ QHBoxLayout *headLayout = new QHBoxLayout; QVBoxLayout *resultLayout = new QVBoxLayout; headLayout->addWidget(button_new); headLayout->addWidget(button_start); headLayout->addWidget(button_delete); headLayout->addWidget(button_login); headLayout->addWidget(button_test); headLayout->addWidget(processBar); headLayout->addLayout(resultLayout); resultLayout->addWidget(testLabel); resultLayout->addWidget(testLabel2); resultLayout->addWidget(testLabel3); resultLayout->setSpacing(0); headLayout->setAlignment(Qt::AlignLeft); QHBoxLayout* memoryLayout = new QHBoxLayout; QLabel* memoryLabel = new QLabel(tr("内存")); memoryLabel->setMinimumWidth(78); memoryLayout->addWidget(memoryLabel); memoryLayout->addWidget(memorySpinBox); memoryLayout->addWidget(memorySlider); QFormLayout *infoLayout = new QFormLayout; vmInfo->setLayout(infoLayout); infoLayout->addRow(tr("名称"), nameEdit); infoLayout->addRow(tr("操作系统"), ostypeEdit); infoLayout->addRow(tr("CPU核数"), cpuEdit); infoLayout->addRow(memoryLayout); infoLayout->addRow(tr("虚拟磁盘格式"), diskTypeEdit); infoLayout->addRow(tr("磁盘剩余容量"), diskSpaceEdit); infoLayout->addRow(tr("网络连接方式"), networkEdit); infoLayout->addRow(tr("IP地址"), ipEdit); infoLayout->addRow(tr("子网掩码"), netmaskEdit); infoLayout->addRow(tr("显存"), vramEdit); infoLayout->addRow(tr("启动顺序"), bootEdit); processBar->setScanValue("0"); infoLayout->setVerticalSpacing(15); QVBoxLayout *vms = new QVBoxLayout; vms->addWidget(listWidget); vmList->setLayout(vms); vmList->setMaximumWidth(200); QHBoxLayout *bodyLayout = new QHBoxLayout; bodyLayout->addWidget(vmList); bodyLayout->addWidget(vmInfo); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(headLayout); mainLayout->addLayout(bodyLayout); QWidget *mainWidget = new QWidget; mainWidget->setLayout(mainLayout); setCentralWidget(mainWidget); // if(listWidget->count() > 0) // on_item_clicked(listWidget->item(0)); /* UI部分 */ this->setStyleSheet("QLineEdit{background: rgb(240,240,240);selection-background-color: darkgrey; padding:0px; margin:0px;}"); }
LiveDataWidget::LiveDataWidget(QStringList &langList, QWidget *parent /* = 0 */) : QWidget (parent) , _langList(langList) , _shortNameListView(0) , _shortNameListModel(0) , _shortNameEdit(0) , _unitEdit(0) , _commandIDBox(0) , _algorithmIDBox(0) , _contentEdits() , _defEdits() , _catalogList() , _shortNameList() , _currentCatalog() , _isAddNew(false) { QHBoxLayout *mainLayout = new QHBoxLayout(this); setLayout(mainLayout); _shortNameListView = new QListView(this); _shortNameListView->setMaximumWidth(240); _shortNameListModel = new QStringListModel(); _shortNameListView->setModel(_shortNameListModel); mainLayout->addWidget(_shortNameListView); QVBoxLayout *editLayout = new QVBoxLayout(this); mainLayout->addLayout(editLayout); { QHBoxLayout *hlayout = new QHBoxLayout(this); editLayout->addLayout(hlayout); // Short Name edit, for add new item QGroupBox *box = new QGroupBox(this); box->setTitle(trUtf8("Short Name")); box->setMaximumHeight(50); QHBoxLayout *layout = new QHBoxLayout(box); _shortNameEdit = new QLineEdit(box); box->setLayout(layout); layout->addWidget(_shortNameEdit); hlayout->addWidget(box); // Unit box = new QGroupBox(this); box->setTitle(trUtf8("Unit")); box->setMaximumWidth(100); box->setMaximumHeight(50); layout = new QHBoxLayout(box); _unitEdit = new QLineEdit(box); box->setLayout(layout); layout->addWidget(_unitEdit); hlayout->addWidget(box); // Command ID. box = new QGroupBox(this); box->setTitle(trUtf8("Command ID")); box->setMaximumWidth(100); box->setMaximumHeight(50); layout = new QHBoxLayout(box); _commandIDBox = new QComboBox(box); box->setLayout(layout); layout->addWidget(_commandIDBox); hlayout->addWidget(box); // Algorithm ID. box = new QGroupBox(this); box->setTitle(trUtf8("Algorithm ID")); box->setMaximumWidth(100); box->setMaximumHeight(50); layout = new QHBoxLayout(box); _algorithmIDBox = new QComboBox(box); box->setLayout(layout); layout->addWidget(_algorithmIDBox); hlayout->addWidget(box); } connect(_unitEdit, SIGNAL(textChanged(QString)), this, SLOT(updateUnit(QString))); connect(_commandIDBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateCommboxID(QString))); connect(_algorithmIDBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateAlgorithmID(QString))); connect(_shortNameEdit, SIGNAL(textChanged(QString)), this, SLOT(changeAddNew())); for (int i = 0; i < _langList.size(); i++) { QGroupBox *box = new QGroupBox(this); box->setTitle(_langList[i]); editLayout->addWidget(box); QVBoxLayout *boxLayout = new QVBoxLayout(box); box->setLayout(boxLayout); // Defalut Value QGroupBox *defBox = new QGroupBox(box); defBox->setTitle(trUtf8("Default Value")); boxLayout->addWidget(defBox); QLineEdit *defEdit = new QLineEdit(defBox); defEdit->setObjectName(_langList[i]); QVBoxLayout *layout = new QVBoxLayout(defBox); defBox->setLayout(layout); layout->addWidget(defEdit); defBox->setMaximumHeight(50); _defEdits.insert(_langList[i], defEdit); // Content Edit QGroupBox *contentBox = new QGroupBox(box); contentBox->setTitle(trUtf8("Content")); boxLayout->addWidget(contentBox); QPlainTextEdit *contentEdit = new QPlainTextEdit(contentBox); contentEdit->setObjectName(_langList[i]); layout = new QVBoxLayout(contentBox); layout->addWidget(contentEdit); contentBox->setLayout(layout); _contentEdits.insert(_langList[i], contentEdit); connect(defEdit, SIGNAL(textChanged(QString)), this, SLOT(updateDefaultValue(QString))); connect(contentEdit, SIGNAL(textChanged()), this, SLOT(updateContent())); } connect(_shortNameListView, SIGNAL(clicked(QModelIndex)), this, SLOT(setCurrentShortName(QModelIndex))); }