Source Code (Use browser search to find items of interest.)
Class Index
kdevelop'UndoListBox (./kdevelop/kdevelop/kwrite/undohistory.h:89)
class UndoListBox : public QListBox
{
Q_OBJECT
public:
UndoListBox(QWidget * parent=0, const char * name=0, WFlags f=0);
virtual ~UndoListBox();
int selCount();
void setSelCount(int count);
void insertItem (const QString &text, int index = -1);
void removeItem (int index);
void clear();
protected:
int _selCount;
signals:
void sigSelected(int);
protected slots:
void _slotSelectionChanged();
};
kdevelop'UndoListBox::UndoListBox() (./kdevelop/kdevelop/kwrite/undohistory.cpp:169)
UndoListBox::UndoListBox(QWidget *parent, const char *name, WFlags f)
: QListBox(parent, name, f)
{
_selCount = 0;
setSelectionMode(Extended);
connect(this, SIGNAL(highlighted(int)), this, SLOT(_slotSelectionChanged()));
connect(this, SIGNAL(selectionChanged()), this, SLOT(_slotSelectionChanged()));
}
kdevelop'UndoListBox::~UndoListBox() (./kdevelop/kdevelop/kwrite/undohistory.cpp:178)
UndoListBox::~UndoListBox()
{}
kdevelop'UndoListBox::insertItem() (./kdevelop/kdevelop/kwrite/undohistory.cpp:181)
void UndoListBox::insertItem (const QString &text, int index)
{
bool sig = false;
if (count() == 0)
sig = true;
else if (index > -1)
sig = (isSelected(index));
QListBox::insertItem(text, index);
if (sig)
_slotSelectionChanged();
}
kdevelop'UndoListBox::removeItem() (./kdevelop/kdevelop/kwrite/undohistory.cpp:196)
void UndoListBox::removeItem (int index)
{
bool sig;
if (count() == 1)
sig = true;
else if (index == -1)
sig = (isSelected(count() - 1));
else
sig = (isSelected(index));
QListBox::removeItem(index);
if (sig)
_slotSelectionChanged();
}
kdevelop'UndoListBox::clear() (./kdevelop/kdevelop/kwrite/undohistory.cpp:213)
void UndoListBox::clear()
{
bool sig = (count() > 0);
QListBox::clear();
if (sig)
_slotSelectionChanged();
}
kdevelop'UndoListBox::selCount() (./kdevelop/kdevelop/kwrite/undohistory.cpp:223)
int UndoListBox::selCount()
{
return _selCount;
}
kdevelop'UndoListBox::setSelCount() (./kdevelop/kdevelop/kwrite/undohistory.cpp:228)
void UndoListBox::setSelCount(int count)
{
if (count == _selCount)
return;
if (count < 1 || count > (int)this->count())
return;
setCurrentItem(count - 1);
}
// make sure the first item is selected, and that there are no holes
kdevelop'UndoListBox::_slotSelectionChanged() (./kdevelop/kdevelop/kwrite/undohistory.cpp:240)
void UndoListBox::_slotSelectionChanged()
{
int count = this->count();
if (! count) {
if (_selCount != 0) {
_selCount = 0;
emit sigSelected(_selCount);
}
return;
}
if (currentItem() < 0)
setCurrentItem(0);
int i;
int currItem = currentItem();
int max = (currItem+1 > _selCount ? currItem+1 : _selCount);
for (i = 0 ; i < max ; i++) {
if (i > currItem) {
if (isSelected(i)) {
setSelected(i, false);
}
} else {
if (! isSelected(i)) {
setSelected(i, true);
}
}
}
if (_selCount != currItem + 1) {
_selCount = currItem + 1;
emit sigSelected(_selCount);
}
}