source: src-qt4/EasyPBI/backend.cpp @ 7a4b57b

9.2-releasereleng/10.0releng/10.0.1
Last change on this file since 7a4b57b was 7a4b57b, checked in by Ken Moore <ken@…>, 6 months ago

Add the first backend functions for EasyPBI to pull information from the pkgng repo instead of requiring a local copy of the FreeBSD ports tree. Just missing the ability to read the pkg-plist within a package now.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1#include "backend.h"
2
3QIcon Backend::icon(QString icon){
4  icon = icon.toLower();
5  //Qt embedded resources (http://www.qtcentre.org/wiki/index.php?title=Embedded_resources)
6  QString iconPath = ":/trolltech/styles/commonstyle/images/";
7  if(icon == "new"){ iconPath.append("newdirectory-128.png"); }
8  else if(icon=="load"){ iconPath.append("diropen-128.png"); }
9  else if(icon=="refresh"){ iconPath.append("refresh-32.png"); }
10  else if(icon=="delete"){ iconPath.append("standardbutton-delete-128.png"); }
11  else if(icon=="left"){ iconPath.append("left-128.png"); }
12  else if(icon=="right"){ iconPath.append("right-128.png"); }
13  else if(icon=="up"){ iconPath.append("up-128.png"); }
14  else if(icon=="down"){ iconPath.append("down-128.png"); }
15  else if(icon=="save"){ iconPath.append("standardbutton-save-32.png"); }
16  else if(icon=="help"){ iconPath.append("standardbutton-help-32.png"); }
17  else if(icon=="open"){ iconPath.append("standardbutton-open-32.png"); }
18  else if(icon=="close"){ iconPath.append("standardbutton-close-32.png"); }
19  else if(icon=="file"){ iconPath.append("file-32.png"); }
20  else if(icon=="trash"){ iconPath.append("trash-32.png"); }
21  else if(icon=="clear"){ iconPath.append("standardbutton-clear-128.png"); }
22  else if(icon=="start"){ iconPath.append("media-play-32.png"); }
23  else if(icon=="stop"){ iconPath.append("media-stop-32.png"); }
24  //EasyPBI embedded resources (EasyPBI.qrc)
25  else if(icon=="easypbi"){ iconPath = ":/png/icons/EasyPBIicon.png"; }
26  else if(icon=="freebsd"){ iconPath = ":/png/icons/freebsd.png"; }
27  else if(icon=="pcbsd"){iconPath = ":/png/icons/pcbsd.png"; }
28  else if(icon=="config"){iconPath = ":/png/icons/config.png"; }
29  //onebit iconset icons (http://www.iconfinder.com/search/?q=iconset%3Aonebit)
30  else if(icon=="plus"){iconPath = ":/png/icons/plus.png"; }
31  else if(icon=="minus"){iconPath = ":/png/icons/minus.png"; }
32  else{ iconPath.clear(); }
33       
34  return QIcon(iconPath);
35}
36
37QStringList Backend::getCmdOutput(QString cmd){
38  QProcess *proc = new QProcess;
39  proc->setProcessChannelMode(QProcess::MergedChannels);
40  proc->start(cmd);
41  while(!proc->waitForFinished(300)){
42    QCoreApplication::processEvents();
43  }
44  QStringList out = QString(proc->readAllStandardOutput()).split("\n"); 
45  delete proc; 
46  return out;
47}
48
49// ====================
50//  PACKAGE DATABASE TOOLS
51// ====================
52QStringList Backend::getPkgList(){
53  //Generate an alphabetized list of all available packages on the repo
54  //format: <category>/<pkgname>
55  QString cmd = "pkg search -o \"/\"";
56  QStringList result = getCmdOutput(cmd);
57  return result;
58}
59
60QStringList Backend::getPkgInfo(QString pkgname){
61  //Function to query the package repository and pull down information about a particular package
62  //Output: <name>, <port>, <maintainer>, <website>
63  QString cmd = "pkg rquery \"%n\\n%o\\n%m\\n%w\" "+pkgname;
64  QStringList out = Backend::getCmdOutput(cmd);
65  return out;
66}
67
68QStringList Backend::getPkgOpts(QString pkgname){
69  //Function to query the package repository and pull down information about a particular package
70  //Output: <name>, <port>, <maintainer>, <website>
71  QString cmd = "pkg rquery \"%Ok=%Ov\" "+pkgname;
72  QStringList out = Backend::getCmdOutput(cmd);
73  return out;
74}
Note: See TracBrowser for help on using the repository browser.