Exemplo n.º 1
0
//Deletes a Node from the list
bool deleteEntry(ListType &list, string theKey) {

  if(hasEntry(list,theKey) != true) { 
    return false;
  }

  ListType p = list;
  
  //found entry is first node in list
  if(list->key == theKey) {

    list = list->next;
    delete p;

  }
  
  else {
    p = p->next;
    ListType q = list;

    while(p->key != theKey) {
      p = p->next;    
      q = q->next;
    }

    q->next = p->next;
    delete p;
  }

  return true;

}
bool MROMInstaller::extractTarballs(const std::string& base)
{
	system("rm -r /tmp/tarballs; mkdir /tmp/tarballs");

	if(!hasEntry("rom"))
	{
		gui_print("Skippping tarball extractions - no rom folder in the ZIP file\n");
		return true;
	}

	bool res = false;
	const MultiROM::baseFolders& folders = MultiROM::getBaseFolders();
	MultiROM::baseFolders::const_iterator itr;
	for(itr = folders.begin(); itr != folders.end(); ++itr)
	{
		if(!extractBase(base, itr->first))
		{
			gui_print("Failed to extract base %s\n", itr->first.c_str());
			goto exit;
		}
	}

	res = true;
exit:
	system("rm -r /tmp/tarballs");
	return res;
}
void TrajectoryVideoLookup::put(const std::string& tkey, view_controller_msgs::CameraPlacement view)
{
  TrajectoryHashtable::iterator entry;
  if( !hasEntry(tkey, entry) )
    createEntry(tkey, entry);
  entry->second.addView( view );
}
void TrajectoryVideoLookup::put(const std::string& tkey, moveit_msgs::RobotTrajectory rt)
{
  TrajectoryHashtable::iterator entry;
  if( !hasEntry(tkey, entry) )
    createEntry(tkey, entry);
  entry->second.rt = rt;
}
void TrajectoryVideoLookup::put(const std::string& tkey, moveit_msgs::PlanningScene ps)
{
  TrajectoryHashtable::iterator entry;
  if( !hasEntry(tkey, entry) )
    createEntry(tkey, entry);
  entry->second.ps = ps;
}
void TrajectoryVideoLookup::putVideoURL(const std::string& tkey, const std::string& vkey, const std::string& url)
{
  TrajectoryHashtable::iterator entry;
  if( !hasEntry(tkey, entry) )
    createEntry(tkey, entry);
  entry->second.addVideoURL(vkey, url);
}
bool MROMInstaller::runScripts(const std::string& dir, const std::string& base, const std::string& root)
{
	system("rm -r /tmp/script; mkdir /tmp/script");

	if(!hasEntry(dir))
	{
		LOGI("Skippping scripts in %s, not in the ZIP\n", dir.c_str());
		return true;
	}

	if(!extractDir(dir, "/tmp/script/"))
		return false;

	if(system("ls /tmp/script/*.sh") == 0)
	{
		system("chmod -R 777 /tmp/script/*");

		gui_print("Running %s scripts...\n", dir.c_str());

		char cmd[512];
		sprintf(cmd, "sh -c 'for x in $(ls /tmp/script/*.sh); do echo Running script $x; sh $x %s %s || exit 1; done'", base.c_str(), root.c_str());
		if(system(cmd) != 0)
		{
			system("rm -r /tmp/script/");
			gui_print("One of the ROM scripts returned error status!");
			return false;
		}
	}
	else
		LOGI("Skipping folder %s, no bash scripts\n", dir.c_str());

	system("rm -r /tmp/script");
	return true;
}
void TrajectoryVideoLookup::put(const std::string& tkey, moveit_msgs::MotionPlanRequest mpr )
{
  TrajectoryHashtable::iterator entry;
  if( !hasEntry(tkey, entry) )
    createEntry(tkey, entry);
  entry->second.mpr = mpr;
}
void TrajectoryVideoLookup::put(const std::string& tkey, TrajectoryVideoEntry vid)
{
  TrajectoryHashtable::iterator entry;
  if( !hasEntry(tkey, entry) )
    createEntry(tkey, entry);
  entry->second.addVideoFile(vid.name, vid.file);
  entry->second.addVideoURL(vid.name, vid.url);
}
 inline bool
 SparseManyIndexed< ValueClass >::hasEntry(
                                std::string const& indicesAsString ) const
 // this returns true if there is an entry at the vector parsed from
 // indicesAsString see operator() for the format).
 {
   return hasEntry( BOL::StringParser::stringToIntVector(
                                                      indicesAsString ) );
 }
Exemplo n.º 11
0
QVariant database::dbPrivate::baseRecord::getValue(int i) const
{
    if(!hasEntry(i))
    {
        return QVariant();
        
    }
    return entries[i]->value();
}
Exemplo n.º 12
0
void database::dbPrivate::baseRecord::setValue(int i, QVariant v)
{
    if(!hasEntry(i))
    {
        v=QVariant();
        return ;
    }
    entries[i]->setValue(v);
}
Exemplo n.º 13
0
database::dbPrivate::baseRecord* database::dbPrivate::baseRecord::getRelated(int t) const
{
    if(!hasEntry(t) )
    {
        return 0;
    }
    
    return getRelatedEntry(entries[t] );
}
Exemplo n.º 14
0
bool Table::insert(const string &key, int value) {

  if(hasEntry(hashTable[hashCode(key)],key)) { 
    return false;
  }

  insertFront(hashTable[hashCode(key)],key,value);

  return true;
}
Exemplo n.º 15
0
Arquivo: INIFile.C Projeto: HeyJJ/ball
	bool INIFile::insertValue(const String& section_name, const String& key, const String& value)
	{
		// does section exists?
		if (!section_index_.has(section_name) || hasEntry(section_name, key))
		{
			return false;
		}

		String new_line(key + "=" + value);
		appendLine(section_name, new_line);

		return true;
	}
Exemplo n.º 16
0
bool PECOFFLinkingContext::validateImpl(raw_ostream &diagnostics) {
  if (_stackReserve < _stackCommit) {
    diagnostics << "Invalid stack size: reserve size must be equal to or "
                << "greater than commit size, but got " << _stackCommit
                << " and " << _stackReserve << ".\n";
    return false;
  }

  if (_heapReserve < _heapCommit) {
    diagnostics << "Invalid heap size: reserve size must be equal to or "
                << "greater than commit size, but got " << _heapCommit
                << " and " << _heapReserve << ".\n";
    return false;
  }

  // It's an error if the base address is not multiple of 64K.
  if (getBaseAddress() & 0xffff) {
    diagnostics << "Base address have to be multiple of 64K, but got "
                << getBaseAddress() << "\n";
    return false;
  }

  // Specifing /noentry without /dll is an error.
  if (!hasEntry() && !isDll()) {
    diagnostics << "/noentry must be specified with /dll\n";
    return false;
  }

  // Check for duplicate export ordinals.
  std::set<int> exports;
  for (const PECOFFLinkingContext::ExportDesc &desc : getDllExports()) {
    if (desc.ordinal == -1)
      continue;
    if (exports.count(desc.ordinal) == 1) {
      diagnostics << "Duplicate export ordinals: " << desc.ordinal << "\n";
      return false;
    }
    exports.insert(desc.ordinal);
  }

  // Check for /align.
  std::bitset<64> alignment(_sectionDefaultAlignment);
  if (alignment.count() != 1) {
    diagnostics << "Section alignment must be a power of 2, but got "
                << _sectionDefaultAlignment << "\n";
    return false;
  }

  _writer = createWriterPECOFF(*this);
  return true;
}
bool MROMInstaller::extractBase(const std::string& base, const std::string& name)
{
	char cmd[256];
	sprintf(cmd, "rom/%s.tar.gz", name.c_str());

	if(hasEntry(cmd))
		return extractTarball(base, name, cmd);
	else
	{
		char cmd[256];
		for(int i = 0; true; ++i)
		{
			sprintf(cmd, "rom/%s_%02d.tar.gz", name.c_str(), i);
			if(!hasEntry(cmd))
				break;

			if(!extractTarball(base, name, cmd))
				return false;
		}
	}

	return true;
}
Exemplo n.º 18
0
void database::dbPrivate::baseRecord::changeEntry ( int i, QVariant& v )
{
    if(!hasEntry(i))
    {
        v=QVariant();
        return ;
    }
    
    entry *e=entries[i];
    e->changeValue(v);
    _hasChanged=true;
    if(e->isUnique())
    {
        _needNewId=true;
    }
}
Exemplo n.º 19
0
inline ValueClass const&
DenseTriplyIndexed< ValueClass >::operator()( int firstIndex,
        int secondIndex,
        int thirdIndex ) const
/* const version of above, though it returns defaultUnsetValue rather
 * than copying in a new element at the sought indices if there isn't
 * an entry there already.
 */
{
    if( hasEntry( firstIndex,
                  secondIndex,
                  thirdIndex ) )
    {
        return valueMatrixArray[ firstIndex - 1 ][ secondIndex
                - 1 ][ thirdIndex - 1 ];
    }
    else
    {
        return this->defaultUnsetValue;
    }
}
Exemplo n.º 20
0
void Configuration::addLauncher(const QString &url)
{
    if (url.isEmpty() || hasEntry(url))
    {
        return;
    }

    Launcher launcher(KUrl(url), m_applet);
    const int row = (m_arrangementUi.currentEntriesListWidget->currentIndex().row() + 1);

    m_arrangementUi.currentEntriesListWidget->model()->insertRow(row);

    const QModelIndex index = m_arrangementUi.currentEntriesListWidget->model()->index(row, 0);

    m_arrangementUi.currentEntriesListWidget->model()->setData(index, launcher.title(), Qt::DisplayRole);
    m_arrangementUi.currentEntriesListWidget->model()->setData(index, launcher.icon(), Qt::DecorationRole);
    m_arrangementUi.currentEntriesListWidget->model()->setData(index, launcher.launcherUrl().pathOrUrl(), Qt::ToolTipRole);
    m_arrangementUi.currentEntriesListWidget->setCurrentRow(row);

    modify();
}
void ChangeJournalWatcher::updateWithUsn(const std::wstring &vol, const SChangeJournal &cj, const UsnInt *UsnRecord)
{
	//logEntry(vol, UsnRecord);

	_i64 dir_id=hasEntry(cj.rid, UsnRecord->FileReferenceNumber);
	if(dir_id!=-1) //Is a directory
	{
		_i64 parent_id=hasEntry(cj.rid, UsnRecord->ParentFileReferenceNumber);
		if(parent_id==-1)
		{
			Server->Log(L"Error: Parent of "+UsnRecord->Filename+L" not found -1", LL_ERROR);
		}
		else if(UsnRecord->Reason & (USN_REASON_CLOSE | watch_flags ) )
		{
			std::wstring dir_fn=getFilename(UsnRecord->ParentFileReferenceNumber, cj.rid);
			if(dir_fn.empty())
			{
				Server->Log(L"Error: Path of "+UsnRecord->Filename+L" not found -2", LL_ERROR);
			}
			else
			{
				if(UsnRecord->Reason & USN_REASON_RENAME_NEW_NAME )
				{
					renameEntry(UsnRecord->Filename, dir_id, UsnRecord->ParentFileReferenceNumber);
				}
				else if(UsnRecord->Reason & USN_REASON_FILE_DELETE)
				{
					if(UsnRecord->attributes & FILE_ATTRIBUTE_DIRECTORY )
					{
						listener->On_DirRemoved(dir_fn+UsnRecord->Filename);
					}
					deleteWithChildren(UsnRecord->FileReferenceNumber, cj.rid);
				}

				if(UsnRecord->Reason & watch_flags )
				{
					listener->On_FileModified(dir_fn+UsnRecord->Filename, false );
				}
			}
		}
		else if(UsnRecord->Reason & USN_REASON_RENAME_OLD_NAME )
		{
			std::wstring dir_fn=getFilename(UsnRecord->ParentFileReferenceNumber, cj.rid);
			if(dir_fn.empty())
			{
				Server->Log(L"Error: Path of "+UsnRecord->Filename+L" not found -3", LL_ERROR);
			}
			else
			{
				if(UsnRecord->attributes & FILE_ATTRIBUTE_DIRECTORY )
				{
					listener->On_DirRemoved(dir_fn+UsnRecord->Filename);
				}
				listener->On_FileModified(dir_fn+UsnRecord->Filename, false);
			}
		}
	}
	else //Is a file
	{
		_i64 parent_id=hasEntry(cj.rid, UsnRecord->ParentFileReferenceNumber);
		if(parent_id==-1)
		{
			Server->Log(L"Error: Parent of file "+UsnRecord->Filename+L" not found -4", LL_ERROR);
		}
		else
		{
			std::wstring dir_fn=getFilename(UsnRecord->ParentFileReferenceNumber, cj.rid);
			std::wstring real_fn=dir_fn+UsnRecord->Filename;
			
			if( UsnRecord->attributes & FILE_ATTRIBUTE_DIRECTORY )
			{
				if((UsnRecord->Reason & USN_REASON_FILE_CREATE) && (UsnRecord->Reason & USN_REASON_CLOSE) )
				{
					addFrn(UsnRecord->Filename, UsnRecord->ParentFileReferenceNumber, UsnRecord->FileReferenceNumber, cj.rid);
				}
			}
			else
			{
				if(UsnRecord->Reason & USN_REASON_CLOSE)
				{
					std::map<std::wstring, bool>::iterator it=open_write_files.find(real_fn);
					if(it!=open_write_files.end())
					{
						open_write_files.erase(it);
					}
				}
				else if(UsnRecord->Reason & watch_flags)
				{
					open_write_files[real_fn]=true;
				}
			}

			if( (UsnRecord->Reason & USN_REASON_RENAME_OLD_NAME)
				|| (UsnRecord->Reason & watch_flags) && (UsnRecord->Reason & USN_REASON_CLOSE) )
			{
				bool save_fn=false;
				if( (UsnRecord->Reason & USN_REASON_BASIC_INFO_CHANGE) && (UsnRecord->attributes & FILE_ATTRIBUTE_DIRECTORY)==0 )
				{
					save_fn=true;
				}
				listener->On_FileModified(real_fn, save_fn);
			}
		}
	}
}
Exemplo n.º 22
0
Configuration::Configuration(Applet *applet, KConfigDialog *parent) : QObject(parent),
    m_applet(applet),
    m_editedLauncher(NULL)
{
    KConfigGroup configuration = m_applet->config();
    KMenu *addLauncherMenu = new KMenu(parent);
    QWidget *generalWidget = new QWidget;
    QWidget *appearanceWidget = new QWidget;
    QWidget *arrangementWidget = new QWidget;
    QWidget *actionsWidget = new QWidget;
    QAction *addLauncherApplicationAction = addLauncherMenu->addAction(KIcon("application-x-executable"), i18n("Add Application..."));
    QAction *addLauncherFromFileAction = addLauncherMenu->addAction(KIcon("inode-directory"), i18n("Add File or Directory..."));
    QAction *addMenuLauncher = addLauncherMenu->addAction(KIcon("start-here"), i18n("Add Menu"));
    KMenu *addMenuLauncherMenu = new KMenu(addLauncherMenu);

    addMenuLauncher->setMenu(addMenuLauncherMenu);

    QAction *action = addMenuLauncherMenu->addAction(QString());
    action->setData("/");
    action->setVisible(false);

    m_generalUi.setupUi(generalWidget);
    m_appearanceUi.setupUi(appearanceWidget);
    m_arrangementUi.setupUi(arrangementWidget);
    m_actionsUi.setupUi(actionsWidget);

    connectWidgets(generalWidget);
    connectWidgets(appearanceWidget);

    m_arrangementUi.addLauncherButton->setMenu(addLauncherMenu);

    m_generalUi.groupingStrategy->addItem(i18n("Do Not Group"), QVariant(TaskManager::GroupManager::NoGrouping));
    m_generalUi.groupingStrategy->addItem(i18n("Manually"), QVariant(TaskManager::GroupManager::ManualGrouping));
    m_generalUi.groupingStrategy->addItem(i18n("By Program Name"), QVariant(TaskManager::GroupManager::ProgramGrouping));
    m_generalUi.groupingStrategy->setCurrentIndex(m_generalUi.groupingStrategy->findData(QVariant(configuration.readEntry("groupingStrategy", static_cast<int>(TaskManager::GroupManager::NoGrouping)))));

    m_generalUi.sortingStrategy->addItem(i18n("Do Not Sort"), QVariant(TaskManager::GroupManager::NoSorting));
    m_generalUi.sortingStrategy->addItem(i18n("Manually"), QVariant(TaskManager::GroupManager::ManualSorting));
    m_generalUi.sortingStrategy->addItem(i18n("Alphabetically"), QVariant(TaskManager::GroupManager::AlphaSorting));
    m_generalUi.sortingStrategy->addItem(i18n("By Desktop"), QVariant(TaskManager::GroupManager::DesktopSorting));
    m_generalUi.sortingStrategy->setCurrentIndex(m_generalUi.sortingStrategy->findData(QVariant(configuration.readEntry("sortingStrategy", static_cast<int>(TaskManager::GroupManager::ManualSorting)))));

    m_generalUi.showOnlyCurrentDesktop->setChecked(configuration.readEntry("showOnlyCurrentDesktop", false));
    m_generalUi.showOnlyCurrentActivity->setChecked(configuration.readEntry("showOnlyCurrentActivity", true));
    m_generalUi.showOnlyCurrentScreen->setChecked(configuration.readEntry("showOnlyCurrentScreen", false));
    m_generalUi.showOnlyMinimized->setChecked(configuration.readEntry("showOnlyMinimized", false));
    m_generalUi.showOnlyTasksWithLaunchers->setChecked(configuration.readEntry("showOnlyTasksWithLaunchers", false));
    m_generalUi.connectJobsWithTasks->setChecked(configuration.readEntry("connectJobsWithTasks", false));
    m_generalUi.groupJobs->setChecked(configuration.readEntry("groupJobs", true));

    m_generalUi.jobCloseMode->addItem(i18n("Instantly"), QVariant(InstantClose));
    m_generalUi.jobCloseMode->addItem(i18n("After delay"), QVariant(DelayedClose));
    m_generalUi.jobCloseMode->addItem(i18n("Manually"), QVariant(ManualClose));
    m_generalUi.jobCloseMode->setCurrentIndex(m_generalUi.jobCloseMode->findData(QVariant(configuration.readEntry("jobCloseMode", static_cast<int>(DelayedClose)))));

    QStringList moveAnimationNames;
    moveAnimationNames << i18n("None") << i18n("Zoom") << i18n("Jump") << i18n("Spotlight") << i18n("Glow") << i18n("Fade");

    QList<AnimationType> moveAnimationIds;
    moveAnimationIds << NoAnimation << ZoomAnimation << JumpAnimation << SpotlightAnimation << GlowAnimation << FadeAnimation;

    for (int i = 0; i < moveAnimationIds.count(); ++i)
    {
        m_appearanceUi.moveAnimation->addItem(moveAnimationNames.at(i), QVariant(moveAnimationIds.at(i)));
    }

    QStringList iconAnimationNames;
    iconAnimationNames << i18n("None") << i18n("Bounce") << i18n("Zoom") << i18n("Blink") << i18n("Spotlight") << i18n("Rotate") << i18n("Glow");

    QList<AnimationType> iconAnimationIds;
    iconAnimationIds << NoAnimation << BounceAnimation << ZoomAnimation << BlinkAnimation << SpotlightAnimation << RotateAnimation << GlowAnimation;

    for (int i = 0; i < iconAnimationIds.count(); ++i)
    {
        m_appearanceUi.demandsAttentionAnimation->addItem(iconAnimationNames.at(i), QVariant(iconAnimationIds.at(i)));
        m_appearanceUi.startupAnimation->addItem(iconAnimationNames.at(i), QVariant(iconAnimationIds.at(i)));
    }

    m_appearanceUi.titleLabelMode->addItem(i18n("Never"), QVariant(NoLabel));
    m_appearanceUi.titleLabelMode->addItem(i18n("On mouse-over"), QVariant(MouseOverLabel));
    m_appearanceUi.titleLabelMode->addItem(i18n("For active icon"), QVariant(ActiveIconLabel));
    m_appearanceUi.titleLabelMode->addItem(i18n("Always"), QVariant(AlwaysShowLabel));
    m_appearanceUi.titleLabelMode->setCurrentIndex(m_appearanceUi.titleLabelMode->findData(QVariant(configuration.readEntry("titleLabelMode", static_cast<int>(AlwaysShowLabel)))));

    m_appearanceUi.activeIconIndication->addItem(i18n("None"), QVariant(NoIndication));
    m_appearanceUi.activeIconIndication->addItem(i18n("Zoom"), QVariant(ZoomIndication));
    m_appearanceUi.activeIconIndication->addItem(i18n("Glow"), QVariant(GlowIndication));
    m_appearanceUi.activeIconIndication->addItem(i18n("Fade"), QVariant(FadeIndication));
    m_appearanceUi.activeIconIndication->setCurrentIndex(m_appearanceUi.activeIconIndication->findData(QVariant(configuration.readEntry("activeIconIndication", static_cast<int>(FadeIndication)))));

    m_appearanceUi.customBackgroundImage->setUrl(KUrl(configuration.readEntry("customBackgroundImage", QString())));
    m_appearanceUi.customBackgroundImage->setFilter("image/svg+xml image/svg+xml-compressed");

    if (m_applet->location() != Plasma::Floating && (!m_applet->containment() || m_applet->containment()->objectName() != "FancyPanel")) {
        m_appearanceUi.customBackgroundImageLabel->hide();
        m_appearanceUi.customBackgroundImage->hide();
    }

    m_appearanceUi.moveAnimation->setCurrentIndex(moveAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("moveAnimation", static_cast<int>(GlowAnimation)))));
    m_appearanceUi.parabolicMoveAnimation->setChecked(configuration.readEntry("parabolicMoveAnimation", false));
    m_appearanceUi.demandsAttentionAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("demandsAttentionAnimation", static_cast<int>(BlinkAnimation)))));
    m_appearanceUi.startupAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("startupAnimation", static_cast<int>(BounceAnimation)))));

    m_arrangementUi.removeButton->setIcon(KIcon("go-previous"));
    m_arrangementUi.addButton->setIcon(KIcon("go-next"));
    m_arrangementUi.moveUpButton->setIcon(KIcon("go-up"));
    m_arrangementUi.moveDownButton->setIcon(KIcon("go-down"));

    KConfig kickoffConfiguration("kickoffrc", KConfig::NoGlobals);
    KConfigGroup favoritesGroup(&kickoffConfiguration, "Favorites");
    const QStringList currentEntries = configuration.readEntry("arrangement", QStringList("tasks"));
    QStringList availableEntries;
    availableEntries << i18n("--- separator ---") << i18n("--- tasks area ---") << i18n("--- jobs area ---") << "menu:/";
    availableEntries.append(favoritesGroup.readEntry("FavoriteURLs", QStringList()));

    for (int i = 0; i < currentEntries.count(); ++i)
    {
        QListWidgetItem *item = NULL;

        if (currentEntries.at(i) == "tasks")
        {
            item = new QListWidgetItem(i18n("--- tasks area ---"), m_arrangementUi.currentEntriesListWidget);
        }
        else if (currentEntries.at(i) == "jobs")
        {
            item = new QListWidgetItem(i18n("--- jobs area ---"), m_arrangementUi.currentEntriesListWidget);
        }
        else if (currentEntries.at(i) == "separator")
        {
            item = new QListWidgetItem(i18n("--- separator ---"), m_arrangementUi.currentEntriesListWidget);
        }
        else
        {
            if (hasEntry(currentEntries.at(i), false))
            {
                continue;
            }

            Launcher *launcher = m_applet->launcherForUrl(KUrl(currentEntries.at(i)));

            if (!launcher)
            {
                continue;
            }

            item = new QListWidgetItem(launcher->icon(), launcher->title(), m_arrangementUi.currentEntriesListWidget);
            item->setToolTip(launcher->launcherUrl().pathOrUrl());

            m_rules[launcher->launcherUrl().pathOrUrl()] = qMakePair(launcher->rules(), launcher->isExcluded());
        }

        m_arrangementUi.currentEntriesListWidget->addItem(item);
    }

    for (int i = 0; i < availableEntries.count(); ++i)
    {
        if (i > 0 && hasEntry(availableEntries.at(i), false))
        {
            continue;
        }

        QListWidgetItem *item = NULL;

        if (availableEntries.at(i).startsWith("--- "))
        {
            item = new QListWidgetItem(availableEntries.at(i), m_arrangementUi.availableEntriesListWidget);
        }
        else
        {
            Launcher *launcher = m_applet->launcherForUrl(KUrl(availableEntries.at(i)));

            if (!launcher)
            {
                continue;
            }

            item = new QListWidgetItem(launcher->icon(), launcher->title(), m_arrangementUi.availableEntriesListWidget);
            item->setToolTip(launcher->launcherUrl().pathOrUrl());

            m_rules[launcher->launcherUrl().pathOrUrl()] = qMakePair(launcher->rules(), launcher->isExcluded());
        }

        m_arrangementUi.availableEntriesListWidget->addItem(item);
    }

    QMap<QPair<Qt::MouseButtons, Qt::KeyboardModifiers>, IconAction> iconActions = m_applet->iconActions();
    QMap<QPair<Qt::MouseButtons, Qt::KeyboardModifiers>, IconAction>::iterator iterator;
    int i = 0;

    m_actionsUi.actionsTableWidget->setItemDelegateForColumn(0, new ActionDelegate(this));
    m_actionsUi.actionsTableWidget->setItemDelegateForColumn(1, new TriggerDelegate(this));

    for (iterator = iconActions.begin(); iterator != iconActions.end(); ++iterator)
    {
        if (iterator.key().first == Qt::NoButton)
        {
            continue;
        }

        QStringList action;

        if (iterator.key().first & Qt::LeftButton)
        {
            action.append("left");
        }

        if (iterator.key().first & Qt::MiddleButton)
        {
            action.append("middle");
        }

        if (iterator.key().first & Qt::RightButton)
        {
            action.append("right");
        }

        if (iterator.key().second & Qt::ShiftModifier)
        {
            action.append("shift");
        }

        if (iterator.key().second & Qt::ControlModifier)
        {
            action.append("ctrl");
        }

        if (iterator.key().second & Qt::AltModifier)
        {
            action.append("alt");
        }

        QTableWidgetItem *triggerItem = new QTableWidgetItem(action.join(QChar('+')));
        triggerItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);

        QTableWidgetItem *actionItem = new QTableWidgetItem(QString::number(static_cast<int>(iterator.value())));
        actionItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);

        m_actionsUi.actionsTableWidget->setRowCount(i + 1);
        m_actionsUi.actionsTableWidget->setItem(i, 0, actionItem);
        m_actionsUi.actionsTableWidget->setItem(i, 1, triggerItem);

        ++i;
    }

    moveAnimationTypeChanged(m_appearanceUi.moveAnimation->currentIndex());

    parent->addPage(generalWidget, i18n("General"), "go-home");
    parent->addPage(appearanceWidget, i18n("Appearance"), "preferences-desktop-theme");
    parent->addPage(arrangementWidget, i18n("Arrangement"), "format-list-unordered");
    parent->addPage(actionsWidget, i18n("Actions"), "configure-shortcuts");

    connect(parent, SIGNAL(applyClicked()), this, SLOT(save()));
    connect(parent, SIGNAL(okClicked()), this, SLOT(save()));
    connect(m_appearanceUi.moveAnimation, SIGNAL(currentIndexChanged(int)), this, SLOT(moveAnimationTypeChanged(int)));
    connect(m_appearanceUi.customBackgroundImage, SIGNAL(textChanged(QString)), this, SLOT(modify()));
    connect(m_arrangementUi.availableEntriesListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(availableEntriesCurrentItemChanged(int)));
    connect(m_arrangementUi.currentEntriesListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(currentEntriesCurrentItemChanged(int)));
    connect(m_arrangementUi.removeButton, SIGNAL(clicked()), this, SLOT(removeItem()));
    connect(m_arrangementUi.addButton, SIGNAL(clicked()), this, SLOT(addItem()));
    connect(m_arrangementUi.moveUpButton, SIGNAL(clicked()), this, SLOT(moveUpItem()));
    connect(m_arrangementUi.moveDownButton, SIGNAL(clicked()), this, SLOT(moveDownItem()));
    connect(m_arrangementUi.editLauncherButton, SIGNAL(clicked()), this, SLOT(editLauncher()));
    connect(m_actionsUi.actionsTableWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(actionClicked(QModelIndex)));
    connect(m_actionsUi.actionsTableWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(actionSelectionChanged()));
    connect(m_actionsUi.addButton, SIGNAL(clicked()), this, SLOT(addAction()));
    connect(m_actionsUi.removeButton, SIGNAL(clicked()), this, SLOT(removeAction()));
    connect(addLauncherApplicationAction, SIGNAL(triggered()), this, SLOT(findLauncher()));
    connect(addLauncherFromFileAction, SIGNAL(triggered()), this, SLOT(addLauncher()));
    connect(addMenuLauncherMenu, SIGNAL(aboutToShow()), this, SLOT(populateMenu()));
    connect(addMenuLauncherMenu, SIGNAL(triggered(QAction*)), this, SLOT(addMenu(QAction*)));
}