Changeset View
Changeset View
Standalone View
Standalone View
korganizer/akonadicollectionview.cpp
Show First 20 Lines • Show All 713 Lines • ▼ Show 20 Lines | if ( xmlclient ) { | ||||
disableAction->setIcon(KIconLoader().loadIcon(QLatin1String("list-remove"), KIconLoader::Small)); | disableAction->setIcon(KIconLoader().loadIcon(QLatin1String("list-remove"), KIconLoader::Small)); | ||||
//Enable (subscribe) to a calendar. | //Enable (subscribe) to a calendar. | ||||
mEnableAction = xmlclient->actionCollection()->addAction( QLatin1String("collection_enable"), this, SLOT(edit_enable()) ); | mEnableAction = xmlclient->actionCollection()->addAction( QLatin1String("collection_enable"), this, SLOT(edit_enable()) ); | ||||
mEnableAction->setText( i18n( "Add to list permanently" ) ); | mEnableAction->setText( i18n( "Add to list permanently" ) ); | ||||
mEnableAction->setIcon(KIconLoader().loadIcon(QLatin1String("bookmarks"), KIconLoader::Small)); | mEnableAction->setIcon(KIconLoader().loadIcon(QLatin1String("bookmarks"), KIconLoader::Small)); | ||||
connect( mDefaultCalendar, SIGNAL(triggered(bool)), this, SLOT(setDefaultCalendar()) ); | connect( mDefaultCalendar, SIGNAL(triggered(bool)), this, SLOT(setDefaultCalendar()) ); | ||||
connect(collectionFilter, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(calendarColorChanged(QModelIndex,QModelIndex))); | |||||
} | } | ||||
} | } | ||||
AkonadiCollectionView::~AkonadiCollectionView() | AkonadiCollectionView::~AkonadiCollectionView() | ||||
{ | { | ||||
//Necessary because it's apparently impossible to detect in the note expander when to save the state before view get's deleted | //Necessary because it's apparently impossible to detect in the note expander when to save the state before view get's deleted | ||||
mNewNodeExpander->saveState(); | mNewNodeExpander->saveState(); | ||||
} | } | ||||
Show All 22 Lines | void AkonadiCollectionView::setDefaultCalendar() | ||||
updateMenu(); | updateMenu(); | ||||
updateView(); | updateView(); | ||||
emit defaultResourceChanged( collection ); | emit defaultResourceChanged( collection ); | ||||
} | } | ||||
void AkonadiCollectionView::assignColor() | void AkonadiCollectionView::assignColor() | ||||
{ | { | ||||
QModelIndex index = mCollectionView->selectionModel()->currentIndex(); //selectedRows() | const QModelIndex index = mCollectionView->selectionModel()->currentIndex(); //selectedRows() | ||||
Q_ASSERT( index.isValid() ); | Q_ASSERT( index.isValid() ); | ||||
const Akonadi::Collection collection = CalendarSupport::collectionFromIndex( index ); | Akonadi::Collection collection = CalendarSupport::collectionFromIndex( index ); | ||||
Q_ASSERT( collection.isValid() ); | Q_ASSERT( collection.isValid() ); | ||||
const QString identifier = QString::number( collection.id() ); | const QColor defaultColor = KOHelper::resourceColor(collection); | ||||
const QColor defaultColor = KOPrefs::instance()->resourceColor( identifier ); | |||||
QColor myColor; | QColor myColor; | ||||
const int result = KColorDialog::getColor( myColor, defaultColor ); | const int result = KColorDialog::getColor( myColor, defaultColor ); | ||||
if ( result == KColorDialog::Accepted && myColor != defaultColor ) { | if ( result == KColorDialog::Accepted && myColor != defaultColor ) { | ||||
KOPrefs::instance()->setResourceColor( identifier, myColor ); | KOHelper::setResourceColor(collection, myColor); | ||||
emit colorsChanged(); | |||||
mCollectionView->model()->setData(index, QVariant::fromValue(collection), Akonadi::EntityTreeModel::CollectionRole); | |||||
updateMenu(); | updateMenu(); | ||||
updateView(); | updateView(); | ||||
} | } | ||||
} | } | ||||
void AkonadiCollectionView::calendarColorChanged(const QModelIndex &topLeft, const QModelIndex &buttomRight) | |||||
{ | |||||
//We may want to have here a logic to detect only color changes | |||||
Q_UNUSED(topLeft); | |||||
Q_UNUSED(buttomRight); | |||||
Akonadi::Collection collection = CalendarSupport::collectionFromIndex(topLeft); | |||||
Q_ASSERT( collection.isValid() ); | |||||
emit colorsChanged(); | |||||
} | |||||
void AkonadiCollectionView::disableColor() | void AkonadiCollectionView::disableColor() | ||||
{ | { | ||||
QModelIndex index = mCollectionView->selectionModel()->currentIndex(); //selectedRows() | QModelIndex index = mCollectionView->selectionModel()->currentIndex(); //selectedRows() | ||||
Q_ASSERT( index.isValid() ); | Q_ASSERT( index.isValid() ); | ||||
const Akonadi::Collection collection = CalendarSupport::collectionFromIndex( index ); | Akonadi::Collection collection = CalendarSupport::collectionFromIndex( index ); | ||||
Q_ASSERT( collection.isValid() ); | Q_ASSERT( collection.isValid() ); | ||||
const QString identifier = QString::number( collection.id() ); | KOHelper::setResourceColor(collection, QColor()); | ||||
KOPrefs::instance()->setResourceColor( identifier, QColor() ); | mCollectionView->model()->setData(index, QVariant::fromValue(collection), Akonadi::EntityTreeModel::CollectionRole); | ||||
updateMenu(); | updateMenu(); | ||||
updateView(); | updateView(); | ||||
emit colorsChanged(); | |||||
} | } | ||||
void AkonadiCollectionView::setCollectionSelectionProxyModel( KCheckableProxyModel *m ) | void AkonadiCollectionView::setCollectionSelectionProxyModel( KCheckableProxyModel *m ) | ||||
{ | { | ||||
if ( mSelectionProxyModel == m ) { | if ( mSelectionProxyModel == m ) { | ||||
return; | return; | ||||
} | } | ||||
Show All 36 Lines | void AkonadiCollectionView::updateMenu() | ||||
bool disableStuff = true; | bool disableStuff = true; | ||||
if ( index.isValid() ) { | if ( index.isValid() ) { | ||||
//Returns an invalid collection on person nodes | //Returns an invalid collection on person nodes | ||||
const Akonadi::Collection collection = CalendarSupport::collectionFromIndex( index ); | const Akonadi::Collection collection = CalendarSupport::collectionFromIndex( index ); | ||||
if ( collection.isValid() && !collection.contentMimeTypes().isEmpty() ) { | if ( collection.isValid() && !collection.contentMimeTypes().isEmpty() ) { | ||||
const QString identifier = QString::number( collection.id() ); | const QColor defaultColor = KOHelper::resourceColor(collection); | ||||
const QColor defaultColor = KOPrefs::instance()->resourceColor( identifier ); | |||||
enableAction = enableAction && defaultColor.isValid(); | enableAction = enableAction && defaultColor.isValid(); | ||||
mDisableColor->setEnabled( enableAction ); | mDisableColor->setEnabled( enableAction ); | ||||
mDefaultCalendar->setEnabled( !KOHelper::isStandardCalendar( collection.id() ) && | mDefaultCalendar->setEnabled( !KOHelper::isStandardCalendar( collection.id() ) && | ||||
collection.rights() & Akonadi::Collection::CanCreateItem ); | collection.rights() & Akonadi::Collection::CanCreateItem ); | ||||
disableStuff = false; | disableStuff = false; | ||||
} | } | ||||
if ( collection.isValid() && collection.shouldList(Akonadi::Collection::ListDisplay) ) { | if ( collection.isValid() && collection.shouldList(Akonadi::Collection::ListDisplay) ) { | ||||
mEnableAction->setEnabled(false); | mEnableAction->setEnabled(false); | ||||
▲ Show 20 Lines • Show All 265 Lines • Show Last 20 Lines |