Ejemplo n.º 1
0
nineButtonSelector::nineButtonSelector(	QPixmap _button0_on,
					QPixmap _button0_off,
					QPixmap _button1_on,
					QPixmap _button1_off,
					QPixmap _button2_on,
					QPixmap _button2_off,
					QPixmap _button3_on,
					QPixmap _button3_off,
					QPixmap _button4_on,
					QPixmap _button4_off,
					QPixmap _button5_on,
					QPixmap _button5_off,
					QPixmap _button6_on,
					QPixmap _button6_off,
					QPixmap _button7_on,
					QPixmap _button7_off,
					QPixmap _button8_on,
					QPixmap _button8_off,
					Uint8 _default,
					Uint32 _x, Uint32 _y,
					QWidget * _parent ):
	QWidget( _parent ),
	IntModelView( new nineButtonSelectorModel(0, 8, _default, NULL, 
				QString::null, true ), this )
{
	setFixedSize( 50, 50 );
	move( _x, _y );

	// TODO: use a generic approach using QSignalMapper

	m_button = new pixmapButton( this, NULL );
	m_button->move( 1, 1 );
	m_button->setActiveGraphic( _button0_on );
	m_button->setInactiveGraphic( _button0_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button0Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 18, 1 );
	m_button->setActiveGraphic( _button1_on );
	m_button->setInactiveGraphic( _button1_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button1Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 35, 1 );
	m_button->setActiveGraphic( _button2_on );
	m_button->setInactiveGraphic( _button2_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button2Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 1, 18 );
	m_button->setActiveGraphic( _button3_on );
	m_button->setInactiveGraphic( _button3_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button3Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 18, 18 );
	m_button->setActiveGraphic( _button4_on );
	m_button->setInactiveGraphic( _button4_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button4Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 35, 18 );
	m_button->setActiveGraphic( _button5_on );
	m_button->setInactiveGraphic( _button5_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button5Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 1, 35 );
	m_button->setActiveGraphic( _button6_on );
	m_button->setInactiveGraphic( _button6_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button6Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 18, 35 );
	m_button->setActiveGraphic( _button7_on );
	m_button->setInactiveGraphic( _button7_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button7Clicked() ) );
	m_buttons.append( m_button );
	
	m_button = new pixmapButton( this, NULL );
	m_button->move( 35, 35 );
	m_button->setActiveGraphic( _button8_on );
	m_button->setInactiveGraphic( _button8_off );
	m_button->setChecked( false );
	connect( m_button, SIGNAL ( clicked () ),
		 this, SLOT ( button8Clicked() ) );
	m_buttons.append( m_button );
	
	m_lastBtn = m_buttons[_default];
	m_lastBtn->setChecked( true );
}
/**
 * 左侧按钮切换页面tabwidget界面类实现
 * @author fanxiang
 * @version 1.0.0
 * @date 2013-08-18
 */
TabWidgetManager::TabWidgetManager(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TabWidgetManager)
{
    ui->setupUi(this);
    QIcon icon;
    icon.addFile(QString::fromUtf8(":image/icon.png"), QSize(), QIcon::Normal, QIcon::Off);
    this->setWindowIcon(icon);

    // 【注意】,此处添加widget为了是窗口布局随大窗口缩放而改变
    // 【注意!】ui->gridLayout为自己在Ui设计器中命名的Layout,该Layout中包含QStackedWidget
    ui->gridLayout->addWidget(ui->page1, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page2, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page3, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page4, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page5, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page6, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page7, 0, 1, 1, 1);
    ui->gridLayout->addWidget(ui->page8, 0, 1, 1, 1);

    BackupDatabaseWidget *widgetbackupdb = new BackupDatabaseWidget(ui->page3);

    WidgetOne *widget2 = new WidgetOne(ui->page1);
    InputBridgeWidget * widget3 = new InputBridgeWidget(ui->page2);
    SelectAvaliableTunnelWidget *widget4 = new SelectAvaliableTunnelWidget(ui->page4);
    SynthesisCorrectWidget * widget56 = new SynthesisCorrectWidget(ui->page5);
    SelectHistoricalTunnelDataWidget *widget7 = new SelectHistoricalTunnelDataWidget(ui->page7);
    OutputClearanceWidget *widget8 = new OutputClearanceWidget(ui->page8);

    QGridLayout *layout1 = new QGridLayout();
    layout1->addWidget(widget2);
    ui->page1->setLayout(layout1);

    QGridLayout *layout8 = new QGridLayout();
    layout8->addWidget(widget3);
    ui->page2->setLayout(layout8);

    QGridLayout *layout7 = new QGridLayout();
    layout7->addWidget(widgetbackupdb);
    ui->page3->setLayout(layout7);

    QGridLayout *layout2 = new QGridLayout();
    layout2->addWidget(widget4);
    ui->page4->setLayout(layout2);

    QGridLayout *layout3 = new QGridLayout();
    layout3->addWidget(widget56);
    ui->page5->setLayout(layout3);

    QGridLayout *layout6 = new QGridLayout();
    layout6->addWidget(widget7);
    ui->page7->setLayout(layout6);

    QGridLayout *layout4 = new QGridLayout();
    layout4->addWidget(widget8);
    ui->page8->setLayout(layout4);

    /************************************/
    // 鼠标点击信号槽
    connect(ui->button1, SIGNAL(clicked()), this, SLOT(button1Clicked()));
    connect(ui->button2, SIGNAL(clicked()), this, SLOT(button2Clicked()));
    connect(ui->button3, SIGNAL(clicked()), this, SLOT(button3Clicked()));
    connect(ui->button4, SIGNAL(clicked()), this, SLOT(button4Clicked()));
    connect(ui->button5, SIGNAL(clicked()), this, SLOT(button5Clicked()));
    connect(ui->button6, SIGNAL(clicked()), this, SLOT(button6Clicked()));
    connect(ui->button7, SIGNAL(clicked()), this, SLOT(button7Clicked()));
    connect(ui->button8, SIGNAL(clicked()), this, SLOT(button8Clicked()));

    // 界面间通信信号槽
    connect(widget7, SIGNAL(updateOutput(SingleOrMultiSelectionMode, CurveType)), widget8, SLOT(updateClearanceTableModel(SingleOrMultiSelectionMode, CurveType)));
    connect(widget2, SIGNAL(signalBridgeToEdit(int, QString)), widget3, SLOT(slotBridgeToEdit(int, QString)));
    connect(widget4, SIGNAL(signalSelectedTunnelToEdit(int, QString, bool)), widget56, SLOT(slotSelectedTunnelToSynthesis(int, QString, bool)));
	// 关闭窗口信号槽,告知数据库可能需要备份
    connect(this, SIGNAL(my_close()), widgetbackupdb, SLOT(checkIfExport()));

    // 按钮切换界面信号槽
    connect(widget7, SIGNAL(updateOutput(SingleOrMultiSelectionMode, CurveType)), this, SLOT(button8Clicked()));
    connect(widget2, SIGNAL(signalBridgeToEdit(int, QString)), this, SLOT(button2Clicked()));
    connect(widget8, SIGNAL(backToSelectionSignal()), this, SLOT(button7Clicked()));
    connect(widget3, SIGNAL(signalEndEdit()), this, SLOT(button1Clicked()));
    connect(widget4, SIGNAL(signalSelectedTunnelToEdit(int, QString, bool)), this, SLOT(button5Clicked()));
    connect(widget56, SIGNAL(toTabCorrect()), this, SLOT(button6Clicked()));
    connect(widget56, SIGNAL(toTabSynthesis()), this, SLOT(button5Clicked()));
    connect(widget56, SIGNAL(finish()), this, SLOT(button4Clicked()));

    /************关于流程控制*************/
    // 开始时禁止点击按钮功能
    ui->button2->setEnabled(false);
    ui->button5->setEnabled(false);
    ui->button6->setEnabled(false);
    ui->button8->setEnabled(false);

    // 显示第一个界面
	button3Clicked();
}