# # # add_file "res/icons/arrow_down.png" # content [6390b8ce26bb5b11266833f57a57266df5667388] # # add_file "res/icons/green_dot.png" # content [9a806782c23117a5bebf10a1ca5f581e7aa13f7e] # # add_file "res/icons/red_dot.png" # content [137b7c7a3e8e311b7168f1bc6b3364d7f1865060] # # add_file "res/icons/yellow_dot.png" # content [d534547752c8546f91dfefa8b352b9eb5e59a87b] # # patch "res/guitone.qrc" # from [d68d97cabc3486a59beaaac87fdb9a936dc75ac3] # to [9e442c897e6755d7320d762f2a9410ecef620221] # # patch "src/model/GetAttributes.cpp" # from [dd05d9f07c224950e04d0365ecec2dbf2aad251a] # to [af7f17de332d7eef87a2bda5f565e094a4c1671a] # # patch "src/view/AttributesView.cpp" # from [622bd8e562abeaa8299ecac4d3a725a0f8eb73ae] # to [79e6d4bc94d165c6023896d599cfb17e25101b4e] # # patch "src/view/AttributesView.h" # from [6331d48f84cd19a9389ea33efd8e11278867b3eb] # to [e61a81362d8675755fed6e28109c93b0b4363313] # # set "res/icons/arrow_down.png" # attr "mtn:manual_merge" # value "true" # # set "res/icons/green_dot.png" # attr "mtn:manual_merge" # value "true" # # set "res/icons/red_dot.png" # attr "mtn:manual_merge" # value "true" # # set "res/icons/yellow_dot.png" # attr "mtn:manual_merge" # value "true" # ============================================================ # res/icons/arrow_down.png is binary ============================================================ # res/icons/green_dot.png is binary ============================================================ # res/icons/red_dot.png is binary ============================================================ # res/icons/yellow_dot.png is binary ============================================================ --- res/guitone.qrc d68d97cabc3486a59beaaac87fdb9a936dc75ac3 +++ res/guitone.qrc 9e442c897e6755d7320d762f2a9410ecef620221 @@ -1,8 +1,12 @@ guitone-logo.svg i18n/guitone_de.qm icons/guitone.png + icons/red_dot.png + icons/yellow_dot.png + icons/green_dot.png + icons/arrow_down.png overlays/added.png overlays/added_missing.png overlays/cdup.png ============================================================ --- src/model/GetAttributes.cpp dd05d9f07c224950e04d0365ecec2dbf2aad251a +++ src/model/GetAttributes.cpp af7f17de332d7eef87a2bda5f565e094a4c1671a @@ -24,6 +24,7 @@ #include "BasicIOParser.h" #include +#include GetAttributes::GetAttributes(QObject *parent) : QAbstractItemModel(parent) @@ -155,51 +156,72 @@ QVariant GetAttributes::data(const QMode return QVariant(); } - if (role != Qt::DisplayRole) - { - return QVariant(); - } - - int row = index.row(); + int row = index.row(), col = index.column(); if (row >= attributes->size()) return QVariant(); Attribute attr = attributes->at(row); - switch (index.column()) + + if (role == Qt::DisplayRole) + { + switch (col) + { + case 1: return QVariant(attr.key); + case 2: return QVariant(attr.value); + default: return QVariant(); + } + } + + if (role == Qt::ToolTipRole) { - case 0: return QVariant(attr.key); - case 1: return QVariant(attr.value); - case 2: - switch (attr.state) - { - case Attribute::Added: return QVariant(tr("added")); - case Attribute::Dropped: return QVariant(tr("dropped")); - case Attribute::Changed: return QVariant(tr("changed")); - case Attribute::Unchanged: return QVariant(tr("unchanged")); - } + switch (attr.state) + { + case Attribute::Added: return QVariant(tr("added")); + case Attribute::Dropped: return QVariant(tr("dropped")); + case Attribute::Changed: return QVariant(tr("changed")); + case Attribute::Unchanged: return QVariant(tr("unchanged")); + default: return QVariant(); + } } + if (role == Qt::DecorationRole && col == 0) + { + switch (attr.state) + { + case Attribute::Added: return QVariant(QIcon(":/icons/green_dot.png")); + case Attribute::Dropped: return QVariant(QIcon(":/icons/red_dot.png")); + case Attribute::Changed: return QVariant(QIcon(":/icons/yellow_dot.png")); + default: return QVariant(); + } + } + return QVariant(); } Qt::ItemFlags GetAttributes::flags(const QModelIndex &index) const { - // TODO: add ItemIsEditable as soon as we can set/drop attributes through - // the automation interface, implement setData() then as well return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } QVariant GetAttributes::headerData(int section, Qt::Orientation orientation, int role) const { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + I(orientation == Qt::Horizontal); + + if (role == Qt::DisplayRole) { switch (section) { - case 0: return QVariant(tr("Key")); - case 1: return QVariant(tr("Value")); - case 2: return QVariant(tr("State")); + case 1: return QVariant(tr("Key")); + case 2: return QVariant(tr("Value")); + default: return QVariant(); } } + + if (role == Qt::DecorationRole && section == 0) + { + return QVariant(QIcon(":/icons/arrow_down.png")); + } + return QVariant(); } ============================================================ --- src/view/AttributesView.cpp 622bd8e562abeaa8299ecac4d3a725a0f8eb73ae +++ src/view/AttributesView.cpp 79e6d4bc94d165c6023896d599cfb17e25101b4e @@ -18,14 +18,80 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "vocab.h" #include "AttributesView.h" +#include + AttributesView::AttributesView(QWidget* parent) : TreeView(parent) { setRootIsDecorated(false); setItemsExpandable(false); + + QHeaderView * headerView = header(); + headerView->setClickable(true); + + connect( + headerView, SIGNAL(sectionClicked(int)), + this, SLOT(sectionClicked(int)) + ); + + popupMenu = new QMenu(this); + popupMenu->addAction( + tr("add new attribute"), this, SLOT(addAttribute()) + ); + popupMenu->addAction( + tr("edit selected attribute"), this, SLOT(editAttribute()) + ); + popupMenu->addAction( + tr("drop selected attribute"), this, SLOT(dropAttribute()) + ); } -AttributesView::~AttributesView() {} +AttributesView::~AttributesView() +{ + delete popupMenu; +} +void AttributesView::sectionClicked(int logicalIndex) +{ + if (logicalIndex != 0) return; + + QHeaderView * headerView = header(); + int visualIndex = headerView->visualIndex(logicalIndex); + + int left = 0; + int top = headerView->height(); + + if (visualIndex > 0) + { + for (int i=0; isectionSize(headerView->logicalIndex(i)); + } + } + + if (left > headerView->width()) + { + left = headerView->width() - headerView->sectionSize(logicalIndex); + } + + popupMenu->exec(mapToGlobal(QPoint(left, top))); +} + +void AttributesView::addAttribute() +{ + D("TODO"); +} + +void AttributesView::editAttribute() +{ + D("TODO"); +} + +void AttributesView::dropAttribute() +{ + D("TODO"); +} + ============================================================ --- src/view/AttributesView.h 6331d48f84cd19a9389ea33efd8e11278867b3eb +++ src/view/AttributesView.h e61a81362d8675755fed6e28109c93b0b4363313 @@ -22,6 +22,7 @@ #define ATTRIBUTES_VIEW_H #include "TreeView.h" +#include class AttributesView : public TreeView { @@ -30,6 +31,15 @@ public: public: AttributesView(QWidget*); ~AttributesView(); + +private slots: + void sectionClicked(int); + void addAttribute(); + void editAttribute(); + void dropAttribute(); + +private: + QMenu * popupMenu; }; #endif