55 q->layout()->setContentsMargins(0, 0, 0, 0);
56 ui.searchFilter->searchLine()->setTreeWidget(
ui.list);
57 ui.list->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
66 ui.list->setSelectionBehavior(QAbstractItemView::SelectItems);
67 ui.list->setSelectionMode(QAbstractItemView::SingleSelection);
69 ui.list->setEditTriggers(QAbstractItemView::NoEditTriggers);
70 ui.list->setAlternatingRowColors(
true);
74 QObject::connect(scroller, SIGNAL(stateChanged(QScroller::State)),
75 q, SLOT(slotScrollerStateChanged(QScroller::State)));
78 QObject::connect(
delegate, SIGNAL(shortcutChanged(QVariant,QModelIndex)),
81 QObject::connect(
ui.searchFilter->searchLine(), SIGNAL(hiddenChanged(QTreeWidgetItem*,
bool)),
82 delegate, SLOT(hiddenBySearchLine(QTreeWidgetItem*,
bool)));
84 QObject::connect(
ui.searchFilter->searchLine(), SIGNAL(searchUpdated(QString)),
85 q, SLOT(searchUpdated(QString)));
87 ui.searchFilter->setFocus();
234 QTreeWidgetItem *root =
ui.list->invisibleRootItem();
237 doc.setDefaultFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
239 QTextCursor cursor(&doc);
240 cursor.beginEditBlock();
241 QTextCharFormat headerFormat;
242 headerFormat.setProperty(QTextFormat::FontSizeAdjustment, 3);
243 headerFormat.setFontWeight(QFont::Bold);
244 cursor.insertText(i18nc(
"header for an applications shortcut list",
"Shortcuts for %1",
245 QGuiApplication::applicationDisplayName()),
247 QTextCharFormat componentFormat;
248 componentFormat.setProperty(QTextFormat::FontSizeAdjustment, 2);
249 componentFormat.setFontWeight(QFont::Bold);
250 QTextBlockFormat componentBlockFormat = cursor.blockFormat();
251 componentBlockFormat.setTopMargin(16);
252 componentBlockFormat.setBottomMargin(16);
254 QTextTableFormat tableformat;
255 tableformat.setHeaderRowCount(1);
256 tableformat.setCellPadding(4.0);
257 tableformat.setCellSpacing(0);
258 tableformat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
259 tableformat.setBorder(0.5);
262 shortcutTitleToColumn << qMakePair(i18n(
"Main:"),
LocalPrimary);
263 shortcutTitleToColumn << qMakePair(i18n(
"Alternate:"),
LocalAlternate);
265 for (
int i = 0; i < root->childCount(); i++) {
266 QTreeWidgetItem *item = root->child(i);
267 cursor.insertBlock(componentBlockFormat, componentFormat);
268 cursor.insertText(item->text(0));
270 QTextTable *table = cursor.insertTable(1, 3);
271 table->setFormat(tableformat);
274 QTextTableCell cell = table->cellAt(currow, 0);
275 QTextCharFormat format = cell.format();
276 format.setFontWeight(QFont::Bold);
277 cell.setFormat(format);
278 cell.firstCursorPosition().insertText(i18n(
"Action Name"));
280 cell = table->cellAt(currow, 1);
281 cell.setFormat(format);
282 cell.firstCursorPosition().insertText(i18n(
"Shortcuts"));
284 cell = table->cellAt(currow, 2);
285 cell.setFormat(format);
286 cell.firstCursorPosition().insertText(i18n(
"Description"));
289 for (QTreeWidgetItemIterator it(item); *it; ++it) {
295 table->insertRows(table->rows(), 1);
296 QVariant data = editoritem->
data(
Name, Qt::DisplayRole);
297 table->cellAt(currow, 0).firstCursorPosition().insertText(data.toString());
299 QTextTable *shortcutTable = 0;
300 for (
int k = 0; k < shortcutTitleToColumn.count(); k++) {
301 data = editoritem->
data(shortcutTitleToColumn.at(k).second, Qt::DisplayRole);
302 QString key = data.value<QKeySequence>().toString();
304 if (!key.isEmpty()) {
305 if (!shortcutTable) {
306 shortcutTable = table->cellAt(currow, 1).firstCursorPosition().insertTable(1, 2);
307 QTextTableFormat shortcutTableFormat = tableformat;
308 shortcutTableFormat.setCellSpacing(0.0);
309 shortcutTableFormat.setHeaderRowCount(0);
310 shortcutTableFormat.setBorder(0.0);
311 shortcutTable->setFormat(shortcutTableFormat);
313 shortcutTable->insertRows(shortcutTable->rows(), 1);
315 shortcutTable->cellAt(shortcutTable->rows() - 1, 0)\
316 .firstCursorPosition().insertText(shortcutTitleToColumn.at(k).first);
317 shortcutTable->cellAt(shortcutTable->rows() - 1, 1)\
318 .firstCursorPosition().insertText(key);
322 QAction *action = editoritem->
m_action;
323 cell = table->cellAt(currow, 2);
324 format = cell.format();
325 format.setProperty(QTextFormat::FontSizeAdjustment, -1);
326 cell.setFormat(format);
327 cell.firstCursorPosition().insertHtml(action->whatsThis());
331 cursor.movePosition(QTextCursor::End);
333 cursor.endEditBlock();
336 QPrintDialog *dlg =
new QPrintDialog(&printer,
q);
337 if (dlg->exec() == QDialog::Accepted) {