예제 #1
0
void MainWindow::NewFileSlot()
{
	TextEdit* child = CreateTextEdit();
	child->NewFile();
	//child->show();
	tabWidget->addTab(child, child->GetCurrentFileName());
	int index = tabWidget->count();
	//tabWidget->addTab(child, child->GetCurrentFileName());
	tabWidget->setTabToolTip(index, child->GetCurrentFile());
}
예제 #2
0
void MainWindow::UpdateWindowMenuSlot()
{
	menuWindow->clear();
	menuWindow->addAction(actionClose);
	menuWindow->addAction(actionClose_All_Windows);
	menuWindow->addSeparator();
	menuWindow->addAction(actionTile);
	menuWindow->addAction(actionStack);
	menuWindow->addSeparator();
	menuWindow->addAction(actionNext_Window);
	menuWindow->addAction(actionPrevious_Window);
	menuWindow->addAction(m_acSeparator);

	int num = tabWidget->count();
	if( num > 0)
	{
		m_acSeparator->setVisible(true);

		for(int i=0; i < tabWidget->count(); ++i)
		{
			TextEdit* child = qobject_cast<TextEdit*> (tabWidget->widget(i));

			QString text;

			if(i < 9){
				text = tr("&%1 %2").arg(i+1).arg(child->GetCurrentFile());
			} else {
				text = tr("%1 %2").arg(i+1).arg(child->GetCurrentFile());
			}

			QAction* action = menuWindow->addAction(text);
			action->setCheckable(true);
			action->setChecked(child == GetCurrentTextEdit());

			connect(action, SIGNAL(triggred()), m_windowMapper, SLOT(map()));

			m_windowMapper->setMapping(action, tabWidget->widget(i));
		}
	}
	
}
예제 #3
0
TextEdit* MainWindow::FindTextEdit(const QString& fileName)
{
	QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath();
	
	int nums = tabWidget->count();
	if (nums > 0)
	{
		for (int i = 0; i < nums; ++i )
		{
			TextEdit* textEdit = static_cast<TextEdit*>( tabWidget->widget(i) );
			if (textEdit->GetCurrentFile() == canonicalFilePath)
			{
				return textEdit;
			}
		}
	}
	
	return NULL;
}
예제 #4
0
void MainWindow::OpenTextEdit( const QString fileName )
{
	TextEdit *existedTextEdit = FindTextEdit(fileName);
	if (existedTextEdit)
	{
		tabWidget->setCurrentWidget(existedTextEdit);
		return;
	}

	TextEdit* child = CreateTextEdit();
	if ( child->LoadFile(fileName) )
	{
		int index = tabWidget->count();
		tabWidget->addTab(child, child->GetCurrentFileName());
		tabWidget->setTabToolTip(index, child->GetCurrentFile());
		//child->show();
	}
	else
	{
		child->close();
	}
}