KeyboardApplet::KeyboardApplet(PanelWindow *panelWindow)
    : Applet(panelWindow)
{
    setObjectName("Keyboard");
    if(panelWindow != 0)
    {
        setPanelWindow(panelWindow);
    }

    QSettings setting(this);
    m_supported_layouts = setting.value("layouts", QStringList() << "us").toStringList();
    m_current_layout = m_supported_layouts.first();


    forwardShortcut = new QxtGlobalShortcut(this);
    forwardShortcut->setShortcut(QKeySequence(setting.value("layoutsForward", "Meta+Space").toString()));
    connect(forwardShortcut, SIGNAL(activated()), this, SLOT(changeForward()));

    backwardShortcut = new QxtGlobalShortcut(this);
    backwardShortcut->setShortcut(QKeySequence(setting.value("layoutsBackward", "Ctrl+Meta+Space").toString()));
    connect(backwardShortcut, SIGNAL(activated()), this, SLOT(changeBackword()));
}
Beispiel #2
0
void NeighbourGenerator::makeNeighbour(){
	vector<Node*> bottleneck;
	Graph g(m_solution,m_SettingTable);
	g.setLongestPath();
	int L=g.getMakespan();
	for(int i=0;i<g.size();i++){
		if(g[i]->m_R+g[i]->m_Q-g[i]->m_Jobpair->time==L){
			bottleneck.push_back(g[i]);
		}
	}

	m_CriticalPathList=pair<vector<Node*>,int>(vector<Node*>(),-1);
	vector<Node*> criticalPath;
	findCriticalPath(g[0],g[g.size()-1],bottleneck,criticalPath,0);

	criticalPath.clear();
	criticalPath=m_CriticalPathList.first;
	for(int j=0;j<criticalPath.size()-1;j++){
		for(int k=j+1;k<criticalPath.size()-1;k++){
			if(criticalPath[j]->m_Jobpair->machine!=
				criticalPath[k]->m_Jobpair->machine)
				continue;
			JobPair *I=criticalPath[j]->m_Jobpair;
			JobPair *J=criticalPath[k]->m_Jobpair;
			JobPair *alphaI=findJobFromSetting(I,PREV);
			JobPair *gammaI=findJobFromSetting(I,NEXT);
			JobPair *alphaJ=findJobFromSetting(J,PREV);
			JobPair *gammaJ=findJobFromSetting(J,NEXT);

			for(int l=0;l<criticalPath.size();l++){
				// gammaJがCriticalPathに含まれていればforwardchangeする
				if(gammaJ!=NULL && gammaI!=NULL && gammaJ->index==criticalPath[l]->m_Jobpair->index &&
					g.getNodeByIndex(J->index)->m_Q-J->time>=g.getNodeByIndex(gammaI->index)->m_Q-gammaI->time){
					vector<vector<JobPair> > forwardSolution;
					forwardSolution=changeForward(m_solution,criticalPath[j]->m_Jobpair,criticalPath[k]->m_Jobpair);
					m_NeighbourList.push_back(forwardSolution);
					Graph forward(forwardSolution,m_SettingTable);
					forward.setLongestPath();
					if(g.getMakespan()>forward.getMakespan()){
					}else{
						if(forward.getNodeByIndex(J->index)->m_R-J->time<=g.getNodeByIndex(J->index)->m_R-J->time-I->time){
						}
						if(forward.getNodeByIndex(J->index)->m_Q<=g.getNodeByIndex(J->index)->m_Q+I->time){
						}
					}
				}
				
				// alphaIがCriticalPathに含まれていればbackwardchangeする
				if(alphaI!=NULL && alphaJ!=NULL && alphaI->index==criticalPath[l]->m_Jobpair->index &&
					g.getNodeByIndex(I->index)->m_R>=g.getNodeByIndex(alphaJ->index)->m_R){
					vector<vector<JobPair> > backwardSolution;
					backwardSolution=changeBackward(m_solution,criticalPath[j]->m_Jobpair,criticalPath[k]->m_Jobpair);
					m_NeighbourList.push_back(backwardSolution);

					Graph backward(backwardSolution,m_SettingTable);
					backward.setLongestPath();
					if(g.getMakespan()>backward.getMakespan()){
					}else{
						if(backward.getNodeByIndex(I->index)->m_Q<=g.getNodeByIndex(I->index)->m_Q-J->time){
						}
						if(backward.getNodeByIndex(I->index)->m_R-I->time<=g.getNodeByIndex(I->index)->m_R-I->time+J->time){
						}
					}
				}
			}
		}
	}
}
void KeyboardApplet::clicked()
{
    changeForward();
}