Commit 482cbe2d authored by Artem Grinev's avatar Artem Grinev Committed by Artem Grinev
Browse files

AUR is working once again

parent 5471c29a
......@@ -57,11 +57,6 @@ Window{
anchors.top: header.bottom
anchors.topMargin: 20
TabBar{
anchors{
left:parent.left
right:parent.right
}
id:tabs
TabButton {
text: qsTr("About")
......
......@@ -10,17 +10,20 @@ Rectangle{
id: header
function getColumnWidth(index){
let a = header.model.headerData(index,0,13);
if(a!="fill"){
if(a!=="fill"){
return a;
} else{
let fillCount = 0;
let size = 0;
for(let i = 0;i<header.model.columnCount;i++){
let b = header.model.headerData(i,0,13);
if(b!="fill"){
if(b!=="fill"){
size+=b;
} else{
fillCount++;
}
}
return header.width-size;
return header.width/fillCount-size;
}
}
Row{
......
......@@ -307,6 +307,8 @@ ApplicationWindow {
}
Component.onCompleted: {
//Init signleton
NotificationService;
}
}
......@@ -7,21 +7,34 @@ import QPamac.Database 1.0
import QPamac.PackageModel 1.0
import QPamac.Transaction 1.0
import QPamac.Async 1.0
import QPamac.AUR.PackageModel 1.0
import "./" as PamacQt
import "../js/JSUtils.js" as JSUtils
Table{
property alias packageList:packageModel.packageList
property var packageList
property alias packageListFuture:packageModelWatcher.future
model: PackageModel{
id:packageModel
property var watcher: FutureWatcher{
id:packageModelWatcher
onFinished: {
packageModel.packageList = result;
}
model: list.packageList.packageType()==="Repo"?repoPackageModel:aurPackageModel
PackageModel{
id:repoPackageModel
packageList: list.packageList
}
AURPackageModel{
id:aurPackageModel
packageList: list.packageList
}
property var watcher: FutureWatcher{
id:packageModelWatcher
onFinished: {
list.packageList = result;
}
}
showHeader: packageList.length>0
Column{
......@@ -73,7 +86,10 @@ Table{
hoveredRow=-1
}
onDoubleClicked: {
if( list.packageList.packageType()==="Repo")
stackView.push("PagePackageInfo.qml",{pkg:Database.getPkgDetails(name,appName,false)})
else
stackView.push("PageAURPackageInfo.qml",{packageFuture:Database.getAurPkgDetails(name)})
}
onClicked: {
list.selectedRows = [];
......@@ -90,7 +106,9 @@ Table{
function packageAction(){
let el;
if(list.packageList.packageType()==="Repo")
if(installedVersion!=""){
el = toRemove.indexOf(name);
if(el!==-1){
......@@ -113,12 +131,35 @@ Table{
}
}
else{
if(installedVersion!=""){
el = toRemove.indexOf(name);
if(el!==-1){
toRemove.splice(el,1)
toRemoveChanged();
}
else{
toRemove.push(name);
toRemoveChanged();
}
} else{
el = toBuild.indexOf(name);
if(el!==-1){
toBuild.splice(el,1)
toBuildChanged();
}
else{
toBuild.push(name);
toBuildChanged();
}
}
}
}
function isPending(){
if(installedVersion!=""){
if(toRemove.indexOf(name)!=-1){
return true
......@@ -126,17 +167,24 @@ Table{
return false
}
if(list.packageList.packageType()==="Repo"){
if(toInstall.indexOf(name)!=-1){
return true
} else {
return false
}
}
else{
if(toBuild.indexOf(name)!=-1){
return true
} else {
return false
}
}
columns: [
}
columns: list.packageList.packageType()==="Repo"?repoColumns:aurColumns
property list<Component> repoColumns: [
Component{
Row{
anchors.left: parent.left
......@@ -150,17 +198,17 @@ Table{
height: width
source:iconUrl.toString().length?Qt.resolvedUrl("file://"+iconUrl):"image://icons/package-x-generic"
}
Column{
anchors.verticalCenter: parent.verticalCenter
width: parent.width-packageIcon.width-5
Label {
width:parent.width
text:appName?appName+" ("+name+")":name
font.weight: Font.Bold
font.bold: true
elide: Text.ElideRight
}
Label {
......@@ -203,6 +251,61 @@ Table{
}
}
]
property list<Component> aurColumns:[
Component{
Row{
height: parent.height
spacing: 5
Image{
anchors.verticalCenter: parent.verticalCenter
id:packageIcon
width: 25
height: width
source:"image://icons/package-x-generic"
}
Column{
anchors.verticalCenter: parent.verticalCenter
width: parent.width-packageIcon.width-5
Label {
width:parent.width
text:name
font.weight: Font.Bold
font.bold: true
elide: Text.ElideRight
}
Label {
width:parent.width
text:desc
elide: Text.ElideRight
}
}
}
},
Component{
Label{
clip: true
text:version
}
},
Component{
Item {
Button{
checkable: true
anchors.fill: parent
anchors.margins: 5
text: installedVersion!=""?"Remove":"Install"
checked: isPending()
onClicked: packageAction()
}
}
}
]
}
clip:true
onPackageListChanged: {
......
......@@ -352,7 +352,11 @@ Page {
}
}
}
ScrollView {
Flickable {
ScrollBar.vertical: ScrollBar{
visible: true
}
boundsBehavior: Flickable.StopAtBounds
anchors.top: buildFileTabBar.bottom
anchors.right: parent.right
anchors.left: parent.left
......
......@@ -36,7 +36,8 @@ Pane{
table.forceLayout();
}
} }
}
}
}
property bool showHeader
property alias delegate: table.delegate
......
......@@ -9,6 +9,8 @@ class AurPackageModel : public QAbstractTableModel
{
Q_OBJECT
Q_PROPERTY(AURPackageList packageList READ packageList WRITE setPackageList NOTIFY packageListChanged)
Q_PROPERTY(int columnCount READ columnCount CONSTANT)
public:
enum PackageRole {
......@@ -28,7 +30,7 @@ public:
int columnCount(const QModelIndex &parent = QModelIndex()) const override
{
Q_UNUSED(parent)
return 4;
return 3;
}
inline AURPackageList packageList() const
{
......@@ -52,6 +54,12 @@ Q_SIGNALS:
void packageListChanged(AURPackageList packageList);
private:
QStringList list = {"Name","Version","State"};
QList<QVariant> sizeList = {"fill",40,70};
AURPackageList m_packageList;
// QAbstractItemModel interface
public:
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
};
} //namespace LibQPamac
......@@ -81,3 +81,18 @@ void LibQPamac::AurPackageModel::sort(int column, Qt::SortOrder order){
endResetModel();
}
QVariant LibQPamac::AurPackageModel::headerData(int section, Qt::Orientation orientation, int role) const
{
switch (role) {
case Qt::DisplayRole:
return list[section];
case Qt::SizeHintRole:
return sizeList[section];
}
return QVariant::Invalid;
}
......@@ -34,11 +34,11 @@ RepoPackageDetails Database::getPkgDetails(const QString &pkgname, const QString
GenericQmlFuture Database::getAurPkgDetails(const QString &pkgname)
{
auto future = new QmlFutureImpl;
pamac_database_get_aur_pkg_details(handle,pkgname.toUtf8(),Utils::cify([=](GObject* parent,GAsyncResult* result,void*){
return futureWrapFunction<AURPackageDetails()>(future,[=](){
pamac_database_get_aur_pkg_details(handle,pkgname.toUtf8(),Utils::cify([](GObject* parent,GAsyncResult* result,void* future){
return futureWrapFunction<AURPackageDetails()>(reinterpret_cast<QmlFutureImpl*>(future),[=](){
return AURPackageDetails(pamac_database_get_aur_pkg_details_finish(reinterpret_cast<PamacDatabase*>(parent),result));
});
}),nullptr);
}),future);
return GenericQmlFuture(future);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment