本文整理汇总了C++中TextEdit::document方法的典型用法代码示例。如果您正苦于以下问题:C++ TextEdit::document方法的具体用法?C++ TextEdit::document怎么用?C++ TextEdit::document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextEdit
的用法示例。
在下文中一共展示了TextEdit::document方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tabWidgetContains
int FrostEdit::tabWidgetContains(TabWidget* wid, Document* doc) {
for(int i = 0; i < wid->count(); i++) {
TextEdit* edit = toTextEdit(wid->widget(i));
if(edit == nullptr)
continue;
if(toDocument(edit->document()) == doc) {
return i;
}
}
return -1;
}
示例2: openEditors
int FrostEdit::openEditors(Document* doc) {
int open = 0;
for(TabWidgetFrame* tab: mTabWidgetFrames) {
for(int i = 0; i < tab->tabWidget()->count(); i++) {
TextEdit* edit = toTextEdit(tab->tabWidget()->widget(i));
if(edit != NULL && edit->document() == doc)
open++;
}
}
return open;
}
示例3: currentTabPageChanged
void FrostEdit::currentTabPageChanged(int id) {
if(id == -1) {
disableActions();
return;
}
QWidget* wid = mCurrentTabWidget->widget(id);
if(wid == nullptr) {
disableActions();
return;
}
TextEdit* e = toTextEdit(wid);
if(e != nullptr && e->document() != getActiveDocument())
emit documentChanged(toDocument(e->document()));
//if there's no editor, let's disable some buttons.
if(e == nullptr) {
disableActions();
} else { //there was editor, enable them
enableActions();
}
}
示例4: updateTabHeader
void FrostEdit::updateTabHeader(Document* doc, bool b) {
for(TabWidgetFrame* tab: mTabWidgetFrames) {
for(int i = 0; i < tab->tabWidget()->count(); i++) {
TextEdit* edit = toTextEdit(tab->tabWidget()->widget(i));
if(edit != nullptr && edit->document() == doc) {
tab->tabWidget()->setTabText(i, doc->getDynamicName());
changeTitle(tab->tabWidget(), i);
}
}
}
}
示例5: on_actionSave_triggered
void FrostEdit::on_actionSave_triggered() {
TextEdit* e = toTextEdit(mCurrentTabWidget->currentWidget());
Document* doc = toDocument(e->document());
if(doc->getFileInfo().isFile()) {
mDocumentWatcher->removePath(doc->getFullPath());
doc->save();
mDocumentWatcher->addPath(doc->getFullPath());
} else {
QString prevPath = doc->getFullPath();
on_actionSave_As_triggered();
if(mCompiledFile == prevPath)
mCompiledFile = doc->getFullPath();
}
updateTabHeader(doc, doc->isModified());
}
示例6: on_actionSave_As_triggered
void FrostEdit::on_actionSave_As_triggered() {
QString file = QFileDialog::getSaveFileName(this, "Save as", "", "FrostBasic code files (*.frb);;CoolBasic code files (*.cb);;Text files (.txt);;All files (*.*)");
if(!file.isEmpty()) {
TextEdit* e = toTextEdit(mCurrentTabWidget->currentWidget());
Document* doc = toDocument(e->document());
mDocumentWatcher->removePath(doc->getFullPath());
for(TabWidgetFrame* tab: mTabWidgetFrames) {
tab->removeComboBoxItem(doc->getFullPath());
tab->addComboBoxItem(file);
}
doc->saveAs(file);
mDocumentWatcher->addPath(file);
updateTabHeader(doc, doc->isModified());
doc->getItem()->update();
}
}
示例7: updateDocumentSelection
void FrostEdit::updateDocumentSelection(TabWidget* wid, int sel) {
if(wid->count() == 0)
return;
if(!wid->count())
return;
TextEdit* e = toTextEdit(wid->widget(sel));
if(e == NULL)
return;
Document* doc = toDocument(e->document());
TabWidgetFrame* parentWidget = toTabWidgetFrame(wid->parentWidget());
parentWidget->setCurrentItem(doc->getFullPath());
if(doc->isActualFile())
mFileSystemTreeView->setCurrentIndex(mFileSystemModel->index(doc->getFullPath()));
doc->getItem()->setSelected(true);
}
示例8: addEditor
void FrostEdit::addEditor(QListWidgetItem* item) {
DocumentItem* docitem = static_cast<DocumentItem*>(item);
Document* doc = docitem->getDocument();
for(int i = 0; i < mCurrentTabWidget->count(); i++) {
TextEdit* edit = toTextEdit(mCurrentTabWidget->widget(i));
if(toDocument(edit->document()) == doc) {
mCurrentTabWidget->setCurrentIndex(i);
return;
}
}
TextEdit* edit = new TextEdit(mCurrentTabWidget, doc);
edit->setFindReplaceInstance(mFindReplace);
edit->setFont(mFont);
mSyntaxStyle.applyToTextEdit(edit);
mCurrentTabWidget->addTab(edit, doc->getDynamicName());
mCurrentTabWidget->setCurrentIndex(mCurrentTabWidget->count()-1);
}
示例9: closeTab
void FrostEdit::closeTab(TabWidget* wid, int id) {
qDebug() << wid << id;
TextEdit* e = toTextEdit(wid->widget(id));
Document* doc = toDocument(e->document());
int editors = openEditors(doc);
qDebug() << "Open in editors: " << editors;
int ans = -1;
if(editors == 1) {
ans = documentSafeClose(doc);
if(ans == 0 || ans == 1) {
wid->removeTab(id);
delete e;
removeDocument(doc);
return;
}
}
wid->removeTab(id);
}
示例10: removeDocument
void FrostEdit::removeDocument(Document* doc) {
for(TabWidgetFrame* tab: mTabWidgetFrames) {
tab->removeComboBoxItem(doc->getFullPath());
for(int i = 0; i < tab->tabWidget()->count(); i++) {
TextEdit* edit = toTextEdit(tab->tabWidget()->widget(i));
if(edit->document() == doc) {
tab->tabWidget()->removeTab(i);
delete edit;
}
}
}
mOpenDocuments.remove(doc->getFullPath());
mDocumentWatcher->removePath(doc->getFullPath());
disconnect(doc, &Document::textChanged, this, &FrostEdit::updateTabHeader);
disconnect(doc, &Document::exterminate, this, &FrostEdit::removeDocument);
delete doc;
doc = nullptr;
}
示例11: CreateTextEdit
TextEdit* MainWindow::CreateTextEdit()
{
TextEdit* child = new TextEdit;
++m_countOfFiles;
//mdiArea->addSubWindow(child);
/*if(tabWidget->count() == 1)
{
tabWidget->insertTab(0, child, "new file");
}
else
{
tabWidget->addTab(child, tr("new file %1").arg(tabWidget->count()+1));
}*/
connect( child, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
connect( child, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
connect( child->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool)) );
connect( child->document(), SIGNAL(redoAvailable(bool)), actionRecover, SLOT(setEnabled(bool)) );
return child;
}
示例12: getActiveDocument
Document* FrostEdit::getActiveDocument() {
TextEdit* edit = toTextEdit(mCurrentTabWidget->currentWidget());
if(edit == nullptr)
return nullptr;
return toDocument(edit->document());
}