Switch to unified view

a/src/qtgui/viewaction_w.cpp b/src/qtgui/viewaction_w.cpp
...
...
38
38
39
#include "viewaction_w.h"
39
#include "viewaction_w.h"
40
40
41
void ViewAction::init()
41
void ViewAction::init()
42
{
42
{
43
    selSamePB->setEnabled(false);
43
    connect(closePB, SIGNAL(clicked()), this, SLOT(close()));
44
    connect(closePB, SIGNAL(clicked()), this, SLOT(close()));
44
    connect(chgActPB, SIGNAL(clicked()), this, SLOT(editActions()));
45
    connect(chgActPB, SIGNAL(clicked()), this, SLOT(editActions()));
45
    connect(actionsLV,SIGNAL(itemDoubleClicked(QTableWidgetItem *)),
46
    connect(actionsLV,SIGNAL(itemDoubleClicked(QTableWidgetItem *)),
46
        this, SLOT(onItemDoubleClicked(QTableWidgetItem *)));
47
        this, SLOT(onItemDoubleClicked(QTableWidgetItem *)));
48
    connect(actionsLV,SIGNAL(itemClicked(QTableWidgetItem *)),
49
      this, SLOT(onItemClicked(QTableWidgetItem *)));
47
    useDesktopCB->setChecked(prefs.useDesktopOpen);
50
    useDesktopCB->setChecked(prefs.useDesktopOpen);
48
    onUseDesktopCBToggled(prefs.useDesktopOpen);
51
    onUseDesktopCBToggled(prefs.useDesktopOpen);
49
    connect(useDesktopCB, SIGNAL(stateChanged(int)), 
52
    connect(useDesktopCB, SIGNAL(stateChanged(int)), 
50
        this, SLOT(onUseDesktopCBToggled(int)));
53
        this, SLOT(onUseDesktopCBToggled(int)));
51
    connect(setExceptCB, SIGNAL(stateChanged(int)), 
54
    connect(setExceptCB, SIGNAL(stateChanged(int)), 
52
        this, SLOT(onSetExceptCBToggled(int)));
55
        this, SLOT(onSetExceptCBToggled(int)));
56
    connect(selSamePB, SIGNAL(clicked()),
57
      this, SLOT(onSelSameClicked()));
53
    resize(QSize(640, 480).expandedTo(minimumSizeHint()));
58
    resize(QSize(640, 480).expandedTo(minimumSizeHint()));
54
}
59
}
55
    
60
    
56
void ViewAction::onUseDesktopCBToggled(int onoff)
61
void ViewAction::onUseDesktopCBToggled(int onoff)
57
{
62
{
...
...
65
    newActionLE->setEnabled(onoff != 0);
70
    newActionLE->setEnabled(onoff != 0);
66
}
71
}
67
72
68
void ViewAction::fillLists()
73
void ViewAction::fillLists()
69
{
74
{
75
    currentLBL->clear();
70
    actionsLV->clear();
76
    actionsLV->clear();
71
    actionsLV->verticalHeader()->setDefaultSectionSize(20); 
77
    actionsLV->verticalHeader()->setDefaultSectionSize(20); 
72
    vector<pair<string, string> > defs;
78
    vector<pair<string, string> > defs;
73
    theconfig->getMimeViewerDefs(defs);
79
    theconfig->getMimeViewerDefs(defs);
74
    actionsLV->setRowCount(defs.size());
80
    actionsLV->setRowCount(defs.size());
...
...
107
    for (QList<QTableWidgetItem *>::iterator it = items.begin();
113
    for (QList<QTableWidgetItem *>::iterator it = items.begin();
108
     it != items.end(); it++) {
114
     it != items.end(); it++) {
109
    (*it)->setSelected(true);
115
    (*it)->setSelected(true);
110
    actionsLV->setCurrentItem(*it, QItemSelectionModel::Columns);
116
    actionsLV->setCurrentItem(*it, QItemSelectionModel::Columns);
111
    }
117
    }
118
}
119
120
void ViewAction::onSelSameClicked()
121
{
122
    fprintf(stderr, "onSelSameClicked()\n");
123
    actionsLV->clearSelection();
124
    QString value = currentLBL->text();
125
    if (value.isEmpty())
126
  return;
127
    string action = qs2utf8s(value);
128
    fprintf(stderr, "value: %s\n", action.c_str());
129
    vector<pair<string, string> > defs;
130
    theconfig->getMimeViewerDefs(defs);
131
    for (unsigned int i = 0; i < defs.size(); i++) {
132
  if (defs[i].second == action) {
133
      QList<QTableWidgetItem *>items = 
134
      actionsLV->findItems(QString::fromAscii(defs[i].first.c_str()), 
135
                Qt::MatchFixedString|Qt::MatchCaseSensitive);
136
      for (QList<QTableWidgetItem *>::iterator it = items.begin();
137
       it != items.end(); it++) {
138
      (*it)->setSelected(true);
139
      QTableWidgetItem *item1 = actionsLV->item((*it)->row(), 1);
140
      item1->setSelected(true);
141
      }
142
  }
143
    }
144
}
145
146
// Fill the input fields with the row's values when the user clicks
147
void ViewAction::onItemClicked(QTableWidgetItem * item)
148
{
149
    QTableWidgetItem *item0 = actionsLV->item(item->row(), 0);
150
    string mtype = (const char *)item0->text().toLocal8Bit();
151
152
    vector<pair<string, string> > defs;
153
    theconfig->getMimeViewerDefs(defs);
154
    for (unsigned int i = 0; i < defs.size(); i++) {
155
  if (defs[i].first == mtype) {
156
      currentLBL->setText(QString::fromAscii(defs[i].second.c_str()));
157
      selSamePB->setEnabled(true);
158
      return;
159
  }
160
    }
161
    currentLBL->clear();
162
    selSamePB->setEnabled(false);
112
}
163
}
113
164
114
void ViewAction::onItemDoubleClicked(QTableWidgetItem * item)
165
void ViewAction::onItemDoubleClicked(QTableWidgetItem * item)
115
{
166
{
116
    actionsLV->clearSelection();
167
    actionsLV->clearSelection();