void NoteMgrForm::on_btnReturn_clicked()
{
    bool isNote = ui->stackedWidget->currentIndex() == 1;
    if(isNote){
        QListWidgetItem* item = ui->lwTitles->currentItem();
        if(ui->edtTitle->text() != item->text()){
            NoteStruct* note = item->data(NDR_OBJECT).value<NoteStruct*>();
            note->title = ui->edtTitle->text();
            item->setText(ui->edtTitle->text());
            item->setData(NDR_MODIFY_TAG,true);
        }
        QTextDocument* doc = ui->NoteTexts->document();
        if(doc->isModified()){
            NoteStruct* note = item->data(NDR_OBJECT).value<NoteStruct*>();
            note->content = doc->toHtml("utf-8");
            note->lastEditTime = QDateTime::currentDateTime().toMSecsSinceEpoch();
            item->setData(NDR_MODIFY_TAG,true);
            doc->setModified(false);
        }
        if(item->data(NDR_MODIFY_TAG).toBool())
            ui->btnSave->setEnabled(true);
        ui->stackedWidget->setCurrentIndex(0);
        ui->btnReturn->setEnabled(false);
        ui->edtTitle->clear();
        ui->edtCrtTime->clear();
        ui->edtLastTime->clear();
    }
}
Example #2
0
void Gitarre::onRepoViewItemChanged (QTreeWidgetItem * current, QTreeWidgetItem * previous)
{
	PurgeRepoViewContextMenu ();

	int topLevelIndex = RepoView->indexOfTopLevelItem(current);
	if (topLevelIndex != -1)	// item is a top level item
	{
		Repository *repo = Repos [topLevelIndex];

		// create context menu for the specific item
		if (repo->GetGitRepo())
		{
			RepoView->addAction(CommitRepoAction);
			RepoView->addAction(PushRepoAction);

			CommitAction->setEnabled(true);
			PushAction->setEnabled(true);
		}
		else
		{
			RepoView->addAction(FindRepoAction);

			CommitAction->setEnabled(false);
			PushAction->setEnabled(false);
		}
		RepoView->addAction(RemoveSeparator);
		RepoView->addAction(RemoveRepoAction);

		// refresh remotes menu
		if (current != previous)
			RefreshRemotesMenu (repo);
	}
	else	// provide the corresponding top level index
	{
		QTreeWidgetItem *parent = current;		// move all the way up the item hierarchy
		while (parent->parent())				// while item "parent" has a parent
			parent = parent->parent();			// set parent to its parent
		topLevelIndex = RepoView->indexOfTopLevelItem(parent);
	}
	Repository *repo = Repos [topLevelIndex];
	QTextDocument *doc = repo->GetIgnoreDocument();
	if (IgnoreEditor->document() != doc)
	{
		IgnoreEditor->setDocument(doc);
		UpdateIgnoreEditorTab (doc->isModified());
	}
}
Example #3
0
/*!
 * Returns \a true if the application is ready to start with other script. Otherwise,
 * returns \a false.
 */
bool CodeEditorWidget::OkToContinue()
{

	QTextDocument* document = codeEditor->document();

	if ( document->isModified () )
	{
		int answer = QMessageBox::warning( this, tr( "Tonatiuh" ),
		                 tr( "The document has been modified.\n"
		                     "Do you want to save your changes?"),
		                 QMessageBox::Yes | QMessageBox::Default,
		                 QMessageBox::No,
		                 QMessageBox::Cancel | QMessageBox::Escape );

		if ( answer == QMessageBox::Yes ) return SaveScript();
		else if ( answer == QMessageBox::Cancel ) return false;
	}
	return true;
}