本文整理汇总了C++中ktexteditor::View::setFocus方法的典型用法代码示例。如果您正苦于以下问题:C++ View::setFocus方法的具体用法?C++ View::setFocus怎么用?C++ View::setFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktexteditor::View
的用法示例。
在下文中一共展示了View::setFocus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: infoSelected
void View::infoSelected(QTreeWidgetItem* item, int column)
{
Q_UNUSED(column);
QString path = item->data(0, Qt::ToolTipRole).toString();
uint line = item->data(1, Qt::ToolTipRole).toUInt();
uint col = item->data(2, Qt::ToolTipRole).toUInt();
if(!path.isEmpty() && QFile::exists(path)) {
KUrl url(path);
KTextEditor::View* kv = mw->openUrl(url);
if(line > 0) {
kv->setCursorPosition(KTextEditor::Cursor(line - 1, col - 1));
} else {
// Line = 0 is used to show information about a file.
// Just go to the beginning.
kv->setCursorPosition(KTextEditor::Cursor(0, 0));
}
kv->setFocus();
kDebug() << "Opened file: " << path;
} else {
setStatus(i18n("File not found: %1", path));
}
}
示例2: slotExport
void DataOutputWidget::slotExport()
{
if (m_model->rowCount() <= 0)
return;
while (m_model->canFetchMore())
m_model->fetchMore();
if (!m_view->selectionModel()->hasSelection())
m_view->selectAll();
ExportWizard wizard(this);
if (wizard.exec() != QDialog::Accepted)
return;
bool outputInDocument = wizard.field("outDocument").toBool();
bool outputInClipboard = wizard.field("outClipboard").toBool();
bool outputInFile = wizard.field("outFile").toBool();
bool exportColumnNames = wizard.field("exportColumnNames").toBool();
bool exportLineNumbers = wizard.field("exportLineNumbers").toBool();
Options opt = NoOptions;
if (exportColumnNames)
opt |= ExportColumnNames;
if (exportLineNumbers)
opt |= ExportLineNumbers;
bool quoteStrings = wizard.field("checkQuoteStrings").toBool();
bool quoteNumbers = wizard.field("checkQuoteNumbers").toBool();
QChar stringsQuoteChar = (quoteStrings) ? wizard.field("quoteStringsChar").toString().at(0) : '\0';
QChar numbersQuoteChar = (quoteNumbers) ? wizard.field("quoteNumbersChar").toString().at(0) : '\0';
QString fieldDelimiter = wizard.field("fieldDelimiter").toString();
if (outputInDocument)
{
Kate::MainWindow *mw = Kate::application()->activeMainWindow();
KTextEditor::View *kv = mw->activeView();
if (!kv)
return;
QString text;
QTextStream stream(&text);
exportData(stream, stringsQuoteChar, numbersQuoteChar, fieldDelimiter, opt);
kv->insertText(text);
kv->setFocus();
}
else if (outputInClipboard)
{
QString text;
QTextStream stream(&text);
exportData(stream, stringsQuoteChar, numbersQuoteChar, fieldDelimiter, opt);
kapp->clipboard()->setText(text);
}
else if (outputInFile)
{
QString url = wizard.field("outFileUrl").toString();
QFile data(url);
if (data.open(QFile::WriteOnly | QFile::Truncate))
{
QTextStream stream(&data);
exportData(stream, stringsQuoteChar, numbersQuoteChar, fieldDelimiter, opt);
stream.flush();
}
else
{
KMessageBox::error(this, i18nc("@info", "Unable to open file <filename>%1</filename>").arg(url));
}
}
}