- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
void KateQuickOpen::update () {
// пропущено
QModelIndex idxToSelect;
int linecount = 0;
QMapIterator<qint64, KTextEditor::View *> i2(sortedViews);
while (i2.hasNext()) {
i2.next();
KTextEditor::Document *doc = i2.value()->document();
if (alreadySeenDocs.contains(doc))
continue;
alreadySeenDocs.insert (doc);
QStandardItem *itemName = new QStandardItem(doc->documentName());
itemName->setData(qVariantFromValue(QPointer<KTextEditor::Document> (doc)), DocumentRole);
itemName->setData(QString("%1: %2").arg(doc->documentName()).arg(doc->url().pathOrUrl()), SortFilterRole);
itemName->setEditable(false);
QFont font = itemName->font();
font.setBold(true);
itemName->setFont(font);
QStandardItem *itemUrl = new QStandardItem(doc->url().pathOrUrl());
itemUrl->setEditable(false);
base_model->setItem(linecount, 0, itemName);
base_model->setItem(linecount, 1, itemUrl);
linecount++;
if (!doc->url().isEmpty() && doc->url().isLocalFile())
alreadySeenFiles.insert (doc->url().toLocalFile());
// select second document, that is the last used (beside the active one)
if (linecount == 2)
idxToSelect = itemName->index();
}
// get all open documents
QList<KTextEditor::Document*> docs = Kate::application()->documentManager()->documents();
foreach(KTextEditor::Document *doc, docs) {
// skip docs already open
if (alreadySeenDocs.contains (doc))
continue;
QStandardItem *itemName = new QStandardItem(doc->documentName());
itemName->setData(qVariantFromValue(QPointer<KTextEditor::Document> (doc)), DocumentRole);
itemName->setData(QString("%1: %2").arg(doc->documentName()).arg(doc->url().pathOrUrl()), SortFilterRole);
itemName->setEditable(false);
QFont font = itemName->font();
font.setBold(true);
itemName->setFont(font);
QStandardItem *itemUrl = new QStandardItem(doc->url().pathOrUrl());
itemUrl->setEditable(false);
base_model->setItem(linecount, 0, itemName);
base_model->setItem(linecount, 1, itemUrl);
linecount++;
if (!doc->url().isEmpty() && doc->url().isLocalFile())
alreadySeenFiles.insert (doc->url().toLocalFile());
}
// insert all project files, if any project around
if (Kate::PluginView *projectView = m_mainWindow->mainWindow()->pluginView ("kateprojectplugin")) {
QStringList projectFiles = projectView->property ("projectFiles").toStringList();
foreach (const QString &file, projectFiles) {
// skip files already open
if (alreadySeenFiles.contains (file))
continue;
QFileInfo fi (file);
QStandardItem *itemName = new QStandardItem(fi.fileName());
itemName->setData(qVariantFromValue(KUrl::fromPath (file)), UrlRole);
itemName->setData(QString("%1: %2").arg(fi.fileName()).arg(file), SortFilterRole);
itemName->setEditable(false);
QFont font = itemName->font();
font.setBold(true);
itemName->setFont(font);
QStandardItem *itemUrl = new QStandardItem(file);
itemUrl->setEditable(false);
base_model->setItem(linecount, 0, itemName);
base_model->setItem(linecount, 1, itemUrl);
linecount++;
}
}
// swap models and kill old one
m_model->setSourceModel (base_model);
delete m_base_model;
m_base_model = base_model;
// пропущено
}
Адская копипаста. У меня мозг сегфолтится при попытке ее формализировать.
https://projects.kde.org/projects/kde/applications/kate/repository/revisions/master/entry/kate/app/katequickopen.cpp#L135