Fix functionality broken by commit 66813ef

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/9/head
Michele Calgaro 10 months ago
parent 66813efe63
commit fc8b3dd4b2
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -1,3 +1,5 @@
#include <algorithm>
#include <tqcheckbox.h>
#include <tqcursor.h>
#include <tqdatetime.h>
@ -5,7 +7,6 @@
#include <tdepopupmenu.h>
#include <tqobjectlist.h>
#include <tqpainter.h>
#include <tqptrlist.h>
#include <tqstrlist.h>
#include <tqstringlist.h>
#include <tqvbox.h>
@ -49,8 +50,8 @@
#include "configdialog.h"
#include "help.h"
#include "linkconfig.h"
#define OPAQUE 0xffffffff
#define OPACITY "_KDE_WM_WINDOW_OPACITY"
#define OPAQUE 0xffffffff
#define OPACITY "_KDE_WM_WINDOW_OPACITY"
#define _BIGSIZE_(_s_) ((_s_ == 16) ? 22 :\
(_s_ == 22) ? 32 :\
@ -1102,6 +1103,7 @@ AppList::AppList(int size, TQWidget * parent) : TQScrollView(parent), _size(size
m_popup->insertItem(i18n("Remove Entry"), this, SLOT(removeEntry()));
m_popup->insertSeparator();
m_popup->insertItem(i18n("Add Entry"), this, SLOT(addDialog()));
currentEntryIdx = -1;
init();
}
@ -1113,19 +1115,18 @@ void AppList::mouseReleaseEvent ( TQMouseEvent * e )
void AppList::windowActivationChange ( bool oldActive )
{
if (isActiveWindow() && entryList.current())
entryList.current()->setFocus();
if (isActiveWindow() && currentEntryIdx >= 0 && currentEntryIdx < entryList.size())
{
entryList[currentEntryIdx]->setFocus();
}
TQScrollView::windowActivationChange ( oldActive );
}
void AppList::reloadIcons( int size)
{
_size = size;
TQPtrListIterator<StartMenuEntry> it(entryList);
StartMenuEntry *runner;
while( (runner = it.current()) != 0 )
for (StartMenuEntry *runner : entryList)
{
++it;
runner->reloadIcon(size);
}
}
@ -1165,7 +1166,6 @@ void AppList::addEntry()
fullpath.remove(0,1);
}
fullpath = KService::newServicePath(true, fullpath + configDialog_->appName->text());
//tqWarning("%s",fullpath.ascii());
writeEntry(fullpath);
KService *s = new KService(fullpath);
TQStringList list(KServiceGroup::group(configDialog_->category->currentText())->caption());
@ -1180,10 +1180,9 @@ void AppList::removeEntry()
popupBlocked_ = true;
if (KMessageBox::questionYesNo (this, i18n("<qt>Are you sure you want to remove<br> %1</qt>").arg(handledEntry->title()), i18n("Remove ALI entry")) == KMessageBox::Yes)
{
tqWarning("gonna delete!");
writeEntry(handledEntry->m_service->locateLocal(), true);
handledEntry->hide();
entryList.removeRef(handledEntry);
entryList.erase(std::find(entryList.begin(), entryList.end(), handledEntry));
delete handledEntry;
handledEntry = 0L;
}
@ -1240,7 +1239,7 @@ void AppList::editEntry()
handledEntry->hide();
TQDate lu = handledEntry->lastUse;
uint u = handledEntry->usage;
entryList.removeRef(handledEntry);
entryList.erase(std::find(entryList.begin(), entryList.end(), handledEntry));
delete handledEntry;
handledEntry = 0L;
KService *s = new KService(fullpath);
@ -1302,8 +1301,6 @@ void AppList::writeEntry(TQString path, bool hidden )
}
delete config;
// configDialog_->category->setCurrentItem (handledEntry->m_service->categories().join("/"), true);
}
void AppList::popup(StartMenuEntry* entry)
@ -1317,21 +1314,16 @@ void AppList::popup(StartMenuEntry* entry)
void AppList::sort()
{
// first clean the layout (i assume that TQLayout::remove() will search from beginning so removing over the current order will be quite fast)
TQPtrListIterator<StartMenuEntry> it(entryList);
StartMenuEntry *runner;
while( (runner = it.current()) != 0 )
for (StartMenuEntry *runner : entryList)
{
++it;
m_VLayout->remove ( runner );
}
((MyVBoxLayout*)m_VLayout)->deleteAllItems(); // get rid of the stretch
// then sort the list
entryList.sort();
it.toFirst();
std::sort(entryList.begin(), entryList.end(), [](StartMenuEntry *a, StartMenuEntry *b) { return *a < *b; });
// now rebuild the layout from new list
while( (runner = it.current()) != 0 )
for (StartMenuEntry *runner : entryList)
{
++it;
m_VLayout->addWidget ( runner );
}
m_VLayout->addStretch(1); // add final stretch
@ -1373,11 +1365,8 @@ void AppList::init()
void AppList::save(TDEConfig *config)
{
config->setGroup("Statistics");
TQPtrListIterator<StartMenuEntry> it(entryList);
StartMenuEntry *runner;
while( (runner = it.current()) != 0 )
for (StartMenuEntry *runner : entryList)
{
++it;
runner->saveStats();
}
}
@ -1437,12 +1426,12 @@ StartMenuEntry* AppList::addApp(KService * s, TQStringList & captions, TQString
connect (tmp, SIGNAL(executed()), this, SLOT(sort()));
m_VLayout->addWidget(tmp);
tmp->hide();
entryList.append(tmp);
entryList.push_back(tmp);
KeyWordList::Iterator it;
if (!(s->name().isNull() || s->name().isEmpty()))
{
it = m_keywordList.insert(s->name(), StartMenuEntryList(), false);
it.data().append( tmp );
it.data().push_back( tmp );
}
TQStringList kw;
#if 0
@ -1455,7 +1444,7 @@ StartMenuEntry* AppList::addApp(KService * s, TQStringList & captions, TQString
if (!((*key).isNull() || (*key).isEmpty()))
{
it = m_keywordList.insJediKnightert(*key, StartMenuEntryList(), false);
it.data().append( tmp );
it.data().push_back( tmp );
}
}
}
@ -1468,7 +1457,7 @@ StartMenuEntry* AppList::addApp(KService * s, TQStringList & captions, TQString
if (!((*key).isNull() || (*key).isEmpty()))
{
it = m_keywordList.insert(*key, StartMenuEntryList(), false);
it.data().append( tmp );
it.data().push_back( tmp );
}
}
}
@ -1480,7 +1469,7 @@ StartMenuEntry* AppList::addApp(KService * s, TQStringList & captions, TQString
if (!((*key).isNull() || (*key).isEmpty()))
{
it = m_groupList.insert(*key, StartMenuEntryList(), false);
it.data().append( tmp );
it.data().push_back( tmp );
}
}
}
@ -1489,25 +1478,29 @@ StartMenuEntry* AppList::addApp(KService * s, TQStringList & captions, TQString
void AppList::finish()
{
entryList.last(); entryList.next();
currentEntryIdx = -1;
m_VLayout->addStretch(1);
categories.sort();
}
void AppList::appDown()
{
StartMenuEntry *save;
if (entryList.current() == 0L/*entryList.getLast()*/)
if (entryList.size() == 0)
{
entryList.first();
save = 0L;
return;
}
if (currentEntryIdx < 0 || currentEntryIdx >= entryList.size())
{
currentEntryIdx = 0;
}
else
{
save = entryList.current();
entryList.next();
++currentEntryIdx;
}
for ( StartMenuEntry *runner = entryList.current(); runner; runner = entryList.next() )
StartMenuEntry *save = entryList[currentEntryIdx];
for (; currentEntryIdx < entryList.size(); ++currentEntryIdx)
{
StartMenuEntry *runner = entryList[currentEntryIdx];
if (runner->isShown())
{
if (save) save->clearFocus();
@ -1517,26 +1510,34 @@ void AppList::appDown()
ensureVisible ( pt.x(), pt.y());
return;
}
// if (currentEntry == entryList.end())
// currentEntry = entryList.begin(); // keep this somewhere valid
}
}
void AppList::appUp()
{
if (entryList.current() == entryList.getFirst())
if (entryList.size() == 0)
{
entryList.current()->clearFocus();
entryList.last(); entryList.next(); // we jump out
return;
}
if (currentEntryIdx == 0)
{
entryList[currentEntryIdx]->clearFocus();
--currentEntryIdx;
emit looseKey();
return;
}
StartMenuEntry *save = entryList.current();
StartMenuEntry *runner;
if (entryList.current())
runner = entryList.prev();
StartMenuEntry *save = entryList[currentEntryIdx];
if (currentEntryIdx > 0)
{
--currentEntryIdx;
}
else
runner = entryList.last();
for ( ; runner != entryList.getFirst(); runner = entryList.prev())
{
currentEntryIdx = entryList.size() - 1;
}
for (; currentEntryIdx >= 0; --currentEntryIdx)
{
StartMenuEntry *runner = entryList[currentEntryIdx];
if (runner->isShown())
{
if (save) save->clearFocus();
@ -1546,30 +1547,19 @@ void AppList::appUp()
ensureVisible ( pt.x(), pt.y());
return;
}
if (runner == entryList.getFirst())
}
if (currentEntryIdx < 0)
{
if (save) save->clearFocus();
if (runner->isShown())
{
runner->setFocus();
TQPoint pt(0,0);
pt = runner->mapToParent(pt);
ensureVisible ( pt.x(), pt.y());
}
else
{
entryList.last(); entryList.next();// we jump out
emit looseKey();
}
emit looseKey();
}
}
void AppList::appLeft()
{
if (entryList.current())
if (currentEntryIdx >= 0 && currentEntryIdx < entryList.size())
{
entryList.current()->clearFocus();
entryList.last(); entryList.next(); // we jump out
entryList[currentEntryIdx]->clearFocus();
}
currentEntryIdx = -1;
emit looseKey();
}
@ -1577,23 +1567,22 @@ void AppList::showCategory(const TQString & string)
{
infoLabel->setText(string);
infoLabel->show();
StartMenuEntry *it2;
KeyWordList::Iterator it;
for ( it = m_groupList.begin(); it != m_groupList.end(); ++it )
{
if (it.key() == string)
{
for ( it2 = it.data().first(); it2; it2 = it.data().next())
for (StartMenuEntry *it2 : it.data())
it2->display = true;
}
else
{
for ( it2 = it.data().first(); it2; it2 = it.data().next())
for (StartMenuEntry *it2 : it.data())
it2->display = it2->display || false;
}
}
uint visibleItems = 0;
for ( it2 = entryList.first(); it2; it2 = entryList.next())
for (StartMenuEntry *it2 : entryList)
{
if (it2->display)
{
@ -1613,13 +1602,12 @@ void AppList::showCategory(const TQString & string)
void AppList::search(const TQString & string)
{
StartMenuEntry *it2;
if (string == TQString::null || string == "") // empty line - remove all and exit
{
infoLabel->setText ( i18n("<qt><b>Favorite Applications</b><br></qt>") );
infoLabel->show();
int i = 0;
for ( it2 = entryList.first(); it2; it2 = entryList.next() )
for (StartMenuEntry *it2 : entryList)
{
i < favItemAmount ? it2->show() : it2->hide();
i++;
@ -1635,12 +1623,12 @@ void AppList::search(const TQString & string)
{
if (it.key().contains(string, false) > 0)
{
for ( it2 = it.data().first(); it2; it2 = it.data().next())
for (StartMenuEntry *it2 : it.data())
it2->display = true;
}
else
{
for ( it2 = it.data().first(); it2; it2 = it.data().next())
for (StartMenuEntry *it2 : it.data())
it2->display = it2->display || false;
}
}
@ -1649,18 +1637,18 @@ void AppList::search(const TQString & string)
{
if (it.key().contains(string, false) > 0)
{
for ( it2 = it.data().first(); it2; it2 = it.data().next())
for (StartMenuEntry *it2 : it.data())
it2->display = true;
}
else
{
for ( it2 = it.data().first(); it2; it2 = it.data().next())
for (StartMenuEntry *it2 : it.data())
it2->display = it2->display || false;
}
}
//items
uint visibleItems = 0;
for ( it2 = entryList.first(); it2; it2 = entryList.next())
for (StartMenuEntry *it2 : entryList)
{
if (it2->display && visibleItems < 50) //limit this to a healthy size
{
@ -1680,7 +1668,7 @@ void AppList::search(const TQString & string)
void AppList::clear()
{
for ( StartMenuEntry *it = entryList.first(); it; it = entryList.next())
for (StartMenuEntry *it : entryList)
it->hide();
}
@ -1692,7 +1680,7 @@ void AppList::reset()
infoLabel->show();
if (newbie)
{
for ( StartMenuEntry *it = entryList.first(); it; it = entryList.next())
for (StartMenuEntry *it : entryList)
{
it->forNewbie ? it->show() : it->hide();
}
@ -1700,7 +1688,7 @@ void AppList::reset()
else
{
uint i = 0;
for ( StartMenuEntry *it = entryList.first(); it; it = entryList.next())
for (StartMenuEntry *it : entryList)
{
i < favItemAmount ? it->show() : it->hide();
i++;
@ -1780,6 +1768,7 @@ StartMenu::StartMenu( int size, TQWidget * parent, WFlags f ) : TQWidget(parent,
connect (categoryCombo, SIGNAL(activated( const TQString &)), appList, SLOT(showCategory(const TQString &)));
connect (searchLine, SIGNAL(typedTextChanged(const TQString &)), appList, SLOT(search(const TQString &)));
connect (searchLine, SIGNAL(textChanged(const TQString &)), this, SLOT(endHistory()));
connect (searchLine, SIGNAL(focusedIn()), this, SLOT(searchLineFocused()));
connect (appList, SIGNAL(looseKey()), searchLine, SLOT(setFocus()));
connect (appList, SIGNAL(looseKey()), searchLine, SLOT(selectAll() ));
connect (kapp, SIGNAL(shutDown()), this, SLOT(save() ));
@ -1861,22 +1850,16 @@ void StartMenu::toggleKTTS(bool on)
if (useKTTS)
{
m_spokenText = 0;
TQPtrListIterator<StartMenuEntry> it(appList->entryList);
StartMenuEntry *runner;
while( (runner = it.current()) != 0 )
for (StartMenuEntry *runner : appList->entryList)
{
++it;
connect (runner, SIGNAL(sayText(const TQString&)), this, SIGNAL(sayText(const TQString&)));
}
connect (appList, SIGNAL(sayText(const TQString&)), this, SLOT(sayText(const TQString&) ));
}
else
{
TQPtrListIterator<StartMenuEntry> it(appList->entryList);
StartMenuEntry *runner;
while( (runner = it.current()) != 0 )
for (StartMenuEntry *runner : appList->entryList)
{
++it;
disconnect (runner, SIGNAL(sayText(const TQString&)), this, SIGNAL(sayText(const TQString&)));
}
disconnect (appList, SIGNAL(sayText(const TQString&)), this, SLOT(sayText(const TQString&) ));
@ -1885,6 +1868,11 @@ void StartMenu::toggleKTTS(bool on)
SearchLine::SearchLine( TQWidget * parent ) : KLineEdit(parent){blocked = false;};
void SearchLine::focusInEvent(TQFocusEvent *)
{
emit focusedIn();
}
void SearchLine::makeCompletion (const TQString & string)
{
if (blocked) {blocked = false; return;}
@ -1942,6 +1930,7 @@ void StartMenu::sayText(const TQString &text)
void StartMenu::show()
{
appList->currentEntryIdx = -1;
m_panel->setBackgroundOrigin(TQWidget::WidgetOrigin);
statusBar->setBackgroundOrigin(TQWidget::ParentOrigin);
searchLine->setText(i18n("Type to search or enter a command"));
@ -2100,6 +2089,11 @@ void StartMenu::endHistory()
currentHistoryItem = history.end();
}
void StartMenu::searchLineFocused()
{
appList->currentEntryIdx = -1;
}
void StartMenu::search(const TQString & string)
{
disconnect (searchLine, SIGNAL(textChanged ( const TQString & )), this, SLOT(search(const TQString &)));

@ -6,6 +6,8 @@
#include "config.h"
#endif
#include <vector>
#include <tqpoint.h>
#include <tqwidget.h>
#include <tqlabel.h>
@ -13,7 +15,6 @@
#include <tqscrollview.h>
#include <tqmap.h>
#include <tqpixmap.h>
#include <tqptrlist.h>
#include <klineedit.h>
#include <kservicegroup.h>
#include "mykey.h"
@ -189,6 +190,7 @@ public:
StartMenuEntry* addApp(KService * service, TQStringList & captions, TQString relPath);
void finish();
StartMenuEntry* handledEntry; // for rightclick menu action
int currentEntryIdx;
void writeEntry(TQString path, bool hidden = false); // for add/edit
void reloadIcons(int size);
public slots:
@ -226,7 +228,7 @@ private:
TDEPopupMenu *m_popup;
bool popupBlocked_;
int _size;
typedef TQPtrList<StartMenuEntry> StartMenuEntryList;
typedef std::vector<StartMenuEntry*> StartMenuEntryList;
typedef TQMap<TQString,StartMenuEntryList> KeyWordList;
StartMenuEntryList entryList;
KeyWordList m_keywordList;
@ -250,11 +252,14 @@ class SearchLine : public KLineEdit
public:
SearchLine( TQWidget * parent );
bool blocked;
protected:
void focusInEvent ( TQFocusEvent * );
protected slots:
void makeCompletion (const TQString &);
void block(){blocked = true;}
signals:
void typedTextChanged(const TQString & string);
void focusedIn();
};
class KURIFilterData;
@ -293,7 +298,7 @@ private slots:
void execute(const TQString & command);
void search(const TQString & string);
void endHistory();
// void slotLock();
void searchLineFocused();
private:
bool inMove;
uint m_spokenText;

Loading…
Cancel
Save