26 #include <KStandardDirs>
33 _baseUrl = KUrl::fromPath(KGlobal::dirs()->findResourceDir(
"appdata", QString(
"plugin/apidoc/objectApi.html")));
34 _baseUrl.addPath(
"plugin/apidoc/");
36 ui =
new Ui::ApiDocWidget;
38 ui->buttonTree->setIcon(KIcon(
"view-sidetree"));
39 ui->buttonHome->setIcon(KIcon(
"go-home"));
40 ui->buttonPrev->setIcon(KIcon(
"go-previous-view"));
41 ui->buttonNext->setIcon(KIcon(
"go-next-view"));
43 ui->buttonPrev->setEnabled(
false);
44 ui->buttonNext->setEnabled(
false);
49 connect(ui->buttonTree, SIGNAL(clicked(
bool)),
this, SLOT(
showTreeOutline()));
50 connect(ui->buttonHome, SIGNAL(clicked(
bool)),
this, SLOT(
showHtmlOutline()));
51 connect(ui->docTree, SIGNAL(clicked(QModelIndex)),
this, SLOT(
showDetails(QModelIndex)));
52 connect(ui->buttonNext, SIGNAL(clicked(
bool)),
this, SLOT(
historyGoForward()));
53 connect(ui->buttonPrev, SIGNAL(clicked(
bool)),
this, SLOT(
historyGoBack()));
56 connect(ui->docDetails, SIGNAL(linkClicked(QUrl)),
this, SLOT(
showObjectApi(QUrl)));
62 ui->docDetails->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
64 ui->docTree->setModel(_model);
69 ui->pageStack->setCurrentIndex(0);
80 ui->pageStack->setCurrentIndex(1);
87 if (_historyPointer < _history.count() - 1) {
88 while (_historyPointer < _history.count() - 1) {
89 _history.removeAt(_history.count() - 1);
91 ui->buttonNext->setEnabled(
false);
95 _history.append(
"_outline");
96 if (_historyPointer > 0) {
97 ui->buttonPrev->setEnabled(
true);
104 ui->pageStack->setCurrentIndex(1);
113 ui->docDetails->setHtml(htmlDocument, _baseUrl);
114 ui->pageStack->setCurrentIndex(1);
118 if (_historyPointer < _history.count() - 1) {
119 while (_historyPointer < _history.count() -1) {
120 _history.removeAt(_history.count() - 1);
122 ui->buttonNext->setEnabled(
false);
126 if (_historyPointer > 0) {
127 ui->buttonPrev->setEnabled(
true);
134 if (aliasPage.toString().isEmpty()) {
135 kError() <<
"No path given, aborting.";
139 QString path = aliasPage.toString();
140 int len = path.length() - 1;
141 while (path.at(len) !=
'/' && len >= 0) {
148 QString
id = path.mid(len + 1);
155 if (_historyPointer <= 0) {
156 kError() <<
"Cannot go back in history, none exist";
160 if (_history.at(_historyPointer) ==
"_outline") {
167 ui->buttonNext->setEnabled(
true);
168 if (_historyPointer <= 0) {
169 ui->buttonPrev->setEnabled(
false);
175 if (_historyPointer >= _history.length() - 1) {
176 kError() <<
"Cannot go forward in history, none exist";
180 if (_history.at(_historyPointer) ==
"_outline") {
186 ui->buttonPrev->setEnabled(
true);
187 if (_historyPointer >= _history.count() - 1) {
188 ui->buttonNext->setEnabled(
false);
QString objectApiDocument(const QString &identifier)
Generates HTML document with the API documentation for the specified object.
QList< ObjectDocumentation * > objectApiList() const
Load and provide api documentation objects.
QVariant data(const QModelIndex &index, int role) const
QString apiOverviewDocument() const
Generates HTML document with the an overview over all available API objects.
void loadLocalData()
This method loads all api documentation files.