-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
uploadpreferences.cpp
125 lines (103 loc) · 3.56 KB
/
uploadpreferences.cpp
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/***************************************************************************
* Copyright 2007 Niko Sams <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "uploadpreferences.h"
#include <QVBoxLayout>
#include <QStandardItemModel>
#include <interfaces/icore.h>
#include <interfaces/iplugincontroller.h>
#include <interfaces/iprojectcontroller.h>
#include <interfaces/iproject.h>
#include <util/path.h>
#include "uploadprofilemodel.h"
#include "ui_uploadpreferences.h"
#include "uploadprofiledlg.h"
#include "uploadprofileitem.h"
using namespace KDevelop;
UploadPreferences::UploadPreferences( KDevelop::IPlugin* plugin, const KDevelop::ProjectConfigOptions& options, QWidget* parent )
: ProjectConfigPage<UploadSettings>(plugin, options, parent)
{
IProject* project = options.project;
m_ui = new Ui::UploadPreferences();
m_ui->setupUi(this);
m_model = new UploadProfileModel();
m_model->setProject(project);
m_ui->profilesList->setModel(m_model);
connect(m_model, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
this, SLOT(changed()));
connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)),
this, SLOT(changed()));
connect(m_ui->addProfileButton, SIGNAL(clicked()),
this, SLOT(addProfile()));
connect(m_ui->modifyProfileButton, SIGNAL(clicked()),
this, SLOT(modifyProfile()));
connect(m_ui->removeProfileButton, SIGNAL(clicked()),
this, SLOT(removeProfile()));
connect(m_ui->profilesList, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(modifyProfile()));
m_dlg = new UploadProfileDlg(this);
}
UploadPreferences::~UploadPreferences( )
{
delete m_ui;
}
void UploadPreferences::reset()
{
ProjectConfigPage::reset();
}
void UploadPreferences::apply()
{
m_model->submit();
m_model->revert();
ProjectConfigPage::apply();
}
void UploadPreferences::defaults()
{
ProjectConfigPage::defaults();
}
void UploadPreferences::addProfile()
{
UploadProfileItem* i = new UploadProfileItem();
i->setLocalUrl(QUrl(m_model->project()->path().path()));
if (m_model->rowCount() == 0) {
i->setDefault(true);
}
m_model->appendRow(i);
if (m_dlg->editProfile(i) == QDialog::Rejected) {
m_model->removeRow(i->index().row());
}
}
void UploadPreferences::removeProfile()
{
Q_FOREACH(QModelIndex index, m_ui->profilesList->selectionModel()->selectedIndexes()) {
m_model->removeRow(index.row());
}
}
void UploadPreferences::modifyProfile()
{
Q_FOREACH(QModelIndex index, m_ui->profilesList->selectionModel()->selectedIndexes()) {
UploadProfileItem* i = m_model->uploadItem(index);
if (i) {
m_dlg->editProfile(i);
}
}
}
QString UploadPreferences::name() const
{
return i18n("Upload");
}
QString UploadPreferences::fullName() const
{
return i18n("Configure Upload settings");
}
QIcon UploadPreferences::icon() const
{
return QIcon::fromTheme(QStringLiteral("go-up"));
}
// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on