コード例 #1
0
void
GXDataDocument::LoadFile
	(
	const JCharacter* fileName
	)
{
	std::ifstream is(fileName);

	if (is.bad())
		{
		JGetUserNotification()->ReportError("Error opening file.");
		}
	else
		{
		const JString str = JReadLine(is);
		if (str == kGloveFileSignature)
			{
			if (!LoadNativeFile(is))
				{
				JGetUserNotification()->ReportError(
					"This file was created by a newer version of Glove.  "
					"You need the newest version in order to open it.");
				}
			}
		else
			{
			is.close();
			FileChanged(fileName, kJFalse);
			itsCurrentFileName = fileName;
			ChooseFileFilter();
			}
		}
}
コード例 #2
0
JXFileDocument::JXFileDocument
	(
	JXDirector*			supervisor,
	const JCharacter*	fileName,
	const JBoolean		onDisk,
	const JBoolean		wantBackupFile,
	const JCharacter*	defaultFileNameSuffix
	)
	:
	JXDocument(supervisor),
	itsFileSuffix(defaultFileNameSuffix),
	itsSaveBeforeClosePrompt(JGetString("SaveBeforeClosePrompt::JXFileDocument")),
	itsSaveNewFilePrompt(JGetString("SaveNewFilePrompt::JXFileDocument")),
	itsOKToRevertPrompt(JGetString("OKToRevertPrompt::JXFileDocument"))
{
	itsAllocateTitleSpaceFlag     = kJFalse;
	itsWantBackupFileFlag         = wantBackupFile;
	itsWantNewBackupEveryOpenFlag = kJTrue;
	itsAutosaveBeforeCloseFlag    = kJFalse;
	itsCSF                        = JGetChooseSaveFile();
	itsNeedSafetySaveFlag         = kJFalse;
	itsSafetySaveFileName         = NULL;

	FileChanged(fileName, onDisk);
}
コード例 #3
0
ファイル: mainwindow.cpp プロジェクト: cosmos180/qpicview
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
	m_pFile(nullptr),
	m_pScene(NULL),
	m_pCurImage(NULL),
	//m_szCurImagePath(),
	m_szCurPath(),
	m_ImageList(),
	m_iCurImageIx(-1),
	m_bMaximized(false)
{
    ui->setupUi(this);
	m_pScene = new QGraphicsScene(this);
	ui->graphicsView->setScene(m_pScene);

	m_szBaseTitle = this->windowTitle();
	
	connect(this, SIGNAL(FileSelection(QString)), SLOT(FileChanged(QString)));
	connect(this, SIGNAL(PathRefresh(QString)), SLOT(PathFileRefresh(QString)));

	// note: set before showing image so window-resize will know this..
	showMaximized();
	m_bMaximized = true;
	
	// if file(s) given in command line,
	// keep as list for browsing
	QStringList vCmdLine = QApplication::arguments();
	if (vCmdLine.size() > 1)
	{
		// remove app name
		vCmdLine.removeAt(0);
		
		if (vCmdLine.size() > 1)
		{
			// keep image list
			// as "playlist" when more than one file given,
			// selecting file manually resets the list also
			m_ImageList = vCmdLine;
		}
		
		emit FileSelection(vCmdLine[0]);

		// for image browsing/switching
		emit PathRefresh(vCmdLine[0]);
	}
}
コード例 #4
0
void
SCCircuitDocument::OpenSomething
	(
	const JCharacter* fileName
	)
{
	JString fullName;
	if (fileName != NULL && fileName[0] != '\0')
		{
		if (JFileExists(fileName))
			{
			fullName = fileName;
			}
		else
			{
			return;
			}
		}
	else if (!(JGetChooseSaveFile())->ChooseFile("File to open:", NULL, &fullName))
		{
		return;
		}

	std::ifstream input(fullName);
	const FileStatus status = CanReadFile(input);
	JXFileDocument* doc;
	if (status == kFileReadable &&
		!(JXGetDocumentManager())->FileDocumentIsOpen(fullName, &doc) &&
		OKToClose())
		{
		CloseAllWindows();
		FileChanged(fullName, kJTrue);
		ReadFile(input);
		}
	else if (status == kNeedNewerVersion)
		{
		(JGetUserNotification())->ReportError(
			"This notebook was created by a newer version of Symcir.  "
			"You need the newest version in order to open it.");
		}
	else if (status == kNotMyFile && OKToClose())
		{
		input.close();
		CloseAllWindows();
		ReadNetlist(fullName);
		}
}
コード例 #5
0
ファイル: mainwindow.cpp プロジェクト: kubanecxxx/StMaster
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    client(new KelnetClient(this)),
    Map(NULL)
{
    ui->setupUi(this);
    connect(client,SIGNAL(Connected()),this,SLOT(Connected()));
    connect(client,SIGNAL(Disconnected()),this,SLOT(Disconnected()));
    connect(client,SIGNAL(CoreStatus(QString&)),this,SLOT(NewCoreStatus(QString&)));

    CoreStatus = new QLabel(this);
    statusBar()->addPermanentWidget(CoreStatus);

    Led = new HLed(this);
    Led->turnOff();
    statusBar()->addPermanentWidget(Led);

    Timer = new QTimer(this);
    Timer->setInterval(500);
    connect(this,SIGNAL(TimerStart()),Timer,SLOT(start()));
    connect(this,SIGNAL(TimerStop()),Timer,SLOT(stop()));
    connect(Timer,SIGNAL(timeout()),this,SLOT(Timeout()));

    MapFile = new QLabel(this);
    MapFile->setText("No map file");
    ui->mainToolBar->addSeparator();
    ui->mainToolBar->addWidget(MapFile);


    QStringList header;
    header << "Name" << "Type" << "Address" << "Period" << "Value" << "Float"  << "Modify";
    ui->Table->setHorizontalHeaderLabels(header);
    connect(ui->Table,SIGNAL(AddNewRow()),this,SLOT(AddNewRow()));
    connect(ui->Table,SIGNAL(EditRow(int)),this,SLOT(EditRow(int)));
    connect(ui->Table,SIGNAL(DeleteRow(int)),this,SLOT(RemoveRow(int)));
    connect(ui->Table,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(CellDoubleClicked(int,int)));
    connect(ui->Table,SIGNAL(cellChanged(int,int)),this,SLOT(CellActivated(int,int)));

    MapFilePath = "/home/kubanec/workspace/ARMCM4-STM32F407-DISCOVERY/build/test.map";
    Map = new MapFileClass(MapFilePath, variables,this);

    //upper part with plots
    GraphSplitter = new QSplitter();
    ui->verticalLayout_2->addWidget(GraphSplitter);
    GraphSplitter->setOrientation(Qt::Vertical);
    GraphSplitter->setContextMenuPolicy(Qt::ActionsContextMenu);
    GraphSplitter->addAction(ui->actionAdd_new_plot);
    plotMenu = new QMenu(this);
    plotMenu->addAction(ui->actionAdd_new_plot);
    plotMenu->addSeparator();
    plotMenu->addAction(ui->actionEdit_plot);
    plotMenu->addAction(ui->actionRemove_plot);

    connect(ui->actionRefresh,SIGNAL(triggered()),Map,SLOT(FileChanged()));

    ui->mainToolBar->insertWidget(ui->actionConnect,ui->toolOpen);
    ui->mainToolBar->insertSeparator(ui->actionConnect);
    ui->mainToolBar->insertWidget(ui->actionRefresh,ui->toolMap);
    connect(ui->toolOpen,SIGNAL(clicked()),this,SLOT(on_actionOpen_triggered()));
    connect(ui->toolMap,SIGNAL(clicked()),this,SLOT(on_actionMapFile_triggered()));

    for (int i = 0 ; i < recentHistorySize; i++)
    {
        QAction * a = new QAction(ui->toolOpen);
        ui->toolOpen->addAction(a);
        connect(a,SIGNAL(triggered()),this,SLOT(action_openFile()));
        a->setVisible(false);

        a = new QAction(ui->toolMap);
        ui->toolMap->addAction(a);
        connect(a,SIGNAL(triggered()),this,SLOT(action_loadMapFile()));
        a->setVisible(false);
    }

    loadIni();
    clearWorkspace();
}
コード例 #6
0
void
CBExecOutputDocument::SetConnection
	(
	JProcess*			p,
	const int			inFD,
	const int			outFD,
	const JCharacter*	windowTitle,
	const JCharacter*	dontCloseMsg,
	const JCharacter*	execDir,
	const JCharacter*	execCmd,
	const JBoolean		showPID
	)
{
	assert( !ProcessRunning() && itsRecordLink == NULL && itsDataLink == NULL );

	itsProcess = p;
	ListenTo(itsProcess);

	if (NeedsFormattedData())
		{
		itsRecordLink = new RecordLink(inFD);
		assert( itsRecordLink != NULL );
		ListenTo(itsRecordLink);
		}
	else
		{
		itsDataLink = new DataLink(inFD);
		assert( itsDataLink != NULL );
		ListenTo(itsDataLink);
		}

	if (outFD != ACE_INVALID_HANDLE)
		{
		itsCmdStream = jnew JOutPipeStream(outFD, kJTrue);
		assert( itsCmdStream != NULL );
		}

	CBTextEditor* te = GetTextEditor();
	if (itsClearWhenStartFlag)
		{
		te->SetText("");
		}
	else if (!te->IsEmpty())
		{
		const JString& text = te->GetText();
		JIndex i            = text.GetLength()+1;
		while (i > 1 && text.GetCharacter(i-1) == '\n')
			{
			i--;
			}
		if (text.IndexValid(i))
			{
			te->SetSelection(i, text.GetLength());
			}

		te->Paste("\n\n----------\n\n");
		te->ClearUndo();
		}

	if (execCmd != NULL)
		{
		const JString timeStamp = JGetTimeStamp();

		te->Paste(timeStamp);
		te->Paste("\n");
		te->Paste(execDir);
		te->Paste("\n");
		te->Paste(execCmd);

		if (showPID)
			{
			te->Paste("\n");
			te->Paste(JGetString("ProcessID::CBExecOutputDocument"));
			te->Paste(JString(p->GetPID(), JString::kBase10));
			}

		te->Paste("\n\n");
		te->ClearUndo();
		}

	itsPath              = execDir;
	itsReceivedDataFlag  = kJFalse;
	itsProcessPausedFlag = kJFalse;
	itsDontCloseMsg      = dontCloseMsg;
	FileChanged(windowTitle, kJFalse);

	UpdateButtons();
	te->SetWritable(kJFalse);
	itsCmdInput->SetText("");
}