Menu

[c54480]: / userdialog.cpp  Maximize  Restore  History

Download this file

84 lines (67 with data), 2.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "userdialog.h"
#include <QRegExp>
#include "confluence-agent.h"
UserDialog::UserDialog(QWidget *parent) : QDialog(parent)
{
ui.setupUi(this);
QDialog::setWindowTitle(
"VYM - " + tr("Find Confluence user", "dialog window title"));
connect (ui.lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(lineEditChanged()));
connect (ui.buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect (ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect (ui.userList, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*) ));
currentRow = -1;
}
int UserDialog::exec()
{
int result = QDialog::exec();
// Interactive implementation... // FIXME-0 needed really?
return result;
}
QString UserDialog::selectedUser()
{
if (userNameList.length() > 0 && currentRow < userNameList.length() && currentRow > -1)
return userNameList.at(currentRow);
else
return QString();
}
QString UserDialog::selectedUserKey()
{
if (userNameList.length() > 0 && currentRow < userNameList.length() && currentRow > -1)
return userKeyList.at(currentRow);
else
return QString();
}
void UserDialog::lineEditChanged()
{
if (ui.lineEdit->text().length() > 3 )
{
ConfluenceAgent ca;
ca.getUsers(ui.lineEdit->text() );
ca.waitForResult();
QString results = ca.getResult();
QStringList list = results.split("\n");
QRegExp re("name:\\s*\"(.*)\",\\s*login: \"(.*)\"\\s*,\\s*key:\\s*\"(.*)\"");
re.setMinimal(true);
ui.userList->clear();
userNameList.clear();
userLoginList.clear();
userKeyList.clear();
currentRow = -1;
for (int i = 0; i< list.length(); i++)
{
if (re.indexIn(list.at(i)) >= 0 && !re.cap(1).isEmpty() )
{
userNameList.append( re.cap(1));
userLoginList.append( re.cap(2));
userKeyList.append( re.cap(3));
new QListWidgetItem(userNameList.last() + " (" + userLoginList.last() + ")", ui.userList);
}
}
}
}
void UserDialog::itemSelected(QListWidgetItem *item)
{
currentRow = ui.userList->row(item);
accept() ;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.