void TagPropWidget::slotSelectionChanged(QList<Album*> albums)
{

    if(albums.isEmpty())
    {
        enableItems(TagPropWidget::DisabledAll);
        return;
    }

    if(d->changed)
    {
        int rez = KMessageBox::questionYesNo(this,
                                             i18n("Previous tags were changed. "
                                                "Save changes? "));
        if(rez == KMessageBox::Yes)
        {
            slotSaveChanges();
        }

        d->changed = false;
    }

    if(albums.size() == 1)
    {
        TAlbum* const album = dynamic_cast<TAlbum*>(albums.first());

        if(!album)
        {
            return;
        }

        QString Seq = album->property(TagPropertyName::tagKeyboardShortcut());
        d->selectedAlbums.clear();
        d->selectedAlbums.append(album);
        d->titleEdit->setText(album->title());
        d->icon     = album->icon();
        d->iconButton->setIcon(SyncJob::getTagThumbnail(album));
        d->keySeqWidget->setKeySequence(Seq);

        if(album->isRoot())
            enableItems(TagPropWidget::DisabledAll);
        else
            enableItems(TagPropWidget::EnabledAll);
    }
    else
    {
        d->selectedAlbums.clear();
        QList<Album*>::iterator it;
        bool containsRoot = false;

        for(it = albums.begin(); it != albums.end(); ++it)
        {
            TAlbum* const temp = dynamic_cast<TAlbum*>(*it);

            if (temp)
            {
                d->selectedAlbums.append(temp);

                if(temp->isRoot())
                    containsRoot = true;
            }
        }

        d->titleEdit->clear();
        d->icon.clear();
        d->iconButton->setIcon(KIcon());
        d->keySeqWidget->clearKeySequence();
        if(containsRoot)
            enableItems(TagPropWidget::DisabledAll);
        else
            enableItems(TagPropWidget::IconOnly);
    }

    d->changed = false;
}
TagPropWidget::TagPropWidget(QWidget* const parent)
    : QWidget(parent), d(new Private())
{
    QGridLayout* const grid = new QGridLayout(this);
    QLabel* const logo      = new QLabel(this);

    logo->setPixmap(KIcon("tag-properties").pixmap(30,30));
    d->topLabel = new QLabel(this);
    d->topLabel->setText(i18n("Tag Properties"));
    d->topLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    d->topLabel->setWordWrap(false);

    KSeparator* const line = new KSeparator(Qt::Horizontal, this);

    // --------------------------------------------------------

    QLabel* const titleLabel = new QLabel(this);
    titleLabel->setText(i18n("&Title:"));
    titleLabel->setMargin(KDialog::marginHint());
    titleLabel->setIndent(KDialog::spacingHint());

    d->titleEdit = new SearchTextBar(this, "TagEditDlgTitleEdit",
                                     i18n("Enter tag name here"));
    d->titleEdit->setCaseSensitive(false);
    titleLabel->setBuddy(d->titleEdit);

    QLabel* const tipLabel = new QLabel(this);
    tipLabel->setTextFormat(Qt::RichText);
    tipLabel->setWordWrap(true);
    tipLabel->setMargin(KDialog::marginHint());
    tipLabel->setIndent(KDialog::spacingHint());

    QLabel* const iconTextLabel = new QLabel(this);
    iconTextLabel->setText(i18n("&Icon:"));
    iconTextLabel->setMargin(KDialog::marginHint());
    iconTextLabel->setIndent(KDialog::spacingHint());

    d->iconButton         = new QPushButton(this);
    d->iconButton->setFixedSize(40, 40);
    iconTextLabel->setBuddy(d->iconButton);

    d->resetIconButton = new QPushButton(KIcon("view-refresh"), i18n("Reset"), this);

    QLabel* const kscTextLabel = new QLabel(this);
    kscTextLabel->setText(i18n("&Shortcut:"));
    kscTextLabel->setMargin(KDialog::marginHint());
    kscTextLabel->setIndent(KDialog::spacingHint());

    d->keySeqWidget      = new KKeySequenceWidget(this);
    kscTextLabel->setBuddy(d->keySeqWidget);
    d->keySeqWidget->setCheckActionCollections(TagsActionMngr::defaultManager()->actionCollections());

    QLabel* const tipLabel2 = new QLabel(this);
    tipLabel2->setTextFormat(Qt::RichText);
    tipLabel2->setWordWrap(true);
    tipLabel2->setText(i18n("<p><b>Note:</b> <i>This shortcut can be used "
                            "to assign or unassign tag to items.</i></p>"));
    tipLabel2->setMargin(KDialog::marginHint() );
    tipLabel2->setIndent(KDialog::spacingHint());

    d->saveButton = new QPushButton(i18n("Save"));
    d->discardButton = new QPushButton(i18n("Discard"));

    // --------------------------------------------------------

    grid->addWidget(logo,               0, 0, 1, 1);
    grid->addWidget(d->topLabel,        0, 1, 1, 4);
    grid->addWidget(line,               1, 0, 1, 4);
    grid->addWidget(tipLabel,           2, 0, 1, 4);
    grid->addWidget(titleLabel,         3, 0, 1, 1);
    grid->addWidget(d->titleEdit,       3, 1, 1, 3);
    grid->addWidget(iconTextLabel,      4, 0, 1, 1);
    grid->addWidget(d->iconButton,      4, 1, 1, 1);
    grid->addWidget(d->resetIconButton, 4, 2, 1, 1);
    grid->addWidget(kscTextLabel,       5, 0, 1, 1);
    grid->addWidget(d->keySeqWidget,    5, 1, 1, 3);
    grid->addWidget(tipLabel2,          6, 0, 1, 4);
    grid->addWidget(d->saveButton,      7, 0, 1, 1);
    grid->addWidget(d->discardButton,   7, 1, 1, 1);
    grid->setRowStretch(8, 10);
    grid->setColumnStretch(3, 10);
    grid->setMargin(KDialog::marginHint());
    grid->setVerticalSpacing(KDialog::spacingHint());

    adjustSize();

    connect(d->iconButton, SIGNAL(clicked()),
            this, SLOT(slotIconChanged()));

    connect(d->titleEdit, SIGNAL(textEdited(QString)),
            this, SLOT(slotDataChanged()));

    connect(d->resetIconButton, SIGNAL(clicked()),
            this,SLOT(slotIconResetClicked()));

    connect(d->keySeqWidget, SIGNAL(keySequenceChanged(QKeySequence)),
            this, SLOT(slotDataChanged()));

    connect(d->saveButton, SIGNAL(clicked()),
            this, SLOT(slotSaveChanges()));

    connect(d->discardButton, SIGNAL(clicked()),
            this, SLOT(slotDiscardChanges()));

    enableItems(TagPropWidget::DisabledAll);
}
STSourceEditor::STSourceEditor(QWidget *parent) : QWidget(parent) {
	ui.setupUi(this);
	CppHighlighter *m_highlighter_header=new CppHighlighter;
	CppHighlighter *m_highlighter_source=new CppHighlighter;
	m_highlighter_header->setDocument(ui.header->editor()->document());
	m_highlighter_source->setDocument(ui.source->editor()->document());
	
	QMap<QString,QTextCharFormat> formats;
	QTextCharFormat format;
	
	format.setForeground(QBrush(Qt::darkGreen));
	formats["comment"]=format;
	
	format.setForeground(QBrush(Qt::darkBlue));
	formats["cpp_keyword"]=format;
	
	format.setForeground(QBrush(Qt::darkMagenta));
	formats["qt_keyword"]=format;
	
	format.setForeground(QBrush(Qt::darkGray));
	formats["operator"]=format;
	
	format.setForeground(QBrush(Qt::darkGray));
	formats["number"]=format;
	
	format.setForeground(QBrush(Qt::red));
	formats["escape_char"]=format;
	
	format.setForeground(QBrush(Qt::darkBlue));
	formats["macro"]=format;
	
	format.setForeground(QBrush(Qt::darkRed));
	formats["string"]=format;
	
	format.setForeground(QBrush(Qt::black));
	formats["function_name"]=format;

	m_highlighter_header->set_text_formats(formats);
	m_highlighter_source->set_text_formats(formats);
	
	QStringList source_keywords; 
	source_keywords << "ST_CLASS" << "ST_PARAMETER" << "ST_CHILD" << "ST_ALIGN" << "ST_DEFAULT";
	foreach (QString source_keyword,source_keywords)
		m_highlighter_source->addUserKeyword(source_keyword);
	
	m_C=0;
	
	QAction *action_save_changes=new QAction("Save changes to code (Ctrl+U)",this);
	action_save_changes->setShortcut(tr("Ctrl+U"));
	ui.save_changes_button->setDefaultAction(action_save_changes);
	addAction(action_save_changes);
	
	QAction *action_find=new QAction(this);
	action_find->setShortcut(tr("Ctrl+F"));
	addAction(action_find);
	connect(action_find,SIGNAL(triggered()),this,SLOT(slot_find()));
	
	connect(ui.header->editor()->document(),SIGNAL(modificationChanged(bool)),this,SLOT(slot_modification_changed()));
	connect(ui.source->editor()->document(),SIGNAL(modificationChanged(bool)),this,SLOT(slot_modification_changed()));		
	connect(ui.save_changes_button,SIGNAL(clicked()),this,SLOT(slotSaveChanges()));
	connect(ui.reload_button,SIGNAL(clicked()),this,SLOT(slot_reload()));
	connect(action_save_changes,SIGNAL(triggered()),this,SLOT(slotSaveChanges()));
	//connect(ui.actionCompile,SIGNAL(triggered()),this,SIGNAL(signalCompile()));
	
	connect(ui.class_box,SIGNAL(currentIndexChanged(QString)),this,SLOT(slot_class_box_changed(QString)));
	
	
	//ui.actionSaveChanges->setShortcut(tr("Ctrl+S"));
	//ui.actionCompile->setShortcut(tr("F9"));
	
}