예제 #1
0
QStringList FileHandler::toQStringList()
{
    emit logmsg(fileName+" ["+getFileStatusString()+"] "+QString::number(fileAge()));
    QStringList tmpStringContainer;

    if(
        (  (getFileStatus() == good) || (getFileStatus() == exists)    )
       &&
        (   fileObject.open(QIODevice::ReadOnly | QIODevice::Text)  )
      )
    {
        QTextStream tmpFileStream(&fileObject);
        QString tmpLine = tmpFileStream.readLine();

        while (!tmpLine.isNull())
        {
            tmpStringContainer.push_back(tmpLine);
            tmpLine = tmpFileStream.readLine();
        }
        emit logmsg("FH: parsed:" + QString::number(tmpStringContainer.size()) + " lines" );
        fileObject.close();
        emit logmsg(m_Downloader->getLogContent());
    }
    return tmpStringContainer;
}
예제 #2
0
 void registerFile( llvm::StringRef compilerPath, llvm::StringRef replacement )
 {
     FileStatus fileStatus;
     CompilerDescription desc = { compilerPath.str(), replacement.str() };
     if ( getFileStatus( compilerPath, fileStatus ) )
         files.insert( std::make_pair( fileStatus, desc ) );
 }
예제 #3
0
const GitFileStatus& FileStatuses::getStatus(const string& fileName) const {
    /* For files which are has not status information from Git */
    const GitFileStatus* result = getFileStatus(fileName);;

    if (result == NULL) {
        result = new GitFileStatus(fileName, GitFileStatus::none,
                         GitFileStatus::none);
        m_virtualStatuses[fileName] = result;
    }
    return (*result);
}
예제 #4
0
void CommitChangesDialog::commitFiles()
{
  QString filePath = MainWindow::instance()->getModelWidgetContainer()->getCurrentModelWidget()->getLibraryTreeItem()->getFileName();
  QString nameStructure = MainWindow::instance()->getModelWidgetContainer()->getCurrentModelWidget()->getLibraryTreeItem()->getNameStructure();
  QFileInfo info(filePath);
  MainWindow::instance()->getGitCommands()->commitFiles(filePath, mpCommitDescriptionTextBox->toPlainText());
  foreach (const QString &fileName, mpModifiedFiles) {
    if(!fileName.isEmpty()) {
      QString activity = getFileStatus(fileName.mid(0, 2));
      QString fileURI = fileName.mid(3);
      generateTraceabilityURI(nameStructure, info.absolutePath(), filePath, activity, fileURI );
      }
   }
  accept();
}
예제 #5
0
void CommitChangesDialog::getChangedFiles()
{
  QString fileName = MainWindow::instance()->getModelWidgetContainer()->getCurrentModelWidget()->getLibraryTreeItem()->getFileName();

  mpModifiedFiles = MainWindow::instance()->getGitCommands()->getChangedFiles(fileName);

  if (const int oldRowCount = mpCommitChangedFilesModel->rowCount())
      mpCommitChangedFilesModel->removeRows(0, oldRowCount);
  foreach (const QString &fileName, mpModifiedFiles)
     if(!fileName.isEmpty()) {
       QString status = getFileStatus(fileName.mid(0, 2));
       QString file = fileName.mid(3);
       addFile(status, file, true);
     }
  for (int c = 0; c < mpCommitChangedFilesModel->columnCount(); c++)
      mpCommitChangedFilesTreeView->resizeColumnToContents(c);
   mpSelectAllCheckBox->setChecked(true);
}
예제 #6
0
void TextRoom::readSettings()
{
	QFile file( settings->fileName() );
	if ( !file.exists() )
	{
		toggleFullScreen();
		writeSettings();
		return;
	}

	if ( settings->value("WindowState/ShowFullScreen", true).toBool() )
	{
		if ( !isFullScreen() )
			showFullScreen();
   	}
	else
	{
		showNormal();
		QPoint pos = settings->value("WindowState/TopLeftPosition", QPoint(100, 100)).toPoint();
		QSize size = settings->value("WindowState/WindowSize", QSize(300, 200)).toSize();
		resize(size);
		move(pos);
	}

	QString foregroundColor = settings->value("Colors/FontColor", "#808080" ).toString();
	QString back = settings->value("Colors/Background", "#000000" ).toString();
	QString status_c = settings->value("Colors/StatusColor", "#202020" ).toString();

	// oxygen does weird stuff with the background
	QApplication::setStyle("plastique");

	QFont font;
	font.fromString( settings->value("StatusFont").toString());
	defaultFont.fromString( settings->value("DefaultFont").toString() );

	statsLabel->setFont( font );
	deadlineLabel->setFont ( font ) ;

	curDir = settings->value("RecentFiles/LastDir", curDir).toString();
	lastSearch = settings->value("TextSearch/LastPhrase", lastSearch).toString();

	QDateTime today = QDateTime::currentDateTime();
	QString todaytext = today.toString("yyyyMMdd");
	
// Read all the settings->
	isAutoSave = settings->value("AutoSave", false).toBool();
	isFlowMode = settings->value("FlowMode", false).toBool();
	isSound = settings->value("Sound", true).toBool();
	isPageCount = settings->value("PageCount", false).toBool();
	isCharacterCount = settings->value("CharacterCount", false).toBool();
	deadlinetext = settings->value("Deadline", todaytext).toString();
	deadline = QDate::fromString(deadlinetext, "yyyyMMdd");
	wordcount = settings->value("WordCount", 0).toInt();
	editorWidth = settings->value("EditorWidth", 800).toInt();
	editorTopSpace = settings->value("EditorTopSpace", 0).toInt();
	editorBottomSpace = settings->value("EditorBottomSpace", 0).toInt();
	alarm = settings->value("TimedWriting", 0).toInt();
	pageCountFormula = settings->value("PageCountFormula", 250).toInt();
	dateFormat = settings->value("DateFormat", "d MMMM yyyy dddd").toString();
	timeFormatBool = settings->value("24-Hour", true ).toBool();
	defaultDir = settings->value("DefaultDirectory", QDir::homePath()).toString();
	backgroundImage = settings->value("BackgroundImage", "").toString();
	isPlainText = settings->value("PlainText", false).toBool();
	language = settings->value("LanguageName", "en_US").toString();
	indentValue = settings->value("Indent", 50).toInt();
        paragraphSpacing = settings->value("ParagraphSpacing", 20).toInt();
        tabStopWidth = settings->value("TabStopWidth", 80).toInt();
	cursorWidth = settings->value("CursorWidth", 3).toInt();

        textEdit->setLayoutDirection(Qt::LayoutDirectionAuto);
        textEdit->setTabStopWidth(tabStopWidth);
	textEdit->setCursorWidth(cursorWidth);

	loadStyleSheet(foregroundColor, back, status_c);
	textEdit->setMaximumWidth(editorWidth);

	textEdit->document()->blockSignals(true);
	bool modified = textEdit->document()->isModified();
	if ( isPlainText )
	{
		QString text( textEdit->document()->toPlainText() );
		textEdit->document()->clear();
		textEdit->insertPlainText(text);
		textEdit->setAcceptRichText( false );
	}
	else
	{
		textEdit->setAcceptRichText( true );
	}

	indentLines(indentValue);

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

	if ( timeFormatBool )
	{
		timeFormat = "h:mm";
	}
	else
	{
		timeFormat = "h:mm AP";
	}

	horizontalSlider->setVisible( settings->value("ScrollBar", true).toBool() );
	isScrollBarVisible = horizontalSlider->isVisible();
	vPositionChanged();

	topSpacer->changeSize(20, editorTopSpace, QSizePolicy::Maximum, QSizePolicy::Maximum);
	bottomSpacer->changeSize(20, editorBottomSpace, QSizePolicy::Maximum, QSizePolicy::Maximum);
	
	timeOut = alarm * 60000;
	if (alarm != 0)
	{
		QTimer::singleShot(timeOut, this, SLOT(alarmTime()));
	}
	
	if ( (optOpenLastFile = settings->value("RecentFiles/OpenLastFile", true).toBool()) )
	{
		curFile = settings->value("RecentFiles/LastFile", curFile).toString();
		if ( (isSaveCursor = settings->value("RecentFiles/SavePosition", true).toBool() ))
			cPosition = settings->value("RecentFiles/AtPosition", cPosition).toInt();
	}

	wordCountChanged = true;
	getFileStatus();
	sCursor();
}
예제 #7
0
TextRoom::TextRoom(QWidget *parent, Qt::WFlags f)
		: QWidget(parent, f), sentenceTally(0)
{
	setupUi(this);
	setObjectName("textroom");

// Set the default values for variables.
	numChanges = 0;
	prevLength = 0;
	wordcount = 0;
	alarm = 0;
	parasold = 0;
	isHighlighted = false;

#ifdef Q_OS_MACX
	// Find the path for the app path 
	QDir tmpDir = QDir(QCoreApplication::applicationDirPath());
	// go into Resources folder
	tmpDir.cdUp();
	tmpDir.cd("Resources");
	// get the full path for the resources
	resourcesDir = tmpDir.path();
#endif

// Create the dialog windows.
	optionsDialog = new OptionsDialog(this);
	helpDialog = new HelpDialog(this);
	selectFont = new SelectFont(this);
	aboutDialog = new AboutDialog(this);
	scratchDialog = new ScratchDialog(this);
	miniFlo = new MiniFlo(this);
	getAWord = new GetAWord(this);
	musicRoom = new MusicRoom(this);
	googleDocsDialog = new GoogleDocsDialog(this);	

// Read settings saved by Options Dialog.
#ifdef Q_OS_WIN32
	settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::applicationName());
#else
	settings = new QSettings();
#endif
	readSettings();

// Sound adjustments.
	int audio_rate = 11025;
	Uint16 audio_format = AUDIO_S16SYS;
	int audio_channels = 2;
	int audio_buffers = 1024;
	
	if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {
		fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
		exit(1);
	}
	atexit(SDL_Quit);
	
	if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) {
		printf("Unable to initialize audio: %s\n", Mix_GetError());
		exit(1);
	}

// Load sounds.
#ifdef Q_OS_WIN32
	soundenter = Mix_LoadWAV("keyenter.wav");
#elif defined(Q_OS_MACX)
	QString tmp = resourcesDir;
	tmp.append("/sounds/keyenter.wav");
	soundenter = Mix_LoadWAV(tmp.toAscii());
#else
	soundenter = Mix_LoadWAV("/usr/share/sounds/keyenter.wav");
#endif
	if(soundenter == NULL) {
		printf("Unable to load WAV file: %s\n", Mix_GetError());
	}

#ifdef Q_OS_WIN32
	soundany = Mix_LoadWAV("keyany.wav");
#elif defined(Q_OS_MACX)
	tmp = resourcesDir;
	tmp.append("/sounds/keyany.wav");
	soundany = Mix_LoadWAV(tmp.toAscii());
#else
	soundany = Mix_LoadWAV("/usr/share/sounds/keyany.wav");
#endif
	if(soundany == NULL) {
		printf("Unable to load WAV file: %s\n", Mix_GetError());
	}
		
// Create the keyboard shortcuts.
	new QShortcut ( QKeySequence(QKeySequence::New), this, SLOT( newFile() ) );
	new QShortcut ( QKeySequence(QKeySequence::Open), this, SLOT( open() ) );
	new QShortcut ( QKeySequence(QKeySequence::Save), this, SLOT( save() ) );
	new QShortcut ( QKeySequence(QKeySequence::HelpContents), this, SLOT( help() ) );
#ifdef Q_OS_MACX
	new QShortcut ( QKeySequence(tr("F1", "Help")), this, SLOT( help() ) );
#endif
	new QShortcut ( QKeySequence(tr("F2", "Options")), this, SLOT( options() ) );
	new QShortcut ( QKeySequence(tr("F3", "About")), this, SLOT( about() ) );
	new QShortcut ( QKeySequence(tr("F5", "Spell Check")), this, SLOT( spellCheck() ) );
	new QShortcut ( QKeySequence(tr("F6", "Scratch Pad")), this, SLOT( showScratchPad() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+P", "Print")), this, SLOT( print() ) );
	new QShortcut ( QKeySequence(tr("Shift+Ctrl+S", "Save As")), this, SLOT( saveAs() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+D", "Insert Date")), this, SLOT( insertDate() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+T", "Insert Time")), this, SLOT( insertTime() ) );	
	new QShortcut ( QKeySequence(tr("Ctrl+Q", "Quit Application")) , this, SLOT( close() ) );
	new QShortcut ( QKeySequence(tr("Alt+F4", "Quit Application")) , this, SLOT( close() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+F", "Find Text")) , this, SLOT( find() ) );
	new QShortcut ( QKeySequence(tr("F11", "Toggle Fullscreen")) , this, SLOT( toggleFullScreen() ) );
	new QShortcut ( QKeySequence(tr("Esc", "Toggle Fullscreen")) , this, SLOT( toggleEscape() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+M", "Minimize TextRoom")) , this, SLOT( showMinimized() ) );
	new QShortcut ( QKeySequence(tr("F4", "Find Next")) , this, SLOT( find_next() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+F4", "Find Previous")) , this, SLOT( find_previous() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+B", "Bold")) , this, SLOT( textBold() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+I", "Italic")) , this, SLOT( textItalic() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+Up", "Increase Text Size")) , this, SLOT( textSizeUp() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+Down", "Decrease Text Size")) , this, SLOT( textSizeDown() ) );	
	new QShortcut ( QKeySequence(tr("Ctrl+W", "Select Font")) , this, SLOT( changeFont() ) );	
        new QShortcut ( QKeySequence(tr("Ctrl+R", "Align Right")) , this, SLOT( alignRight() ) );
        new QShortcut ( QKeySequence(tr("Ctrl+L", "Align Left")) , this, SLOT( alignLeft() ) );
        new QShortcut ( QKeySequence(tr("Ctrl+J", "Align Justify")) , this, SLOT( alignJustify() ) );
        new QShortcut ( QKeySequence(tr("Ctrl+E", "Align Center")) , this, SLOT( alignCenter() ) );
        new QShortcut ( QKeySequence(tr("Ctrl+Alt+I", "Insert Image")) , this, SLOT( insertImage() ) );
        new QShortcut ( QKeySequence(tr("F7", "Show MiniFlo")) , this, SLOT( showMiniFlo() ) );
        new QShortcut ( QKeySequence(tr("F8", "Get A Word")) , this, SLOT( showGetAWord() ) );
        new QShortcut ( QKeySequence(tr("F9", "MusicRoom")) , this, SLOT( showMusicRoom() ) );
        new QShortcut ( QKeySequence(tr("F10", "Google Docs")) , this, SLOT( exportToGoogle() ) );
	// Service: show cursor
	new QShortcut ( QKeySequence(tr("Shift+F4", "Show Cursor")) , this, SLOT( sCursor() ) );

	//fw = new QFileSystemWatcher(this);
	//fw->addPath( settings->fileName() );

	// If file is changed, read the settings->
	//connect(fw, SIGNAL(fileChanged(const QString)),
	//		this, SLOT(readSettings()));
	// If the document is changed, do some stuff.
	connect(textEdit->document(), SIGNAL(contentsChanged()),
		this, SLOT(documentWasModified()));

	// If position is changed, scroll.
	connect(textEdit->verticalScrollBar(), SIGNAL(valueChanged(int)),
		this, SLOT(vPositionChanged()));
	// If horizontal scrollar is changed, scroll.
	connect(horizontalSlider, SIGNAL(valueChanged(int)),
		this, SLOT(hSliderPositionChanged()));
	connect(textEdit, SIGNAL(anchorClicked(QUrl)), this, SLOT(showScratchPad()));

	// check if we need to open some file at startup
	const QStringList args = QCoreApplication::arguments();
	if (args.count() == 2)
	{
		QFile file( args.at(1) );
		if ( file.exists() )
			curFile = args.at(1);
	}
	
	if (!curFile.isEmpty())
		loadFile(curFile);
	else
		newFile();


	// set cursor position
	if ( isSaveCursor )
	{
		textEdit->textCursor().setPosition(cPosition);
	}

	writeSettings();

// Refresh the file status every second.
	QTimer *timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), this, SLOT(getFileStatus()));
	timer->start(1000);
}
예제 #8
0
void TextRoom::loadFile(const QString &fileName)
{
// Loads the file.
	QApplication::setOverrideCursor(Qt::WaitCursor);

	QFile file(fileName);
	if (!file.open(QFile::ReadOnly | QFile::Text))
	{
		QMessageBox::warning(this, qApp->applicationName(),
							 tr("Cannot read file %1:\n%2.")
							 .arg(fileName)
							 .arg(file.errorString()));
		newFile();
		return;
	}
	else if (fileName.endsWith("odt"))
	{
		QMessageBox::warning(this, qApp->applicationName(),
							tr("Cannot read odt files."));
		newFile();
		return;
	}
	
	QByteArray data = file.readAll();
	QTextCodec *codec = QTextCodec::codecForName("UTF-8");

	textEdit->document()->blockSignals(true);
	textEdit->setUndoRedoEnabled(false);
	textEdit->setPlainText("");
	scratchDialog->ui.scratchTextEdit->setPlainText("");

	QString strall = codec->toUnicode(data);
	QStringList strlist = strall.split("\n<split>\n", QString::SkipEmptyParts);
	if (fileName.endsWith("txr") && strlist.length() > 1)
	{
		QString strscratch = strlist.at(0);
		QString strdoc = strlist.at(1);

		textEdit->append(strdoc);
		scratchDialog->ui.scratchTextEdit->append(strscratch);
	}
	else
	{
		textEdit->append(strall);
	}

	if (fileName.endsWith("txt"))
	{
		textEdit->setFont(defaultFont);
	}
	QString text = textEdit->document()->toPlainText();

	textEdit->moveCursor(QTextCursor::Start);

	parasold = textEdit->document()->blockCount();
	indentLines(indentValue);
	setCurrentFile(fileName);
	textEdit->setUndoRedoEnabled(true);
	textEdit->document()->blockSignals(false);
	vPositionChanged();
	wordCountChanged = true;
	getFileStatus();

	QApplication::restoreOverrideCursor();
}