Commit 254f0b37 authored by Urs Wolfer's avatar Urs Wolfer

* Use of some const iterators

* Declare some vars as const to prevent programming mistakes
* Minor other optimizations

svn path=/trunk/KDE/kdenetwork/krdc/; revision=863185
parent 82ec8e23
......@@ -36,7 +36,7 @@ BookmarkManager::BookmarkManager(KActionCollection *collection, KMenu *menu, Mai
{
m_menu = menu;
QString file = KStandardDirs::locateLocal("data", "krdc/bookmarks.xml");
const QString file = KStandardDirs::locateLocal("data", "krdc/bookmarks.xml");
m_manager = KBookmarkManager::managerForFile(file, "krdc");
......@@ -140,7 +140,7 @@ QList<QPair<QString, QString> > BookmarkManager::currentBookmarkList() const
while (iter.hasNext()) {
RemoteView *next = iter.next();
QString url = next->url().prettyUrl(KUrl::RemoveTrailingSlash);
const QString url = next->url().prettyUrl(KUrl::RemoveTrailingSlash);
list << QPair<QString, QString>(url, url);
}
......
......@@ -108,7 +108,7 @@ void HostPreferencesList::configureHost()
QList<QListWidgetItem *> selectedItems = hostList->selectedItems();
foreach(QListWidgetItem *selectedItem, selectedItems) {
QString url = selectedItem->text();
const QString url = selectedItem->text();
kDebug(5010) << "Configure host: " << url;
......@@ -135,7 +135,7 @@ void HostPreferencesList::configureHost()
void HostPreferencesList::removeHost()
{
QList<QListWidgetItem *> selectedItems = hostList->selectedItems();
const QList<QListWidgetItem *> selectedItems = hostList->selectedItems();
foreach(QListWidgetItem *selectedItem, selectedItems) {
kDebug(5010) << "Remove host: " << selectedItem->text();
......@@ -163,7 +163,7 @@ void HostPreferencesList::removeHost()
void HostPreferencesList::selectionChanged()
{
bool enabled = hostList->selectedItems().isEmpty() ? false : true;
const bool enabled = hostList->selectedItems().isEmpty() ? false : true;
configureButton->setEnabled(enabled);
removeButton->setEnabled(enabled);
......
......@@ -246,9 +246,9 @@ void FloatingToolBar::mouseMoveEvent(QMouseEvent *e)
return;
// compute the nearest side to attach the widget to
QPoint parentPos = mapToParent(e->pos());
float nX = (float)parentPos.x() / (float)d->anchorWidget->width();
float nY = (float)parentPos.y() / (float)d->anchorWidget->height();
const QPoint parentPos = mapToParent(e->pos());
const float nX = (float)parentPos.x() / (float)d->anchorWidget->width();
const float nY = (float)parentPos.y() / (float)d->anchorWidget->height();
if (nX > 0.3 && nX < 0.7 && nY > 0.3 && nY < 0.7)
return;
bool LT = nX < (1.0 - nY);
......@@ -295,7 +295,7 @@ void FloatingToolBar::wheelEvent(QWheelEvent *e)
{
e->accept();
qreal diff = e->delta() / 100.0 / 15.0;
const qreal diff = e->delta() / 100.0 / 15.0;
// kDebug(5010) << diff;
if (((d->opacity <= 1) && (diff > 0)) || ((d->opacity >= 0) && (diff < 0)))
d->opacity += diff;
......@@ -307,12 +307,12 @@ void FloatingToolBar::wheelEvent(QWheelEvent *e)
void FloatingToolBarPrivate::buildToolBar()
{
bool prevUpdates = q->updatesEnabled();
const bool prevUpdates = q->updatesEnabled();
q->setUpdatesEnabled(false);
// 1. init numbers we are going to use
bool topLeft = anchorSide == FloatingToolBar::Left || anchorSide == FloatingToolBar::Top;
bool vertical = anchorSide == FloatingToolBar::Left || anchorSide == FloatingToolBar::Right;
const bool topLeft = anchorSide == FloatingToolBar::Left || anchorSide == FloatingToolBar::Top;
const bool vertical = anchorSide == FloatingToolBar::Left || anchorSide == FloatingToolBar::Right;
if (anchorSide == FloatingToolBar::Left || anchorSide == FloatingToolBar::Right) {
offsetPlaceHolder->setFixedSize(1, 7);
......@@ -323,8 +323,8 @@ void FloatingToolBarPrivate::buildToolBar()
}
// 2. compute widget size
int myWidth = q->sizeHint().width() - 1;
int myHeight = q->sizeHint().height() - 1;
const int myWidth = q->sizeHint().width() - 1;
const int myHeight = q->sizeHint().height() - 1;
// 3. resize pixmap, mask and widget
QBitmap mask(myWidth + 1, myHeight + 1);
......
......@@ -66,7 +66,7 @@ int main(int argc, char **argv)
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->count() > 0) {
for (int i = 0; i < args->count(); i++) {
for (int i = 0; i < args->count(); ++i) {
KUrl u(args->url(i));
if (u.scheme().isEmpty() || u.host().isEmpty()) { // unusable url; try to recover it...
......
......@@ -287,9 +287,9 @@ void MainWindow::setupActions()
void MainWindow::restoreOpenSessions()
{
QStringList list = Settings::openSessions();
QStringList::Iterator it = list.begin();
QStringList::Iterator end = list.end();
const QStringList list = Settings::openSessions();
QStringList::ConstIterator it = list.begin();
QStringList::ConstIterator end = list.end();
while (it != end) {
newConnection(*it);
++it;
......@@ -300,7 +300,7 @@ void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConn
{
m_switchFullscreenWhenConnected = switchFullscreenWhenConnected;
KUrl url = newUrl.isEmpty() ? m_addressNavigator->uncommittedUrl() : newUrl;
const KUrl url = newUrl.isEmpty() ? m_addressNavigator->uncommittedUrl() : newUrl;
if (!url.isValid() || (url.host().isEmpty() && url.port() < 0)
|| !url.path().isEmpty()) {
......@@ -360,7 +360,7 @@ void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConn
QScrollArea *scrollArea = createScrollArea(m_tabWidget, m_remoteViewList.at(m_remoteViewList.count() - 1));
int newIndex = m_tabWidget->addTab(scrollArea, KIcon("krdc"), url.prettyUrl(KUrl::RemoveTrailingSlash));
const int newIndex = m_tabWidget->addTab(scrollArea, KIcon("krdc"), url.prettyUrl(KUrl::RemoveTrailingSlash));
m_tabWidget->setCurrentIndex(newIndex);
tabChanged(newIndex); // force to update m_currentRemoteView (tabChanged is not emitted when start page has been disabled)
......@@ -369,11 +369,11 @@ void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConn
void MainWindow::openFromDockWidget(const QModelIndex &index)
{
QString data = index.data(Qt::UserRole).toString();
const QString data = index.data(Qt::UserRole).toString();
if (!data.isEmpty()) {
KUrl url(data);
const KUrl url(data);
// first check if url has already been opened; in case show the tab
for (int i = 0; i < m_remoteViewList.count(); i++) {
for (int i = 0; i < m_remoteViewList.count(); ++i) {
if (m_remoteViewList.at(i)->url() == url) {
int numNonRemoteView = 0;
if (m_showStartPage)
......@@ -401,12 +401,12 @@ void MainWindow::resizeTabWidget(int w, int h)
kDebug(5010) << "tabwidget border: w: " << m_leftRightBorder << ", h: " << m_topBottomBorder;
}
int newTabWidth = w + m_leftRightBorder;
int newTabHeight = h + m_topBottomBorder;
const int newTabWidth = w + m_leftRightBorder;
const int newTabHeight = h + m_topBottomBorder;
QSize newWindowSize = size() - m_tabWidget->size() + QSize(newTabWidth, newTabHeight);
const QSize newWindowSize = size() - m_tabWidget->size() + QSize(newTabWidth, newTabHeight);
QSize desktopSize = QSize(QApplication::desktop()->availableGeometry().width(),
const QSize desktopSize = QSize(QApplication::desktop()->availableGeometry().width(),
QApplication::desktop()->availableGeometry().height());
if ((newWindowSize.height() >= desktopSize.height()) || (newWindowSize.width() >= desktopSize.width())) {
......@@ -430,7 +430,7 @@ void MainWindow::statusChanged(RemoteView::RemoteStatus status)
if (status == RemoteView::Disconnecting || status == RemoteView::Disconnected)
return;
QString host = m_remoteViewList.at(m_currentRemoteView)->host();
const QString host = m_remoteViewList.at(m_currentRemoteView)->host();
QString iconName = "krdc";
QString message;
......@@ -471,7 +471,7 @@ void MainWindow::statusChanged(RemoteView::RemoteStatus status)
void MainWindow::takeScreenshot()
{
QPixmap snapshot = QPixmap::grabWidget(m_remoteViewList.at(m_currentRemoteView));
const QPixmap snapshot = QPixmap::grabWidget(m_remoteViewList.at(m_currentRemoteView));
QApplication::clipboard()->setPixmap(snapshot);
}
......@@ -489,7 +489,7 @@ void MainWindow::switchFullscreen()
QScrollArea *scrollArea = createScrollArea(m_tabWidget, m_remoteViewList.at(m_currentRemoteView));
int currentTab = m_tabWidget->currentIndex();
const int currentTab = m_tabWidget->currentIndex();
m_tabWidget->insertTab(currentTab, scrollArea, m_tabWidget->tabIcon(currentTab), m_tabWidget->tabText(currentTab));
m_tabWidget->removeTab(m_tabWidget->currentIndex());
m_tabWidget->setCurrentIndex(currentTab);
......@@ -575,7 +575,7 @@ void MainWindow::disconnect()
void MainWindow::closeTab(QWidget *widget)
{
int index = m_tabWidget->indexOf(widget);
const int index = m_tabWidget->indexOf(widget);
kDebug(5010) << index;
......@@ -779,14 +779,14 @@ void MainWindow::updateConfiguration()
numNonRemoteView++;
if (m_zeroconfPage)
numNonRemoteView++;
for (int i = numNonRemoteView; i < m_tabWidget->count(); i++) {
for (int i = numNonRemoteView; i < m_tabWidget->count(); ++i) {
QPalette palette = m_tabWidget->widget(i)->palette();
palette.setColor(QPalette::Dark, Settings::backgroundColor());
m_tabWidget->widget(i)->setPalette(palette);
}
// Send update configuration message to all views
for (int i = 0; i < m_remoteViewList.count(); i++) {
for (int i = 0; i < m_remoteViewList.count(); ++i) {
m_remoteViewList.at(i)->updateConfiguration();
}
......@@ -794,7 +794,7 @@ void MainWindow::updateConfiguration()
void MainWindow::quit()
{
bool haveRemoteConnections = m_remoteViewList.count();
const bool haveRemoteConnections = !m_remoteViewList.isEmpty();
if (!haveRemoteConnections || KMessageBox::warningContinueCancel(this,
i18n("Are you sure you want to quit the KDE Remote Desktop Client?"),
i18n("Confirm Quit"),
......@@ -803,7 +803,7 @@ void MainWindow::quit()
if (Settings::rememberSessions()) { // remember open remote views for next startup
QStringList list;
for (int i = 0; i < m_remoteViewList.count(); i++) {
for (int i = 0; i < m_remoteViewList.count(); ++i) {
kDebug(5010) << m_remoteViewList.at(i)->url();
list.append(m_remoteViewList.at(i)->url().prettyUrl(KUrl::RemoveTrailingSlash));
}
......@@ -864,7 +864,7 @@ void MainWindow::tabChanged(int index)
m_currentRemoteView = index - numNonRemoteView;
QString tabTitle = m_tabWidget->tabText(index).remove('&');
const QString tabTitle = m_tabWidget->tabText(index).remove('&');
setCaption(tabTitle == i18n("Start Page") ? QString() : tabTitle);
......
......@@ -64,7 +64,7 @@ void NxCallbacks::resumeSessionsSignal(std::list<nxcl::NXResumeData> sessions)
{
QList<nxcl::NXResumeData> qsessions;
for(std::list<nxcl::NXResumeData>::const_iterator it = sessions.begin(); it != sessions.end(); it++)
for(std::list<nxcl::NXResumeData>::const_iterator it = sessions.begin(); it != sessions.end(); ++it)
qsessions << (*it);
emit suspendedSessions(qsessions);
......
......@@ -33,7 +33,7 @@
#include <QByteArray>
#include <QTextEdit>
static QStringList keymaps = (QStringList()
static const QStringList keymaps = (QStringList()
<< "ar"
<< "cs"
<< "da"
......@@ -77,7 +77,7 @@ static const int defaultKeymap = 7; // en-us
inline int keymap2int(const QString &keymap)
{
int index = keymaps.lastIndexOf(keymap);
const int index = keymaps.lastIndexOf(keymap);
return (index == -1) ? defaultKeymap : index;
}
......@@ -89,7 +89,7 @@ inline QString int2keymap(int layout)
return keymaps.at(defaultKeymap);
}
static QStringList desktopTypes = (QStringList()
static const QStringList desktopTypes = (QStringList()
<< "unix-kde"
<< "unix-gnome"
<< "unix-cde"
......@@ -100,7 +100,7 @@ static const int defaultDesktopType = 0;
inline int desktopType2int(const QString &desktopType)
{
int index = desktopTypes.lastIndexOf(desktopType);
const int index = desktopTypes.lastIndexOf(desktopType);
return (index == -1) ? defaultDesktopType : index;
}
......@@ -166,8 +166,8 @@ void NxHostPreferences::showDialog()
connect(nxUi.buttonImportPrivateKey, SIGNAL(pressed()), SLOT(chooseKeyFile()));
connect(nxUi.kcfg_NxPrivateKey, SIGNAL(textChanged()), SLOT(updatePrivateKey()));
QString resolutionString = QString::number(width()) + 'x' + QString::number(height());
int resolutionIndex = nxUi.resolutionComboBox->findText(resolutionString, Qt::MatchContains);
const QString resolutionString = QString::number(width()) + 'x' + QString::number(height());
const int resolutionIndex = nxUi.resolutionComboBox->findText(resolutionString, Qt::MatchContains);
nxUi.resolutionComboBox->setCurrentIndex((resolutionIndex == -1) ? 5 : resolutionIndex);
if (dialog->exec() == KDialog::Accepted) {
......@@ -241,7 +241,7 @@ void NxHostPreferences::updatePrivateKey()
void NxHostPreferences::chooseKeyFile()
{
QString fileName = KFileDialog::getOpenFileName(KUrl(QDir::homePath()),
const QString fileName = KFileDialog::getOpenFileName(KUrl(QDir::homePath()),
"*.key|" + i18n("Key Files (*.key)"),
nxPage, i18n("Open DSA Key File"));
......
......@@ -71,17 +71,16 @@ void NxResumeSessions::clear()
void NxResumeSessions::addSessions(QList<nxcl::NXResumeData> sessions)
{
QTreeWidgetItem *tmp = NULL;
for(int i = 0; i < sessions.size(); i++)
for(int i = 0; i < sessions.size(); ++i)
{
tmp = new QTreeWidgetItem();
tmp->setText(0, QString::number(sessions.at(i).display));
tmp->setText(1, QString(sessions.at(i).sessionType.c_str()));
tmp->setText(2, QString(sessions.at(i).sessionID.c_str()));
tmp->setText(3, QString::number(sessions.at(i).depth));
tmp->setText(4, QString(sessions.at(i).screen.c_str()));
tmp->setText(5, QString(sessions.at(i).sessionName.c_str()));
const nxcl::NXResumeData session = sessions.at(i);
QTreeWidgetItem *tmp = new QTreeWidgetItem();
tmp->setText(0, QString::number(session.display));
tmp->setText(1, QString(session.sessionType.c_str()));
tmp->setText(2, QString(session.sessionID.c_str()));
tmp->setText(3, QString::number(session.depth));
tmp->setText(4, QString(session.screen.c_str()));
tmp->setText(5, QString(session.sessionName.c_str()));
nxUi.sessionsList->addTopLevelItem(tmp);
}
......
......@@ -87,7 +87,7 @@ void NxView::startQuitting()
{
kDebug(5013) << "about to quit";
bool connected = status() == RemoteView::Connected;
const bool connected = status() == RemoteView::Connected;
setStatus(Disconnecting);
m_quitFlag = true;
......@@ -120,7 +120,7 @@ bool NxView::start()
if (m_hostPreferences->walletSupport()) {
if (m_url.userName().isEmpty()) {
QString userName;
bool ok = true;
bool ok = false;
userName = KInputDialog::getText(i18n("Enter Username"),
i18n("Please enter the username you would like to use for login."),
......@@ -252,7 +252,7 @@ void NxView::connectionOpened()
{
kDebug(5013) << "Connection opened";
QSize size(m_hostPreferences->width(), m_hostPreferences->height());
kDebug(5013) << "Size hint: " << size.width() << " " << size.height();
kDebug(5013) << "Size hint: " << size.width() << size.height();
setStatus(Connected);
setFixedSize(size);
resize(size);
......
......@@ -29,7 +29,7 @@
#include <QDesktopWidget>
static QStringList keymaps = (QStringList()
static const QStringList keymaps = (QStringList()
<< "ar"
<< "cs"
<< "da"
......@@ -73,7 +73,7 @@ static const int defaultKeymap = 7; // en-us
inline int keymap2int(const QString &keymap)
{
int index = keymaps.lastIndexOf(keymap);
const int index = keymaps.lastIndexOf(keymap);
return (index == -1) ? defaultKeymap : index;
}
......@@ -131,8 +131,8 @@ void RdpHostPreferences::showDialog()
connect(rdpUi.resolutionComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateWidthHeight(int)));
QString resolutionString = QString::number(width()) + 'x' + QString::number(height());
int resolutionIndex = rdpUi.resolutionComboBox->findText(resolutionString, Qt::MatchContains);
const QString resolutionString = QString::number(width()) + 'x' + QString::number(height());
const int resolutionIndex = rdpUi.resolutionComboBox->findText(resolutionString, Qt::MatchContains);
rdpUi.resolutionComboBox->setCurrentIndex((resolutionIndex == -1) ? 5 : resolutionIndex);
if (dialog->exec() == KDialog::Accepted) {
......@@ -182,7 +182,7 @@ void RdpHostPreferences::updateWidthHeight(int index)
break;
}
bool enabled = (index == 6) ? true : false;
const bool enabled = (index == 6) ? true : false;
rdpUi.kcfg_Height->setEnabled(enabled);
rdpUi.kcfg_Width->setEnabled(enabled);
......
......@@ -116,7 +116,7 @@ bool RdpView::start()
if (m_hostPreferences->walletSupport()) {
if (m_url.userName().isEmpty()) {
QString userName;
bool ok = true;
bool ok = false;
userName = KInputDialog::getText(i18n("Enter Username"),
i18n("Please enter the username you would like to use for login."),
......@@ -127,7 +127,7 @@ bool RdpView::start()
}
if (!m_url.userName().isEmpty()) {
bool useLdapLogin = Settings::recognizeLdapLogins() && m_url.userName().contains('\\');
const bool useLdapLogin = Settings::recognizeLdapLogins() && m_url.userName().contains('\\');
kDebug(5012) << "Is LDAP login:" << useLdapLogin << m_url.userName();
QString walletPassword = readWalletPassword(useLdapLogin);
......@@ -179,7 +179,7 @@ bool RdpView::start()
arguments << "-r" << "sound:" + sound;
if (!m_hostPreferences->extraOptions().isEmpty()) {
QStringList additionalArguments = m_hostPreferences->extraOptions().split(' ');
const QStringList additionalArguments = m_hostPreferences->extraOptions().split(' ');
arguments += additionalArguments;
}
......@@ -209,7 +209,7 @@ void RdpView::switchFullscreen(bool on)
void RdpView::connectionOpened()
{
kDebug(5012) << "Connection opened";
QSize size = m_container->minimumSizeHint();
const QSize size = m_container->minimumSizeHint();
kDebug(5012) << "Size hint: " << size.width() << " " << size.height();
setStatus(Connected);
setFixedSize(size);
......@@ -255,7 +255,7 @@ void RdpView::processError(QProcess::ProcessError error)
void RdpView::receivedStandardError()
{
QString output(m_process->readAllStandardError());
const QString output(m_process->readAllStandardError());
QString line;
int i = 0;
while (!(line = output.section('\n', i, i)).isEmpty()) {
......
......@@ -37,7 +37,7 @@ RemoteDesktopsModel::RemoteDesktopsModel(QObject *parent)
{
rootItem = new RemoteDesktopsItem(QList<QVariant>() << "Remote desktops");
QString file = KStandardDirs::locateLocal("data", "krdc/bookmarks.xml");
const QString file = KStandardDirs::locateLocal("data", "krdc/bookmarks.xml");
m_manager = KBookmarkManager::managerForFile(file, "krdc");
m_manager->setUpdate(true);
......
......@@ -78,7 +78,7 @@ void RemoteView::setStatus(RemoteView::RemoteStatus s)
}
// smooth state transition
RemoteStatus origState = m_status;
for (int i = origState; i < s; i++) {
for (int i = origState; i < s; ++i) {
m_status = (RemoteStatus) i;
emit statusChanged((RemoteStatus) i);
}
......
......@@ -36,7 +36,7 @@ TestView::TestView(QWidget *parent, const KUrl &url)
pal.setColor(QPalette::Dark, Qt::yellow);
setPalette(pal);
QSize size = QSize(640, 480);
const QSize size = QSize(640, 480);
setStatus(Connected);
setFixedSize(size);
setFixedSize(size);
......
......@@ -33,8 +33,8 @@ rfbBool VncClientThread::newclient(rfbClient *cl)
VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0);
Q_ASSERT(t);
int width = cl->width, height = cl->height, depth = cl->format.bitsPerPixel;
int size = width * height * (depth / 8);
const int width = cl->width, height = cl->height, depth = cl->format.bitsPerPixel;
const int size = width * height * (depth / 8);
if (t->frameBuffer)
delete [] t->frameBuffer; // do not leak if we get a new framebuffer size
t->frameBuffer = new uint8_t[size];
......@@ -79,9 +79,9 @@ void VncClientThread::updatefb(rfbClient* cl, int x, int y, int w, int h)
{
// kDebug(5011) << "updated client: x: " << x << ", y: " << y << ", w: " << w << ", h: " << h;
int width = cl->width, height = cl->height;
const int width = cl->width, height = cl->height;
QImage img(cl->frameBuffer, width, height, QImage::Format_RGB32);
const QImage img(cl->frameBuffer, width, height, QImage::Format_RGB32);
if (img.isNull())
kDebug(5011) << "image not loaded";
......@@ -96,7 +96,7 @@ void VncClientThread::updatefb(rfbClient* cl, int x, int y, int w, int h)
void VncClientThread::cuttext(rfbClient* cl, const char *text, int textlen)
{
QString cutText = QString::fromUtf8(text, textlen);
const QString cutText = QString::fromUtf8(text, textlen);
kDebug(5011) << cutText;
if (!cutText.isEmpty()) {
......@@ -281,7 +281,7 @@ void VncClientThread::run()
// Main VNC event loop
while (!m_stopped) {
int i = WaitForMessage(cl, 500);
const int i = WaitForMessage(cl, 500);
if (i < 0)
break;
if (i)
......
......@@ -136,8 +136,8 @@ void VncView::scaleResize(int w, int h)
m_verticalFactor = m_horizontalFactor = qMin(m_verticalFactor, m_horizontalFactor);
#endif
qreal newW = m_frame.width() * m_horizontalFactor;
qreal newH = m_frame.height() * m_verticalFactor;
const qreal newW = m_frame.width() * m_horizontalFactor;
const qreal newH = m_frame.height() * m_verticalFactor;
setMaximumSize(newW, newH); //This is a hack to force Qt to center the view in the scroll area
resize(newW, newH);
}
......@@ -155,7 +155,7 @@ void VncView::startQuitting()
{
kDebug(5011) << "about to quit";
bool connected = status() == RemoteView::Connected;
const bool connected = status() == RemoteView::Connected;
setStatus(Disconnecting);
......@@ -408,10 +408,10 @@ void VncView::paintEvent(QPaintEvent *event)
QRect rect = event->rect();
if (rect.width() != width() || rect.height() != height()) {
kDebug(5011) << "Partial repaint";
int sx = rect.x()/m_horizontalFactor;
int sy = rect.y()/m_verticalFactor;
int sw = rect.width()/m_horizontalFactor;
int sh = rect.height()/m_verticalFactor;
const int sx = rect.x()/m_horizontalFactor;
const int sy = rect.y()/m_verticalFactor;
const int sw = rect.width()/m_horizontalFactor;
const int sh = rect.height()/m_verticalFactor;
painter.drawImage(rect,
m_frame.copy(sx, sy, sw, sh).scaled(rect.width(), rect.height(),
Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
......@@ -491,8 +491,8 @@ void VncView::wheelEventHandler(QWheelEvent *event)
else
eb |= 0x8;
int x = qRound(event->x() / m_horizontalFactor);
int y = qRound(event->y() / m_verticalFactor);
const int x = qRound(event->x() / m_horizontalFactor);
const int y = qRound(event->y() / m_verticalFactor);
vncThread.mouseEvent(x, y, eb | m_buttonMask);
vncThread.mouseEvent(x, y, m_buttonMask);
......@@ -559,12 +559,12 @@ void VncView::keyEventHandler(QKeyEvent *e)
k = e->key() - Qt::Key_Dead_Grave + XK_dead_grave;
}
bool pressed = (e->type() == QEvent::KeyPress) ? true : false;
const bool pressed = (e->type() == QEvent::KeyPress) ? true : false;
m_modifiersMask = pressed ? m_modifiersMask | mask : m_modifiersMask & ~mask;
bool hasShift = m_modifiersMask & KMOD_Shift_L;
bool hasOtherMod = m_modifiersMask & (KMOD_Alt_R | KMOD_Alt_L | KMOD_Meta_L | KMOD_Control_L);
bool isUpper = e->key() >= 'A' && e->key() <= 'Z';
const bool hasShift = m_modifiersMask & KMOD_Shift_L;
const bool hasOtherMod = m_modifiersMask & (KMOD_Alt_R | KMOD_Alt_L | KMOD_Meta_L | KMOD_Control_L);
const bool isUpper = e->key() >= 'A' && e->key() <= 'Z';
// bool isLower = e->key() >= 'a' && e->key() <= 'z';
// bool isLetter = isLower || isUpper;
......@@ -600,7 +600,7 @@ void VncView::clipboardSelectionChanged()
if (m_clipboard->ownsSelection() || m_dontSendClipboard)
return;
QString text = m_clipboard->text(QClipboard::Selection);
const QString text = m_clipboard->text(QClipboard::Selection);
vncThread.clientCut(text);
}
......@@ -615,7 +615,7 @@ void VncView::clipboardDataChanged()
if (m_clipboard->ownsClipboard() || m_dontSendClipboard)
return;
QString text = m_clipboard->text(QClipboard::Clipboard);
const QString text = m_clipboard->text(QClipboard::Clipboard);
vncThread.clientCut(text);
}
......
......@@ -148,7 +148,7 @@ void ZeroconfPage::rowSelected()
void ZeroconfPage::newConnection()
{
int currentRow = m_serviceTable->currentRow();
const int currentRow = m_serviceTable->currentRow();
KUrl url;
url.setProtocol(m_serviceTable->item(currentRow, 0)->text().toLower());
url.setHost(m_serviceTable->item(currentRow, 1)->text());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment