Changeset View
Changeset View
Standalone View
Standalone View
src/akonadicollectionview.cpp
Show First 20 Lines • Show All 762 Lines • ▼ Show 20 Line(s) | |||||
763 | 763 | | |||
764 | void AkonadiCollectionView::assignColor() | 764 | void AkonadiCollectionView::assignColor() | ||
765 | { | 765 | { | ||
766 | QModelIndex index = mCollectionView->selectionModel()->currentIndex(); //selectedRows() | 766 | QModelIndex index = mCollectionView->selectionModel()->currentIndex(); //selectedRows() | ||
767 | Q_ASSERT(index.isValid()); | 767 | Q_ASSERT(index.isValid()); | ||
768 | const Akonadi::Collection collection = CalendarSupport::collectionFromIndex(index); | 768 | const Akonadi::Collection collection = CalendarSupport::collectionFromIndex(index); | ||
769 | Q_ASSERT(collection.isValid()); | 769 | Q_ASSERT(collection.isValid()); | ||
770 | 770 | | |||
771 | const QString identifier = QString::number(collection.id()); | 771 | const QColor defaultColor = KOHelper::resourceColor(collection); | ||
772 | const QColor defaultColor = KOPrefs::instance()->resourceColor(identifier); | | |||
773 | QColor myColor; | 772 | QColor myColor; | ||
774 | myColor = QColorDialog::getColor(defaultColor); | 773 | myColor = QColorDialog::getColor(defaultColor); | ||
775 | if (myColor.isValid() && myColor != defaultColor) { | 774 | if (myColor.isValid() && myColor != defaultColor) { | ||
776 | KOPrefs::instance()->setResourceColor(identifier, myColor); | 775 | KOHelper::setResourceColor(collection, myColor); | ||
777 | KOPrefs::instance()->eventViewsPreferences()->writeConfig(); | | |||
778 | Q_EMIT colorsChanged(); | 776 | Q_EMIT colorsChanged(); | ||
779 | updateMenu(); | 777 | updateMenu(); | ||
780 | updateView(); | 778 | updateView(); | ||
781 | } | 779 | } | ||
782 | } | 780 | } | ||
783 | 781 | | |||
784 | void AkonadiCollectionView::disableColor() | 782 | void AkonadiCollectionView::disableColor() | ||
785 | { | 783 | { | ||
786 | QModelIndex index = mCollectionView->selectionModel()->currentIndex(); //selectedRows() | 784 | QModelIndex index = mCollectionView->selectionModel()->currentIndex(); //selectedRows() | ||
787 | Q_ASSERT(index.isValid()); | 785 | Q_ASSERT(index.isValid()); | ||
788 | const Akonadi::Collection collection = CalendarSupport::collectionFromIndex(index); | 786 | const Akonadi::Collection collection = CalendarSupport::collectionFromIndex(index); | ||
789 | Q_ASSERT(collection.isValid()); | 787 | Q_ASSERT(collection.isValid()); | ||
790 | const QString identifier = QString::number(collection.id()); | 788 | KOHelper::setResourceColor(collection, QColor()); | ||
791 | KOPrefs::instance()->setResourceColor(identifier, QColor()); | | |||
792 | KOPrefs::instance()->eventViewsPreferences()->writeConfig(); | | |||
793 | updateMenu(); | 789 | updateMenu(); | ||
794 | updateView(); | 790 | updateView(); | ||
795 | Q_EMIT colorsChanged(); | 791 | Q_EMIT colorsChanged(); | ||
796 | } | 792 | } | ||
797 | 793 | | |||
798 | void AkonadiCollectionView::setCollectionSelectionProxyModel(KCheckableProxyModel *m) | 794 | void AkonadiCollectionView::setCollectionSelectionProxyModel(KCheckableProxyModel *m) | ||
799 | { | 795 | { | ||
800 | if (mSelectionProxyModel == m) { | 796 | if (mSelectionProxyModel == m) { | ||
Show All 25 Lines | 821 | Q_EMIT resourcesChanged(mSelectionProxyModel ? | |||
826 | mSelectionProxyModel->selectionModel()->hasSelection() : | 822 | mSelectionProxyModel->selectionModel()->hasSelection() : | ||
827 | false); | 823 | false); | ||
828 | } | 824 | } | ||
829 | 825 | | |||
830 | void AkonadiCollectionView::updateMenu() | 826 | void AkonadiCollectionView::updateMenu() | ||
831 | { | 827 | { | ||
832 | if (!mHasContextMenu) { | 828 | if (!mHasContextMenu) { | ||
833 | return; | 829 | return; | ||
834 | } | 830 | } | ||
dkurz: QString identifier in 829 is no longer used | |||||
835 | bool enableAction = mCollectionView->selectionModel()->hasSelection(); | 831 | bool enableAction = mCollectionView->selectionModel()->hasSelection(); | ||
836 | enableAction = enableAction && | 832 | enableAction = enableAction && | ||
837 | (KOPrefs::instance()->agendaViewColors() != KOPrefs::CategoryOnly); | 833 | (KOPrefs::instance()->agendaViewColors() != KOPrefs::CategoryOnly); | ||
838 | mAssignColor->setEnabled(enableAction); | 834 | mAssignColor->setEnabled(enableAction); | ||
839 | QModelIndex index = mCollectionView->selectionModel()->currentIndex(); //selectedRows() | 835 | QModelIndex index = mCollectionView->selectionModel()->currentIndex(); //selectedRows() | ||
840 | 836 | | |||
841 | bool disableStuff = true; | 837 | bool disableStuff = true; | ||
842 | 838 | | |||
843 | if (index.isValid()) { | 839 | if (index.isValid()) { | ||
844 | //Returns an invalid collection on person nodes | 840 | //Returns an invalid collection on person nodes | ||
845 | const Akonadi::Collection collection = CalendarSupport::collectionFromIndex(index); | 841 | const Akonadi::Collection collection = CalendarSupport::collectionFromIndex(index); | ||
846 | 842 | | |||
847 | if (collection.isValid() && !collection.contentMimeTypes().isEmpty()) { | 843 | if (collection.isValid() && !collection.contentMimeTypes().isEmpty()) { | ||
848 | const QString identifier = QString::number(collection.id()); | 844 | const QColor defaultColor = KOHelper::resourceColor(collection); | ||
849 | const QColor defaultColor = KOPrefs::instance()->resourceColor(identifier); | | |||
850 | enableAction = enableAction && defaultColor.isValid(); | 845 | enableAction = enableAction && defaultColor.isValid(); | ||
851 | if (collection.remoteId() == QLatin1String("akonadi_birthdays_resource")) { | 846 | if (collection.remoteId() == QLatin1String("akonadi_birthdays_resource")) { | ||
852 | enableAction = false; | 847 | enableAction = false; | ||
853 | mAssignColor->setEnabled(enableAction); | 848 | mAssignColor->setEnabled(enableAction); | ||
854 | } | 849 | } | ||
855 | 850 | | |||
856 | mDisableColor->setEnabled(enableAction); | 851 | mDisableColor->setEnabled(enableAction); | ||
857 | mDefaultCalendar->setEnabled(!KOHelper::isStandardCalendar(collection.id()) && | 852 | mDefaultCalendar->setEnabled(!KOHelper::isStandardCalendar(collection.id()) && | ||
▲ Show 20 Lines • Show All 254 Lines • Show Last 20 Lines |
QString identifier in 829 is no longer used