Changeset View
Changeset View
Standalone View
Standalone View
korganizer/koprefsdialog.cpp
Show All 21 Lines | /* | ||||
with any edition of Qt, and distribute the resulting executable, | with any edition of Qt, and distribute the resulting executable, | ||||
without including the source code for Qt in the source distribution. | without including the source code for Qt in the source distribution. | ||||
*/ | */ | ||||
#include "koprefsdialog.h" | #include "koprefsdialog.h" | ||||
#include "kitemiconcheckcombo.h" | #include "kitemiconcheckcombo.h" | ||||
#include "kocore.h" | #include "kocore.h" | ||||
#include "koglobals.h" | #include "koglobals.h" | ||||
#include "kohelper.h" | |||||
#include "koprefs.h" | #include "koprefs.h" | ||||
#include "ui_kogroupwareprefspage.h" | #include "ui_kogroupwareprefspage.h" | ||||
#include <calendarsupport/kcalprefs.h> | #include <calendarsupport/kcalprefs.h> | ||||
#include <calendarsupport/categoryconfig.h> | #include <calendarsupport/categoryconfig.h> | ||||
#include <calendarsupport/utils.h> | |||||
#include <incidenceeditor-ng/globalsettings.h> | #include <incidenceeditor-ng/globalsettings.h> | ||||
#include <widgets/tagwidgets.h> | #include <widgets/tagwidgets.h> | ||||
#include <Akonadi/AgentFilterProxyModel> | #include <Akonadi/AgentFilterProxyModel> | ||||
#include <Akonadi/AgentInstanceCreateJob> | #include <Akonadi/AgentInstanceCreateJob> | ||||
#include <Akonadi/AgentManager> | #include <Akonadi/AgentManager> | ||||
#include <Akonadi/AgentTypeDialog> | #include <Akonadi/AgentTypeDialog> | ||||
#include <Akonadi/CollectionComboBox> | #include <Akonadi/CollectionComboBox> | ||||
#include <Akonadi/CollectionModel> | #include <Akonadi/CollectionModel> | ||||
#include <akonadi/calendar/calendarsettings.h> | #include <akonadi/calendar/calendarsettings.h> | ||||
#include <Akonadi/EntityTreeModel> | |||||
#include <KCalCore/Event> | #include <KCalCore/Event> | ||||
#include <KCalCore/Journal> | #include <KCalCore/Journal> | ||||
#include <KHolidays/Holidays> | #include <KHolidays/Holidays> | ||||
#include <Mailtransport/TransportManagementWidget> | #include <Mailtransport/TransportManagementWidget> | ||||
▲ Show 20 Lines • Show All 906 Lines • ▼ Show 20 Lines | KOPrefsDialogColorsAndFonts::KOPrefsDialogColorsAndFonts( const KComponentData &inst, | ||||
fontLayout->setColumnStretch( 1, 1 ); | fontLayout->setColumnStretch( 1, 1 ); | ||||
fontLayout->setRowStretch( 4, 1 ); | fontLayout->setRowStretch( 4, 1 ); | ||||
load(); | load(); | ||||
} | } | ||||
void KOPrefsDialogColorsAndFonts::usrWriteConfig() | void KOPrefsDialogColorsAndFonts::usrWriteConfig() | ||||
{ | { | ||||
{ | |||||
QHash<QString, QColor>::const_iterator i = mCategoryDict.constBegin(); | QHash<QString, QColor>::const_iterator i = mCategoryDict.constBegin(); | ||||
while ( i != mCategoryDict.constEnd() ) { | while ( i != mCategoryDict.constEnd() ) { | ||||
CalendarSupport::KCalPrefs::instance()->setCategoryColor( i.key(), i.value() ); | CalendarSupport::KCalPrefs::instance()->setCategoryColor( i.key(), i.value() ); | ||||
++i; | ++i; | ||||
} | } | ||||
} | |||||
i = mResourceDict.constBegin(); | { | ||||
QHash<QPersistentModelIndex, QColor>::const_iterator i = mResourceDict.constBegin(); | |||||
while ( i != mResourceDict.constEnd() ) { | while ( i != mResourceDict.constEnd() ) { | ||||
KOPrefs::instance()->setResourceColor( i.key(), i.value() ); | const QModelIndex index = i.key(); | ||||
if (index.isValid()) { | |||||
Akonadi::Collection col = CalendarSupport::collectionFromIndex(index); | |||||
KOHelper::setResourceColor(col, i.value()); | |||||
mResourceCombo->model()->setData(index, QVariant::fromValue(col), Akonadi::EntityTreeModel::CollectionRole); | |||||
} | |||||
++i; | ++i; | ||||
} | } | ||||
} | |||||
//mCalendarViewsPrefs->writeConfig(); | //mCalendarViewsPrefs->writeConfig(); | ||||
} | } | ||||
void KOPrefsDialogColorsAndFonts::usrReadConfig() | void KOPrefsDialogColorsAndFonts::usrReadConfig() | ||||
{ | { | ||||
updateCategories(); | updateCategories(); | ||||
updateResources(); | updateResources(); | ||||
//mCalendarViewsPrefs->readConfig(); | //mCalendarViewsPrefs->readConfig(); | ||||
Show All 25 Lines | |||||
void KOPrefsDialogColorsAndFonts::updateResources() | void KOPrefsDialogColorsAndFonts::updateResources() | ||||
{ | { | ||||
updateResourceColor(); | updateResourceColor(); | ||||
} | } | ||||
void KOPrefsDialogColorsAndFonts::setResourceColor() | void KOPrefsDialogColorsAndFonts::setResourceColor() | ||||
{ | { | ||||
bool ok; | const QModelIndex index = mResourceCombo->model()->index(mResourceCombo->currentIndex(), 0); | ||||
const QString id = | if (!index.isValid()) { | ||||
QString::number( mResourceCombo->itemData( | |||||
mResourceCombo->currentIndex(), | |||||
Akonadi::CollectionModel::CollectionIdRole ).toLongLong( &ok ) ); | |||||
if( ! ok ) { | |||||
return; | return; | ||||
} | } | ||||
mResourceDict.insert( id, mResourceButton->color() ); | |||||
mResourceDict.insert(QPersistentModelIndex(index), mResourceButton->color()); | |||||
slotWidChanged(); | slotWidChanged(); | ||||
} | } | ||||
void KOPrefsDialogColorsAndFonts::updateResourceColor() | void KOPrefsDialogColorsAndFonts::updateResourceColor() | ||||
{ | { | ||||
bool ok; | const QModelIndex index = mResourceCombo->model()->index(mResourceCombo->currentIndex(), 0); | ||||
const QString id = | if (!index.isValid()) { | ||||
QString::number( mResourceCombo->itemData( | |||||
mResourceCombo->currentIndex(), | |||||
Akonadi::CollectionModel::CollectionIdRole ).toLongLong( &ok ) ); | |||||
if ( !ok ) { | |||||
return; | return; | ||||
} | } | ||||
kDebug() << id << mResourceCombo->itemText( mResourceCombo->currentIndex() ); | |||||
QColor color = mResourceDict.value( id ); | QColor color = mResourceDict.value(QPersistentModelIndex(index)); | ||||
if ( ! color.isValid() ) { | if ( ! color.isValid() ) { | ||||
color = KOPrefs::instance()->resourceColor( id ); | color = KOHelper::resourceColor(mResourceCombo->currentCollection()); | ||||
} | } | ||||
mResourceButton->setColor( color ); | mResourceButton->setColor( color ); | ||||
} | } | ||||
extern "C" | extern "C" | ||||
{ | { | ||||
KDE_EXPORT KCModule *create_korganizerconfigcolorsandfonts( QWidget *parent, const char * ) | KDE_EXPORT KCModule *create_korganizerconfigcolorsandfonts( QWidget *parent, const char * ) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 532 Lines • Show Last 20 Lines |