Exemplo n.º 1
0
void MainWindow::setCurrentFile(const QString &fileName)
{
    curFile = fileName;
    setWindowModified(false);

    QString shownName = "Untitled";
    if (!curFile.isEmpty()) {
        shownName = strippedName(curFile);
        recentFiles.removeAll(curFile);
        recentFiles.prepend(curFile);
        updateRecentFileActions();
    }

    setWindowTitle(tr("%1[*] - %2").arg(shownName)
                                   .arg(tr("Spreadsheet")));
}
Exemplo n.º 2
0
void MainWindow::saveFormAs()
{
	QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
													recentFolder,
													tr("Jupiter Forms (*.jform);;All Files (*.*)"));
	if (fileName != "")
	{
		if (!fileName.toLower().endsWith(".jform"))
			fileName += ".jform";
		setWindowFilePath(fileName);
		form->saveFile(fileName);
		setWindowModified(false);
		recentFolder = QFileInfo(fileName).path();
		updateRecentFile(fileName);
	}
}
Exemplo n.º 3
0
void QWERTYEditor::setCurrentFile(const QString &fileName) {
	/* 
		Функция установки текущего файла. 
		Вызывается для сброса состояний переменных при загрузки\сохранения\изменении
		и тд файл. Обновляется имя файла. Если имя пустое, то показываем имя new.txt
	*/

    curFile = fileName;
    textEdit->document()->setModified(false);
    setWindowModified(false);

    QString shownName = curFile;
    if (curFile.isEmpty())
        shownName = "new.txt";
    setWindowFilePath(shownName);
}
Exemplo n.º 4
0
void MdiChild::setCurrentFile(const QString &fileName)
{
  curFile = QFileInfo(fileName).canonicalFilePath();
  isUntitled = false;
  fileChanged = false;
  setWindowModified(false);
  updateTitle();
  int MaxRecentFiles = g.historySize();
  QStringList files = g.recentFiles();
  files.removeAll(fileName);
  files.prepend(fileName);
  while (files.size() > MaxRecentFiles)
      files.removeLast();

  g.recentFiles( files );
}
Exemplo n.º 5
0
void VentanaPrincipal::setArchivoActual(const QString &nombreArchivo)
{
    archivoActual = nombreArchivo;

    editorTexto->document()->setModified(false);
    setWindowModified(false);

    QString nombreaAMostrar = archivoActual;

    if (archivoActual.isEmpty())
    {
        nombreaAMostrar = "Archivo sin nombre.txt";
    }

    setWindowFilePath(nombreaAMostrar);
}
void WordFrequencyForm::exportFrequencyList()
{
    if (!wordFrequencyList_)
    {
        QMessageBox::information(this, tr("Unable to export frequency list"),
                                 tr("Unable to export frequency list. There is no list to export."));
        return;
    }

    QString wflistFilePath = QFileDialog::getSaveFileName(this, tr("Save word frequency list file..."),
                             workingDirectoryPath_, tr("XML files (*.xml)"));
    if (!wflistFilePath.isEmpty())
    {
        wordFrequencyList_->write_xml(wflistFilePath.toStdString());
        setWindowModified(false);
    }
}
Exemplo n.º 7
0
void MainWindow::loadFile(const QString &fileName)
{
    //if is empty
    if(fileName.isEmpty())
    {
        //set the file name
        this->setFileName(QString ());
        ui->AppOutput->append("No file is open");
        return;
    }
    // create a QFile Object with the fileName variable
    QFile *qfo=new QFile(fileName);

    //if
    if(!(qfo->open(QIODevice::Text|QIODevice::ReadOnly)))
    {
        ui->AppOutput->append("The file "+fileName+" cannot be opened");
        QMessageBox::warning(this,"Error","The file cannot be opened",QMessageBox::Ok,QMessageBox::Ok);
        setFileName(QString());
        return;
    }
    else
    {
        ui->AppOutput->append("The file at "+fileName+" is opened");
        QTextStream qts(qfo);
        //codigo de parseo.

        int count_lines=0;
        while(!qts.atEnd())
        {
            //se lee la linea
            QString line=qts.readLine();
            //se muestra en la pantalla
            ui->textEdit->appendPlainText(line);
            //se envia a parsearla
            lineParser(line);
            //se cuenta la cantidad de lineas
            count_lines++;
        }
        ui->AppOutput->append("Lines: "+QString::number(count_lines));
        qfo->close();
        setFileName(fileName);
        setWindowModified(false);
    }

}
Exemplo n.º 8
0
//*****************************************************************************
void mlMainWindow::setCurrentFile(const QString &fileName) {

    curFile = fileName;
    ui->tbxEditor->document()->setModified(false);
    setWindowModified(false);

    QString shownName = curFile;
    if( curFile.isEmpty() )
        shownName = "untitled.txt";
    else
        shownName = strippedName();

    setWindowFilePath(shownName);
    setWindowTitle( tr("%1 - %2[*]")
                    .arg(sAPPNAME)
                    .arg(shownName) );
}
Exemplo n.º 9
0
/*--------------------------------------- Private functions -----------------------------------------*/
bool PicEditWindow::saveFile(const QString &fileName){
    // !!! if here the cursor state change hasn't been used, the program will announce abnormal ending
    // once close the program ??? why
    // set cursor as wait state
    QApplication::setOverrideCursor(Qt::WaitCursor);

    // emit save file signal
    emit saveImgFile(fileName);
    settitle(fileName);

    // restore cursor state
    QApplication::restoreOverrideCursor();

    // restore window modify state
    setWindowModified(false);

    return true;
}
void ArchiverWindow::slotFileOpen()
{
    QString fileName =
        QFileDialog::getOpenFileName(this, tr("Open Archive"),
                                     QString(), tr("Tar Archives (*.tar *.tar.gz *.tar.xz *.tar.bz2 *.tgz *.tbz2"));
    if (!fileName.isEmpty()) {
        setBusy(true);

        if (m_model->openArchive(fileName)) {
            setWindowModified(false);
            setWindowFilePath(fileName);

            setBusy(false);

            ui->actionFileSaveAs->setEnabled(false);
        }
    }
}
void MeshSubWindow::setCurrentFile(const QString &fileName)
{
	curFile = fileName;
	setWindowModified(false);

	QString shownName = tr("Untitled");
	if (!curFile.isEmpty()) 
	{
		shownName = strippedName(curFile);
		recentFiles.removeAll(curFile);
		recentFiles.prepend(curFile);
		//emit current_file_changed();
	}

	setWindowTitle(tr("%1[*] - %2").arg(shownName)
		.arg(tr("Simplex Spline")));
	updateStatusBar();
}
Exemplo n.º 12
0
bool MainWindow::resize()
{
    bool ok;
    int width = QInputDialog::getInt(this, tr("Painter"),
                                         tr("Please enter the width"
                                            "(less than 1024)"),
                                     painter->curSize().width(), 0,
                                     1024, 1, &ok);
    if(!ok) return ok;
    int height = QInputDialog::getInt(this, tr("Painter"),
                                         tr("Please enter the height"
                                            "(less than 1024)"),
                                      painter->curSize().height(), 0,
                                      1024, 1, &ok);
    if(!ok) return ok;
    setWindowModified(painter->setSize(QSize(width, height)));
    return ok;
}
Exemplo n.º 13
0
bool HtmlEditor::fileSave()
{
    if (fileName.isEmpty() || fileName.startsWith(QLatin1String(":/")))
        return fileSaveAs();

    QFile file(fileName);
    bool success = file.open(QIODevice::WriteOnly);
    if (success) {
        // FIXME: here we always use UTF-8 encoding
        QString content = ui->webView->page()->mainFrame()->toHtml();
        QByteArray data = content.toUtf8();
        qint64 c = file.write(data);
        success = (c >= data.length());
    }

    setWindowModified(false);
    return success;
}
Exemplo n.º 14
0
void HtmlEditor::setCurrentFileName(const QString &fileName)
{
    this->fileName = fileName;

    QString shownName;
    if (fileName.isEmpty())
        shownName = "untitled";
    else
        shownName = QFileInfo(fileName).fileName();

    setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("HTML Editor")));
    setWindowModified(false);

    bool allowSave = true;
    if (fileName.isEmpty() || fileName.startsWith(QLatin1String(":/")))
        allowSave = false;
    ui->actionFileSave->setEnabled(allowSave);
}
Exemplo n.º 15
0
//////////////////////////////////////////////////////////////////
//单文档实现。
void CMainWindow::setCurrentFile(const QString& fileName)
{
	curFile = QFileInfo(fileName).canonicalFilePath();
	isUntitled = false;
	setWindowTitle(curFile + "[*]");	
	textEdit->document()->setModified(false);
	setWindowModified(false);
	
	QSettings settings("709", "SDI example");
	QStringList files = settings.value("recentFiles").toStringList();
	files.removeAll(fileName);
	files.prepend(fileName);
	while (files.size() > MaxRecentFiles)
		files.removeLast();
	settings.setValue("recentFiles", files);

	updateRecentFiles();
}
Exemplo n.º 16
0
void MdiChild::setView(MdiChild *mdiChild)
{
	_document = mdiChild->view();
	setDocument(_document);
	bool modified = document()->isModified();
	setCurrentFile(_document->fileName());
	document()->setModified(modified);
	isUntitled = mdiChild->isUntitled;
	setWindowModified(modified);
	setWindowTitle(userFriendlyCurrentFile() + "[*]");

	connect(_document, SIGNAL(contentsChanged()),
		this, SLOT(documentContentsChanged()));
	connect(document(), SIGNAL(modificationChanged(bool)),
		this, SLOT(documentWasModified()));
	connect(_document, SIGNAL(fileNameChanged(QString)),
		this, SLOT(setCurrentFile(QString)));
}
Exemplo n.º 17
0
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent),
   m_toolBar(this),
   m_aboutDialog(this),
   m_helpBrowser(this),
   m_viewerModel(this),
   m_viewerView(this),
   m_undoStack(this),
   m_undoStackView(&m_undoStack, this),
   m_viewerSelectionModel(&m_viewerModel, this),
   m_logMessageDialog(0),
   m_preferencesBrowser(this),
   m_quiInputDialog(0),
   m_context(0)
{
   QGLFormat format(QGL::SampleBuffers);
   format.setVersion(2,1);
   format.setProfile(QGLFormat::CompatibilityProfile);
   //format.setSampleBuffers(true);
   //format.setSamples(4);
   //format.setVersion(3,3);
   //format.setProfile(QGLFormat::CoreProfile);

   m_context = new QGLContext(format);
   m_viewer  = new Viewer(m_context, m_viewerModel, this);
   m_viewer->initShaders();

   setStatusBar(0);
   setWindowTitle("IQmol");
   setWindowModified(false);
   setAcceptDrops(false);
   setWindowIcon(QIcon(":/resources/icons/iqmol.png"));

   createMenus();
   createLayout();
   createConnections(); 

   m_undoStack.setUndoLimit(Preferences::UndoLimit());
   m_undoStackView.setEmptyLabel("History:");
   m_viewerView.setModel(&m_viewerModel);
   m_viewerView.setSelectionModel(&m_viewerSelectionModel);
   m_viewer->setActiveViewerMode(Viewer::BuildAtom);
   m_viewer->setDefaultSceneRadius();
   m_viewer->resetView();
}
Exemplo n.º 18
0
/*
  Save the file currently in the editor.
*/
bool MainWindow::save( )
{
  QFile file(currentFile);
	if(file.open(QFile::WriteOnly | QFile::Text))
	{
    QTextStream out(&file);
    QApplication::setOverrideCursor(Qt::WaitCursor);
    out << editor->toPlainText();
    QApplication::restoreOverrideCursor();
    editor->document()->setModified(false);
    setWindowModified(false);
    return true;
	}
  else
  {
    statusBar()->showMessage( "Couldn't save...maybe the current file has been moved or deleted.", 3500 );
    return false;
  }
}
Exemplo n.º 19
0
void Opeke::openFile(const QString &inputFileName)
{
    QString tmpFile;
    if ( KIO::NetAccess::download (inputFileName, tmpFile, this ) )
    {
        emit clear();
        fileName = inputFileName;
        QFile* file  = new QFile (tmpFile);
        file->open ( QIODevice::ReadOnly );
        m_view->openBricks(file);
        file->close();
        setWindowModified(false);
        setCaption(fileName, false);
    }
    else
    {
        KMessageBox::error ( this, KIO::NetAccess::lastErrorString() );
    }
}
void	win_char_editor::file_open()
{
	if (!ask_if_save())
		return;

	QString new_file = open_chr(this);
	if (!new_file.isEmpty())
		if (w_main->char_open(new_file, &(c->cs), TRUE))
			{
			file = new_file;
			never_saved = FALSE;
			setWindowModified(FALSE);
			setWindowTitle(QFileInfo(file).completeBaseName() + "[*] - Char Editor");
			char_width->setCurrentIndex(c->cs.width - 1);
			c->ur.clear();
			c->setUpdatesEnabled(FALSE);
			c->setUpdatesEnabled(TRUE);
			}
}
Exemplo n.º 21
0
void UXTEditor::insertRow()
{
	blockTableSignals( true );

	d_ptr->infos.push_back( STRING_MANAGER::TStringInfo() );
	d_ptr->t->setRowCount( d_ptr->t->rowCount() + 1 );
	int row = d_ptr->t->rowCount() - 1;

	QTableWidgetItem *item1 = new QTableWidgetItem();
	QTableWidgetItem *item2 = new QTableWidgetItem();
	d_ptr->t->setItem( row, 0, item1 );
	d_ptr->t->setItem( row, 1, item2 );

	markRowUntranslated( row );

	setWindowModified( true );

	blockTableSignals( false );
}
Exemplo n.º 22
0
bool AnnoqtConfEditor::saveFile( const QString &fileName )
{
  QFile file( fileName );

  if ( !file.open( QFile::WriteOnly | QFile::Text ) )
  {
    QMessageBox::warning( this, tr( "Application" ),
                          tr( "Cannot write file %1:\n%2." )
                          .arg( fileName )
                          .arg( file.errorString() ) );
    return false;
  }

  QTextStream out( &file );

  out << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << endl;
  out << "<annotationConfiguration>" << endl;
  out << "  <entities>" << endl;
  QApplication::setOverrideCursor( Qt::WaitCursor );

  for (int i = 0; i < m_listWidget->count(); i++)
  {
    QListWidgetItem* item = m_listWidget->item(i);
    out << "    <entity name=\""<<item->text()<<"\" color=\""<<item->background().color().name()<<"\"";
    if (item->checkState() == Qt::Checked)
    {
      out << " recursive=\"true\"";
    }
    out << "/>" << endl;
  }


  
  QApplication::restoreOverrideCursor();
  out << "  </entities>" << endl;
  out << "  <templates>" << endl;
  out << "  </templates>" << endl;
  out << "</annotationConfiguration>" << endl;

  statusBar()->showMessage( tr( "File saved" ), 2000 );
  setWindowModified( false );
  return true;
}
Exemplo n.º 23
0
/*!

*/
void Monofin::setCurrentFile(const QString &fileName)
{
    qDebug() << QString("entering Monofin::setCurrentFile(%1)...").arg(fileName);
    _curFile = fileName;
    setWindowModified(false);

    QString shownName = tr("(Untitled %1)").arg(documentNumber);
    _isUntitled = true;

    if (!_curFile.isEmpty()) {
        shownName = strippedName(_curFile);
        qDebug() << QString("setting current file name %1").arg(shownName);
        _isUntitled = false;
        emit currentFileChanged();
    }

    setWindowTitle(tr("%1[*]").arg(shownName));
    qDebug("leaving Monofin::setCurrentFile...");
}
Exemplo n.º 24
0
void MainWindow::plainTextChanged()
{
    QString code = ui->plainTextEdit->toPlainText();

    // update statistics
    if (wordCountLabel) {
        int words = ui->plainTextEdit->countWords();
        int lines = ui->plainTextEdit->document()->lineCount();
        int chars = ui->plainTextEdit->document()->characterCount();
        wordCountLabel->setText(tr("%1 words").arg(words));
        wordCountLabel->setToolTip(tr("Lines: %1  Words: %2  Characters: %3").arg(lines).arg(words).arg(chars));
    }

    // generate HTML from markdown
    generator->markdownTextChanged(code);

    // show modification indicator in window title
    setWindowModified(ui->plainTextEdit->document()->isModified());
}
Exemplo n.º 25
0
void MainWindow::setCurrentFile(const QString &fileName)
{
    static int sequenceNumber = 1;

    isUntitled = fileName.isEmpty();
    if (isUntitled) {
        curFile = tr("document%1.txt").arg(sequenceNumber++);
    } else {
        curFile = QFileInfo(fileName).canonicalFilePath();
    }

    textEdit->document()->setModified(false);
    setWindowModified(false);

    if (!isUntitled && windowFilePath() != curFile)
        MainWindow::prependToRecentFiles(curFile);

    setWindowFilePath(curFile);
}
Exemplo n.º 26
0
bool MainWindow::fileSave()
{
    // file has no name yet?
    if (fileName.isEmpty()) {
        return fileSaveAs();
    }

    QTextDocumentWriter writer(fileName, "plaintext");
    bool success = writer.write(ui->plainTextEdit->document());
    if (success) {
        // set status to unmodified
        ui->plainTextEdit->document()->setModified(false);
        setWindowModified(false);

        // add to recent file list
        recentFilesMenu->addFile(QDir::toNativeSeparators(fileName));
    }

    return success;
}
Exemplo n.º 27
0
void TextRoom::setCurrentFile(const QString &fileName)
{
	curFile = fileName;

	const QFileInfo f(fileName);
	
	textEdit->document()->setModified(false);
	setWindowModified(false);

	if (curFile.isEmpty())
	{
		shownName = "Untitled.txr";
   	}
	else
	{
		shownName = strippedName(curFile);
		curDir = f.absolutePath();
   	}
	setWindowTitle(tr("%1[*] - %2").arg(shownName).arg( qApp->applicationName() ));
}
Exemplo n.º 28
0
void MainWindow::slotSaveProject(QString filename)
{
    if (filename.length() == 0) {
        filename = m_project->projectFilename();
    }	
    if (filename.length() == 0) {
        qDebug() << "No filename given, won't save. (Perhaps an empty project?)";
        statusBar()->showMessage(tr("No filename given, won't save. (Perhaps an empty project?)"), 5000);
    } else {
        qDebug() << "Saving project as " << filename;
        try {
            XmlProjectRW_sV writer;
            writer.saveProject(m_project, filename);
            statusBar()->showMessage(QString(tr("Saved project as: %1")).arg(filename));
            setWindowModified(false);
        } catch (Error_sV &err) {
            QMessageBox(QMessageBox::Warning, tr("Error writing project file"), err.message()).exec();
        }
    }
}
Exemplo n.º 29
0
/*
  A file has been removed from the project.
  Close it if it's open in the editor, and remove it from the list
  of project files in the dropdown.
*/
void MainWindow::removeFileFromProject(QString file)
{
  QFileInfo fi(file);
  int idx = currentFileDropDown->findData(fi.filePath());
  // remove the file from the dropdown
  if(idx > -1)
    currentFileDropDown->removeItem(idx);
  // if it's currently loaded in the editor, get it out
  if(file == currentFile)
  {
    QString newfile = currentFileDropDown->itemData(currentFileDropDown->currentIndex()).toString();
    if(!newfile.isEmpty())
      editorLoadFile(newfile);
    else
    {
      currentFile = "";
      editor->clear();
      setWindowModified(false);
    }
  }
}
Exemplo n.º 30
0
void AnnoqtConfEditor::loadAnnotationConfigurationFile(const QString& fileName)
{
  if (fileName.isEmpty())
      return;

  QFile file(fileName);
  if (!file.open(QFile::ReadOnly | QFile::Text)) {
      QMessageBox::warning(this, tr("Annotation Tool"),
                            tr("Cannot read file %1:\n%2.")
                            .arg(fileName)
                            .arg(file.errorString()));
      return;
  }

  m_currentAnnotationConfigurationFile = fileName;

  m_listWidget->clear();
  m_colors.clear();
  setWindowModified( false );

  QList<QString> recursiveEntityTypes;
  AnnotationConfigurationHandler handler(m_listWidget, &m_colors, &m_colorNames2EntityTypes, &recursiveEntityTypes, true);
  QXmlSimpleReader reader;
  reader.setContentHandler(&handler);
  reader.setErrorHandler(&handler);

  QXmlInputSource xmlInputSource(&file);
  if (reader.parse(xmlInputSource))
      statusBar()->showMessage(tr("Annotation Configuration File loaded"), 2000);

  for (QMap<QString, QString>::const_iterator it=m_colorNames2EntityTypes.begin();
        it != m_colorNames2EntityTypes.end(); it++)
  {
    m_entityNames2Types.insert(it.value(),m_entityNames2Types.size());
    m_entityTypes2Names.insert(m_entityNames2Types.size()-1,it.value());
    m_entityTypes2ColorNames.insert(m_entityNames2Types[it.value()],it.key());
  }
  statusBar()->showMessage( tr( "Loaded configuration file " ) + fileName );
}