the default tags can be reset to standard in the settings

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3053 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-06-02 12:11:09 +00:00
parent 141fdbe6fe
commit f06ed5fbed
5 changed files with 88 additions and 44 deletions

View File

@ -473,30 +473,31 @@ static void setMessageTags (RSettings *pConfig, QString &msgId, QList<int> &tagI
pConfig->endGroup();
}
/*static*/ void MessagesDialog::initStandardTagItems(std::map<int, TagItem> &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<int, TagItem> &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<int, TagItem> &Items)
m_pConfig->beginGroup(*id);
TagItem Item;
if (nId < 0) {
// standard tag
Item = Items[nId];

View File

@ -51,6 +51,7 @@ public:
~MessagesDialog();
#ifdef STATIC_MSGID
static void initStandardTagItems(std::map<int, TagItem> &Items);
void getTagItems(std::map<int, TagItem> &Items);
void setTagItems(std::map<int, TagItem> &Items);
#endif

View File

@ -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<int, TagItem>::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<int, TagItem>::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);

View File

@ -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<int, TagItem> m_TagItems;

View File

@ -529,7 +529,7 @@
</property>
</widget>
</item>
<item row="1" column="0" rowspan="4">
<item row="1" column="0" rowspan="6">
<widget class="QListWidget" name="tags_listWidget"/>
</item>
<item row="1" column="1">
@ -546,14 +546,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="deletepushButton">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="6" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -566,6 +559,36 @@
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="deletepushButton">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="defaultTagButton">
<property name="text">
<string>Default</string>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>