示例#1
0
文件: hostlog.cpp 项目: dd32/PonyEdit
HostLog::HostLog(SshHost* host) :
	QWidget(NULL),
	ui(new Ui::HostLog)
{
	ui->setupUi(this);
	ui->textBox->setPlainText(host->getLog().join("\n"));
	connect(host, SIGNAL(newLogLine(QString)), this, SLOT(newLogLine(QString)));

	setWindowTitle("Log: " + host->getName());
}
示例#2
0
LogSink &GuiLogSink::operator<<(LSEndl i) {
	QColor c = Qt::black;
	switch (level){
	case Debug:
		c = Qt::gray;
		break;
	case Warning:
		c = Qt::magenta;
		break;
	case Error:
		c = Qt::red;
		break;
	case Standard:
		c = Qt::black;
		break;
	default:
		c = Qt::black;
		break;
	}
	Q_EMIT newLogLine(buf,c);
	buf.clear();
	return *this;
}
DMMainWindow::DMMainWindow(QWidget * parent) : QMainWindow(parent), ui(new Ui::DMMainWindow)
{
	// qt init
	Q_INIT_RESOURCE(icons);
	ui->setupUi(this);
	this->setParent(parent);

	// logger init
	log_updater = new GuiLogSink();
	connect(log_updater, SIGNAL(newLogLine(QString)), SLOT(newLogLine(QString)), Qt::QueuedConnection);
#if defined DEBUG || _DEBUG
	DM::Log::init(log_updater,DM::Debug);
#else
	DM::Log::init(log_updater,DM::Standard);
#endif
	// add log export to file
	QString logfilepath = QDir::tempPath() + "/dynamind" 
		+ QDateTime::currentDateTime().toString("_yyMMdd_hhmmss_zzz")+".log";
	if(QFile::exists(logfilepath))
		QFile::remove(logfilepath);

	outputFile = new ofstream(logfilepath.toStdString().c_str());
	DM::Log::addLogSink(new DM::OStreamLogSink(*outputFile));
	DM::Logger() << "logfile: " << logfilepath;

	// init python env
	DM::PythonEnv *env = DM::PythonEnv::getInstance();
	env->addPythonPath(QApplication::applicationDirPath().toStdString());
	env->addOverWriteStdCout();

	// init simulation, we only use one instance
	this->simulation = new GUISimulation(parent, ui->tabWidget_4);
	simulationThread = NULL;
	simulationThreadWrapper = NULL;

	this->simulation->registerModulesFromDefaultLocation();
	this->simulation->registerModulesFromSettings();
	createModuleListView();

	connect( ui->actionRun, SIGNAL( triggered() ), this, SLOT( runSimulation() ), Qt::DirectConnection );
	connect( ui->actionPreferences, SIGNAL ( triggered() ), this, SLOT(preferences() ), Qt::DirectConnection );
	connect(ui->actionSave, SIGNAL(triggered()), this , SLOT(saveSimulation()), Qt::DirectConnection);
	connect(ui->actionSaveAs, SIGNAL(triggered()), this , SLOT(saveAsSimulation()), Qt::DirectConnection);
	connect(ui->actionOpen, SIGNAL(triggered()), this , SLOT(loadSimulation()), Qt::DirectConnection);
	connect(ui->actionNew, SIGNAL(triggered()), this , SLOT(clearSimulation()), Qt::DirectConnection);
	connect(ui->actionReload_Modules, SIGNAL(triggered()), this , SLOT(ReloadModules()), Qt::DirectConnection);
	connect(ui->actionUpdate, SIGNAL(triggered()), this , SLOT(updateSimulation()), Qt::DirectConnection);
	connect(ui->actionReset, SIGNAL(triggered()), this , SLOT(resetSimulation()), Qt::DirectConnection);
	connect(ui->actionCancel, SIGNAL(triggered()), this, SLOT(cancelSimulation()), Qt::DirectConnection);
	connect(ui->actionCancel, SIGNAL(triggered()), this, SLOT(cancelSimulation()), Qt::DirectConnection);
	connect(ui->actionShow_Help, SIGNAL(triggered()), this, SLOT(showHelp()), Qt::DirectConnection);

	QStringList args = QCoreApplication::arguments();
	if (args.size() == 2) {
		this->clearSimulation();
		this->getSimulation()->currentDocument = args[1];
		simulation->loadSimulation(args[1].toStdString());
	}

	ui->actionCancel->setEnabled(false);

	// load from qsettings
	QSettings settings;
	DM::DBConnectorConfig cfg = DM::DBConnector::getInstance()->getConfig();
	qulonglong v = settings.value("cacheBlockwritingSize", -1).toULongLong();
	if (v != (qulonglong)-1)
		cfg.cacheBlockwritingSize = v;

	v = settings.value("queryStackSize", -1).toULongLong();
	if (v != (qulonglong)-1)
		cfg.queryStackSize = v;

	int i = settings.value("peterDatastream", -1).toInt();
	if (i != -1)
		cfg.peterDatastream = (bool)i;
}