diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index ed6732b45..0ae002409 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -473,30 +473,31 @@ static void setMessageTags (RSettings *pConfig, QString &msgId, QList &tagI pConfig->endGroup(); } +/*static*/ void MessagesDialog::initStandardTagItems(std::map &Items) +{ + // create standard enties ... id = sort, maybe later own member + Items [-5].text = tr("Important"); + Items [-5].color = QColor(255, 0, 0).rgb(); + + Items [-4].text = tr("Work"); + Items [-4].color = QColor(255, 153, 0).rgb(); + + Items [-3].text = tr("Personal"); + Items [-3].color = QColor(0, 153, 0).rgb(); + + Items [-2].text = tr("Todo"); + Items [-2].color = QColor(51, 51, 255).rgb(); + + Items [-1].text = tr("Later"); + Items [-1].color = QColor(153, 51, 153).rgb(); +} + void MessagesDialog::getTagItems(std::map &Items) { - TagItem Item; + initStandardTagItems (Items); - // create standard enties ... id = sort, maybe later own member - Item.text = tr("Important"); - Item.color = QColor(255, 0, 0).rgb(); - Items [-5] = Item; - - Item.text = tr("Work"); - Item.color = QColor(255, 153, 0).rgb(); - Items [-4] = Item; - - Item.text = tr("Personal"); - Item.color = QColor(0, 153, 0).rgb(); - Items [-3] = Item; - - Item.text = tr("Todo"); - Item.color = QColor(51, 51, 255).rgb(); - Items [-2] = Item; - - Item.text = tr("Later"); - Item.color = QColor(153, 51, 153).rgb(); - Items [-1] = Item; + // create standard enties + initStandardTagItems(Items); // load user tags and colors m_pConfig->beginGroup(CONFIG_SECTION_TAGS); @@ -509,6 +510,7 @@ void MessagesDialog::getTagItems(std::map &Items) m_pConfig->beginGroup(*id); + TagItem Item; if (nId < 0) { // standard tag Item = Items[nId]; diff --git a/retroshare-gui/src/gui/MessagesDialog.h b/retroshare-gui/src/gui/MessagesDialog.h index e444f3b3f..32a3c51f4 100644 --- a/retroshare-gui/src/gui/MessagesDialog.h +++ b/retroshare-gui/src/gui/MessagesDialog.h @@ -51,6 +51,7 @@ public: ~MessagesDialog(); #ifdef STATIC_MSGID + static void initStandardTagItems(std::map &Items); void getTagItems(std::map &Items); void setTagItems(std::map &Items); #endif diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index b06ca35a0..8019cde70 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -35,6 +35,7 @@ MessagePage::MessagePage(QWidget * parent, Qt::WFlags flags) connect (ui.addpushButton, SIGNAL(clicked(bool)), this, SLOT (addTag())); connect (ui.editpushButton, SIGNAL(clicked(bool)), this, SLOT (editTag())); connect (ui.deletepushButton, SIGNAL(clicked(bool)), this, SLOT (deleteTag())); + connect (ui.defaultTagButton, SIGNAL(clicked(bool)), this, SLOT (defaultTag())); connect (ui.tags_listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(currentRowChangedTag(int))); @@ -80,34 +81,41 @@ MessagePage::load() pPage->getTagItems (m_TagItems); // fill items - std::map::iterator Item; - for (Item = m_TagItems.begin(); Item != m_TagItems.end(); Item++) { - if (Item->second._delete) { - continue; - } - - QListWidgetItem *pItemWidget = new QListWidgetItem(Item->second.text, ui.tags_listWidget); - pItemWidget->setTextColor(QColor(Item->second.color)); - pItemWidget->setData(Qt::UserRole, Item->first); - } - - if (m_TagItems.size()) { - ui.tags_listWidget->setCurrentItem(ui.tags_listWidget->item(0)); - } + fillTagItems(); } else { + // MessagesDialog not available ui.tags_listWidget->setEnabled(false); ui.addpushButton->setEnabled(false); ui.editpushButton->setEnabled(false); ui.deletepushButton->setEnabled(false); + ui.defaultTagButton->setEnabled(false); } #else ui.tags_listWidget->setEnabled(false); ui.addpushButton->setEnabled(false); ui.editpushButton->setEnabled(false); ui.deletepushButton->setEnabled(false); + ui.defaultTagButton->setEnabled(false); #endif } +// fill items +void MessagePage::fillTagItems() +{ + ui.tags_listWidget->clear(); + + std::map::iterator Item; + for (Item = m_TagItems.begin(); Item != m_TagItems.end(); Item++) { + if (Item->second._delete) { + continue; + } + + QListWidgetItem *pItemWidget = new QListWidgetItem(Item->second.text, ui.tags_listWidget); + pItemWidget->setTextColor(QColor(Item->second.color)); + pItemWidget->setData(Qt::UserRole, Item->first); + } +} + void MessagePage::addTag() { NewTag Tag(m_TagItems); @@ -163,6 +171,14 @@ void MessagePage::deleteTag() delete (pItemWidget); } +void MessagePage::defaultTag() +{ +#ifdef STATIC_MSGID + MessagesDialog::initStandardTagItems(m_TagItems); +#endif + fillTagItems(); +} + void MessagePage::currentRowChangedTag(int row) { QListWidgetItem *pItemWidget = ui.tags_listWidget->item(row); diff --git a/retroshare-gui/src/gui/settings/MessagePage.h b/retroshare-gui/src/gui/settings/MessagePage.h index 56f29f2e9..f6dece5f1 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.h +++ b/retroshare-gui/src/gui/settings/MessagePage.h @@ -46,11 +46,13 @@ private slots: void addTag(); void editTag(); void deleteTag(); + void defaultTag(); void currentRowChangedTag(int row); private: void closeEvent (QCloseEvent * event); + void fillTagItems(); std::map m_TagItems; diff --git a/retroshare-gui/src/gui/settings/MessagePage.ui b/retroshare-gui/src/gui/settings/MessagePage.ui index f32039772..aa095d386 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.ui +++ b/retroshare-gui/src/gui/settings/MessagePage.ui @@ -529,7 +529,7 @@ - + @@ -546,14 +546,7 @@ - - - - Delete - - - - + Qt::Vertical @@ -566,6 +559,36 @@ + + + + Delete + + + + + + + Default + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + +