InfoBar: Use Core::Id

Change-Id: I0918fbc20027a340facbedc685938a72d117d53b
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Orgad Shaneh
2012-11-08 21:12:56 +02:00
committed by hjk
parent 192e3f81b5
commit 10be8c9a48
11 changed files with 31 additions and 31 deletions

View File

@@ -1711,19 +1711,19 @@ void EditorManager::updateMakeWritableWarning()
if (ww) {
// we are about to change a read-only file, warn user
if (promptVCS) {
InfoBarEntry info(QLatin1String(kMakeWritableWarning),
InfoBarEntry info(Id(kMakeWritableWarning),
tr("<b>Warning:</b> This file was not opened in %1 yet.")
.arg(versionControl->displayName()));
info.setCustomButtonInfo(tr("Open"), this, SLOT(vcsOpenCurrentEditor()));
curEditor->document()->infoBar()->addInfo(info);
} else {
InfoBarEntry info(QLatin1String(kMakeWritableWarning),
InfoBarEntry info(Id(kMakeWritableWarning),
tr("<b>Warning:</b> You are changing a read-only file."));
info.setCustomButtonInfo(tr("Make Writable"), this, SLOT(makeCurrentEditorWritable()));
curEditor->document()->infoBar()->addInfo(info);
}
} else {
curEditor->document()->infoBar()->removeInfo(QLatin1String(kMakeWritableWarning));
curEditor->document()->infoBar()->removeInfo(Id(kMakeWritableWarning));
}
}
}

View File

@@ -85,7 +85,7 @@ void IDocument::setRestoredFrom(const QString &name)
{
m_autoSaveName = name;
m_restored = true;
InfoBarEntry info(QLatin1String(kRestoredAutoSave),
InfoBarEntry info(Id(kRestoredAutoSave),
tr("File was restored from auto-saved copy. "
"Select Save to confirm or Revert to Saved to discard changes."));
infoBar()->addInfo(info);
@@ -98,7 +98,7 @@ void IDocument::removeAutoSaveFile()
m_autoSaveName.clear();
if (m_restored) {
m_restored = false;
infoBar()->removeInfo(QLatin1String(kRestoredAutoSave));
infoBar()->removeInfo(Id(kRestoredAutoSave));
}
}
}

View File

@@ -40,7 +40,7 @@
namespace Core {
InfoBarEntry::InfoBarEntry(const QString &_id, const QString &_infoText)
InfoBarEntry::InfoBarEntry(Id _id, const QString &_infoText)
: id(_id)
, infoText(_infoText)
, object(0)
@@ -77,7 +77,7 @@ void InfoBar::addInfo(const InfoBarEntry &info)
emit changed();
}
void InfoBar::removeInfo(const QString &id)
void InfoBar::removeInfo(Id id)
{
QMutableListIterator<InfoBarEntry> it(m_infoBarEntries);
while (it.hasNext())
@@ -88,7 +88,7 @@ void InfoBar::removeInfo(const QString &id)
}
}
bool InfoBar::containsInfo(const QString &id) const
bool InfoBar::containsInfo(Id id) const
{
QListIterator<InfoBarEntry> it(m_infoBarEntries);
while (it.hasNext())
@@ -183,7 +183,7 @@ void InfoBarDisplay::update()
}
QToolButton *infoWidgetCloseButton = new QToolButton;
infoWidgetCloseButton->setProperty("infoId", info.id);
infoWidgetCloseButton->setProperty("infoId", info.id.uniqueIdentifier());
// need to connect to cancelObjectbefore connecting to cancelButtonClicked,
// because the latter removes the button and with it any connect
@@ -216,7 +216,7 @@ void InfoBarDisplay::widgetDestroyed()
void InfoBarDisplay::cancelButtonClicked()
{
m_infoBar->removeInfo(sender()->property("infoId").toString());
m_infoBar->removeInfo(Id::fromUniqueIdentifier(sender()->property("infoId").toInt()));
}
} // namespace Core

View File

@@ -31,6 +31,7 @@
#define INFOBAR_H
#include "core_global.h"
#include <coreplugin/id.h>
#include <QObject>
@@ -46,14 +47,14 @@ class InfoBarDisplay;
class CORE_EXPORT InfoBarEntry
{
public:
InfoBarEntry(const QString &_id, const QString &_infoText);
InfoBarEntry(Id _id, const QString &_infoText);
InfoBarEntry(const InfoBarEntry &other) { *this = other; }
void setCustomButtonInfo(const QString &_buttonText, QObject *_object, const char *_member);
void setCancelButtonInfo(QObject *_object, const char *_member);
void setCancelButtonInfo(const QString &_cancelButtonText, QObject *_object, const char *_member);
private:
QString id;
Id id;
QString infoText;
QString buttonText;
QObject *object;
@@ -71,8 +72,8 @@ class CORE_EXPORT InfoBar : public QObject
public:
void addInfo(const InfoBarEntry &info);
void removeInfo(const QString &id);
bool containsInfo(const QString &id) const;
void removeInfo(Id id);
bool containsInfo(Id id) const;
void clear();
signals: