Changeset View
Changeset View
Standalone View
Standalone View
sidebar/SidebarMode.cpp
Show First 20 Lines • Show All 253 Lines • ▼ Show 20 Line(s) | 222 | public: | |||
---|---|---|---|---|---|
254 | void setActionMenuVisible(SidebarMode* sidebarMode, const bool &actionMenuVisible) | 254 | void setActionMenuVisible(SidebarMode* sidebarMode, const bool &actionMenuVisible) | ||
255 | { | 255 | { | ||
256 | if (m_actionMenuVisible == actionMenuVisible) { | 256 | if (m_actionMenuVisible == actionMenuVisible) { | ||
257 | return; | 257 | return; | ||
258 | } | 258 | } | ||
259 | m_actionMenuVisible = actionMenuVisible; | 259 | m_actionMenuVisible = actionMenuVisible; | ||
260 | emit sidebarMode->actionMenuVisibleChanged(); | 260 | emit sidebarMode->actionMenuVisibleChanged(); | ||
261 | } | 261 | } | ||
262 | bool m_introPageVisible = true; | ||||
262 | }; | 263 | }; | ||
263 | 264 | | |||
264 | SidebarMode::SidebarMode( QObject *parent, const QVariantList& ) | 265 | SidebarMode::SidebarMode( QObject *parent, const QVariantList& ) | ||
265 | : BaseMode( parent ) | 266 | : BaseMode( parent ) | ||
266 | , d( new Private() ) | 267 | , d( new Private() ) | ||
267 | { | 268 | { | ||
268 | qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); | 269 | qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); | ||
269 | d->aboutIcon = new KAboutData( QStringLiteral("SidebarView"), i18n( "Sidebar View" ), | 270 | d->aboutIcon = new KAboutData( QStringLiteral("SidebarView"), i18n( "Sidebar View" ), | ||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Line(s) | 411 | { | |||
416 | for (const QString &actionName : actionList) { | 417 | for (const QString &actionName : actionList) { | ||
417 | menu->addAction(d->collection->action(actionName)); | 418 | menu->addAction(d->collection->action(actionName)); | ||
418 | } | 419 | } | ||
419 | 420 | | |||
420 | menu->popup(position); | 421 | menu->popup(position); | ||
421 | d->setActionMenuVisible(this, true); | 422 | d->setActionMenuVisible(this, true); | ||
422 | } | 423 | } | ||
423 | 424 | | |||
424 | void SidebarMode::changeModule( const QModelIndex& activeModule ) | 425 | void SidebarMode::changeModule( const QModelIndex& activeModule ) | ||
mart: this should be a bool property setter | |||||
425 | { | 426 | { | ||
426 | d->moduleView->closeModules(); | 427 | d->moduleView->closeModules(); | ||
427 | 428 | | |||
428 | const int subRows = d->searchModel->rowCount(activeModule); | 429 | const int subRows = d->searchModel->rowCount(activeModule); | ||
429 | if ( subRows < 2) { | 430 | if ( subRows < 2) { | ||
430 | d->moduleView->loadModule( activeModule ); | 431 | d->moduleView->loadModule( activeModule ); | ||
431 | } else { | 432 | } else { | ||
432 | d->moduleView->loadModule( d->searchModel->index(0, 0, activeModule) ); | 433 | d->moduleView->loadModule( d->searchModel->index(0, 0, activeModule) ); | ||
Show All 10 Lines | |||||
443 | 444 | | |||
444 | int SidebarMode::activeCategory() const | 445 | int SidebarMode::activeCategory() const | ||
445 | { | 446 | { | ||
446 | return d->searchModel->mapFromSource(d->searchModel->sourceModel()->index(d->activeCategory, 0)).row(); | 447 | return d->searchModel->mapFromSource(d->searchModel->sourceModel()->index(d->activeCategory, 0)).row(); | ||
447 | } | 448 | } | ||
448 | 449 | | |||
449 | void SidebarMode::setActiveCategory(int cat) | 450 | void SidebarMode::setActiveCategory(int cat) | ||
450 | { | 451 | { | ||
452 | if (cat != -1) { | ||||
453 | setIntroPageVisible(false); | ||||
454 | } | ||||
455 | | ||||
451 | const QModelIndex idx = d->searchModel->index(cat, 0); | 456 | const QModelIndex idx = d->searchModel->index(cat, 0); | ||
452 | const int newCategoryRow = d->searchModel->mapToSource(idx).row(); | 457 | const int newCategoryRow = d->searchModel->mapToSource(idx).row(); | ||
453 | 458 | | |||
454 | if (d->activeCategory == newCategoryRow) { | 459 | if (d->activeCategory == newCategoryRow) { | ||
455 | return; | 460 | return; | ||
456 | } | 461 | } | ||
457 | if( !d->moduleView->resolveChanges() ) { | 462 | if( !d->moduleView->resolveChanges() ) { | ||
458 | return; | 463 | return; | ||
Show All 19 Lines | 476 | { | |||
478 | } | 483 | } | ||
479 | 484 | | |||
480 | d->activeSubCategory = cat; | 485 | d->activeSubCategory = cat; | ||
481 | d->moduleView->closeModules(); | 486 | d->moduleView->closeModules(); | ||
482 | d->moduleView->loadModule( d->subCategoryModel->index(cat, 0) ); | 487 | d->moduleView->loadModule( d->subCategoryModel->index(cat, 0) ); | ||
483 | emit activeSubCategoryChanged(); | 488 | emit activeSubCategoryChanged(); | ||
484 | } | 489 | } | ||
485 | 490 | | |||
491 | void SidebarMode::setIntroPageVisible(const bool &introPageVisible) | ||||
492 | { | ||||
493 | if (d->m_introPageVisible == introPageVisible) { | ||||
494 | return; | ||||
495 | } | ||||
496 | | ||||
497 | if (introPageVisible) { | ||||
498 | setActiveCategory(-1); | ||||
GB_2: Yes, here. | |||||
499 | d->placeHolderWidget->show(); | ||||
500 | d->moduleView->hide(); | ||||
501 | } else { | ||||
502 | d->placeHolderWidget->hide(); | ||||
503 | d->moduleView->show(); | ||||
504 | } | ||||
505 | | ||||
506 | d->m_introPageVisible = introPageVisible; | ||||
507 | emit introPageVisibleChanged(); | ||||
508 | } | ||||
509 | | ||||
486 | int SidebarMode::width() const | 510 | int SidebarMode::width() const | ||
487 | { | 511 | { | ||
488 | return d->mainWidget->width(); | 512 | return d->mainWidget->width(); | ||
489 | } | 513 | } | ||
490 | 514 | | |||
491 | bool SidebarMode::actionMenuVisible() const | 515 | bool SidebarMode::actionMenuVisible() const | ||
492 | { | 516 | { | ||
493 | return d->m_actionMenuVisible; | 517 | return d->m_actionMenuVisible; | ||
494 | } | 518 | } | ||
495 | 519 | | |||
496 | int SidebarMode::activeSubCategory() const | 520 | int SidebarMode::activeSubCategory() const | ||
497 | { | 521 | { | ||
498 | return d->activeSubCategory; | 522 | return d->activeSubCategory; | ||
499 | } | 523 | } | ||
500 | 524 | | |||
525 | bool SidebarMode::introPageVisible() const | ||||
526 | { | ||||
527 | return (d->m_introPageVisible); | ||||
528 | } | ||||
529 | | ||||
501 | void SidebarMode::initWidget() | 530 | void SidebarMode::initWidget() | ||
502 | { | 531 | { | ||
503 | // Create the widgets | 532 | // Create the widgets | ||
504 | 533 | | |||
505 | if (!KMainWindow::memberList().isEmpty()) { | 534 | if (!KMainWindow::memberList().isEmpty()) { | ||
506 | KXmlGuiWindow *mainWindow = qobject_cast<KXmlGuiWindow *>(KMainWindow::memberList().first()); | 535 | KXmlGuiWindow *mainWindow = qobject_cast<KXmlGuiWindow *>(KMainWindow::memberList().first()); | ||
507 | if (mainWindow) { | 536 | if (mainWindow) { | ||
508 | d->collection = mainWindow->actionCollection(); | 537 | d->collection = mainWindow->actionCollection(); | ||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |
this should be a bool property setter